Question

I am sorry if what I ask is a trivial question, but I have no idea how to even begin searching for the answer in a search engine.

I clearly understand how to create a model in 3ds max and load it into an XNA (for instance) program, what I need is to be able to pick a point on a model in the 3ds MAX app and then to be able to trace it's world space position in my XNA app at any given point it time.

Why? I need it to trace where the player gun's muzzle is to create a muzzleflash effect in the right spot when the player fires.

I would appreciate any help, thanks.

Was it helpful?

Solution

Well in XNA the problem is solved quite easily by copying the bone transforms of the point. One just needs to set the point as a ModelMesh in the 3d creation tool. E. g. in 3ds MAX it is by setting it as a separate element of the scene. Then in the engine you can access the ModelMesh by its .Name propery and get it's position by doing Model.CopyAbsoluteBoneTransformsTo(). There are a few more steps to do, but if you search CopyAbsoluteBoneTransformsTo you will find all you need.

Here is the Stack Overfrol article that helped me:

Position of a modelmesh in XNA

OTHER TIPS

Usually you want to use some kind of Scene Graph in your application to manage objects and their transformational relation. 3DS Max also uses a scene graph, and your exporter and export file format should take care of it.

From there you can attach an empty node (dummy object etc.) at the desired position in 3ds max and export it to the application. Suppose your scene graph is working, you are able to retrieve the world space coordinates of the empty node or attach (as children) other objects like the muzzle flash.

Another Solution not involving a scene graph is determine the position from the vertex positions or face position of the mesh (submesh).

This however can be quite tricky, since i'm not sure if the VertexID or FaceID of 3ds max correspond to the exported ids.

If you model is static, you can use this picking example to determine the face and picked position on the face (talking about barycentric coordinates) inside XNA.

You can now write down your face ID and then you should be able using model transformation to calculate the position of the picked point in world space at any time.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top