Jump to content
The Dark Mod Forums

MD3 models?


rich_is_bored

Recommended Posts

I was working my way through the code and noticed the game supports loading MD3 models. I can't believe Doom 3 has been around for 12 years and nobody played around with this. Vertex animation is a bit dated but it still has valid use cases.

 

Of course I was immediately sidetracked. I had to track down an exporter for Blender and try it.

 

Nothing complicated. Just a sphere with a wave modifier on it. I've packaged it up if anyone would like to tinker. It's testmd3.pk4.

 

If you load the model you'll note that it doesn't animate. But there's a bit of code in Model_md3.cpp that's of interest...

    // TODO: these need set by an entity

    frame = ent->shaderParms[SHADERPARM_MD3_FRAME];            // probably want to keep frames < 1000 or so

    oldframe = ent->shaderParms[SHADERPARM_MD3_LASTFRAME];

    backlerp = ent->shaderParms[SHADERPARM_MD3_BACKLERP];

These shaderparm references translate into parms 8, 9, and 10. I have determined that setting shaderparm 8 changes the current frame. You can see for yourself by loading the model with "testModel models/test.md3" and advancing frames with "testShaderParm 8 [frame]".

 

Anyway. Just sharing my findings. Maybe I'll figure it out a way to make use of this eventually.

  • Like 3
Link to comment
Share on other sites

I think Arcturus did some fake cloth physics by baking animation to models then used animation commands to swap models.

This seems to be a better way to achieve that. This may also come in handy for water effects.

 

Edit:

 

I might be remembering wrong. All I can find is a baked bone animation:

 

http://forums.thedarkmod.com/topic/16469-model-request-furniture-covered-in-sheets/page-3?do=findComment&comment=353012

 

still, using vertex animation instead should reduce the amount of calculation needed for these effects as I gather.

(At the expense of more storage and memory.)

Please visit TDM's IndieDB site and help promote the mod:

 

http://www.indiedb.com/mods/the-dark-mod

 

(Yeah, shameless promotion... but traffic is traffic folks...)

Link to comment
Share on other sites

I recall back on the D3W forums der_ton wrote an experimental MD5 exporter that baked vertex animation by creating a bone for every vertex. It's funny looking back on it as we were clearly shoving a square peg into a round hole.

 

At any rate, I initially was going to use a Q3 character model for testing purposes since they could be found everywhere. But then I saw how they are split into three separate MD3s, paired with a CFG, and the code doesn't appear to reflect this. I'm fine with that however. MD5 is far superior for character models with fewer keyframes, support for frame events, interpolation, ect. We'd only be using MD3 for props like grass, fabric, and spider webs blowing in the wind.

Link to comment
Share on other sites

Very nice work.

 

I may add that such effects can be achieved using vertex shaders either. The question would be which way is easier and less performance consuming, though.

 

As md5 is most probably a successor of md3, I am wondering whether the same stuff could be achieved with normal md5's either.

FM's: Builder Roads, Old Habits, Old Habits Rebuild

Mapping and Scripting: Apples and Peaches

Sculptris Models and Tutorials: Obsttortes Models

My wiki articles: Obstipedia

Texture Blending in DR: DR ASE Blend Exporter

Link to comment
Share on other sites

Very nice work.

 

I may add that such effects can be achieved using vertex shaders either. The question would be which way is easier and less performance consuming, though.

 

As md5 is most probably a successor of md3, I am wondering whether the same stuff could be achieved with normal md5's either.

 

Very nice work indeed!!

 

You can achive something similar to this with Md5 but only using bones and is more time consuming.

 

Btw i knew that idtech 4 add a MD3 loader but i always thought it was old legacy code that didn't worked!

 

I also assume modern exporters for this old format aren't plenty?

Edited by HMart
Link to comment
Share on other sites

(AFAIK) Yes, currently you'd need to distort _currentRender or jump through hoops re-rendering the whole lighting pipeline

to make that work.

 

That said, perhaps I can look into changing the place in the pipeline where vertex arb can be

inserted. Ideally we'd do what the shadow.vp does and write to the VBO before the lighting process begins.

Please visit TDM's IndieDB site and help promote the mod:

 

http://www.indiedb.com/mods/the-dark-mod

 

(Yeah, shameless promotion... but traffic is traffic folks...)

Link to comment
Share on other sites

@Obsttorte

 

I'm sure a vertex shader would be better for performance. My concern is the custom shaders we call from our materials are executed after interaction.vfp. Will you see any changes to vertex positions if they are rendered before they are moved?

I played around with vertex shaders moving vertices and it works. I've used it to create water waves.

  • Like 1

FM's: Builder Roads, Old Habits, Old Habits Rebuild

Mapping and Scripting: Apples and Peaches

Sculptris Models and Tutorials: Obsttortes Models

My wiki articles: Obstipedia

Texture Blending in DR: DR ASE Blend Exporter

Link to comment
Share on other sites

;) Water is transparent...

 

The arb programs work as long as you are doing some sort of transparency. You can hack them back to opaque of course.

Depends on how much juggling you wanna do:

 

http://wiki.thedarkmod.com/index.php?title=Making_Semi-transparent_textures

Please visit TDM's IndieDB site and help promote the mod:

 

http://www.indiedb.com/mods/the-dark-mod

 

(Yeah, shameless promotion... but traffic is traffic folks...)

Link to comment
Share on other sites

If I can dig out the files related to the water I could check whether it works with opaque surfaces either.

FM's: Builder Roads, Old Habits, Old Habits Rebuild

Mapping and Scripting: Apples and Peaches

Sculptris Models and Tutorials: Obsttortes Models

My wiki articles: Obstipedia

Texture Blending in DR: DR ASE Blend Exporter

Link to comment
Share on other sites

I'm trying to wrap my head around this.

    {
        setShaderParm(8, currentFrame);
        currentFrame = (currentFrame + 1) % numFrames;
        sys.waitFrame();
    }

Does this depend on current FPS? I made a test md3 with two frames. I want to play one frame per second. I also would like to animate texture so that first image is displayed exactly at frame one and second image at frame two. I could add sixty of these: sys.waitFrame();

 

 

    {
        setShaderParm(8, currentFrame);
        currentFrame = (currentFrame + 1) % numFrames;
        sys.waitFrame();
        sys.waitFrame();
        sys.waitFrame();
        sys.waitFrame();
        sys.waitFrame();
        sys.waitFrame();
        sys.waitFrame();
        sys.waitFrame();
        sys.waitFrame();
        sys.waitFrame();
        sys.waitFrame();
        sys.waitFrame();
        sys.waitFrame();
        sys.waitFrame();
        sys.waitFrame();
        sys.waitFrame();
        sys.waitFrame();
        sys.waitFrame();
        sys.waitFrame();
        sys.waitFrame();
        sys.waitFrame();
        sys.waitFrame();
        sys.waitFrame();
        sys.waitFrame();
        sys.waitFrame();
        sys.waitFrame();
        sys.waitFrame();
        sys.waitFrame();
        sys.waitFrame();
        sys.waitFrame();
        sys.waitFrame();
        sys.waitFrame();
        sys.waitFrame();
        sys.waitFrame();
        sys.waitFrame();
        sys.waitFrame();
        sys.waitFrame();
        sys.waitFrame();
        sys.waitFrame();
        sys.waitFrame();
        sys.waitFrame();
        sys.waitFrame();
        sys.waitFrame();
        sys.waitFrame();
        sys.waitFrame();
        sys.waitFrame();
        sys.waitFrame();
        sys.waitFrame();
        sys.waitFrame();
        sys.waitFrame();
        sys.waitFrame();
        sys.waitFrame();
        sys.waitFrame();
        sys.waitFrame();
        sys.waitFrame();
        sys.waitFrame();
        sys.waitFrame();
        sys.waitFrame();
        sys.waitFrame();
        sys.waitFrame();
    }

 

That will play at roughly 1 FPS.

I use this material:

