CHAI3DCHAI3D

normal Adding texture to MultiMesh object

More
17 Feb 2016 22:47 #1

Hi

cMultiMesh* object;

I created an object and i assigned this object to an .stl file(hollow sphere) , which i created using solid works.

I am trying to add texture, which is .jpg file to this object

cTexture1dPtr textureImage = cTexture1d::create();

And i assigned textureImage to my .jpg file.

object->setTexture(textureImage, true);
object->setUseTexture(true, true);

I am unable to see texture.And I am not sure about the scale of the image, whether it is too big to fit in the world or too small to see. How can i scale it to appropriate size.

Also, I am trying to add texture to the inner surface(my object is hollow sphere) of my object, how can i do that ?


Thanks

Please Log in or Create an account to join the conversation.

More
18 Feb 2016 21:05 #2

There are two problems:

1.
If you are using a 2D image, make sure to use cTexture2dPtr instead of cTexture1dPtr

2.
In order to program mesh objects, you need to define texture coordinates for each vertex of your object.
See example 14-textures for more information.

Since an STL file only contains geometrical information that include the position of vertices and triangles, texture mapping information is not defined.

If you wish to apply a texture on the object you would need to use a 3D editor to edit your STL file and assign it a texture. You could use Blender (www.blender.org/) to accomplish this task and then export the model to an OBJ format so that the texture coordinates and material properties are included.

More information on how to apply a texture on a model using Blender can be found here:

Please Log in or Create an account to join the conversation.