MD5 reader fixed

For what reason its good to import the skeleton into the 3D Engine, if you can't move the single Bones and update the mesh? Is this only to save memory by keyframing?



@Ender I think stuff like Inverse Kinematics(IK) of the bones belongs to ragdoll physics… http://en.wikipedia.org/wiki/Ragdoll_physics


JTroll said:
For what reason its good to import the skeleton into the 3D Engine, if you can't move the single Bones and update the mesh? Is this only to save memory by keyframing?


I think it is a good thing for coders :D . If you have no possibility to import a skeleton into your 3D engine you should do every animation by code. In a complex structure like a human body skeleton, doing animation directly by code is not feasible. Also, doing it with a 3D package can lead to more realistic results, cause of you can immediatelly see results of your modifications.

@Ender I think stuff like Inverse Kinematics(IK) of the bones belongs to ragdoll physics.... http://en.wikipedia.org/wiki/Ragdoll_physics


If this is what you need, I am almost sure that neither jME and MD5 Reader support such a feature. IK is rarelly supported in 3D engines specifically done for game development. Also, I think that is very unlikely that I will try to support such a feature within MD5 Reader. IK is well known as one of the hardest features to be implemented in a 3D engine.

I try to explain my standard of knowledge. For sure, I'm a newbie, so correct me if something is wrong.  :slight_smile:



There are two possibilities to animate a Model: Keyframe Animation and Bone Animation.



1)Keyframe Animation: You have a 3D Model A1 in a 3D Modelling Tool and save it. Then you modify the mesh and save it as A2. You load A1 and A2 into a 3D Engine and the engine interpoltes for you.



2)Bone Animation: You have a riggid and skinned Model in your 3D Modelling Tool. Load it into a 3D Engine and have acces to the bones. If you rotate a bone, the joint vertices rotate relative to the bone. (this is independend of Inverse Kinematics) The 3D Engine Interpolates the movement of the joint vertices in dependence to the moved bone.





One Further thing is:



3)Keyframe Animation with Bones: You have a riggid and skinned Model B1 in your 3D Modelling Tool. Then you modify the mesh by using the Bones in your 3D Tool and save it as B2. You load it into a 3D Engine and the engine interpoltes for you. But the 3D Engine load not the Mesh of B1 and B2. It only loads the Mesh, the Skeleton and the movment of the bones to save memory.





What I want to do, would look like this (Bone Animation):



  • Load a riggid and skinned Model in jme

  • Bone b = Model.getBone("funny bone");

  • b.setTranslation(new Vector3f(0,0,1));

  • And see that all the joint vertices moved relative to the bone




I do not understand why this should be impossible. The information of the joints are contained in MD5. I think i'm only not able to use the information to fit my needs, till now.  :|


IK is absolutly not neceassary for me. Modelled constraints of bone movments are nice, but also unimportaint.

just a question, but is there a specific reason you need this functionality and what exactly are you animating, because doing if by code seems time consuming

JTroll said:
I do not understand why this should be impossible. The information of the joints are contained in MD5. I think i'm only not able to use the information to fit my needs, till now.  :|

IK is absolutly not neceassary for me. Modelled constraints of bone movments are nice, but also unimportaint.


I think that mcbeth misunderstood you, I misunderstood both and you misunderstood me. mcbeth (who first used the word "ragdoll" in this thread), for some reason, thought that you need IK. So I believed that mcbeth understood something that I have not understood, reading your post. Than I answered you, presuming that you wants IK. And now you are confused and you think that I answered negative for the bone translation, while I was talking about IK support. :P

The pseudocode you sent, seem to be right, I need to do some investigation anyway to understand what exactly you need to made it working.

I believe that what you need is possible and not difficult. But, at this point, please, post your code, if you can, so that we can understand what is really wrong with it.

…and I misunderstood everybody.



Or not understood a thing of it all, better said.

:wink:


"Is this only to save memory by keyframing?"

that's way important for some us --->  downloadable games. Specially with animation rich games. If u have a single character with loads of anims, the gain is of several dozen times in memory, at least.
Otherwise, I'd be using since long hevee's. (with a key per frame or per 2 frames)

I'm confused with your A1 and A2 explanations ;)

And the categories u did, me as an artist, dont think are clear...for an artist...I'll try to see if is this what you mean :


