Archived

This topic is now archived and is closed to further replies.

loading MORE THEN ONE MILKSHAPE model

This topic is 5780 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

Ok I have read bretts fantastic tutorial. Im a beginner and thought I''d like to import more then one. here is my main functions code so you can see where I have added/changed stuff **** at the top of file... int modCount; // used in reload textures loop for MS models int modTexCount; // used in initial tga loading loop const int totalTex = 4; // total textures for the scene const int totalMod = 2; // total milkshape models Model *pModel[totalMod] = NULL; // Holds The Model Data ************ ......other variables... *********** GLuint LoadGLTexture( const char *filename ) // Load Bitmaps And Convert To Textures { Texture modelTexture[totalMod]; for (modTexCount = 0; modTexCount <= totalMod-1; modTexCount++) { if ( !LoadTGA( &modelTexture[modTexCount], const_cast( filename ))) { return 0; } else { glGenTextures(1, &modelTexture[modTexCount].texID); // Create The Texture // Typical Texture Generation Using Data From The Bitmap glBindTexture(GL_TEXTURE_2D, modelTexture[modTexCount].texID); glTexImage2D(GL_TEXTURE_2D, 0, 3, modelTexture[modTexCount].width, modelTexture[modTexCount].height, 0, GL_RGB, GL_UNSIGNED_BYTE, modelTexture[modTexCount].imageData); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR); if (modelTexture[modTexCount].imageData) // If Texture Image Exists ( CHANGE ) { free(modelTexture[modTexCount].imageData); // Free The Texture Image Memory ( CHANGE ) } } } // return texture.texID; // Return The Status int Status=FALSE; // Status Indicator, use this variable to keep track of whether or not // we were able to load the bitmap and build a texture. // We set Status to FALSE (meaning nothing has been loaded or built) by default. AUX_RGBImageRec *TextureImage[totalTex]; // Create Storage Space For The Texture // The storage will hold the bitmap width, height, and data. memset(TextureImage,0,sizeof(void *)*totalTex); // clear image pointer, Set To NULL // Load The Bitmap, Check For Errors, If Bitmap''s Not Found Quit ************ ....then my bitmap loading routine, works fine with one model and any number of textures I wish to load independantly. ********** int InitGL(GLvoid) // All Setup For OpenGL Goes Here { for (modCount = 0; modCount <= totalMod-1; modTexCount++) { pModel[modCount]->reloadTextures(); } // reload each model ***********.... I believe this makes sense, go through each model in the array....GLDraw function.... ************* pModel[0]->draw(); glTranslatef(10.0f, 0.0f, -20.0f); pModel[1]->draw(); return TRUE; ************* notice I just tried two models two start with as a test.... and finally....... ************ for (modCount = 0; modCount <= totalMod-1; modTexCount++) { pModel[modCount] = new MilkshapeModel(); if ( pModel[modCount]->loadModelData( modelFilename[modCount] ) == false ) { MessageBox( NULL, "Couldn''t load the model data\\model.ms3d", "Error", MB_OK | MB_ICONERROR ); return 0; // If model Didn''t Load Quit } } ********* which should make sense.... ok everything compiles fine except for one single error.... Compiling... main.cpp C:\Documents and Settings\Sir 666\My Documents\programming\opengl\simple scene\main.cpp(39) : error C2440: ''initializing'' : cannot convert from ''const int'' to ''class Model *[2]'' There are no conversions to array types, although there are conversions to references or pointers to arrays Error executing cl.exe. simple scene.exe - 1 error(s), 0 warning(s) ********* I kind of understand it but also I kind of dont anyone help?

Share this post


Link to post
Share on other sites
hello,

i tried and i tried...
i don''t understand the most of what you done.
could you explain more please ?

concerning your error while compiling:
what is the line invoked ? you tried to cast a const int to a **Model ! give me the line please. and a description (even if it''s not all) of this class Model.

concerning your aim problem: i understood that you want to load more than one model, is that true ? if so, just load each new model in a new instance of a class Model. it may work.

cordially,

Fratt

Share this post


Link to post
Share on other sites
Yeah I figured just pasting code at 12 am would not be smart.

Ok basically Ï am trying to do that as you say, but it crashes on the Model *pmodel[totalMod]; command.
I think I tried Model *pmodel = new Model[totalMod]; with the same result.

I just pasted all that code to show what modifications I did to bretts code to try and load more then one model.

Do you have a way I can invoke more then one instance of the class, Im kinda lost.
Its probably simple I know

I just want to realter his code, so it will load more then one model....how would you do it?

cheers

Share this post


Link to post
Share on other sites
Yeah I figured just pasting code at 12 am would not be smart.

Ok basically Ï am trying to do that as you say, but it crashes on the Model *pmodel[totalMod]; command.
I think I tried Model *pmodel = new Model[totalMod]; with the same result.

I just pasted all that code to show what modifications I did to bretts code to try and load more then one model.

Do you have a way I can invoke more then one instance of the class, Im kinda lost.
Its probably simple I know

I just want to realter his code, so it will load more then one model....how would you do it?

cheers

Share this post


Link to post
Share on other sites
that''s a C++ problem, so far not an opengl problem in fact.
but i like helping people.

how do you instanciate you *pmodel[] ?
i must see your code in order to try helping you; i don''t want to steal you; no reason to be afraid.

it seems a pointer problem, maybe someone at null, or a bad memory assignement... i don''t know, i can''t see.
when you do: Model *pmodel[...], what do you want to do ? an array of Model classes ? if so, try avoiding keeping pointers.

first of all: destroy your error.
then, you may be more able to do what you want

cordially,

Fratt

Share this post


Link to post
Share on other sites
The problem is that when you do the following you try to assign NULL to the pointer that points to the array.

Model *pModel[totalMod] = NULL; // Holds The Model Data

I believe you wanted to set the pointers in the array to NULL. Then you'll have to do this:

Model *pModel[totalMod] = {NULL, NULL}; // Holds The Model Data

That will initialize the contents of the array. There are two NULLs because totalMod is set to 2. You'd have to change the number of NULLs in this line every time you change totalMod, so a better approach would be:

  
Model *pModel[totalMod];

// In some Init function

...
for(int i=0; i<totalMod; i++)
pModel[i] = NULL;
...

I hope that helps you, if you have any further questions feel free to contact me.

------------------------
Der_Doener@gmx.de
ICQ: #9279368

Edited by - Doener on February 20, 2002 9:35:01 AM

Share this post


Link to post
Share on other sites