Jump to content
The Dark Mod Forums

MD5 models and animations (Blender)


RPGista

Recommended Posts

Hi, I thought I should document this discussion here, for future reference, as info on this subject has become quite scattered and out of date.

 

I've been wrestling with MD5s for a while now with no success. Importing works but the meshes and armatures are problematic. I decided to start with an animated model from scratch. Followed a few instructions in videos or tutorials (most recently trying out Sotha's solution http://forums.thedarkmod.com/topic/14970-blender-rig-for-standard-male-npc/?do=findComment&comment=325423 ) but have yet to be able to export successfully. The animation oddly enough is working correctly (on the model viewer, havent gotten into the game yet), but the mesh itself is getting horribly deformed.

 

Im using the io_scene_md5 importer/exporter. Going back to version 2.72 didnt solve it for me.

 

In blender

 

post-8474-0-35172700-1523480693_thumb.jpg

 

After exporting

 

post-8474-0-76624900-1523480703_thumb.jpg

 

Any thoughts?

 

 

 

 

 

  • Like 1
Link to comment
Share on other sites

Hard to say as I haven't actually made the scary venture into MD5s, but does the game expect an explicit hierarchy for the bone setup? It would explain the strange deforming but that would be my first guess. Thing that gets me is every engine I've dabbled with animations for, have their own proprietary implementation. The result being quirks that need tending to else strange errors persist. Needless to say I'm very interested in seeing what could resolve in your case here.

Modeler galore & co-authors literally everything

 

 

Link to comment
Share on other sites

First can you explain how you made the skeleton? Have you called the root bone "origin"? That is very important. Are you sure all vertices of your model are weighted to a bone correctly? I assume that is open3mod? Try ingame or try to see the model in another md5 viewer, like Noesis for example, in my experience Noesis can see Md5 models and animations that make open3Mod crash, imo i also think Noesis is a better tool overall.

Edited by HMart
Link to comment
Share on other sites

HMart - thanks for the suggestion. Indeed Noesis imports the model and it looks correct! I can see the armature in there with the mesh, and I can play the animation separately, working fine. Unfortunately, it seems you cant have them both at the same time, I can only inspect the mesh or the animation at one point, would be great to see them working together. I was using open3mod and it still shows a heavily deformed mesh. Now I have no clue if the problem is in the mesh or the viewer.

 

post-8474-0-26037000-1523550571_thumb.jpg

 

The armature is a simple FK one from the ground up, the first bone being called origin (no parent) and 3 or 4 more bones from that. Its true, I was reading that vertex groups and weights are a problem for the exporter, but it all seems correct to me (bones and vertex groups have the same names, cant see any issues on weight painting mode, etc). Obvisouly theres something Im missing. I parented the mesh to the armature with automatic weights. Tried renaming everything with simple short names (materials, objects, bones, etc). The process I used for exporting was the one described by sotha, with the exception that I set the bones layer on 1.

 

Arcturus - Im linking the blend file, in case you have some time to take a look, thanks a bunch. https://1drv.ms/u/s!Al4XNpzYMsVvcgfKkF6bQ179nBc

 

Epi - Tackling MD5 is kinda scary for sure. The modeler version and plugin version combo alone will keep you guessing for a while. I dont think the armature hierarchy is essential in this case, though you do need a root bone called origin located at zero, like HMart said. I think the rest is pretty much free? Hopefully as I progress with it I'll be able to post enough info to help others with this process.

Edited by RPGista
Link to comment
Share on other sites

I've really wanted to animate stuff for a while, I just didn't wanna bite the bullet and learn Blender. However, I think I could settle for importing a finished model and animating it from there. Thanks for linking the tool Arcturus!

Modeler galore & co-authors literally everything

 

 

Link to comment
Share on other sites

Yeah, thanks a lot Arcturus, I guess the process is actually working then, should be able to test more stuff in game soon now. And Epi, yes, if you cant find an exporter for your favourite modeler, Blender is always there, and it has pretty good animation capabilities. A bit of a learning curve to get there, but nothing you havent seen before.

Link to comment
Share on other sites

