Sign in to follow this  

Skeletal Animation

This topic is 3628 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm currently working on my first character animation, but keeping it small at moment, to the left arm (with shoulder,elbow and wrist pivots - using structures; and upperarm,forearm and hand boxes - simple quads (top-spec graphics I know!) This is my source so far.
// STEP 1 ..................... 
void Skeleton::LeftUpperArm(void)
{
  glTranslated(leftshoulder.x,leftshoulder.y,leftshoulder.z);
  glRotatef(leftshoulder.yz, 1.0, 0.0, 0.0);
  FrameUpperArm();
  LeftForeArm();
  glRotatef(leftshoulder.yz,-1.0, 0.0, 0.0);
  glTranslated(-leftshoulder.x,-leftshoulder.y,-leftshoulder.z);
}

void Skeleton::FrameUpperArm(void)
{
  float abc = 1 / leftshoulder.bone;
  glColor3f(1.0,0.5,0.5);
  glBegin(GL_QUADS);
  for(int a = 0; a < 4; a++)
  {
    int dog = arm_indices[a]*3;
    glVertex3f(arm_coords[dog],arm_coords[dog+1]/abc,arm_coords[dog+2]);
  }
  glEnd();
  glColor3f(0.0,0.0,0.0);
}

// STEP 2 ..................... 
void Skeleton::LeftForeArm(void)
{
  glTranslated(leftelbow.x,leftelbow.y,leftelbow.z);
  glRotatef(leftelbow.yz, 1.0, 0.0, 0.0);
  FrameForeArm();
  LeftHand();
  glRotatef(leftelbow.yz,-1.0, 0.0, 0.0);
  glTranslated(-leftelbow.x,-leftelbow.y,-leftelbow.z);
}

void Skeleton::FrameForeArm(void)
{
  float abc = 1 / leftelbow.bone;
  glColor3f(1.0,0.5,0.5);
  glBegin(GL_QUADS);
  for(int a = 0; a < 4; a++)
  {
    int dog = arm_indices[a]*3;
    glVertex3f(arm_coords[dog],arm_coords[dog+1]/abc,arm_coords[dog+2]);
  }
  glEnd();
  glColor3f(0.0,0.0,0.0);
}

// STEP 3 ..................... 
void Skeleton::LeftHand(void)
{
  glTranslated(leftwrist.x,leftwrist.y,leftwrist.z);
  glRotatef(leftwrist.yz, 1.0, 0.0, 0.0);
  FrameLeftHand();
  glRotatef(leftwrist.yz,-1.0, 0.0, 0.0);
  glTranslated(-leftwrist.x,-leftwrist.y,-leftwrist.z);
}

void Skeleton::FrameLeftHand(void)
{
  float abc = 1 / leftwrist.bone;
  glColor3f(1.0,0.5,0.5);
  glBegin(GL_QUADS);
  for(int a = 0; a < 4; a++)
  {
    int dog = arm_indices[a]*3;
    glVertex3f(arm_coords[dog],arm_coords[dog+1]/abc,arm_coords[dog+2]);
  }
  glEnd();
  glColor3f(0.0,0.0,0.0);
}

This all works and I can move each limb as I please and each child limb moves accordingly. BUT.... Is this the right way to do it? I've got a mesh of a whole arm, but can't think how i'd rotate each bit accordingly? QUESTION: WHOLE ARM MANIPULATION v LIMB MANIPULATION? Anyone got any insight? would be much appreciated, using C++/OpenGL/Dev-Cpp++

Share this post


Link to post
Share on other sites
I work with Blitz 3D, but I understand where you're going.

If you need rotation at the elbow/knee, I would suggest getting two different meshes for the upper arm and lower arm, and putting a pivot point at the elbow/ knee for the lower arm/leg (respectively) and another at the shoulder/hip for the upper arm/leg (respectively).

Share this post


Link to post
Share on other sites

This topic is 3628 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this