a)vertex animation. Artist side, is done the same than anyother, as the artists, for charactters or monsters, will surely allways use bones and weights (influences of the bones over certain amount of vertices, with different strengths..cool thing when format allows more than one bone influence over a vertex) The only thing is that exporting the thingie, the format and exporter what does is take like snapshots(is like a dump in the form of several meshes in a timeline, if is with some dump of interpolation info, great) of every important moment (hevee's system allowed to set by hand which keyframes to export out of blender, usual md2 or md3 plugins only allow a fixed interval and from blender, are way less mesh-accurate than his)  , that is, like "copies" of the mesh, same vertices, just different positions, just this way you are exporting a mesh per pose, or "moment". usually engines help here with calculating an interpolation in the inbetweens. be it linear (ugly non organic, this one, is used by md2, and only looks better with loads of keyframes-meshes--> loads of memory/low performance/big zip&hd size) . There was a better solution like Quake3 quadratic spline interpolation(was that the name?), and my favourite, when a plugin, usually inhouse made, or...a modern and complete plugin, it just takes the curves of interpolation of EACH bone, taken from curve editor or whatever the place the exporter looks at...it just grabs the curve out of the track of certain bone, so it will behave exactly as in the 3d art tool.  Other solution, which I suspect half life 2 mod exporters use...is...while being bones and weights, and while not saving meshes-keyframes, it still store a keyframe in every frame,(more memory, but not as much as storing 2k verts meshes each n frames) and, of EVERY bone. If it's sofisticated enough, only of each bone which actually changed.  I've seen some engines . But i am mixing concepts, this would be for bone animation, where the key thing is... to import: a base mesh, the bones, the weights for each bone, and the keyframes(in a timeline), together with the curves of interpolation between bones changes -keyframes- of rotations and traslations in time.That's my fav(actual 1:1 with the 3d tool), but this wholepoint was about vertex animation...which I dunno if is possible to then export accurately, without some extra verts interpolation track...or a keyframe mesh per frame, huge in memory, and of course, worse in performance. But more 1:1.

a) Bone animations, this can be weighted (md5, x, collada...) or unweighted (milkshape 3d, already in the engine, cant have weights other than zero or 1, terrible for organic anims.)
Apart from weighted or not, you can have a loader which allows you access the bones in code (btw, an interesting point of it is access em for bullet or whatever the collission, but I guess this is already possible in jme) .And then, doing ragdoll,yup, need of ik. I know possitively of a friend who long ago did succesfully code for md5, doing ragdolls, and even using scripts per bone channel, so able to handle it perfectly each bone and animation, by code. But it was all c++, and he did I think for personal project.
So, certainly, the md5 format does not stops you for it.

This are the two big groups...the keyframes are allways in any animation, be it bone based, or simple objects, or vertex animations...are just new positions/rotations, changes of stuff in time. There are material and light keyframes in the 3d packages, or visibility keyframes. The key here is...exporters supporting the stuff, and loaders/engines capable of it all.
I think collada support it all.
But am in love for the lightweight of md5...


welll... this is so in a limited artist's brain.

Whether if u can do IK in jme...dunno.Till recently we had not even bones and weights. I cried a lot for that. :D

Now we happily have a bunch, and all good.

bones and weights: cal3d, md5, collada. All good it seems. Vertex animations, the great hevee's blender format, (my recomendation for vertex animation) , md2, md3. Bones only... no real true weights , milkshape3d.great for mechs...but...u can do mechs with md5 too, so why use two formats, one day u'll wish to make human anims with ms3d, and tho I have made em with tricks, and also using othe rigid format, is a pain and a limit for the artist and more things..

Surely this has nothing to do with your worries, but I am like that, you know, useless. Anyway, maybe some of the info adds somethin', dunno.

Great explanation, snaga!



It is exactly what I wanted to say but I had not the time to write it.



About MD5 Reader, I think that this fix, can be a starting point. Now we have it working again and we can think to go on an add features.

All that you say about MD5 features is really interesting. I will read more about that.

Thx guys for your answers. I'm not immersed. I will answer soon. Sorry for the delay  8)

mcbeth said:

just a question, but is there a specific reason you need this functionality and what exactly are you animating, because doing if by code seems time consuming


I want to simulate a head. I have a Headmodell like
http://orange.blender.org/wp-content/themes/orange/images/blog/oodles_o_gizmos.jpg in Blender.
The sliders you see on the picture are Bones using Driven Shape Keys. You define some Keyshapes and
connect it to the bones, so you can use the sliders from, e.g. 0 to 1, to interpolate between the keyshapes.
My goal is to load this model to JME and use the bones to change the facial expression during runtime.

Final goal is to do something like this:

model.setEyes(0.7) // 0 is closed 1 is open
model.setNoseWrinkels(0.2)
model.setRightUpperLip(0.4)

and model is recalculated at runtime.  8)

@snaga Thank you for your detailed answer!  :slight_smile:


snaga said:

...will surely allways use bones and weights (influences of the bones over certain amount of vertices, with different
strengths..cool thing when format allows more than one bone influence over a vertex)...


Is this possible with md5?  :|

I found a way to move the bones at runtime:



Skeleton skeleton = modelInstance.getModelSkeletal().getSkeleton();

      int boneIndex = skeleton.findJoint("Bone");

      SkeletalKeyFrame sFrame = skeleton.getBindFrame();

      sFrame.positions[boneIndex].set(sFrame.positions[boneIndex].add(new Vector3f(10,0,0)));

      modelInstance = new SkeletalModelInstance( model );



Maybe its no good idea to make a lot of modelInstances at runtime, but was good enough to test some things. :evil:



hmmm… I'm not sure any longer about my optimistic approach. Maybe its not possible (for me) in that way i wanna go.

I also have trouble exporting my models with the "Driven Shape Key" Stuff to MD5. Maybe its impossible to export

this stuff to md5, cause I think this isn't supported. If anybody of you are interested in the blender head model, send me an pm. The head model is not my own work.

Its taken from a blender forum, from a guy who wanted to share it with the community.



So now i have to meditate about everything and the world…  :expressionless:

I know that head. (beware on permission on use on own projects and credits and stuff …)



That is a good blender rig.



I'll look at it at the end of the day if I have some minute.



But…

am not yet experienced in driven shape keys, I think is new in blender…beware. As they could probably be an advanced form of just a hook to vertex, traslating as simple vertex animation. Md5 , as far as I know, like x, do traslate all what is influenced by a bone, or a full object…I dont believe it does traslate vertex animation.



For your purpose, I'd avice Hevee's plugin and loader, if itworks with thelatest blender, which i dont know.


Is this possible with md5?


partial weights? Absolutely. All you wanna do can be done with bones, weights and md5. Just probably not that rig. U could use that head, but I'd start a new bone/weight system for it.

I call it "micro bones" .Is like making any armature, just smaller and a lot more bones, and clever positioning, thinking of angle which will develope, etc.
It's been done (also I did)

This relates to der_ton’s reader. I exported a model created in blender of a man along with a run animation. I’ve been able to load the fish and animate it no problem, its great. I can also load and animate my man model and have him run around.



The problem is, when the model is loaded and shown in jme, it seems to be compressed into a small cube, the bounding box actually, which is way to small for the model. But when an animation begins, the model magically assumes the correct shape by expanding in all directions and the the animation looks like it should.



So the model mesh before its modified by an animation is all out of whack. During an animation the model is great, but the bounding box is still its original size, too small. Any idea’s?



Model loaded this way:





During animation:





I guess I could always have an animation going, but this doesn’t solve the bounding box issue.


I smell some edit needed in blender..

maybe a ctrl+a with both armature and mesh selected...that is best to be done first to weight and animate... ;)

looks like the transformation box of the mesh is not what it should...

Or maybe is something to set  in your code, dunno.

i believe there is a problem with the base frame being exported. The md5 specification for the loader says that the initial pose of the model being loaded is set in base md5 files mesh and skeleton.

exported file might be part of the problem and then there might also be the fact  that I patched boundings with OrientedBoundingBox which I only just found out still has bugs a patch was donated Renanse looked at it found that it solves some issues but not all, don't know if he checked it in.



if more bounding issues develop you can always adjust your copy back to BoundingBox I'll give details, if needed when I get home, dont have the code with me now.

I don't think the model is squeezed into the bounding box, the bounding box just fits the model (then when you animate you probably don't call updateModelBound)

that should work too ://

Alright, thanks for all the discussion.



I put an updateModelBounds() call during the animation and the bounding box is corrected, but I guess thats not the real issue here. I'll spend some time in blender today to see if I can figure something out.



Also, the MD5 reader classes I'm using are dated for April 29, 2006, these were the most recent I found when looking a few weeks ago. Are there newer versions out there, before this goes too far?