• Advertisement
Sign in to follow this  

Skeletal Animation With Attachments (And Clothing)

This topic is 4610 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

Skeletal Animation With Attachments Hello developers, For the last two weeks, I have been looking though books, searching the net, reading forums, and still have found nothing useful. I have even queried this form a few times with specific questions that have all received ridiculous, poor, or just plain arrogant responses. Responses along the lines of "It's easy", "Just google", and "No, do it this way." are not appreciated or helpful in the least bit. It's not easy, I have googled, and I don't want to hack it together because you think it's "easier". I apologize for the harshness of this little intro, but I'm sure many of you probably feel my frustrations. Anyway, I'm trying to learn about skeletal animation and item attachments. It might BE easy, but I have no idea where to start, and "skeletal animation" tutorials are not what I want. I am looking for someone to discuss attachments and model file type pros and cons and loading of the items and attaching them to points on the skeleton. Yes I know there are lots of skeletal animation tutorials, but once the guy is walking in a file format that is usually quite practically useless, I'm lost. Is there a tutorial about attaching two spheres to a cube so that when I move the cube around in its animation frames the spheres stay attached? How do "professionals" who know all these things learn it? There must be something out there. Does anyone here even know how to do such things? I know there are not many games that implement it, and I assume it is due to the difficulty. If anyone even knows of a book or anything that would go over these more advanced skeletal concepts, or is willing to help with creating a demo I would be MOST grateful. I usually program in C# but anything in C++ is fine as well, and I'm using DirectX. One of the biggest problems with doing skeletal animations for me is handling file formats. I can load a md2 consistently, but I've had little to no luck with other formats, and obviously md2s are rather useless for my current interests. So here's my summary of the think I'd like to know. 1. Model file type pros and cons (bones, animations, attachment points) 2. Converting to .x where to find converters, where to find and how to use loaders 3. Swapable parts (Clothing, weapons) 4. Detachable limbs? (removing bones, probably similar to swapable parts) Remember, getting to a point where I can load a single bone cube and attach two spheres would greatly brighten my day. Thank you in advance EDIT: Title change - GeekPlusPlus [Edited by - GeekPlusPlus on June 1, 2005 4:39:14 AM]

Share this post


Link to post
Share on other sites
Advertisement
Consider Half-Life 1's approach.

Each model has a number of attachment points defined. These are bone-relative positions, so as the bones move, the attachment points move too.

When rendering, you first use the current state of the bones to figure out where your attachment points are in worldspace (by applying the transforms from root bone down to the bone the point is attached to).

You then match that position to a key point on the attached model (e.g. the origin), by translating/orienting the attached model to match the attachment point.

Once you've got that, things like swappable parts should be obvious - use the same attachment point on the parent model, but different child models - though detachable limbs is a little harder (because you usually have to patch up the mesh a bit so as not to leave a hole). As far as file formats go, you can get it working by just providing a second file along with each md2 (.attach, maybe?) which contains human-readable bone indices + position for each attachment point.

Share this post


Link to post
Share on other sites
Hey GeekPlusPlus, I am after the same thing as you are, swapping body parts of a mesh etc... I just posted a new thread before reading urs... if you've found some answers please notify me here as well, thx in advance. I will do the same.

I'm not too familiar with attaching parts to a in the program, but to my understanding, the mesh itself will have to have some dummy frames defined, so when u load a mesh hierarchy (for x files), the frame will be there for u to use.

Share this post


Link to post
Share on other sites
I've just finished implementing my MD3 loader for my game engine and since I was after exactly what you after, it certainly gave me an introduction to skeletal animation (though some argue MD3 is not true skeleton animated).

The thing is, before I did this I knew how skeletal animation worked simply by understanding transformations and a hierarchy of matrices which I'm assuming you should know before attempting this.

To have two spheres follow a ball around its a matter of simply setting the cubes transformation then drawing its children whos transformations are their own combined with its parent (the cube) so that when the cube moves or rotates, the transformation of the spheres also move along with it.

I suggest implementing MD3 for a started. It shows how you attatch models at 'tag' points and interpolating key-frames of animation using quaternions which is all what you need to be implementing skeleton animation.
I can point you to links if you want to do it and even provide code if you ask.

Share this post


