Hi,

[EMAIL PROTECTED] wrote:

Hi..

We are trying to change the texture on a characters head. The character is
a vrml model which is loaded in to the program. We have managed to get
hold of the correct node and obtain the geometry of that node. We want to
change the image in the material of the node and use the same texture
coordinates that is stored in the file. Below is some code which tries to
do this, but doesn't work. Basically we are trying to change only the
image field of the material and leave the rest of the material as it is.

GeometryPtr geo = GeometryPtr::dcast(node->getCore());
SimpleTexturedMaterialPtr material =
SimpleTexturedMaterialPtr::dcast(node>getCore());
beginEditCP(material,SimpleTexturedMaterial::ImageFieldMask);
material->setImage(image);
endEditCP(material,SimpleTexturedMaterial::ImageFieldMask);


Can anyone help?
Any comments will be appreciated!
well, I had a look into both VRML loaders of OpenSG.

The problem with your code above is that the VRML loader does not attach materials directly to geometry but uses a MaterialGroup node above the geometry. If you have the geometry node you have to search for
the first node above which is a MaterialGroup node.

The material in this MaterialGroup is not a SimpleTexturedMaterial, but the most general ChunkMaterial.
Therein you find chunks
  TextureChunk  which contains the texture Image
  MaterialChunk which contains the Phong material coefficients

Greetings,
Christoph



-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
Opensg-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensg-users

Reply via email to