loading multiple .ms3d files at once
Hey there,
I did the tutorial on how to load .ms3d files and then added a dialog box so that I could load any file I want. The problem is that it replaces the previous model after I load new model. I know this is probably a simple programming question, but, I am not a good programmer (yet!) so if anyone could help me, that owuld be great.
Depends entirely on how your loader code is built. The "best" way would be to make a vector, in which you can just push_back the models as you load them. Another way is just a static array of the maximum number you''ll ever need. Any way, you should probably encapsulate the model functions into a class. This will make things very modular, and easier to work with.
Peace,
ZE.
//email me.//zealouselixir software.//msdn.//n00biez.//
miscellaneous links
Peace,
ZE.
//email me.//zealouselixir software.//msdn.//n00biez.//
miscellaneous links
[twitter]warrenm[/twitter]
Thanks, I''ll look into it *looks in c++ book to find out how to do static arrays*
const int MAX_MODELS = 10;
CMS3DModel ModelArray[MAX_MODELS];
CMS3DModel ModelArray[MAX_MODELS];
[twitter]warrenm[/twitter]
You could do an array but that will limit how many models you can load. You may want to do that because all of this takes up memory but if you want unlimited, well untill your comps memory runs out then you can do this.
[edited by - nukem on August 22, 2002 9:39:33 PM]
static int count = 0;MS3D* model;model = new MS3D[count];model[count].Load(filename);/*when you close your app you should have this code if you dont your going to have a HUGE memory leak*/delete [] model;
[edited by - nukem on August 22, 2002 9:39:33 PM]
--------------------------Nukemmsn: nukem996@hotmail.comaim: nukem996open source open mind
quote:
Original post by Neosmyle
OT - ZE is moderator?
Yes, as of yesterday I am. People are starting to notice, and I really don''t want to drag any threads OT, but I wanted to note that anyone can contact me anytime. Sorry for the interruption.
[twitter]warrenm[/twitter]
I couldn''t get it to work. I was able to compile it but it still only loads one model at a time. Does it have something to do with the nehe model loading code?
Have you tryed my code? What you have to do is. In you intilize funtion load everything and in your display show everything. It would sort of be like this.
It would be something like that.
int count;MS3D* model;void Load(){ model = new MS3D[the_amount_of_files_u_want_to_load]; for(int a=0;a!=the_amount_of_files_u_want_to_load;a++) { model[a].Load(filename); }}void Display(){ for(int a=0;a!=the_amount_of_files_u_want_to_load;a++) { model[a].Display(); }}void Shutdown(){ delete [] model;}int main(void){ count = 0; //blah blah other gl code return 0;}
It would be something like that.
--------------------------Nukemmsn: nukem996@hotmail.comaim: nukem996open source open mind
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement