MD2 animation and memory usage

If you have any questions on programming, this is the place to ask them, whether you're a newbie or an experienced programmer. Discussion on programming in general is also welcome. We will help you with programming homework, but we will not do your work for you! Any porting requests must be made in Developmental Ideas.
Post Reply
kazade
Insane DCEmu
Insane DCEmu
Posts: 145
https://www.artistsworkshop.eu/meble-kuchenne-na-wymiar-warszawa-gdzie-zamowic/
Joined: Tue May 02, 2017 3:11 pm
Has thanked: 3 times
Been thanked: 34 times

MD2 animation and memory usage

Post by kazade »

This is kinda aimed at PH3NOM as I know MD2-like models were used in In the Line of Fire...

I was just wondering what's the best approach for animating MD2 models while keeping memory usage low. In my game engine (which until recently didn't really have to worry about memory usage) I've been unpacking the vertices and frames of the MD2 on load. But on the Dreamcast this rapidly uses up the available memory. I'm thinking of restructuring things so that only the previous and next frames are unpacked in memory, but then that adds a CPU cost.

I just wondered what approaches people here have used?
User avatar
bogglez
Moderator
Moderator
Posts: 578
Joined: Sun Apr 20, 2014 9:45 am
Has thanked: 0
Been thanked: 0

Re: MD2 animation and memory usage

Post by bogglez »

MD2 models contain copies of the 3D mesh at various points in time. So the memory usage is size_of_vertex * vertices_in_model * animation_frames.
In other words the only options you have are
- storing vertices more compactly
- reducing polygon count
- reducing keyframe count.

If memory usage is a problem and you need sophisticated animation you will need to switch to skeletal animation. There you only have one copy of the 3D mesh (T-pose) and instead compute the next frame, then interpolate towards that. So much less memory usage, but more CPU usage.
In cheap skeletal animation you just cut the mesh into multiple parts, then add a transformation matrix to each part and create matrix multiplication chains (torso_transform * upper_arm_transform * hand_transform * hand_pos = current_hand_pos).
In more sophisticated skeletal animation each vertex can be affected by multiple transformation matrices using a weight. This allows for smooth transitions at joints, but is more computationally expensive.
Wiki & tutorials: http://dcemulation.org/?title=Development
Wiki feedback: viewtopic.php?f=29&t=103940
My libgl playground (not for production): https://bitbucket.org/bogglez/libgl15
My lxdream fork (with small fixes): https://bitbucket.org/bogglez/lxdream
Post Reply