void ApplyTransform(KEYFRAME *T)
{
glTranslatef(T->Position.x,T->Position.y,T->Position.z);
//don`t execute if not needed
if (T->angle!=0)
glRotatef(T->angle/0.01745329252,T->Rotation.x,T->Rotation.y,T->Rotation.z);//transform PI values into degrees
glScalef(T->Scale.x,T->Scale.y,T->Scale.z);
}
void SKELETON::RenderRemBone(BONE *B,float frame,unsigned animation)
{
glPushMatrix();
//add transformations
ApplyTransform(&B->Transform);
if (Rem->nrObjects>B->Object_Index)
Rem->RenderObject(B->Object_Index);
for(int y=0;y<B->nrchildren;y++)//render the children
RenderRemBone(&Bone[B->Children_Index[y]],frame,animation);
glPopMatrix();
}
Local to Global Matrix System
For some days now I`m strugglling to get a local point from a certain matrix into my global world space. Basicly I need this for collision, I have a gun which is an object and I need to make the line based on direction in world space. So... I have an animation system that functions like this The Animation sistem works, no problems there, the thing is that I`d wish to know the position of my translated/rotated/scaled system for let`s say Bone 3 which is child to 2 which is child to 1. The Thing is that I don`t yet understand how to compose rotations and translations :(. I thought of getting the OpenGL ModelView/Projection Matrix at the specifyed bone but how do I extract position from that 4x4 Matrix ?
Relative Games - My apps
I strongly sugest you do matrix calculation on CPU. Once you have transformation matrix then you only need to multiply your local position with matrx to get world position. There were number of posts about it so just look around a bit.
You should never let your fears become the boundaries of your dreams.
Hm... but actually I need to read the position from that Matrix, how do I do that ?
Relative Games - My apps
This should clear thing up a bit : Matrix FAQ
You should never let your fears become the boundaries of your dreams.
Let me know if I did things wrong->
That`s X,Y,Z, indices as I`ve seen in the FAQ. I do remember something about OpenGL matrices being column major state in which some indices change, so I might get things rather confused...?
GLdouble modelMatrix[16]; // The model matrix. glGetDoublev(GL_MODELVIEW_MATRIX, modelMatrix);Vector3 P(modelMatrix[0],modelMatrix[3],modelMatrix[6]);
That`s X,Y,Z, indices as I`ve seen in the FAQ. I do remember something about OpenGL matrices being column major state in which some indices change, so I might get things rather confused...?
Relative Games - My apps
Eventually I figured out that [12],[13],[14] indices are for translations, so getting these before and then subtracting it at the end might be my desired translation but... I also need the rotation... pending
Relative Games - My apps
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement