Advertisement Jump to content


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


Importing MORE THEN ONE milkshape model

This topic is 6178 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
hard to see where the problem is actually located but quickly it can be explained as follow : const int is not a pointer thats for sure it would be const int*. What the message is actually saying is that there is a parameter that cannot be cast as a pointer. It is saying that references can be casted and pointers to array too. just like in this example :

void Dothis(Tparam& p1)
TparamOther* p2 = (TparamOther*)&& ð

or simply

void Dothis(Tparam* p1)
TparamOther* p2 = dynamic_cast(TparamOther)pi;

or something like it, it can be faulty i am at work, but for the theroy it is right. I am not sure of the syntax here so dont copy paste but look around for "Pointer casting" for more info.

Edited by - hotdot on February 19, 2002 9:52:39 AM

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 altered all the other code to get it to work the way I would make an ordinary array work.
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. Im definately reading up on pointers atm
Its probably simple I know

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


Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!