Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I'm trying, for many days, to get the Matrix or the Vector3 of my 3D model, I don't want to use the World matrix because I need first to idenfy the axes of my object for animation (= rotation of a second object around my first object).

If you have an idea or a tutorial for this ?

Many thanks,

Jeangil

share|improve this question
    
I'm not sure what you are asking. Are you asking how to get the vertices of your 3D model? –  CiscoIPPhone Jul 4 '11 at 14:29
    
Do you have the orientation and the position of your model? Now you want to put that in a 4x4 matrix? –  Maik Semder Jul 4 '11 at 14:40
    
Please elaborate on the problem you are trying to solve. –  Steve H Jul 4 '11 at 15:48
    
Sorry to be not very clear, but it's not very clear in my mind.I want to know the orientation, the axis(= means the UP, Right and Forward vector) of my model at any time. Is it possible with Matrix and vector3 ? Thank you in advance Jeangil –  jeangil Jul 4 '11 at 18:06
add comment

2 Answers

It sounds like you may be looking for the bone transforms, which define transforms for each mesh in a model relative to the model's coordinate system. This lets you, say, rotate a car wheel about its own axis, and keep it correctly positioned relative to the car chassis.

Assuming that you have already loaded a model with

var model = Content.Load<Model>(@"mymodel") 

You can easily get to the bone transforms with

model.CopyAbsoluteBoneTransformsTo(transforms)

See this link for a decent explanation, or this one from Riemer's.

This XNA App Hub sample demonstrates loading a tank model, and having its wheels and turret move relative to the model.

The basic idea is that different meshes (in this case, the wheels and tank) are connected via "bones." Bones represent a hierarchical relationship between model elements (despite the name, they are not exclusive to animal or human models).

In your 3D modeling app of choice, you define bones connecting child meshes (wheels) to parent meshes (the tank chassis), and define transforms in the child mesh's space that transform the mesh relative to its parent.

By using the .CopyAbsoluteBoneTransforms() method, you can quickly concatenate the child's transforms with the parent. This has the effect of putting the child mesh in the parent's coordinate space, so that you'll get a valid result when you multiply the result by the view and projection matrices.

share|improve this answer
add comment

The "matrix" of an object in model space with no transformations applied is simply:

Matrix.Identity

Similarly the position would simply be:

Vector3.Zero

The "world" matrix is responsible for transforming an object that is in model space into world space.

To make object A orbit object B you could do this with object B's world matrix. Simply apply an appropriate orbit matrix (translation then rotation), followed by object B's world matrix, to object A. This will then be object A's world matrix.

Alternately: you could take object B's world matrix and use the appropriate Matrix properties: Translation to get the position and Forward, Left, Up, etc (MSDN), to get the appropriate axes for constructing the series of transformations to orbit object B.

share|improve this answer
    
Thank you, Andrew I am going to read and try what you have sent to me. Jeangil –  jeangil Jul 4 '11 at 18:11
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.