Drawing Details on Mesh Post Mesh Draw
by Demolishun · in Torque Game Engine · 01/09/2006 (7:46 pm) · 1 replies
Here is what I want to do:
- Draw mesh for character as normal (vehicle code in this case, but example for player would most likely work just as well).
- Go back and draw lines representing hairs on the model based upon surface normals of the mesh faces.
This is for a very specific character type. I don't really "need" this feature, but I was wondering where to start on this. Is there an easy way to peruse the mesh to get face normals? This character is nice as the hairs can be added anywhere and it will not hurt the overrall look. I thought about drawing hairs using triangles, but that sounded like more of a drain on rendering resources than just a simple glLines call.
I guess, if will make it faster I could draw the hairs when the faces are drawn, but I would need to switch textures off and on for each hair. I do not want texture mapped hairs. I will just use alpha to blend the end into the background.
- Draw mesh for character as normal (vehicle code in this case, but example for player would most likely work just as well).
- Go back and draw lines representing hairs on the model based upon surface normals of the mesh faces.
This is for a very specific character type. I don't really "need" this feature, but I was wondering where to start on this. Is there an easy way to peruse the mesh to get face normals? This character is nice as the hairs can be added anywhere and it will not hurt the overrall look. I thought about drawing hairs using triangles, but that sounded like more of a drain on rendering resources than just a simple glLines call.
I guess, if will make it faster I could draw the hairs when the faces are drawn, but I would need to switch textures off and on for each hair. I do not want texture mapped hairs. I will just use alpha to blend the end into the background.
About the author
I love programming, I love programming things that go click, whirr, boom. For organized T3D Links visit: http://demolishun.com/?page_id=67
Torque 3D Owner Stephane Conde
Well I don't know about the whole drawing part, but I do definitely know how to get surface normals from a mesh pre or post draw. Check out this post for more information on obtaining data from a mesh. The last post in that thread should be what you are looking for. Just use the 'norms' vector instead of the 'verts' vector to get all the mesh's normals. Also, if you are using a 'skinned' mesh (ie. a mesh with bones, weighting and animation) then you need to refer to Chris Weiland's post in that same thread for how to deal with those... be careful as referring to a skinned mesh as a static mesh can have really bad consequences.
Now, as far as actually rendering the hair, perhaps using some sort of cloth rendering with a constraint at the point you want to start drawing the hair and then using the normals of your mesh faces to create more constraints (so that the hair doesn't go through the head)? There is a resource for adding cloth to the Torque engine (its a definite work-in-progress though, so beware!)
Stephane