• Create Account

MS3D - Problem displaying the Bones

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

3 replies to this topic

#1novousmihi  Members   -  Reputation: 108

Like
0Likes
Like

Posted 02 July 2009 - 01:17 AM

Hi, I have a pretty decent 3D engine. I can draw models, sprites, load textures without a problem, and I can fly around with my cam, use lights and all the basic stuff. I have been putting this off for way too long - but I've finally taken the step to actually make the models do something. The problem is, I can't display my bones correctly. If I draw them like points, they appear like they should, assuming that bones[...].position[...] in the ms3d spec file is the joints absolute x-,y-,z- coordinates and not anything relative to a given position - like its parent-joint. I try to connect the joints positions with a line for every joint that has a parent, that is I push two vertices at a time into a vertexbuffer in the order: parent, child, parent, child, parent, child,... and then render the buffer like a list of separate lines with D3DPT_LINELIST. My problem is that I get these failed bones: The Failed Bones Compared to how they should be: The bones in Milkshape 3D Below is the linkage between all the joints in psuedo-code. (A correct text-dump of the actual MS3D-file) Each valid joint is linked with the indexes of the parent- and child- joints. Much the same as how the triangles are linked through the indexes of the vertexbuffer. So the syntax in the bone-list below is: bone( index ) = ( parent-joint, child-joint ) I can't see where the problem is... Everything seems fine in the dump file. Tey seem correctly linked. And I have loaded the file correctly, that much I know for sure. I've double-checked with an MS3D text-dump of the same file. Any help would be appreciated, and if you can't see a problem in my logic or how I've linked the bones or how I've rendered them, then that would also be appreciated so I atleast know that much. Is the problem with the rendering of the bones or the linking of them?
Model(...)
{
Vertices( 839 )
Triangles( 1007 )

Mesh Groups( 2 )
Materials( 5 )

Textures( 5 )
Joints( 28 )
Bones( 27 )

Frames( 300 )
FPS( 25.00 )

Bonelist
{
Bone(0) = { 0, 1 }
Bone(1) = { 1, 2 }
Bone(2) = { 1, 18 }
Bone(3) = { 1, 23 }
Bone(4) = { 2, 3 }
Bone(5) = { 3, 4 }
Bone(6) = { 4, 5 }
Bone(7) = { 5, 6 }
Bone(8) = { 5, 8 }
Bone(9) = { 5, 14 }
Bone(10) = { 6, 7 }
Bone(11) = { 8, 9 }
Bone(12) = { 9, 10 }
Bone(13) = { 10, 11 }
Bone(14) = { 11, 12 }
Bone(15) = { 12, 13 }
Bone(16) = { 14, 15 }
Bone(17) = { 15, 16 }
Bone(18) = { 16, 17 }
Bone(19) = { 18, 19 }
Bone(20) = { 19, 20 }
Bone(21) = { 20, 21 }
Bone(22) = { 21, 22 }
Bone(23) = { 23, 24 }
Bone(24) = { 24, 25 }
Bone(25) = { 25, 26 }
Bone(26) = { 26, 27 }
}
Jointlist
{
Joint(Joint1).Index: 0
{
ParentName:
ParentIndex: -1
}
Joint(Joint2).Index: 1
{
ParentName: Joint1
ParentIndex: 0
}
Joint(Joint3).Index: 2
{
ParentName: Joint2
ParentIndex: 1
}
Joint(Joint4).Index: 3
{
ParentName: Joint3
ParentIndex: 2
}
Joint(Joint5).Index: 4
{
ParentName: Joint4
ParentIndex: 3
}
Joint(Joint6).Index: 5
{
ParentName: Joint5
ParentIndex: 4
}
Joint(Joint7).Index: 6
{
ParentName: Joint6
ParentIndex: 5
}
Joint(Joint8).Index: 7
{
ParentName: Joint7
ParentIndex: 6
}
Joint(Joint9).Index: 8
{
ParentName: Joint6
ParentIndex: 5
}
Joint(Joint10).Index: 9
{
ParentName: Joint9
ParentIndex: 8
}
Joint(Joint11).Index: 10
{
ParentName: Joint10
ParentIndex: 9
}
Joint(Joint12).Index: 11
{
ParentName: Joint11
ParentIndex: 10
}
Joint(Joint13).Index: 12
{
ParentName: Joint12
ParentIndex: 11
}
Joint(Joint29).Index: 13
{
ParentName: Joint13
ParentIndex: 12
}
Joint(Joint14).Index: 14
{
ParentName: Joint6
ParentIndex: 5
}
Joint(Joint15).Index: 15
{
ParentName: Joint14
ParentIndex: 14
}
Joint(Joint16).Index: 16
{
ParentName: Joint15
ParentIndex: 15
}
Joint(Joint17).Index: 17
{
ParentName: Joint16
ParentIndex: 16
}
Joint(Joint18).Index: 18
{
ParentName: Joint2
ParentIndex: 1
}
Joint(Joint19).Index: 19
{
ParentName: Joint18
ParentIndex: 18
}
Joint(Joint20).Index: 20
{
ParentName: Joint19
ParentIndex: 19
}
Joint(Joint21).Index: 21
{
ParentName: Joint20
ParentIndex: 20
}
Joint(Joint22).Index: 22
{
ParentName: Joint21
ParentIndex: 21
}
Joint(Joint23).Index: 23
{
ParentName: Joint2
ParentIndex: 1
}
Joint(Joint24).Index: 24
{
ParentName: Joint23
ParentIndex: 23
}
Joint(Joint25).Index: 25
{
ParentName: Joint24
ParentIndex: 24
}
Joint(Joint26).Index: 26
{
ParentName: Joint25
ParentIndex: 25
}
Joint(Joint27).Index: 27
{
ParentName: Joint26
ParentIndex: 26
}
}


struct Bone{
unsigned short parentIndex;
unsigned short childIndex;
}


[Edited by - novousmihi on July 3, 2009 8:28:17 AM]

#2Caste  Members   -  Reputation: 969

Like
0Likes
Like

Posted 03 July 2009 - 06:06 AM

I didn't look into MS3D recently, but from what you get it seems as if the child bone positions are relative to the parent's position (and probably orientation). Thus you might want to apply the transformation matrix of the parent node to it's children too.

Just my thoughts :)

#3novousmihi  Members   -  Reputation: 108

Like
0Likes
Like

Posted 03 July 2009 - 06:48 AM

I found the problem, after 2 days excessibe programming.

The problem was I used the pos[..] information from the ms3D spec.
I should have used the floats 41 to 43 in the mFinal matrix for each joint as the coordinate information.

#4novousmihi  Members   -  Reputation: 108

Like
0Likes
Like

Posted 03 July 2009 - 06:52 AM

Quote:
 Original post by CasteI didn't look into MS3D recently, but from what you get it seems as if the child bone positions are relative to the parent's position (and probably orientation). Thus you might want to apply the transformation matrix of the parent node to it's children too.Just my thoughts :)

Thanks man, I just found the problem.
I might as well type it here if more people have this kind of problem.

I had to use the pos and rotation information from the joint and
create a rotational matrix and a translational matrix and then
multiply them into one to get mFinal:
CreateRotationXYZ(&rots, pitch,yaw,roll);CreateTranslation(&trans, x,y,z);mFinal = rots * trans;

Though my programming book did not state this as well as it should have...

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

PARTNERS