View Full Version : Animations
05-10-2004, 03:33 AM
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??
05-10-2004, 04:40 AM
can you display some code? it would help a lot.
05-10-2004, 05:12 AM
well this is the code i use to work out the rotations for the x y z angles
}its pretty much initial rotation +speed*time. The mutltiplication before speed*time is the axis that the rotation is being performed on.
05-10-2004, 01:17 PM
Put glPushMatrix() - glPopMatrix() around your glRotate() maybe ?
05-11-2004, 11:02 AM
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\n\n", 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
05-11-2004, 12:46 PM
>> glRotatef(animatedObject.animRotate.x, animatedObject.animRotate.y, animatedObject.animRotate.z, object.rotation.w);
Hehe, :p 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.
05-12-2004, 12:21 AM
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
05-12-2004, 08:35 AM
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
Powered by vBulletin® Version 4.2.0 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.