Sign in to follow this  

Drawing Bones of a Mesh

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

Been trying to draw the bones of an animated mesh, and despite drawing the bones being probably the easiest part of the project, its the one that I can't seem to figure out. I've got the mesh animating properly through Matrix Lerp (Yeah, not the most accurate, but it looks fine), so I know my bone matrices are all correct. Right now I've been trying to do something like: Disable the Zbuffer; Create a line using D3DXCreateLine; Set up the line with two D3DXVECTOR3s, going from (0,0,0) to (1,1,1); Then call Line->DrawTransform() on the line using the current bone matrix; Re-enable the Zbuffer; I'm not really sure on how to set up the current length of the line, but even then I should see the lines being aligned with the mesh.... or so I thought. The lines are drawn in what appears to be random locations as I animate the mesh. Dunno what to do from here. And just for the record: my bone matrices are the result of multiplying the bone offsets and the current frames combined transform matrix. Any tips would be greatly appreciated.

Share this post


Link to post
Share on other sites
If I'm not mistaken, ID3DXLine draws in screen space, so your line needs to be unprojected.

The length of the line ( a bone ) should be the difference between it's translated position* and it's child's position** (in world space, before unprojection).

*you can get that from the transform. If the bones are only subject to rotation and not translation (common), you only have to get the length once.

**if it has no child, you'll have to pick a default.

Rather than mess with screen lines, you could use a vertex buffer of lines and render them in world space with the same transform as the bones they represent.

Share this post


Link to post
Share on other sites
Quote:
my bone matrices are the result of multiplying the bone offsets and the current frames combined transform matrix.


The offset matrices bring a vertex in object space into bone space. The point you want is the origin of the bone space, as this represents a joint. Transforming (0,0,0,1) through (current frames combined transform matrix) will get you the object space location of the joint.

As for the end point of the line... As Buckeye said, it is the origin of each child the bone has. If the bone has no children you have to use a point along some "default axis." The default axis is the vector the bone would represent without any transformation... Most probably the x-axis.

Share this post


Link to post
Share on other sites

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