I worked on to projects seperately. 1 creates a skymap and the other loads in and textures a 3ds max model car. I am having problems now getting my car into my skymap.
This is the code which loads in my car

In my main class, i tried adding somthing like
coursework2 aCoursework2, a bit like what i done for skymap. This didnt seem to work though. Is this the right approach to get my car into my skymap? And if it is, does it mean i would have to add a constructor to my coursework2.h file? At the moment my coursework2.h is like

I seem to get errors if i add a constructor. Any advise or help would be greatly appreciated in how i can get the car into the skymap.
cheers

trinitrotoluene

11-27-2008, 03:20 PM

First are you able to draw the car model alone without texture? Do you use lighting? Do the car model need a scaling factor glScale (http://www.opengl.org/sdk/docs/man/xhtml/glScale.xml) to fit inside your sky box?

nick2price

11-27-2008, 03:41 PM

The car works fine as its own project. I havnt attempted to put it in the skybox yet. This is what i am trying to achieve now but i am unsure of how to go abouts this.

trinitrotoluene

11-27-2008, 04:15 PM

Ok, then you must check first if it will fit inside your sky box. If you can calculate the bounding box (maybe estimate it) of your car then you will know if you need to scale your car or your sky box. After, this should be very easy to place it in the center of the sky box.

nick2price

11-27-2008, 04:33 PM

I am not sure how to work out the bounding box, very new, but from visual i would say that the car would have no problem fitting in the skymap. The next step would be to learn how to get it in which is whats getting me. So, i would have to do it through my main class, but what would be the procedure?

trinitrotoluene

11-27-2008, 05:02 PM

If the center of the car is near the origin and the center of your sky box is the origin, just draw the car and all will be fine. But if the center of your car is not at the origin (maybe the person who model it didn't take care of that thing), you have to translate it back with glTranslatef(...). The translate value are to be find. Notice that most 3d modeler have the Z axis up (Y axis in OpenGL) , so your car may appear lying on a side. So maybe you will have to rotate it too. But you write before that you already achieve to draw the car successfully.

glTranslatef(...)// Elevate it to make the tire of the car over the road T3
glRotate(...)//Rotate it if needed T2
glTranslate(...)//Put the origin at the center of the car T1
draw_car()

This is a trivial transform to perform. You know, transformation in OpenGL will be performed in the inverse order they are declared.

nick2price

11-27-2008, 05:36 PM

I done some changes and added the methods to draw the car into my skymap class.