Sign in to follow this  

c++ and md2 format models memory

This topic is 4488 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm using md2 format models. Suppose I have 30 enememies in my game all of the same model and so the same class in C++, can you answer the following questions I have: 1. will the memory taken by the models be 30 times the size of the model after loading it up at start time - or is it that as it's the same data then it's only stored once. If I make this data 'const' then does this ensure the size is smaller ? 2. if the memory taken by all this is 30 times more then should I make the model data static ? 3. How do I load md2 format data into vbo's ? I could probably do this but I mean if you've done it zillioins of times before then it would stop me re-inventing the wheel. thanks Adrian

Share this post


Link to post
Share on other sites
Quote:
Original post by ade-the-heat
1. will the memory taken by the models be 30 times the size of the model after loading it up at start time - or is it that as it's the same data then it's only stored once.

Depends how you do it. You could end up using 30x as much memory if you implemented it naively. The proper way is to reference the geometry data for each entity of the same character, that way the data is stored only once.

Quote:
Original post by ade-the-heat
If I make this data 'const' then does this ensure the size is smaller ?

Er no.
const means it is 'constant' meaning it can't be modified (so its value never changes).

Quote:
Original post by ade-the-heat
2. if the memory taken by all this is 30 times more then should I make the model data static ?

Thats one way, that way all the entites can access the data as necessary. However, static data is not a good idea 99.9% of the time, better to load the data into a geometry class and have each entity hold a reference/pointer to it.

Quote:
Original post by ade-the-heat
3. How do I load md2 format data into vbo's ? I could probably do this but I mean if you've done it zillioins of times before then it would stop me re-inventing the wheel.

What about this? However I think its a bit premature (dunno maybe not) first focus on getting it into a vertex buffer (if you have not done so already). If you are animating this model then a VBO might not be the best/easiest option as you need to interpolate between keyframes.

Hope that was some help

Share this post


Link to post
Share on other sites
I am using md2 for my game. I estimated that roughly about 700 KB are taken for each md2 model with animations . I mean in a way that is going to be used by vertex arrays. So I am going to stick max 10 models at one map. The non animated objects, furniture other debris is in a more simple format , without animation.

So how it works, just for example:

I have 3 enemy models:

Grunt
Cyborg
Player

They are loaded in the memory. But actually in the game there are their spawns. The spawns have a unique position , current animation frame, interpolation value and so on. I found this to be the best way.

Still I think in the future I am going to look at other more modern formats.

and btw here are some information that might be usefull:
clicky

And here are some posts I made while working on my md2 loader:

http://www.gamedev.net/community/forums/topic.asp?topic_id=325841



http://www.gamedev.net/community/forums/topic.asp?topic_id=325455

Share this post


Link to post
Share on other sites

This topic is 4488 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this