DanoOKC

Please take it easy on me, I'm new to XNA and DirectX in general. In previous applications I would model say two boxes in Caligari GameSpace and join these as a sibling. After I save this as a .x file, I could access each box as a limb of the main model. Doing a count for limbs would return 3, 0 being the model as a whole, 1 being one box, and 2 being the other. Looking through the docs, I'm unable to put my finger on the equivalent in XNA. I do see a model class and mesh classes seem to be under this. Is this the same as limb 0 = the main model of the object, and then two meshes under the model that represent the two boxes

Sorry if this makes no sense or if it has been asked previously. I really did try to search these forums for this before I posted.

Any pointers in the right direction here would be awesome.

Thanks!
Dan


Re: XNA Game Studio Express What is the .X file limbs equivalent

leclerc9

If object B is a limb of object A, in a .X file, object B would be a mesh inside a child frame of object A (technically its the transform of that mesh, but read on).  In a .X file, a frame contains a transformation matrix that represents its location in 3D space relative to its parent frames.  In addition to its transformation matrix, a frame can optionally have any number of child frames or a mesh.  This frame hierarchy is written to the Model class in the form of ModelBoneCollection, in which each bone has a transformation matrix, a parent bone (optionally), and 0 or more children.  Meshes, which would be the visible manifestation of the limbs you describe, contain the index to their parent frame (bone in XNA).  The actual limbs, however, are these parent frames.


Here is an example of a simple hierarchy in a .X file:

Frame RootFrame
{
  FrameTransformMatrix {...} 
  
  Frame FrameA
  {
     FrameTransformMatrix {...}
     Mesh MeshA {...}


  }

   Frame FrameB
   {
       Mesh MeshB {...}
       FrameTransformMatrix {...}
    }

}

In this example, FrameA would be a limb of the RootFrame, which represents the bone of the main model.  FrameA would also be the bone of MeshA.  FrameB would be another limb of RootFrame.

In code,
model.Root; // The RootFrame
model.Bones["FrameA"] == model.Meshes["MeshA"].ParentBone // This line is true
model.Meshes["MeshA"].ParentBone.Parent == model.Root // Also true




Re: XNA Game Studio Express What is the .X file limbs equivalent

Jon Watte

In .X, the various relative transform matrices are known as "Frames". Each "Frame" is a matrix frame of reference, relative to its parent.

In the Model class, you can get a list of Bones that correspond to these Frames, and in each ModelMesh instance, there is a ParentBone which is the bottom-most Frame in the mesh. To get the full transform of each ModelMesh, you have to multiply the ParentBone by each of its parents in succession, until you reach the root. There are helper functions to do all this for you. Check out the member documentation on Model for more information.






Re: XNA Game Studio Express What is the .X file limbs equivalent

DanoOKC

Thanks guys! This was exactly what I was looking for.