Link to post
Share on other sites
MeshMan:
I agree that MD3 could be a start for learning more about character animation, but as you say it's not really skeletal animation - in its best form (with interpolation betweeen key frames) it's more like a "mesh morphing" technique IMO.

GeekPlusPlus:
You're asking about a lot of different topics in your post and I don't have time to answer them all so I'll focus on the core question of attachment points and leave the other questions for yourself to figure out or for other people to answer :)

Anyway, attachments are certainly not trivial - but once you got a nice skeletal animation system up and running it's not that hard either, so don't give up!

You can think of a complete skeletal animation system as consisting of two parts

1) Animation: This part animates a hierachy of bones that shapes your "skeleton". Each bone is modelled as a kind of "tripod" or "basis" and consists of a *position* and an *orientation*. Combined, a bone can be represented as a 4x4 matrix - just like a world matrix in your rendering system.

2) Skinning: This part maps each vertex in your model to a bone (or more, if you're doing weighted skinning). Before rendering the mesh you apply to each vertex the corresponding bone. This sets up the pose of your character.

Lets assume that you have a working skeletal animation system up and running and wants to attach a gun to the hand of your character. What do you need to render the gun? You need a world matrix for it that will place the model at the correct position and orientation based on the animation of the character.

But that's really just the "hand bone" in the skeleton you just calculated for your animation system - combined with the overall world matrix for your character! This combined matrix will first position the gun at the correct position in model-space of the character, then transform it to the correct position in world-space based on the characters world matrix.

This is the first thing you should do - get this up and running and you'll see your gun model being rendered at the hand of the character and follow the hand as it's animated. First step of an attachment system!

Ok, now you'll probably find out that even though the gun is rendered at the approximately correct position it isn't really looking as good as you want - and the orientation is probably also wrong. This is because the "hand bone" of the character probably doesn't decribe a very good attachment point. This is where "tags", "attachment points" or "attachment bones" comes into the system. There are a number of ways to handle this problem:

- You could simply add a new "dummy" bone in MAX or whatever animation package you are using, link it to the hand bone and make sure it's at the correct position and orientation. Even though you are not skinning any vertices to this bone you can still use it for attaching the gun.

- You could somehow come up with a correct *relative* displacement and rotation and type it in a data file. At runtime you apply this relative transformation to the hand bone and use the result for the gun instead of using the hand bone directly. If you have your own editor for setting up characters you could add this functionality to it so you can adjust the attachment point visually and have the editor spit out the data you need for the game.

So to sum up the entire process:

1) Get a (any!) skeletal system working.
2) In your game engine, create a way to get a hold of the bone you want to attach to (look it up by name, bone index or whatever you want)
3) Use the bone combined with the character world matrix to render the gun

Hope this was helpful and good luck in getting the system up and running!

- Kasper Fauerby

Share this post


Link to post
Share on other sites
Skeletal animation is one of the most difficult subjects to find help on. I have no idea why. Lots of games impliment it, and it's not that hard to get working. But it is difficult to jump into an empty pool.

Quote:

1. Model file type pros and cons (bones, animations, attachment points)
2. Converting to .x where to find converters, where to find and how to use loaders
3. Swapable parts (Clothing, weapons)
4. Detachable limbs? (removing bones, probably similar to swapable parts)

1. I can't help, I've only used the x file format in my projects. I don't know of other formats which support skeletal animation.
2. What modeler do you use? You can export to x-files straight from the modeler if you choose to do so. I think Microsoft also has a 3ds converter, but I'm not sure where it is.
3. Weapons are easy (see source box below). Clothing is even easier to get working, but a bitch to get optimized. To put it bluntly, you simply render the character and his clothes as two seperate animated skinmeshes, both using the same skeleton and the same array of matrix states. The clothes will not magically fit. You have to make sure the weight envelopes match well enough in the modeling program. To optimize, you would have to hide all of the parts of the character's body and lower-clothing levels when something is equipped over it. That took me some time.
4. You wouldn't remove the bones. You would just avoid rendering anything where the bones used to be. If you're referring to severed limbs, you would need each limb as a seperate mesh subset. You would then need a replacement subset for that limb, such as a chopped shoulder (yummy). You then animate and render the chopped shoulder and character the same way you would as if the shoulder was a peice of clothing.

