iconjunky

Hi, I`ll get straight to my question.

What`s a good way of setting a models position with a vertex position from another model

I`ve only recently started with c# and am struggling a little with the syntax. With python it would have just been a case of, roughly something like:

modelA.setPosition(modelB.getMesh().getVertex[1].getPosition())

Thanks in advance.

-Daz.



Re: XNA Game Studio Express Setting a model position with a vertex position?

Jon Watte

You can't generally get the position of vertices, because their position depends on the execution of the vertex shader.

What you typically want to do is to create "attachment point" bones/frames/nodes, which you can look up using the Bones collection on the Model. You can then use the transform of that bone as the the relative transform of the attached object.






Re: XNA Game Studio Express Setting a model position with a vertex position?

iconjunky

Ah, thanks very much. I was on completely the wrong lines then.

I`m assuming that I create these attachment points with C# and NOT during the actual modeling process of the model





Re: XNA Game Studio Express Setting a model position with a vertex position?

Jon Watte

No, you create them during modeling -- they are bones, basically.

Then, to "attach" a mesh to another, every frame, you get the (world space) location of the attachment bone, and set the location of the attached mesh to the location of that bone.