I remembered that i have a old viewer for model/animations made specially for idtech 4, is called "modelviewer093a" and I made a link for it here https://drive.google.com/open?id=1QkU-8-7XOQj-8v0MChZp7OaLbk4-UgjZ. Is old so to make it work well in W10, you need to set it to start as administrator and perhaps even set the compatibility mode for windows XP sp2/sp3. You also need to edit the file "scene.txt" and give it the link for the base folder.

The good thing about this old model viewer is that it supports basic Doom 3 shading capabilities, (stencil shadows, per-pixel lighting, normal mapping, specular) so you can see the models almost like they look ingame.

About Noesis i also don't know how to make it play MD5 animations with the models, it does that for collada and fbx models, it seems it needs the animations to reside inside the same file has the models, but i could be wrong. Noesis also has a nice extra tool in the "tools" menu option called Data viewer, in there you can, not only change program settings but also see the bones names, nice to see what naming convention idSoftware used for their bones and you can also edit the bones xyz values directly in Noesis!

Edited by HMart
  • Like 1
Link to comment
Share on other sites

I was using that modelviewer before but it was so unstable, cheers for the reminder, I completely forgot to set it to compatibility mode. It seems a bit more workable now. It loads the tree model and animation successfully.

Arcturus, sorry to be a pain, but do you mind posting the def file you used to test the tree in game? I have been using the flag and your tree ones as examples, but I cant get the model to appear in game. They look fine in DR but wont show up once I load the map.

 

Heres the one I tried last:

 

 

//cube1

model cube1 {
mesh models/md5/test/cube1.md5mesh
anim idle models/md5/test/cube1.md5anim

{
random_cycle_start
}
}

entityDef atdm:cube1
{
"spawnclass" "idAnimated"
"model" "cube1"
"start_anim" "idle"


}

 

 

 

Im getting a NULL JOINTS on the mesh warning.

Edited by RPGista
Link to comment
Share on other sites

Sure, def file is:

model tree_anim_test2a1exp1
{
mesh models/md5/nature/tree_anim_test2a1exp1.md5mesh
anim idle models/md5/nature/tree_anim_test2a1exp1.md5anim
}
entityDef atdm:tree_anim_test2a1exp1
{
"editor_displayFolder" "Nature"
"spawnclass" "idAnimated"
"model" "tree_anim_test2a1exp1"
"start_anim" "idle"
}
  • Like 1

It's only a model...

Link to comment
Share on other sites

  • 2 months later...

Ok, so Im gonna post a WIP tutorial on how to export MD5 models and animations from blender to TDM. Its pretty rough, I will be polishing it as I go along:

 

A couple of guidelines:

 

- The mesh needs to be valid and clean with triangulated polygons;

- It must be UV unwrapped and have a material applied (with one texture image);

- Apply all transformations and modifiers before binding it to the rig;

- No more than four joints may influence any one vertex, as far as vertex weights go;

- Mesh must be parented to the rig;

- Rig must have a root bone called origin. The origin’s translation on Z should normally be zero;

- You can use the material file’s actual name as the blender material name, which will save you the need to edit the md5mesh and change the shader name manually afterwards;

 

Quick step by step:

 

After you model your mesh, uvunwrap it and apply a material to it (name it after your material in TDM); apply all transformations or modifiers.

 

Build the rig, by creating a root bone, and from that, extrude all other bones (in edit mode). Rename the root bone (as “origin”). If the model was imported, make sure you delete all existing vertex groups. Parent the mesh to the rig (ctrl+p) with automatic weights, this will create vertex groups for each bone (make sure you dont rename them afterwards, the vertex groups should be named the same as the bones).

 

To animate it, create a new action (rename it as “idle” or something), turn on automatic keyframe, activate keying set as “whole character” (optional?). Once you have your animation ready – make sure the action is selected in the dropdown list (doesnt hurt to select all the keyframes in the action editor window as well). On 3D view, in object mode, select the armature and then the mesh. Export (with the rig, the mesh and the animation selected).

 

Place the md5mesh and md5anim files together inside the folder structure you need for your FM (example: models\md5\nature or props, etc);

 

The md5mesh needs a material file (like any ase or lwo model) and a def file. The material can either be created specifically for the md5mesh and be set inside blender (as the material name) or you can edit the mesh shader manually (by opening the file in a text editor) and refer it to an existing material – find this line in the file and place the material name inside the quotes (you will need to do that for each mesh in your model):

 

