problem with milkshape model loading

Started by
6 comments, last by game_dev01 13 years, 4 months ago
Hey all..

I wanted to laod my milkshape car model in opengl and took help from Nehe's lesson no. 31 for it and though, model was loaded properly but to my grief, its textures are not loaded. and also, when i browsed through Nehe's code, i couldn't find assignment of transparency of the material. Currently, i am getting only "white" car which is looking very sluggish..

Can anybody help me out with it?? I'll be very thankful for ur help!! :)
Advertisement
I believe when you read the file it only gives you the name of the texture (carTex.tga for example). It's up to you to give the location of the texture
("Data/Textures/"+TextureName).

Try just binding the texture manually before the car is drawn.
Hey.. thanx a lot Agro for ur help.. i changed the directory where i was placing my textures and thus, got the problem solved!! ;) :)
But, now another one faces me!! how can i detect collision of the model i loaded into opengl with any object..
(here i loaded a car in opengl and i have to detect its collision with any obstacle on the road) .. how can i accomplish that???
How collision is handled for the most part in 3d games is not actually checking if the 3d models (meshes) collide, but rather, they check simplified shapes of the objects.

For instance for a player, they may substitute a cylinder or a box in collision detection.

For a space ship, a sphere may be used.

For a car, a box might work, or a couple boxes.

Sometimes after doing the simplified shape test, games then test versus the individual polygons in a model but that's fairly rare or only used in special circumstances.

collision detection (and response) is an incredibly in depth subject. I suggest starting simple by wrapping your objects in simple shapes and just collision test those simple shapes (:
hmm.. thanx a lot for ur quick reply.. :)
i think since m just a beginner so taking simple shape should work!! ;)
by the way, can u please also tell me that is there any other way to translate an object in opengl than translating the whole opengl window (using glTranslatef). this also applies for rotation and all other transformations also.. since, i wish to rotate the tyres of my car irrespective of the whole car body.. Can this be done??
I know a quick hack but this isn't something you would want to use.

First rotate the model vertices yourself around the center of you object
Then add the translation to the vertices.

This generates the same effect.



But I'm getting the idea you need this snippet
//Load identity matrix, everything will be rendered at (0,0,0)glLoadIdentity()//Save the identity matrix by pushing it onto the matrix stackglPushMatrix();//Do a translation (also works for rotation), everything will be rendered at (50,100,-10)glTranslatef(50, 100, -10);//Render the objectObject->Render();//Pop back the matrix, everything will be rendered at (0,0,0) againglPopMatrix();


You can do this multiple times.

Hope it helps
"What? It disintegrated. By definition, it cannot be fixed." - Gru - Dispicable me

"Dude, the world is only limited by your imagination" - Me

Quote:Original post by game_dev01
hmm.. thanx a lot for ur quick reply.. :)
i think since m just a beginner so taking simple shape should work!! ;)
by the way, can u please also tell me that is there any other way to translate an object in opengl than translating the whole opengl window (using glTranslatef). this also applies for rotation and all other transformations also.. since, i wish to rotate the tyres of my car irrespective of the whole car body.. Can this be done??


Well you can push and pop transformation matrices from a stack (glPush/glPopMatrix) so it only applies to the objects you want.

But the current non-deprecated way to do what you want is by using shaders with your own transformation matrices. That way you can keep each object translation separate and send it to the shader (as the model/view matrix) when you want to draw the object.
ohk.. so that means i need to perform this push and pop when tyres are drawn.. right??/ bt problem is i am drawing the whole car on loading from milkshape 3d.. so actually i dont know tyres vertices also.. and i wish to rotate tyres only when car is moving that is when "up' arrow key is pressed.. at that tym i wish to move car and at the same time rotate its tyres.. till now i am moving car on dis key event.. where and how shud i add this push/pop matrix function for rotating my tyres??

This topic is closed to new replies.

Advertisement