Horde3D

Next-Generation Graphics Engine
It is currently 28.04.2024, 20:55

All times are UTC + 1 hour




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Changing material
PostPosted: 13.04.2011, 17:45 
Offline

Joined: 27.03.2011, 08:40
Posts: 47
Location: Fi
Hi again.

Having problems with setNodeParamI, dont know how to use it correctly.

I try to change a material of my wall object (called wallNode), to make it transparent.
Code:
int wallNode = h3d.addNodes(h3d.H3DRootNode, wallRes);
transparentWallRes = h3d.addResource((int)h3d.H3DResTypes.Material, "models/transparent_wall.material.xml", 0);
Horde3DUtils.loadResourcesFromDisk(Settings.ContentDir);


// I have tried this
h3d.setNodeParamI(wallNode, (int)h3d.H3DMesh.MatResI, transparentWallRes);

// and this
// h3d.setNodeParamI(wallNode, (int)h3d.H3DMatRes.MatLinkI, transparentWallRes);

// and even this
// h3d.setNodeParamStr(wallNode, (int)h3d.H3DMatRes.MatClassStr, "Translucent");
//( class="Translucent" is the difference with original material and transparent_wall.material.xml)

I always get 'Invalid param in h3dSetNodeParam'.


Top
 Profile  
Reply with quote  
 Post subject: Re: Changing material
PostPosted: 13.04.2011, 19:37 
Offline

Joined: 24.03.2010, 10:17
Posts: 55
I assume your wallRes is a Scenegraph and wallNode is a Model node.
Have a look at http://www.horde3d.org/docs/html/_api.html#H3DModel
It does not have a MatResI param, that's why you get the Invalid Param.
You can change the material resource on a Mesh node only.
If you only have a Model node at hand, use the h3dFindNodes function to search for your specific Mesh below the Model node.


Top
 Profile  
Reply with quote  
 Post subject: Re: Changing material
PostPosted: 13.04.2011, 23:01 
Offline

Joined: 27.03.2011, 08:40
Posts: 47
Location: Fi
Ahaa, I understand now little better that setNodeParamI method.

I wrote
Code:
if (h3d.findNodes(wallNode, "Rectangle01", (int)h3d.H3DNodeTypes.Mesh) != 0)
{
   int mesh = h3d.getNodeFindResult(0);
   h3d.setNodeParamI(mesh, (int)h3d.H3DMesh.MatResI, transparentWallRes);
}

and it worked. Thanks! :mrgreen:


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 18 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group