V
Vikom
Guest
Hi!
I have a dilema about storing 3d models in my game.
I'm making a game that will contain a variety of 3d models like buildings, cars, trees... so, I believe I should approach it in a clever way. I have an universal "obj_building" object who's instances load external models.
The first idea was quite simple: just use a string to define a way to load the external model. It works quite well - easy implementation but it needs unnecessary amount of RAM when every instance stores the model.
The second idea is: there's one instance (object "models") that stores all the models and the instance that needs a model, loads it from there like... model = models.familyhouse3;
I've tried it and the RAM is much better.
The problem is, I don't know how to store it effectively.
My idea was that the "models" object would store them this way...
and the "obj_building" would have a string var with a name of the model and somehow converted the string into var's name like...
The problem is, I found nothing like the "str_to_var".
Also, now the "models" would have to load all the models right at the beginning of the game which would cause an unnecessarily long loading time in case of higher numbers.
Do you have any idea how to solve it or even a better idea how to reach it?
Maybe I got one while writing this but I'll have to think about it first how to make it. I'll let you know and eventually explain it.
Still, I'll be happy for any suggestions.
I have a dilema about storing 3d models in my game.
I'm making a game that will contain a variety of 3d models like buildings, cars, trees... so, I believe I should approach it in a clever way. I have an universal "obj_building" object who's instances load external models.
The first idea was quite simple: just use a string to define a way to load the external model. It works quite well - easy implementation but it needs unnecessary amount of RAM when every instance stores the model.
The second idea is: there's one instance (object "models") that stores all the models and the instance that needs a model, loads it from there like... model = models.familyhouse3;
I've tried it and the RAM is much better.
The problem is, I don't know how to store it effectively.
My idea was that the "models" object would store them this way...
Code:
familyhouse1 = d3d_model_create();
familyhouse2 = d3d_model_create();
...
store1= d3d_model_create();
store2= d3d_model_create();
Code:
modelname = "familyhouse1";
model = models.str_to_var(modelname); //model = models.familyhouse1;
Also, now the "models" would have to load all the models right at the beginning of the game which would cause an unnecessarily long loading time in case of higher numbers.
Do you have any idea how to solve it or even a better idea how to reach it?
Maybe I got one while writing this but I'll have to think about it first how to make it. I'll let you know and eventually explain it.
Still, I'll be happy for any suggestions.