Quote:

Remember, getting to a point where I can load a single bone cube and attach two spheres would greatly brighten my day.

You need to practice playing with matrices. Using matrices, it's very simple to setup a hierarchy of states which control each other. The parent (cube) just ignores it's children and simply rotates or animates. The children (spheres) do the same thing. But once everything is animated, the spheres must multiply their parent's matrix with their own. But only to render. Something like this:

Matrix parent;
Matrix child;
Matrix child_offset; // the state where the sphere exists relative to the cube

// Update
parent.Rotate( 0, PI / 4, 0 );
child.Rotate( PI / 8, 0, 0 );

// Render
SetWorld( parent );
RenderCube();

Matrix child_state = child * child_offset * parent;
SetWorld( child_state );
RenderSphere();

Let me know if something needs more clarification.

edit: Edited #3 :)

[Edited by - Jiia on June 1, 2005 3:38:25 AM]

Share this post


Link to post
Share on other sites
EDIT: Kasper Fauerby and Jiia, I was typing while you posted so consider my post to be above yours. However, yours seem to be much more detailed so I'm looking them over now. Thanks!

Hello,

First of all I would just like to thank the current responders for their genuine assistance. =)

Ok, so what I understand about attachments is that when an an arm is told to do a "Wave" animation, it goes through a series of transformation over delta time. If this arm were holding a gun, then as a child to the arm (a pointer in some 'attached' variable for the arm) it would then also be put through these transformations, keeping it in the same position relative to the moving arm.

If that's the general idea, it seems pretty simple. Please correct me if I have something wrong.

Now clothing would be different. I think you would have all the relevant animations for that article right? For example pants need to walk, but don't need to wave. Now, lets say your model stats to run "Run". Then, you want to put on a pair of trousers. You wouldn't want to render the animated pants overtop of the legs, as that would be quite a waste of rendering power. So, you would have to detach from the hip downward on your model, then reattach the new legs modeled wearing trousers, and have them set to "Run" starting at the key frame you stopped the last legs at. If this is correct, I'm a little lost on how to "cut off the legs". I know if you are just changing pants, it would be possible to just re-skin the legs, but for something like plate mail, that wouldn't work.

I know some people model every part separately and then use an offset value from a point of reference, but then you would have problem with "scaling" our model, and attachment points wouldn't tween nicely since they a actually different models.

I hope there's some new information to add to this topic. I encourage anyone with some information to contribute it. If I can get something working, I would be more than willing to write a tutorial and share spread the wealth.

It's going well so far, lets keep up the quality responses.

- GeekPlusPlus

Share this post


Link to post
Share on other sites
Quote:
Original post by Jiia
Quote:

Remember, getting to a point where I can load a single bone cube and attach two spheres would greatly brighten my day.

You need to practice playing with matrices. Using matrices, it's very simple to setup a hierarchy of states which control each other. The parent (cube) just ignores it's children and simply rotates or animates. The children (spheres) do the same thing. But once everything is animated, the spheres must multiply their parent's matrix with their own. But only to render. Something like this:
*** Source Snippet Removed ***
Let me know if something needs more clarification.

edit: Edited #3 :)


I'm wondering how you put this all into a OOP kind of system? I've never fully understood how the render path looks. Like say you have a "class MeshNode" which essentialy is your mesh which contains - its local transform? If I also store a list of attatched MeshNode's, does it go something like:

if (pParent)
ApplyMyTransformWithCombinedParentTransform();
else
ApplyMyTransform();

RenderMesh();

For Each child in Children
RenderChild(child);

Pseudo code of course :)

Edit: I forgot to ask how you cascade the root matrix to the final child if the skeleton tree is say 5 levels.

Share this post


Link to post
Share on other sites
Quote:
Original post by GeekPlusPlus
You wouldn't want to render the animated pants overtop of the legs, as that would be quite a waste of rendering power. So, you would have to detach from the hip downward on your model, then reattach the new legs modeled wearing trousers, and have them set to "Run" starting at the key frame you stopped the last legs at.


