Original Post
im using the following code to obtain a bones absolute matrix in a skeletal animation structure:
however it is terribly slow :(
are there any GL-functions i should avoid or how else could i improve the performance?
btw im currently running this function 1500 times per frame (to test performance) and the bone im obtaining the matrix for has 4 parent bones...
[Edited by - blubberbert on September 13, 2010 11:08:29 AM]
void Bone::getMatrix(GLfloat time, GLfloat *matrix){ list<Bone *> parents; Bone *b = this; while(b->getParent() != NULL) { parents.push_front(b->getParent()); b = b->getParent(); } glPushMatrix(); glLoadIdentity(); KeyFrame f; for(list<Bone *>::iterator it = parents.begin(); it != parents.end(); it++) { f = (*it)->getFrame(time); glRotatef(f.angleX, 1.0f, 0.0f, 0.0f); glRotatef(f.angleY, 0.0f, 1.0f, 0.0f); glRotatef(f.angleZ, 0.0f, 0.0f, 1.0f); glTranslatef(f.length, 0.0f, 0.0f); } f = getFrame(time); glRotatef(f.angleX, 1.0f, 0.0f, 0.0f); glRotatef(f.angleY, 0.0f, 1.0f, 0.0f); glRotatef(f.angleZ, 0.0f, 0.0f, 1.0f); glGetFloatv(GL_MODELVIEW_MATRIX, matrix); glPopMatrix();}however it is terribly slow :(
are there any GL-functions i should avoid or how else could i improve the performance?
btw im currently running this function 1500 times per frame (to test performance) and the bone im obtaining the matrix for has 4 parent bones...
[Edited by - blubberbert on September 13, 2010 11:08:29 AM]