Advertisement

importing MORE THEN ONE MILKSHAPE MODEL into open GL scene

Started by February 19, 2002 07:33 AM
4 comments, last by fatherjohn666 22 years, 9 months ago
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?
~~~~~~~~~~~~~~~~~~~~~~~~~http://on.to/oni
you know showing line 39 would help, so since you expect us to magically know it, i will give you the magic answer that will fix it.

from the looks of things it looks like you are passing a "const int" instead of a "model" pointer on line 39 in "C:\Documents and Settings\Sir 666\My Documents\programming\opengl\simple scene\main.cpp".
Advertisement
Ok lets just say ALL I want to do is import more then one model, forget my code, how do I initialize the *pModel pointer so its a pointer to an array of models rather then just a pointer to a model.

If there is some code somewhere....where!!!
sorry I just pasted code, that is definately a silly way to expect results
~~~~~~~~~~~~~~~~~~~~~~~~~http://on.to/oni
there might be thousands of ways for this but the simplest.. use
"Model** pModel" instead of "Model* pModel"

more clearly;
      Model** pModels = new Model*[2]; //for two models//inside init or sth like that// I didn't read your code, but I hope a function like that below, if not write it :)LoadModel(pModel[0], parameters_for_first_model);LoadModel(pModel[1], parameters_for_second_model);// somewhere else in your renderer functionRender(pModel[0]);Render(pModel[1]);    


now you have two model pointers for two different models..

cheers

-----------
my quote is under construction

Edited by - mentat on February 20, 2002 10:52:24 AM

Edited by - mentat on February 20, 2002 10:53:20 AM
-----------my quote is under construction
I find it annoying when somebody just dumps their entire code to the forum. Grr

Oli


All the best problems start with C

.:: K o s m o s E n g i n e ::.
quote: Original post by downgraded
I find it annoying when somebody just dumps their entire code to the forum. Grr

Oli



yeah sorry bout that, reread my original message which does not clearly state about BRETT PORTERS TUTORIAL (http://rsn.gamedev.ent) being the main source, and what I pasted was what I had changed of his code. Sorry guys
~~~~~~~~~~~~~~~~~~~~~~~~~http://on.to/oni

This topic is closed to new replies.

Advertisement