Hmm, I have this picture in my head that I would have the parts I can attach to a model with the same skinning as the actual legs on the model and just draw the clothes on top of the legs.
Say like I have a pair of bear legs (woho!) that have the run animation and its composed of 5/4? bones. I play the animation of the legs and the vertices are affected by the transformations of the bones as usual, and now I want to attatch a pair of shorts or trousers (pants for you US people). I would just have the trousers have the same skinning as the legs themselves and attach them to the torso like the legs would be.
Would that work?

Share this post


Link to post
Share on other sites
Hello,

I think I get the clothing thing and now I think my lack of experience with bone animations might be the problem. Originally I thought it might be like 2d, where you had to animate every article of clothing. But with bone animations. All you need is a single skeleton that has all the motions. And then have the envelopes setup nicely so that no matter what mesh legs you use, or what mesh torso, or arms, they will always fit on the bones, inside the envelopes and animate nicely. And that is why Shadowbane does not have capes. They do not have bones and envelopes for a cape since could not make it look nice without lots of tiny bones animating (and we all know SB doesn't need more lag) or rag doll physics.

I have played with envelopes and animating bones in 3d Max. I didn't know that you could load a skeleton and then swap different meshes into the envelopes though. As I said this may have to do with my inexperience with skeletal models, but maybe you could give me some pseudo pointers as to how that's done?

Also, does anyone know where I could find a .x or a .max or .md3 that has bones and animations in it? Not up to paying for a model just for learning this technique. I have Max, if worse comes to worse I can run though a tutorial to make my own. However I can never get the knee to tween right where the envelopes overlap, but that's clearly off topic. =)

By the way, this is quite possibly the best discussion I've had on GD for a good while.

- GeekPlusPlus

Share this post


Link to post
Share on other sites
Quote:
Original post by MeshMan
I'm wondering how you put this all into a OOP kind of system? I've never fully understood how the render path looks. Like say you have a "class MeshNode" which essentialy is your mesh which contains - its local transform? If I also store a list of attatched MeshNode's, does it go something like:

I just use a tree list. The root node is at the top, and each node sends it's final result down to all of it's children.

If you're referring to weapons, I don't have them as part of the skeleton. Each weapon controls itself, rather than be part of the hierarchy. Characters would just have a simple list of attached objects. Scroll through the list to update and/or render, and let each object take care of itself. All the object really needs is a link to the bone matrix that it's attached to.

Quote:
I think I get the clothing thing and now I think my lack of experience with bone animations might be the problem. Originally I thought it might be like 2d, where you had to animate every article of clothing. But with bone animations. All you need is a single skeleton that has all the motions. And then have the envelopes setup nicely so that no matter what mesh legs you use, or what mesh torso, or arms, they will always fit on the bones, inside the envelopes and animate nicely.

Skeletons are very important. If it's possible to use the same skeleton for all of the humanoid models in your game, go for it. I couldn't get away with it; my women looked like freaks with male shoulders. So I have gender specific skeletons. That means I can recycle animations between any gender-matching characters. Remember that you can scale models, so it's not very hard to make an ogre using the same skeleton you use to make an elf, with a bit of tweaking. Providing accurate melee-type contact between different scaled characters may bite you, though.

Quote:
I have played with envelopes and animating bones in 3d Max. I didn't know that you could load a skeleton and then swap different meshes into the envelopes though. As I said this may have to do with my inexperience with skeletal models, but maybe you could give me some pseudo pointers as to how that's done?

The envolopes do not need to be exactly the same. I fitted a really thick hooded coat (like Jin's coat in Tekken 4) to a guy, and the coat's envolopes were huge. What I did was import the character mesh into the coat scene and gave it the same animations. As the time slider is moved around, they both animate together, and envolope/bending problems become obvious. So it's only the skeleton that is a must. You could start from scratch with new envolopes for each model, as long as you have a method to see the results.

Quote:
Also, does anyone know where I could find a .x or a .max or .md3 that has bones and animations in it? Not up to paying for a model just for learning this technique.

There was a model, tiny.x, that comes with the Direct SDK. I think it still does.

Quote:
I have Max, if worse comes to worse I can run though a tutorial to make my own. However I can never get the knee to tween right where the envelopes overlap, but that's clearly off topic. =)

I feel ya. I've been through it so many times, the pain is starting to subside, though. I personally hate the hip area more than the knees.

Share this post


Link to post
Share on other sites
When it comes to loading the skeleton itself. Would that be in it's own .x? And then you would load the clothing meshes separately? If so, how do you attach the mesh to the skeleton. Is it a DirectX operation? Otherwise it sounds like it would be very complicated. lastly, you would have the torso and legs as separate meshes so you can change clothes, and the head separate for custom faces, and the arms separate so you can chop them off, then you would have tweening issues at those joints right? Unless you made the mesh continue past the joint for the arm and then had the break not at a joint. Did I just answer my own question?

So if you wanted to have changeable pants and allow both legs to be lopped off. You would have to build the legs, each as a separate mesh, build the hip area up to the top of the pants as a separate mesh. Then load all 3 when changing pants and apply them to the skeleton. I think that sounds right.

So could you give an example of how, through code, you apply meshes to a skeleton? I don't need actual source, I just don't even know where to look for that. For C# would it be in DirectX? or would you have to somehow write it yourself?

Lastly, do you have problems finding skeletal animations that will load properly other than tiny.x. I have heard it's near impossible.

Wow, I've learnt quite a bit already. I'm actually working on this right now. I'll keep you all up to date.

Thanks,
- GeekPlusPlus

Share this post


Link to post
Share on other sites
Hi, I am currently working on a similar thing. I hope somebody can provide an explanation on the relationship between frames and mesh containers in a mesh hierarchy. I am quite confused, as different meshes are structured differently. As I step through my program when it's creating the frames and mesh containers, some meshes creates all the frames (bones) first and then create a single mesh container which "skins" the mesh, I think tiny.x does this. And other meshes I've encountered creates a frame, then creates a mesh container for that frame, and it does that for all the frames of the mesh.

I'm quite confused on the fact that if I want to create a mesh with swappable body parts, what kind of mesh format should i use... and how. thanks in advance...

and would somebody please have a look at my thread (below) and provide some responses if possible, thank you..!

http://www.gamedev.net/community/forums/topic.asp?topic_id=322974

Share this post


Link to post
Share on other sites
oh yeah I forgot,

GeekPlusPlus, I found this simple x file of a basic skeleton, with animations, which is quite nice, and thought it might be useful for you. not sure if you have it already but here it is:

http://www.toymaker.info/Games/html/x_file_animation.html

download the source code for this tutorial and u will find the x files. It comes in separate files for each animation set, but u can use Mesh Viewer in the SDK to combine the animation sets into a single file, like the tiny_4anim.x in the MultiAnimation sample of the SDK.

thx

-fuchiefck

Share this post


Link to post
Share on other sites
Quote:
Original post by GeekPlusPlus
When it comes to loading the skeleton itself. Would that be in it's own .x? And then you would load the clothing meshes separately?

It just depends on how you prefer to do it. In my engine, I created an object called a "Race", which is basically just a skeleton class, with extra details like distance values and heights. Humanoid males have a race, and humanoid females use a different race. The race file is created externally using a small tool I made. It basically just rips the skeletal information (not animation, but bone offsets, hierarchy order and such) out of an x-file skinmesh and stores it by itself. All skin meshes from that point on are implimented as "suits". Characters equip suits to build their body just like they equip clothing or armor. All suits have a race type, and all compatible suits are of the same race.

There is never a reason to "attach" the skeleton to a mesh. The skeleton is only needed to animate. So the character object in your game would animate his skeleton, then pass the final array of animated bone matrices to all of his meshes. That array of matrices is all that's needed to render your skinmesh.

This is how I currently accomplish this. But it wasn't an easy task getting this far. I don't recommend diving in head first. You should probably try to experiment with a single animated mesh, at least until you get a good grasp of how it works.

Quote:
lastly, you would have the torso and legs as separate meshes so you can change clothes, and the head separate for custom faces, and the arms separate so you can chop them off, then you would have tweening issues at those joints right? Unless you made the mesh continue past the joint for the arm and then had the break not at a joint. Did I just answer my own question?

Again, I made another tool. The tool loads in an x-file and allows me to select subsets to export as individual meshes. There are no tweening issues because all of the seem vertices have the exact same bone weights. You can see a snap of one of my characters here (don't poke fune, he's WIP [smile]). He's made up of about 16 seperate meshes, and there are never visible seams or cracks as he animates.

Quote:
So if you wanted to have changeable pants and allow both legs to be lopped off. You would have to build the legs, each as a separate mesh, build the hip area up to the top of the pants as a separate mesh. Then load all 3 when changing pants and apply them to the skeleton. I think that sounds right.

Yes you could do it that way. But you might want to consider using subsets to seperate parts rather than seperate meshes.

Quote:
Lastly, do you have problems finding skeletal animations that will load properly other than tiny.x. I have heard it's near impossible.

I use the exporter from www.Quest3D.com with a slightly old version of 3D Studio. Once again, I made a tool which extracts the animation from an x-file and stores it seperately. But I've never had any problems reading the exported files.

Share this post


Link to post
Share on other sites
Hey Jiia,

Thanks for replying again.

Right now, I have successfully loaded a bone animated character into a hierarchy structure in C#. At the moment I have rendered different parts of the frame with it's mesh and skin. Next I will whip up a structure to recurse through the tree and show all the available meshes. Then, I can try altering them.

Things seem to be going quite well so far. Hopefully I don't go insane when I get to actual animations and switching.

At the moment I don't have anymore specific questions since your last post, but I'm sure I will soon.

And thanks to fuchiefck for the C++ source and the .x skeleton, they have helped a lot.

- GeekPlusPlus

Share this post


Link to post
Share on other sites
Hello I'm back.

I have managed to load, display, and animate a few x files (some I even made and exported from 3d Max) with my C# skeletal demo program. It's fairly similar to the C++ so if you know that you can help with my next problem.

I'm trying to get swapable meshes working on my frame. The first thing I tried to do was take the MeshContainer of a simple mesh cylinder and set it to be the MeshContainer for the left thigh bone. When I did this nothing happened. Obviously my cylinder is missing some information needed to work with that frame. Could someone explain this to me?

Now, I'm assuming if I made a bunch of animations for a skeleton. then I added the mesh components to it so that they would be animated along with the bones, then if I save the mesh in a separate x file, then it would work when I set that mesh to be the mesh container for the frame? Since it was designed for that frame?

That might sound confusing, but the bottom line is if I have an animated skeleton, I'd like to be able to use different meshes on it without reanimating everything. And I might want to switch just the legs. (thighx2 calfx2). So what do I need to do to attach new mesh to my animated frame?

Thanks

- GeekPlusPlus

Share this post


Link to post
Share on other sites
>take the MeshContainer of a simple mesh cylinder and set it to be the MeshContainer for >the left thigh bone.

You cannot swap the whole meshcontainer like you tried, what happens is, you will be replacing the position (transform matrix) of the original mesh container, along with other information that you might like to keep original... and the matrix of the new mesh may not be the same as the original one. When this happenes the cylinder may appear out of position, or just being rendered somewhere outside the screen. What u should do is: load a new mesh and get its pMesh pointer, and when you are rendering the part that you want to replace, just CloneMeshFVF the new mesh, so the pMesh pointer of the original left thigh bone will become the pMesh of the cylinder. Your code may become something like this:

if (pFrame->Name == "L_ThighBone")
{
pCylinderMesh->CloneMeshFVF(pCylinderMesh->GetOptions(), pCylinderMesh->GetFVF(), pDevice, &pMeshContainer->MeshData.pMesh);
}
//continue drawing the meshcontainer..

Teh above code will make a copy of the pCylinderMesh and place it in pMeshContainer->MeshData.pMesh, which was your original mesh.

>I'd like to be able to use different meshes on it without reanimating everything.
You won't have to reanimate anything if you just change the pMesh pointer, since your frame and meshcontainers remains original.

Other things you have to look for is the transform matrix of the Cylinder by itself, it may affect the position, and may not be placed in the right position. For more info please goto: http://msdn.microsoft.com/newsgroups/default.aspx?dg=microsoft.public.win32.programmer.directx.graphics

and look for a thread called "swapping meshes in a mesh hierarchy"... I've been getting quite a bit of help from there.

Hope I have helped...

-fuchiefck

Share this post


Link to post
Share on other sites
Thanks for replying.

I get what you're saying, I'm just having problems converting this part to C#. The C++ clone function takes a reference of the current mesh pointer so that you can attach the new mesh pointer to it. In C# there is no parameter, but the function returns the cloned mesh. However, the Mesh proporty on the MeshData is "not a variable" so I can't just set it

MeshContainer.MeshData.Mesh = newMesh.Clone(<flags>,<vert format>, _d3dDevice);

That's how I tried to do it, and it tells me that Mesh is not a variable, so I can't set it that way. There is no SetMesh or anything like that either. Does anyone know how to set the mesh pointer in C#?

- GeekPlusPlus

Share this post


Link to post
Share on other sites
Hey, I figured out my mesh switching problem.

Instead of setting the mesh I set the MeshData

MeshContainer.MeshData = newMeshData

I'm going to have troubles if I want to load meshes with FromFile() though since I can't seem to copy a pure Mesh into the MeshContainer.

Anyway, then I setup the new textures and materials and it did switch. The problem is the new "leg" is about 20x smaller when attached to the skeleton than if I render it by itself. Now this means that somewhere along the skeleton's chain he has been scaled down. But _I_ have never applied a scale of any sort, or even changed the default starting position. Is it possible that the model has some inherit auto scale down?

I did think it was odd that he was only about 2 units tall...

- GeekPlusPlus

Share this post


Link to post
Share on other sites
I have never touched c# before, so I don't know... but its weird how you can't get the pMesh property from the MeshData. But I guess copying the MeshDatas directly should do the job too.

About the scaling of your cylinder, its like the problem of the position i guess. Your cylinder must be in the right scale with the rest of your skeleton parts. I don't think you can resize anything, or even if u could I don't think its a good idea. Its better to start off with all your meshes in the same proportion.

BTW how are you loading your cylinder mesh? It seems like you are loading it as a hierarchy, since u are working with the meshdata of the cylinder mesh, which is a property of a meshcontainer... I'm sure theres a way to access Meshcontainer.MeshData.Mesh or something like that in c#. If u figure that out you can simply LoadMeshFromX and use the pMesh pointer, instead of having to use LoadMeshHierarchyFromX. anyway just a suggestion...

-fuchiefck

Share this post


Link to post
Share on other sites
Yeah, I thought about that problem. I wouldn't be able to use FromFile() because it returns a pure Mesh.

However, if I were to model a pair of pants in Max, then I would have to have a hierarchy for the mesh. When I export, I wouldn't export the bones/frame but I would still need to export the hierarcy of the mesh so that I could apply the proper mesh subsection to the proper bone in my program right?

The only time I wouldn't use a mesh hierarchy is if I were importing a mesh for a single bone. Or possibly weapons and other simple attachables.

Also, I believe my cylinder _IS_ in the right units. I can render my cylinder by itself right beside the skeleton and it is about the same size as one of his legs. When I replace any bone's mesh with the simple cylinder, it shrinks down to about 1/20th the size. It's very weird.

- GeekPlusPlus

Share this post


Link to post
Share on other sites
Quote:
Original post by GeekPlusPlus
Yeah, I thought about that problem. I wouldn't be able to use FromFile() because it returns a pure Mesh.

However, if I were to model a pair of pants in Max, then I would have to have a hierarchy for the mesh. When I export, I wouldn't export the bones/frame but I would still need to export the hierarcy of the mesh so that I could apply the proper mesh subsection to the proper bone in my program right?


Umm... sorry I'm a bit unclear on your question... I think if you mean by exporting the hierarchy, you are actually exporting the frames and mesh containers... To apply the proper mesh subsection to the proper bone, you just have to do what I suggested before... in the DrawMeshContainer function (or something similar), when the Frame is the part you want to relpace, eg pFrame->Name == "L_ThighBone", then you just replace the mesh with the new one. You don't need any hierarchy information for your new body part, as you are keeping the original set, in order for the animation to work.

hmm... with the scaling of the cylinder, I don't know where the problem is... soz... :p But if I were you, instead of drawing a whole new cylinder, I would modify the bone in 3d max, say the Left thigh, like make it fatter, then just export that bone as a new mesh. And try to replace that (somewhat demented)bone onto your skeleton and see if it works. Coz I think if you were to design different body parts, they are best designed on the same skeleton.

-fuchiefck



Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement