I’m having problems with implementing animations that are controlled by equations.
Im currently doing simple rotations. When rotating in x it seems to work fine but when rotating in y or z it turns a but and then just stops. Ive checked the values being returned from my maths and they all increase as they should, so i cant figure out why its doing this.
Can anyone help??
can you display some code? it would help a lot.
well this is the code i use to work out the rotations for the x y z angles
its pretty much initial rotation +speedtime. The mutltiplication before speedtime is the axis that the rotation is being performed on.
Put glPushMatrix() - glPopMatrix() around your glRotate() maybe ?
yeah i have glpush and glpop. heres my drawing code:
void Recursive_Draw(TreeStorageNode object)
animatedObject=Update_Animation(object, animationData->controllers[i], newSimTime);
printf("ROTX %.2f ROTY %.2f ROTZ %.2f
", animatedObject.animRotate.x, animatedObject.animRotate.y, animatedObject.animRotate.z);
glRotatef(animatedObject.animRotate.x, animatedObject.animRotate.y, animatedObject.animRotate.z, object.rotation.w);
glTranslatef(animPosition.x, animPosition.y, animPosition.z);
glVertexPointer(3, GL_FLOAT, sizeof(VectorStorage), &object.mesh.pos);
glNormalPointer(GL_FLOAT, sizeof(VectorStorage), &object.mesh.normal);
glTexCoordPointer(2, GL_FLOAT, sizeof(VectorStorage), &object.mesh.texCoord);
glDrawElements(GL_TRIANGLES, 3*object.mesh->triangleCount, GL_UNSIGNED_INT, object.mesh->indices);
for(i=0; i<object.childCount; i++)
its not great but it reflects my rather rubbish programming techniques
>> glRotatef(animatedObject.animRotate.x, animatedObject.animRotate.y, animatedObject.animRotate.z, object.rotation.w);
Hehe, don’t forget to read the docs
glRotate is defined as :
glRotatef (GLfloat angle, GLfloat x, GLfloat y, GLfloat z);
So you need to use :
glRotatef( rotate.z , 0,0,1);
glRotatef( rotate.x , 1,0,0);
glRotatef( rotate.y , 0,1,0);
The correct order will depend of your case.
ohh im so dumb. thanks very much, most problems i come across are ones like these it gets a bit tiresome hehehe.
ps it works like a dream
ok so i have the animations working just perfectly but now things are rotating around the axis of other objects axis. I was thinking it was my pop push matrices being in the wrong place but ive looked over it and i cant see that its wrong.
can someone with a fresh pair of eyes see if this is the problem. the code from above hasnt changed much from what i currently have. so if there is a problem it will be in there.
cheers for any help