AB4D Forum

Full Version: PLY with Texture Color
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

I'm a .NET WPF developer and I'm looking for a 3D Toolset able to Load and Show different types of 3D models.
I downloaded your PowerToys Samples and I tryed to load different 3D model files using the Assimp Model Viewer sample under Assimp importer/exporter section. 

While I was able to correctly load OBJ files with specific textures, I couldn't load correctly PLY files with a JPG file as a texture: the mesh is loaded but has a generic beige color.

Looking to the code I saw that the AssimpWpfImporter class use the ReadModel3D method to load the file and you can specify a Texture path. I tried to put the path of the JPG file there but nothing changed.

What I'm doing wrong?
Thank you for the support.
I think that ply files define only the data for the mesh and not for the material.

If you want to preserve the material information, you will need to export to some other file format - for example fbx, obj or dea.

If this is not possible, then you will need to manually change the material of the loaded object - you can use the following code:
var imageBrush = new ImageBrush();
imageBrush.ImageSource = new BitmapImage(new Uri("fileName"));

// To read image from resource use the following (replace AssemblyName and FilePath)
//imageBrush.ImageSource = new BitmapImage(new Uri("pack://application:,,,/[AssemblyName];component/[FilePath]"));

var material = new DiffuseMaterial(imageBrush);

// Change material on the read readModel3D
Ab3d.Utilities.ModelUtils.ChangeMaterial(readModel3D, material, newBackMaterial: null);
Thank you for the fast answer.

Yes, the PLY file defines the mesh but it can also contain the information about the Texture file that must be used to color the 3D model. Usually these files have one line like:

comment TextureFile nameofthetexturefile.jpg

By the way, using the code snippet that you posted, I could load the texture file but now I have the problem of placing it correctly on the model, because unfortunately this is not going to happen automatically as it happens in other 3D viewer programs (like MeshLab), as you can see from the attached pictures.

Capture2 and Capture3 show respectively the same model opened with MeshLab and my TestApp.

I tried to change the Stretch property of the ImageBrush but none of the available options solved my problem...

Capture4 shows the parameters of the ImageBrush used as the Texture.

Have you got any advice for this kind of issue?
After checking the file I have found out that it is correctly opened and the texture is correctly shown when it is loaded with the new version of assimp importer.

The new version of assimp importer will be available with the next version of Ab3d.PowerToys that will be available soon.

If you want to get the next version before it is released, please contact me.
I confirmed that with the new version of PowerToys the problem is solved.

The only think that you have to do is to change only the ViewportUnits property of the ImageBrush from RelativeToBoundingBox to Absolute!

Thank you for the support!