Horde3D

Next-Generation Graphics Engine
It is currently 28.03.2024, 10:16

All times are UTC + 1 hour




Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: 16.07.2016, 10:14 
Offline

Joined: 21.10.2012, 15:32
Posts: 18
How to change the H3Dres for a model during the simulation?


Top
 Profile  
Reply with quote  
PostPosted: 17.07.2016, 22:41 
Offline
Tool Developer

Joined: 13.11.2007, 11:07
Posts: 1150
Location: Germany
Did you already read the wiki entry for how to modify vertex data?


Top
 Profile  
Reply with quote  
PostPosted: 18.07.2016, 06:28 
Offline

Joined: 21.10.2012, 15:32
Posts: 18
Volker wrote:
Did you already read the wiki entry for how to modify vertex data?


Sorry, i'm still not clear about it.

In my crowd simulation, i prepared 64 materials of different colors, as shown in Fig.1. For each model, it has the independent "scene.xml" and "material.xml"(Fig.2).

Attachment:
File comment: Fig.1
20160718131312.png
20160718131312.png [ 59.96 KiB | Viewed 10870 times ]

Attachment:
File comment: Fig.2
20160718131438.png
20160718131438.png [ 77.69 KiB | Viewed 10870 times ]


Right now, i use the following codes to achieve the change of each crowd node:

Code:
   for( unsigned int i = 0; i < _particles.size(); ++i )
   {
      Particle &p = _particles[i];
      h3dRemoveNode(p.node);
      p.node = h3dAddNodes( H3DRootNode, walk[cl[i]]);
      h3dSetupModelAnimStage( p.node, 0, walka[cl[i]], 0, "", false );
   }


where
vector<H3DRes> walk, walka;
cl is the latest index of the H3DRes.

Although it works(refer to Fig.3), it's time consuming. Is there a better method with high efficiency?

Attachment:
File comment: Fig.3
crowd.jpg
crowd.jpg [ 114.96 KiB | Viewed 10870 times ]


Thanks.


Top
 Profile  
Reply with quote  
PostPosted: 26.07.2016, 18:25 
Offline

Joined: 17.11.2009, 17:00
Posts: 205
Location: Russia, Moscow
There are several ways to achieve what you want.

1) You can modify a uniform in material through h3dSetMaterialUniform. For example, you have a color uniform that you can change in application. But this way requires modification of shaders.
2) Change a material of a mesh.
h3dSetNodeParamI( meshID, H3DMatRes::MaterialElem, materialID );
You can also change a texture in a material, if needed:
h3dSetResParamI( materialID, H3DMatRes::SamplerElem, 0, H3DMatRes::SampTexResI, TextureID)


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

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 44 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