Sign in to follow this  
ekba89

Skinned mesh

Recommended Posts

ekba89    788
I'm trying to move parts of the skinned mesh freely. I learned from and used the code in [url="http://www.toymaker.info/Games/html/load_x_hierarchy.html"]this link[/url]. I think i mostly understand how it works. And now what i want to do is move my character's feet freely to align with terrain height. I'm not sure if trying to compute bones position every frame according to height is the best way so i'm open to suggestions :). Lastly as far as i learned there are few methods to implement skinned mesh. Which one is faster? Thanks.

Share this post


Link to post
Share on other sites
Buckeye    10747
What you describe (move the character's feet to align with the terrain) is a pretty difficult task as it would involve some relatively complicated calculations. One method would be [b]inverse kinematics[/b], which really involves more than a few posts in a thread could teach you. You should google for that term and read up on it if you want to give it a try.

A more common method, which may or may not be precise enough for you, is to load a "walk" or "run" animation, and position the character the correct distant above the terrain as it moves, letting the feet be positioned by the animation (whereever that may be). If the terrain is particularly angled in one direction or another, the feet will likely penetrate the surface a little here and there, but it's a much simpler approach.

As far as I know, there is generally just one method to animate skinned meshes. A similar method (which isn't really a "skinned" mesh as commonly understood) is to create several meshes (head, torso, arms, legs) and animate each mesh in its entirety (not per-vertex) in it's own frame - I think the "bones-all" example (the skeleton) on toymaker implements that method.

It's likely that the second method mentioned is a bit faster as it renders multiple vertices with a single transform, versus weighting multiple matrices against each vertex.

Share this post


Link to post
Share on other sites
ekba89    788
Thanks for reply. Now I am using 2nd method. I am creating terrain with height map so i've height data. And i position my character according to this height but as you mentioned it is not precise enough and looks very bad. So my solution was find height data under both foot with rays and position them according to this height. Is there a problem with this solution? I thought it should be easy to implement.

Share this post


Link to post
Share on other sites
Buckeye    10747
[quote] Is there a problem with this solution? I thought it should be easy to implement. [/quote]
Whether 2D or 3D, if you're using a skinned mesh - see my first reply.

Unfortunately, there isn't an "easy" method, as you'll probably want to position the hips a certain distance above the terrain (average between the two feet?), [i]and[/i] position the feet in an animated position. That position probably won't be always [i]on[/i] the terrain. Characters normally have, at most, just one foot on the terrain when they walk/run. Then the knees will have to be positioned properly between the hip position and the foot position.

EDIT: Also, if you're working in 2D, shooting rays seems to be overkill. If you have height versus (e.g.) x values, you can just retrieve the height for the x-value of each foot from the array.

Share this post


Link to post
Share on other sites
ekba89    788
Sorry i forgot to mention i am working in 3D. Its late here so i'll look for inverse kinematics tomorrow and is there any physics library which supports both height map terrains and skinned mesh characters? And my second question in my first post, i found out there are 4 ways to implement skinned mesh, i know software method is slowest but what are the advantages of others which one should i try to learn. I know i am asking a lot of question sorry for that but it is really hard to find good tutorials or sources about skinned mesh. Thanks for answers again :)

Share this post


Link to post
Share on other sites
Buckeye    10747
I don't know of any library that handles the specific case you're describing (maybe someone else can help out here?).

With regard to the number of methods, I was generalizing "skinned mesh" to mean per-vertex positioning using weighted bone influences. I wasn't distinguishing between software calcs and, for instance, calcs done in the GPU (with a shader, etc.). There might be subtle variations, but the principle of combining the weighted results of position-matrix multiplications remains the same.

If you know of other methods (other than simple mesh translation/rotation or per-vertex calcs as described), I (for one) would certainly be interested.

In any case, best of luck.

Share this post


Link to post
Share on other sites
ekba89    788
No i don't know any other method than these either I don't think i know more than you about skinned meshes :) . Now i am making calculation in CPU (software method) and trying to learn other methods from directx sdk example because i couldn't find any other tutorial about that. In documentation it says non-indexed, indexed, shader-based and software skinning. If with shader skinning calculations are made in GPU and with other methods made in CPU, for every method there should be advantages and disadvantages over other methods. Actually i would like to learn most flexible method. So I am trying to find out what are the differences or should i use the easiest one :).

Share this post


Link to post
Share on other sites
Buckeye    10747
Ah! Okay. I understand what you're saying about the 4 methods.

Interjection: Don't assume I know more about anything! I [i]may[/i] have a bit more education or experience, but I try to be careful about saying "To the best of my knowledge.." I've found all too frequently that my "best" is sometimes incomplete.

In any case, indexed vs non-indexed is just a way of accessing the vertices within the vertex buffer. I think the general principle of multiplying positions and matrices with weighting still holds. I haven't written code myself for non-indexed skinning as the x-files I use are indexed.

Regarding software vs shader - the same algorithm is done. However, depending on the way in which software calcs are done, I would guess that a shader, specialized for a specific vertex structure and matrix array, is faster for skinned meshes.

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