mesh {

shader "materialname"

 

The MD5 model will also need a def file, to be placed in a folder called def. The def file works like this:

 

// your model name, description and author (optional)

 

model yourmodelname

{

mesh models/md5/yourfolder/yourmodelname.md5mesh

anim idle models/md5/yourfolder/yourmodelname.md5anim

}

 

entityDef atdm:yourmodelname //will define your entity name

{

"editor_displayFolder" "Animated Props" //or any folder you want to create in DR

"spawnclass" "idAnimated"

"model" "yourmodelname"

"start_anim" "idle" //will start your anim "idle" automatically

}

 

 

This setup works for a "static" animated model, something like a bush moving with the wind, in a looped animation. The animated model, once placed inside your mission folder structure, will be available inside DR (remember to have your mission and TDM referenced in DR’s properties). To place it inside the map, you need to create it as an entity. This can be confusing, because the model (as a static model) is still available in the lists, but placing that in the map instead will result in an error and it wont show up at map start. I dont know exactly why that is.

 

Im not 100% sure about some of the steps, any improvements or mistakes in the guide, let me know.

Edited by RPGista
  • Like 3
Link to comment
Share on other sites

I just did a test and it seems that neither 'automatic keyframe' nor setting the 'activate keying set' is necessary. In my case I set a keyframe for the rotation (only) of a bone at frame 1, and set another keyframe/rotation at a later frame and the md5anim looked the same as it did when I initially performed the two steps you mentioned above.

 

It looks like auto keyframing is down to user choice. It stores scale and location as well as rotation, but looks like the latter two are the only things that is supported in the md5anim system.

I can't see what difference the active keying set makes, so I think that's also down to whatever the user prefers.

Edited by R Soul
Link to comment
Share on other sites

Yes, you can set keyframes manually, sure. The "whole character" option will keyframe the whole skeleton everytime you do it (instead of just the bones that moved). But it is, as you say, optional.

Link to comment
Share on other sites

  • 1 year later...

I just started working with md5 and animation as well, but I'm having 2 weird problems. First of all, these models don't seem to have any collision. And second thing: the shading looks wrong, materials are dark, almost wet, and often you can see triangulation errors. I'm using the exporter for 3dsmax found on katsbits, maybe that's the problem.

Link to comment
Share on other sites

For collision it's hard to say without knowing what kind of entity you're using the model for (AI, ragdoll, func_animate...), but is there meant to be a collision model set up? See http://wiki.thedarkmod.com/index.php?title=An_AI_consists_of_6_Models

For func_animate nonsolidity is normal (there's a spawnarg to let articulated figures push moveables, though I haven't tried it).

  • Thanks 1

Some things I'm repeatedly thinking about...

 

- louder scream when you're dying

Link to comment
Share on other sites

I'm using a simple setup, a box with one origin bone that is rotating – not much, but will do for a first setup :) The entity def is by-the-book:

Quote

model anm_test01
{
    mesh        models/buildercompound/md5/anm_test01.md5mesh
    anim idle    models/buildercompound/md5/anm_test01.md5anim
}

entityDef anim_test
{
    "spawnclass" "idAnimated"
    "model"             "anm_test01"
    "editor_usage"        "Rotating box. Just a test."
    "editor_displayFolder"    "Animated"
    "start_anim"            "idle"
}

As for the weird material problem, I think it had to do with model and origin bone having a different pivot position and rotation. Once both are in 0,0,0 and with their original orientation (identical for both), weird speculars have gone away. That said, I seem to have no control over smoothing groups. Once I convert the model to Editable Mesh and apply the skin modifier, going down to Editable Mesh modifier and changing SGs does nothing.

Link to comment
Share on other sites

I remembered we had an MD5 animated tree that's solid, and on checking atdm:animated_tree_01 it looks as though the interesting difference from a basic func_animate is "articulatedFigure" "tree_01". (Edit: also, it inherits from atdm:af_entity_base, even though it overrides the spawnclass with idAnimated.) So I'd guess you've no collision because there's no AF set up.

Edited by VanishedOne
  • Thanks 1

Some things I'm repeatedly thinking about...

 

- louder scream when you're dying

Link to comment
Share on other sites

I also think that for physics collision with MD5 meshes you need a Articulated figure or AF, that was what I did for all my MD5 models. 

But even tho I never tried it, I think you can use DR to make a brush sheel around the md5 model and export has a collision proxy.

I also seem to remember reading somewhere, that you can give the entity a spawnarg of  "combatModel"   "1" and it will use the original MD5 model has the collision model, I don't know if this is true or not, just try it. Also this last one if works, can potentially kill performance (if used in many models) as i think it uses every triangle of the mesh for collision detection.

  • Thanks 1
Link to comment
Share on other sites

I will examine stock TDM models to pinpoint the problem, but yeah, it seems that both proper entity def and AFs are mandatory. That smoothing groups problem worries me as well, maybe I'm not doing what the export script expects.

I tried the combat model arg, and as soon as I touch the model, the game crashes.

Edited by peter_spy
Link to comment
Share on other sites

Hum, unless you are playing with a debug compiled exe and triggering a c++ assert then that crash indicates that the combat model arg seems to be old code that doesn't work anymore, petty.  I will look at the  (fhDoom) engine source and see where that arg is defined...

 

edit: peter_spy it seems a combatModel is set by default in the c++ code in all models defined as idActors and they do require a AF (is loaded before the combatModel is set up in the code).

idAnimated by the look of it do use the "combatModel" spawn arg, because its spawn function looks for the existence of it and seems to be the only one. So to me looks like that arg was made for idAnimated models only. 

Not really important for the discussion at hand but when looking at the code, I saw that for idActors you can set the (bullet/projectile) hit detection to use the bounding box instead of the default combatModel (per-triangle hit detection) by using "use_combat_bbox" "1".  Could be a good option for performance tuning, at least for non important actors, not sure if really useful in a game like TDM that uses very low projectile counts tho.

Edited by HMart
  • Thanks 1
Link to comment
Share on other sites

It looks as though I misremembered I'm afraid: atdm:animated_tree_01 isn't actually solid. I was mixing it up with something like atdm:nature_tree_01, which uses texture scrolling to appear animated. Sorry about that.

Edit: I'm currently trying to get af_posed_by_anim to work; according to the description, it and af_push_moveables should provide some sort of collision...

Edit 2: after it occurred to me to set "solid" "1" I'm having some luck getting moveables to collide, though with the tree it's pretty glitchy: it seems to work at first, then stop working after a bit. I haven't found a way to enable player collision on an idAnimated.

Edit 3: a bit more progress. Initially I assumed the "ragdoll" spawnarg for a func_animate ought to point to an AF decl, as the description implied and as it seems to be set up for AI, so I used a human body as the model and copied "ragdoll" "guard_base_newskel" from an AI. That got me an entity that was solid to moveables when I pushed or threw them at him, but when I had him walk through some he literally did walk right through them. Then I thought, what if it wants an actual ragdoll entity class (with the articulatedFigure defined inside that class)? This gets me an entity that does push moveables away... but they go right through him while I'm holding them.

Edit 4: TDM's idAnimated::LoadAF has been modified from D3's, including a conditional call to af.GetPhysics()->EnableClip(); that isn't in id's code. I wonder what difference that makes.

Edited by VanishedOne
  • Like 1

Some things I'm repeatedly thinking about...

 

- louder scream when you're dying

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recent Status Updates

    • Petike the Taffer

      I've finally managed to log in to The Dark Mod Wiki. I'm back in the saddle and before the holidays start in full, I'll be adding a few new FM articles and doing other updates. Written in Stone is already done.
      · 1 reply
    • nbohr1more

      TDM 15th Anniversary Contest is now active! Please declare your participation: https://forums.thedarkmod.com/index.php?/topic/22413-the-dark-mod-15th-anniversary-contest-entry-thread/
       
      · 0 replies
    • JackFarmer

      @TheUnbeholden
      You cannot receive PMs. Could you please be so kind and check your mailbox if it is full (or maybe you switched off the function)?
      · 1 reply
    • OrbWeaver

      I like the new frob highlight but it would nice if it was less "flickery" while moving over objects (especially barred metal doors).
      · 4 replies
    • nbohr1more

      Please vote in the 15th Anniversary Contest Theme Poll
       
      · 0 replies
×
×
  • Create New...