Jump to content
  • Advertisement
Sign in to follow this  
yaneks

X file exported from 3DMax

This topic is 4159 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 to everyone! I there any one who could help me with this problem? I would like to know is it possible to get actual position of the mesh in DirectX application in case if mesh is translated in 3Dmax editor? Which DirectX function I need to use to get the mesh position? When I load the mesh I can't find the anything what will help me to find the actual position of the mesh.

Share this post


Link to post
Share on other sites
Advertisement
"Actual position"? Do you mean the centre point? The vertex m_xCenter gets the center of the mesh when you use this function.

            GraphicsStream xVertexData = m_xMesh.VertexBuffer.Lock(0, 0, LockFlags.None);
m_fRadius = Geometry.ComputeBoundingSphere(
xVertexData,
m_xMesh.NumberVertices,
m_xMesh.VertexFormat,
out m_xCentre
);
m_fScale = 1.0f;
m_xMesh.VertexBuffer.Unlock();


If that's not what you're looking there'd be a transform matrix somewhere in the meshes parent frame/container (I doubt you're using those though). Otherwise you'd just use the world matrix that you use when you render it.

[Edited by - CodeReaver on July 23, 2007 5:43:39 PM]

Share this post


Link to post
Share on other sites
The center of a mesh exported from 3dsmax is the position of the origin relative to the mesh. But, the position of the mesh in DirectX is (0,0,0), which means that the center of the mesh(the origin in 3dsmax before export) is at (0,0,0). You'll usually change the position of the mesh by applying world transformations to it using IDirect3DDevice9::SetTransform(D3DTS_WORLD, &someMatrix). If you dont know how transformation work, google for it . . .

Share this post


Link to post
Share on other sites
I mean if I change in 3DMax editor position of the object to (0, 25.0, 0) and
after that export it to DirectX file format. I would like to get this positon what I transformed in 3D max.
Is it possible?
It shoulde be done by matrix, but I don't know how to get access to that positon.

Thanks...

Share this post


Link to post
Share on other sites
It depends on how you export the mesh and how you load the mesh. If you export the mesh with frames, the frame matrices will determine the mesh orientation/scale/translation and the mesh vertices will likely be defined around the 0,0,0 model space...but not always.

As an example: In Blender, you can move a model as a whole or move each vertex. If you move each vertex, those vertices will now be exported with the offset. If you leave them centered around the origin, and move the entire object, the frame matrix is updated rather than updating every single vertex position. I don't know if your exporter behaves similiar, but it could.

In this case, you have several things to consider: The offset of each vertex and the offset of the frames. If you use the D3DXLoadMeshFromXFile() (or whatever it is called) and the mesh is simplified and frames are removed, you lose the heirarchical information. In this case, all you know is that you have a set of vertices that you could guess would have a geometric center, and that's the best you can do. To solve, calculate the geometric center of all of the vertices, and that vector is the (best guess) offset from the origin.

If you use the D3DXLoadMeshHeirarchyFromXFile (or whatever it's called), you retain the framing information and can simply look at the combined frame matrix (after you calculate it). The translation values in a matrix are in the bottom row, first three values being x,y,z respectively. Calculating the combined matrix and skinning/bones are a whole topic in themselves.

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!