Horde3D

Next-Generation Graphics Engine
It is currently 22.11.2024, 20:04

All times are UTC + 1 hour




Post new topic Reply to topic  [ 5 posts ] 
Author Message
PostPosted: 28.01.2012, 03:57 
Offline

Joined: 28.01.2012, 00:57
Posts: 3
Hello all,

I am working on a project that involves picking mesh objects in 3D space and I am looking for a way to convey to the user which rendered object is currently selected by having the object glow, or distinguish itself in a similar way. I have already created a simple shader in a context called "PICKED" and am attempting to use API calls similar to the one below to accomplish this.

h3dSetResParamStr(shaderMatRes, ContextElem, 0, ContNameStr, "PICKED");

The following call gives me the string name of the context that I want to replace, but I cannot seem to figure out how to replace it procedurally.

h3dGetResParamStr(shaderMatRes, ContextElem, 0, ContNameStr);

The message boards and Wiki pages have been an invaluable resource, but I've been unable to find a solution to this task so far.

Any guidance or advice would be greatly appreciated! Thanks!


Top
 Profile  
Reply with quote  
PostPosted: 28.01.2012, 12:51 
Offline
Tool Developer

Joined: 13.11.2007, 11:07
Posts: 1150
Location: Germany
ContNameStr is a read only attribute as mentioned in the docs. I guess you might want to use uniforms or different materials with different ShaderFlags?


Top
 Profile  
Reply with quote  
PostPosted: 31.01.2012, 01:08 
Offline

Joined: 28.01.2012, 00:57
Posts: 3
I was able to utilize a uniform to tell the shader to change it's behavior. I ended up finding a solution to procedurally switching the shader by using the follownig:

Code:
 
//materialRes: texture resource attached to the selected node (cube)

//specularShaderRes: resource handle to shader added with h3dAddResource

h3dSetResParamI(materialRes, MaterialElem, 0, MatShaderI, specularShaderRes);


I guess the thing I can't get my head is around is how to dynamically shade an unknown number of cubes. My project can have anywhere from 1 to about 2000+ cubes render at a time. The user can select a subset of cubes which will glow after being selected. As cubes timeout I would like them to gradually fade out by adjusting their alpha over a timeout. I know I can use a uniform to communicate timing information for the fading to a shader. I'm just not sure how to do this dynamically for each cube. Are there any resources that cover similar situations?

Thanks again for your help!


Top
 Profile  
Reply with quote  
PostPosted: 31.01.2012, 12:14 
Offline
Tool Developer

Joined: 13.11.2007, 11:07
Posts: 1150
Location: Germany
Maybe you can use the model specific uniforms via h3dSetNodeUniforms as mentioned here.

Unfortunately they are not part of the official beta 5, but only in the current svn trunk.


Top
 Profile  
Reply with quote  
PostPosted: 01.02.2012, 16:43 
Offline

Joined: 28.01.2012, 00:57
Posts: 3
Fantastic! Thanks again for all of your help.


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

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 10 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:  
Powered by phpBB® Forum Software © phpBB Group