How to access model normals in "world space"?

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
gamebeavis
Posts: 12
Joined: Mon Jun 25, 2007 11:45 pm

How to access model normals in "world space"?

Post by gamebeavis »

I was curious how to access a models vertex position and normals translated into world space. Basically, if I load a model into irrlicht, and perform an animation, rotation, and translation I dont think the actual mesh data changes, just the view of it does or does it actually change? If it dosnt, how do I access the vertex/normal data in its changed form?? If it does change I suppose I can just read that data directly from the mesh buffer of the node??
bitplane
Admin
Posts: 3204
Joined: Mon Mar 28, 2005 3:45 am
Location: England
Contact:

Post by bitplane »

the data held in the mesh buffers doesn't actually change, just the position which it is rendered from. so if you want a vertex position in world space, you have to transform the position by the model's absolute transformation matrix:

Code: Select all

node->getAbsoluteTransformation().transformVect(tempPosition)
normals are a unit vector that holds a direction rather than a position, so it makes no sense to translate or scale them. so just rotate them instead:

Code: Select all

node->getAbsoluteTransformation().rotateVect(tempNormal)
Submit bugs/patches to the tracker!
Need help right now? Visit the chat room
omaremad
Competition winner
Posts: 1027
Joined: Fri Jul 15, 2005 11:30 pm
Location: Cairo,Egypt

Post by omaremad »

btw this will only yield valid normals if you dont scale your model, scaled models need to use the inverse transpose of the model matrix.
"Irrlicht is obese"

If you want modern rendering techniques learn how to make them or go to the engine next door =p
Post Reply