Jump to content
  • Advertisement
Sign in to follow this  
Kasya

Unity How to Draw Skeleton?

This topic is 3412 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

Hello, This is my system: http://www.gamedev.net/community/forums/topic.asp?topic_id=533640 (Posted - 5/3/2009 3:39:24 AM) How can i draw a skeleton? (in any api) Thanks, Kasya

Share this post


Link to post
Share on other sites
Advertisement
Transform Vector(0,0,0,1) by all your bone matrices, this will generate a point cloud where all your bones start. You may need an extra point for your end effector. It'll depend on what axis it's aligned to, maybe Vector(0,0,1,1) will suit you.

Then you just render lines between the points. Alternatively you can use a bone model, and just use the bone transform as the model transform. Render the model in each bone location.

Share this post


Link to post
Share on other sites
I want to know one thing?

Is that correct to use rotation in Rendering?



void RenderSkeleton() {



glBegin(GL_LINES);

RenderBone(root);

glEnd();

}






void RenderBone(Bone * bone) {

Matrix trans, rot, final;
trans.Translate(position);
orientation.ToMatrix(rot);
final = (trans * rot);

glVertex3f(final.getTranslate().x, final.getTranslate().y, final.getTranslate().z);

for(bone in children /* This is not c++ :) */) {

RenderBone(bone);

}

}




Will that be correct?

Thanks,
Kasya

Share this post


Link to post
Share on other sites
yes, except the last bone's orientation will not be visible. For example, if your wrist was the last bone in your arm chain, the last vertex will be placed at the wrist, not indicating the orientation of the wrist, only the position. You'll need to draw another point where the next bone would be, such as the tip of your fingers. If your hand is in the local Z direction of the wrist bone, then transforming Vector(0,0,x,1) by the wrist bone will give you the last vertex to draw. Where x is the length of the last line segment to draw.


void RenderBone(Bone * bone) {

Matrix trans, rot, final;
trans.Translate(position);
orientation.ToMatrix(rot);
final = (trans * rot);

glVertex3f(final.getTranslate().x, final.getTranslate().y, final.getTranslate().z);

if (children.size() == 0) {
const float lastSegLength = 2;
Vector lastSeg = final * Vector(0,0,lastSegLength,1);

glVertex3f(lastSeg.x, lastSeg.y, lastSeg.z);
}
else {
for(bone in children /* This is not c++ :) */) {
RenderBone(bone);
}
}
}

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!