anim_test
{
    noshadows
    noimpact
    nonsolid
    {
        if ( (time * 1) % 2 == 0 )
        blend blend
        alpha 1
        map    textures/anim_test/anim_test_01.tga
    }
    {
        if ( (time * 1) % 2 == 1 )
        blend blend
        alpha 1
        map    textures/anim_test/anim_test_02.tga
    }
}

Time means seconds here?

If I set up the script and material like this they both play at roughly 1 FPS but never exactly in sync. Do I get it right that one is dependent on FPS and other not?

It's only a model...

Link to comment
Share on other sites

;) Water is transparent...

 

The arb programs work as long as you are doing some sort of transparency. You can hack them back to opaque of course.

Depends on how much juggling you wanna do:

 

http://wiki.thedarkmod.com/index.php?title=Making_Semi-transparent_textures

 

If I can dig out the files related to the water I could check whether it works with opaque surfaces either.

Found the files and testet it. It works.

 

Note that the vertex shader only affects the visual representation, not the physics (= collision). But I'm not sure whether the md3 examples above would do so either.

 

However, in case of moving cobwebs (why is it called like that, aren't those spiderwebs?) or waves you don't expect them to be solid anyways (unless you want to make a FM where the player can walk over water, preferable after he had turned it into wine :P ).

FM's: Builder Roads, Old Habits, Old Habits Rebuild

Mapping and Scripting: Apples and Peaches

Sculptris Models and Tutorials: Obsttortes Models

My wiki articles: Obstipedia

Texture Blending in DR: DR ASE Blend Exporter

Link to comment
Share on other sites

@Arcturus

 

Yes, the scriptobject as currently constructed is linked to FPS. To base it on a set duration instead you would use...

sys.wait(X);

... where X is the number of seconds.

 

I'm sure you've noticed that the engine does not interpolate between keyframes? I figured smooth playback was preferable so I coupled playback to FPS.

 

In your case, why not export two static models each with their own material? Then you can toggle their visibility on or off at 1 FPS and you won't have to worry about sync issues. The script events you're interested in are "show" and "hide".

 

@Bikerdude

 

Hold that thought. If Obsttorte's shader works nobody will need to model anything.

 

@Obsttorte

 

If you could put those files into a package and make it available somewhere I'd like to see it.

Link to comment
Share on other sites

I used 2 frames just as an example. What I really want to do is to have an ocean with 50 frames that plays at 24-30 FPS. I want to bake normalmap for each frame so I would like them to align, although it's not super important. At 60 FPS I would need twice as many frames for a nice loop and I thought that would be an overkill.

 

I used sys.wait(1); and they still don't synchronize perfectly.

It's only a model...

Link to comment
Share on other sites

Oh man, that looks fantastic! It's exactly what I was looking for when I was working on the harbour mission.

  • Like 1
Link to comment
Share on other sites

I used this experimental shader by SteveL with addition of specular reflections. It looks great on the shore. Too bad that further away all the reflections and refractions are masked leaving only the diffusemaps.

This is amazing, would it be possible to get the edges of the water where is touches another brush/shader to foam-up -

 

- https://forum.unity3d.com/threads/release-calm-water.381288/

 

Edited by Bikerdude
Link to comment
Share on other sites

That's probably done with a particle emitter, I imagine. Would be nice to have one.

Link to comment
Share on other sites

The white foam could be applied via the shader me thinks as it occours were the water is not very deep.

FM's: Builder Roads, Old Habits, Old Habits Rebuild

Mapping and Scripting: Apples and Peaches

Sculptris Models and Tutorials: Obsttortes Models

My wiki articles: Obstipedia

Texture Blending in DR: DR ASE Blend Exporter

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  »  DeTeEff

      I've updated the articles for your FMs and your author category at the wiki. Your newer nickname (DeTeEff) now comes first, and the one in parentheses is your older nickname (Fieldmedic). Just to avoid confusing people who played your FMs years ago and remember your older nickname. I've added a wiki article for your latest FM, Who Watches the Watcher?, as part of my current updating efforts. Unless I overlooked something, you have five different FMs so far.
      · 0 replies
    • 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.
      · 4 replies
    • 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
×
×
  • Create New...