Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 2 of 2

Thread: Linear Blend Skinning

Hybrid View

  1. #1
    Junior Member Newbie
    Join Date
    Feb 2014
    Posts
    7

    Question Linear Blend Skinning

    I am working on implementing LBS for a model, however it is slightly different since the bone structure does not use a hierarchy. Transformations are given each frame in respect to the rest pose (they aren't incremental).

    Right now i have figured out how to draw the skeleton in its rest pose, however I am having trouble animating the skeleton. The animation is given in the form of a file with an axis/angle transform for every bone on each keyframe.



    Code :
    void drawSkeleton()
    {
    	if (bones.size() == 0)
    	{
    		cout << "ERROR - NO BONES!" << endl;
    		return;
    	}
     
    	glDisable(GL_LIGHTING);
    	glDisable(GL_CULL_FACE);
    	glDisable(GL_POLYGON_OFFSET_FILL);
    	glDisable(GL_DEPTH_TEST);
     
    	glColor3f(0.2, 0.8, 0.2);
     
    	for (int i = 0; i < bones.size(); i++) 
    	{
    		Joint jnta = *bones[i].jointA;
    		Joint jntb = *bones[i].jointB;
    		Transform trans = getTransform(bones[i].id);
     
    		glPushMatrix();
     
    		glBegin(GL_LINES);
     
    		double degrees = (trans.angle * 180 / 3.1415926) * 57.2957795;
     
    		glTranslatef(trans.translation[0], trans.translation[1], trans.translation[2]);
    		glRotatef(degrees, trans.rotation[0], trans.rotation[1], trans.rotation[2]); 
     
    		glVertex3f(jnta.vector[0], jnta.vector[1], jnta.vector[2]);
    		glVertex3f(jntb.vector[0], jntb.vector[1], jntb.vector[2]);
     
    		glEnd();
     
    		glPopMatrix();
     
    		glPushMatrix();
            glTranslatef(jnta.vector[0], jnta.vector[1], jnta.vector[2]);
            glutSolidSphere(0.01, 30, 10);
    		glPopMatrix();
     
    	}
    }

    For some reason the lines i am drawing are not affected by glTranslatef. If i do the same glTranslatef with the glutSphere, the joints will move around.

  2. #2
    Senior Member OpenGL Pro Ilian Dinev's Avatar
    Join Date
    Jan 2008
    Location
    Watford, UK
    Posts
    1,290
    It is invalid to call glTranslatef() and glRotatef() inside a glBegin()/glEnd() section.
    Move the "glBegin(GL_LINES);" after glRotatef() .

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •