Game Editing > Scripts & Support
[MD5] EXPORT script for Blender 2.6x (OPEN)
kat:
You're almost there, you just have to reconsider the mechanics of animating relative to a game engine rather than Blender - there's a difference because Blender understands what the Scene data means and the way it's set up to make the character walk the line. Third-party game engines don't. To get a character to walk a path the way you want you have to fully animate it, i.e. the model has to be posed and keyframed the full distance and duration. In essence you're producing a unique sequence rather than looping a walk.
The way that should actually be done is to keep the root bone static, it should never move, the appearance of motion comes from the other bones moving in relation to the root, and away from it. If this isn't done the sequences gets mushed because the positional data of each keyframe is rooted at the origin and grid centre (0,0,0), that point, and manipulation from it, is what determines distance. So whilst the keyframes are thusly rooted, the Armature isn't, it's origin is moving with the mesh resulting in a collapsed sequence (gets squished like an accordion).
To correct this you need to unparent everything and then reassign an Armature modifier to the mesh, linked to the Armature. That's your basic structure. In the Action Editor when you animate, the "Control" bone should remain static, everything else being posed and keyframed appropriately relative to the sequence needed, in other words, you have to physically move the character incrementally along the guide and pose each step whilst doing so.
A couple of other observations.
When you create animated object you'll generally want to 'ground' them so the base of the feet sit on the on the horizontal plain. This is also where the mesh and armature origins are located (they are again, what determine the position of objects in game). Loading the little guy into a previewing tool it's buried up to the waist.
The mesh is collapsed when loaded because it doesn't have a properly formed 'default' pose - usually this is because the vertex weighting or pose data isn't corresponding properly to the mesh structure. The problem disappears once an md5anim file is loaded though.
Ideally you'll want to reduce the polycount of the mesh, 50k is super high so use a Decimate Modifier on it to reduce it to a reasonable level (anything under 2500 for the kind of simple structure you have there).
Hopefully all this make sense. If not ask away ;)
Blayne Bradley:
It's going to take me a minute to full absorb it all, I'll clarify that right now I just want to pull the mesh and render it at its rest pose; I don't want to animate it yet as I just want to test my engine one module at a time.
If I follow what you say it should still work for just making the T-Pose mesh right?
Edit: The absurd polycount size on the Mesh is because it was provided by my professor during my graphics course two semesters ago, (the course itself was horribly out of date so I've been working on updating the code to modern opengl specs) so for testing performance stuff I kept the absurd polycount size for academic purposes; practically when I make my own characters hopefully they won't be so absurdly large in numbers :D
Edit2: Still undergoing implosion with the file you sent me, is that because I'm not applying its animations?
Edit3: Yeah that's exactly what you're saying, I'm not loading the animation file so it ain't lookin' right.
Regarding animating a unique sequence, so you mean do what I did to keyframe it for 30 frames and then just keep repeating that while incrementally moving it bit by bit away from the control bone?
Edit4: Wouldn't it actually make more sense to not do movement in blender and do it in the engine?
kat:
The characters Armature has not been reset so it carries a scale value, the likely cause of the mushed up mesh when its loaded without a supporting anim file - the Armature should carry a "Scale:" value of "1.0" indicating it's been 'reset' ("Apply") but if that's done now the rig will get messed up (this is why both mesh and Armature need to be reset before being parented and animated, if it's done after the fact it'll mess up any sequences that already exist; and why when making content the origin should always sit on the horizontal plain as a representation of the ground, you then build and animated relative to that).
Re: Edit 1. Make sure to triangulate the mesh before export (in Edit mode, Select All, press "Ctrl+T") otherwise a mesh like that can crash Blender when its parsed by the script.
Re: Edit 2. You should be able to export a single framed sequence (can be a couple of frames, they just need to be the exact same pose) so you have a posed character to work with.
Re: Edit 3. Yes, you animate the sequence as one long event. In this instance it might result in an animation that has the character walk, that is swing the arms and legs for a full cycle, 20 or so times over a duration of about 30 seconds and maybe 250 frames.
Re: Edit 4. That is infact how objects generally move, it's done in-game. There are different way to physically do it depending on what the character is supposed to do, but essentially you export a walk cycle, a loop of a couple of steps like the one you've already got (you can do either a 'static' or 'dynamic' animation - the character will loop standing on the spot, or will move a short distance away from the origin as part of the cycle) , and move the game object around based on controlled input (mouse/keyboard) whilst the loop is triggered to play. This gives the impression of an actual walk.
If you want the character to walk along a path, you'd normally set that up in game, treating the character as a scripted event (if the character is the player you'll usually script the event using a 'third-person' representation - its mechanically easier to script movement of a 'bot' than doing it to the object the player is observing the game through).
Blayne Bradley:
Thanks, I'll get back to fiddling with that in a moment as soon as I can get my animation code working :D
Is there a way in blender to make sure no vertex is affected by no more than four bones? I think that might be better than trying to get the code to work for 4+.
kat:
As far as I'm aware there isn't a way to restrict vertex assignments like that. You can however, see which vertices are members of which vertex groups and then manage them by checking "Vertex Weight" in the Properties panel ("N") - obviously with 50k+ verts on the model you're using that will be quite a task!
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version