Keeping MD2 animations in time

Blitz3D Forums/Blitz3D Beginners Area/Keeping MD2 animations in time

Bankie(Posted 2006) [#1]
I've created my first ever animated MD2 model (using Milkshape) and looking at the available commands it seems that Blitz may be a little lacking. I understand that I need to call AnimateMD2 before hitting the main game loop, but the problem is that I don't know at that point what the delta time is going to be on the target PC (i.e. I don't know the frame rate), and there don't appear to be any commands that will allow me to dynamically alter the animation speed. So, what is the best way to deal with this?

The only way I can think of is to start the animations after a short period (say, 5 seconds) and use an average delta time to work out how fast to play the animation.

So my question: Is there another (better) way of working out how fast to make the animation, or better, change it on the fly? Or is Blitz simply too crap with MD2s and I should be learning to use B3D models instead?


Bankie(Posted 2006) [#2]
As I haven't had any replies, I've tried exporting as a b3d instead, and of course altering the command to loadanimmesh for loading the mesh:

test = LoadAnimMesh("models\test.b3d")

However, I get a memory access violation followed by "Entity does not exist" on the above line. However, if I remove all joints/animations and export again, I don't get an error and the model loads successfully.

Are there restrictions on how you can carry out animations with b3d models? For my test, all I did was add a box, assign the vertices to a joint, then add a sphere and add those vertices to another joint. Finally I created a couple of keyframes, moving one of the joints for a very simple animation. Exporting to an MD2 works, but to a b3d gives the aforementioned error. Does anyone have any suggestions?


Matty(Posted 2006) [#3]
Hi Bankie,

I can't answer the second post, but the first post I have an idea for:

When animating your md2 model set it to '1 shot' animation, and specify the exact frame (firstframe=lastframe) that you want it to play rather than a range of first to last. Specify a transition value other than 0.0. If you want it to animate faster then simply progress through the frames faster.

Alternatively, if you do use b3d models then you can use setanimtime to specify the exact position in the models animation sequence that you want it to play.


Bankie(Posted 2006) [#4]
Thanks for the reply Matty. Your suggestion sounds pretty good, though it means a few more lines of code to keep everything organised. I think I'd rather use B3Ds if I can find a way of exporting them from Milkshape in a way that Blitz can read them, but at least with your method I can fall back on the more stable MD2s if I can't suss this problem out.


Matty(Posted 2006) [#5]
I've had no problems exporting b3d from milkshape (with animation). I am using Milkshape 3d version 1.7.4 which may be a little older though.


Bankie(Posted 2006) [#6]
I have at last solved the B3D file problem. It seems you have to regroup all your groups together before exporting. It's a bit queer, and means having to remember to save the Milkshape file before doing this process, but at least it works.


Dustin(Posted 2006) [#7]
Depending on the number of animated characters you might want to rethink the B3D anim approach. You'll know when you've reached the limit when your FPS drop like a rock. But you can have 3x or 4x as many MD2 characters without the slowdown.

I mentioned in a previous thread that I'm sticking with one animated B3D character (to allow the user to select the character but still use the same boned animations) and use MD2 for all other anims. Just my $.02.


BIG BUG(Posted 2006) [#8]
Your first problem, model animation with delta timing isn't solved by just using b3d files. The Animate command works similar to AnimateMD2.

To set animation speed depending on your framerate, use the additional parameter of UpdateWorld.

   time_new   = MilliSecs()
   time_diff# = (time_new - time_old) / 1000.0
   time_old   = time_new

  UpdateWorld time_diff#



Bankie(Posted 2006) [#9]
Thanks Dustin & Big Bug for the replies.

I had read elsewhere that B3Ds were more efficient than MD2s, but if this is not the case, then I think I'll just stick with the MD2 format.

As for the additional parameter of UpdateWorld, I didn't have a clue. For me it has always been something you just stick near the end of your main loop to make sure everything gets displayed. The additional parameter looks like it will also affect all of my animations (i.e. MoveEntity, TurnEntity, etc), so I believe I'll need to remove my use of delta throughout the rest of the code.


Matty(Posted 2006) [#10]
If you are going for a game where the player can see the character models up close then b3ds can look much better than md2s - md2s in my opinion are better for RTS type games or other games with lots of low detail models.