Sign in to follow this  
be17_17y

Attach new mesh

Recommended Posts

be17_17y    128
i've read one of the topic about attaching mesh in somewhere in this forum. it said if i want to make my character can hold something in his hand, then maybe i must build the character bone plus 1 bone in hand so that we can attach mesh to it with mesh hierarcy. how if i use another mesh so the character can hold many kind of things. for example : he can use sword or axe or spear..... so...if i want to change what his holding later, i just have to create mesh of that thing and attach it to the character mesh..... someone can help me??

Share this post


Link to post
Share on other sites
Kahsm    302
Hello be17_17y,

I said something like that not too long ago, so it was probably my thread.

If you've done work with an animated frame hierarchy then you know that frames have matrices which give their position relative to their parent frame. When you call your UpdateFrameMatrices(...) your recurse through the frames multiplying the parent's position with the child's position so that every frame also has a matrix which represents it's absolute (relative to world) position and rotation.

If you get that matrix off your extra bone and use it when you render the item that is "attached" then it would get rendered right where that bone is and at that bone's rotation (which would be based on it's parent's rotation and its animation).

So it doesn't matter what the mesh is. If it's a sword then you'd want the handle in the hand, so you might need a constant matrix to offset from the centre of the mesh. Then you would setup one of these for each mesh type.

Also, if you wanted to move the sword from attached to the hand to attached to the back then you wouldn't want the handle portion attached anymore so you would need another offset from your attachment bone on his back.

I hope that is clear enough.
Good Luck,

Share this post


Link to post
Share on other sites
kodeninja    214
I did something like that before. All I did was for each of my bones in a mesh's skeleton I had a list of other meshes that were attached at that point (which was usually empty). When it came time to render the part of the mesh assocated with that bone I simply sent a render call to the object that was attached and used the current matrix that was there. This worked quite well and was simple to impliment. This is of course assuming you have access to the skeleton system you are useing (ie. your writing your own custom engine, or atleast can modify the one you are using)

Share this post


Link to post
Share on other sites
be17_17y    128
What if i dont build my hierarcy frame / bone in the code, i used
app. like 3dsmax or 3dmilkshape to create bone and animation of my character (exmp. warrior.x) ?,
so when i want to "attach" other mesh from other file (example : sword.x), HOW
I get "which" / "where" bone or place i will put that mesh???.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this