I recently found myself in need of a function that retrieved the absolute world transform of a particular node and was a bit disappointed when I found that the h3dGetNodeTransform function only retrieved the transform relative to a nodes parent. I needed to retrieve the world coordinates of a node within a scenegraph to integrate collision volumes with the nodes. So I propose that a new function be added to help with that.
Code:
// The implementation I am using uses references and nixes the scale value, but the theory is the same.
void h3dutGetNodeWorldTransform(H3DNode node, float* tx,float* ty,float* tz,float* rx,float* ry,float* rz,float*,float* sx, float* sy, float* sz)
{
H3DNode parent;
float tra_x,tra_y,tra_z;
float rot_x,rot_y,rot_z;
float sca_x,sca_y,sca_z;
do
{
parent = h3dGetNodeParent(node);
h3dGetNodeTransform(node,&tra_x,&tra_y,&tra_z,&rot_x,&rot_y,&rot_z,&sca_x,&sca_y,&sca_z);
*tx+=tra_x;*ty+=tra_y;*tz+=tra_z;
*rx+=rot_x;*ry+=rot_y;*rz+=rot_z;
*sx+=sca_x;*sy+=sca_y;*sz+=sca_z;
}while(parent!=H3DRootNode);
}
By the way, if I am doing this wrong, please let me know. That was my other reason for this post.