Drawing complex objects

I’ve made a heightmap in openGL, the idea of the heightmap is to use on aeroplanes so passengers can see where they are. What I want to do is include a 3D object that represents an aeroplane, so I can make something that will look like this. How would I go about making something like that? Would I have to define all the points manually or is there an easier way?

Thanks for any advice.

What you want is termed a 3D modeling program. Here are some examples: <a href=“http://www.povray.org/resources/links/3D_Programs/POV-Ray_Modelling_Programs/” target="_blank">
“POV-Ray Modelling Programs”</a>. Some other modeling programs: Maya, 3DS Max, Lightwave 3D, Multigen (Presagis) Creator, Remo3D, OSGEdit, … They’re all over the place, targeting varying markets (media/movies, vis-sim/real-time, games, specific scene graphs, etc.) with varying features and price points. If this is your first foray into modeling, I would recommend focusing on the editors that target real-time graphics, not uber-pretty/uber-slow batch graphics.

Alternatively (simpler), find a free or low-cost pre-built 3D plane model (on 3dcafe or elsewhere) and use that. That may work for starters, depending on the poly count and format, but you’ll probably find that you want some sort of tools path to adjust the number of polys, optimize the triangle order, split them into batches and material states, and translate them into a format your renderer can deal with more efficiently. If you’ve got time, doing this yourself will teach you alot.

Thanks for the reply Dark Photon. I’ve had a read into loading pre built models, .3ds in specific. The trouble is that the models available, and the techniques for loading them are far too complex for my needs. The aeroplane is only a very small feature of the program, it will not be viewed close up so quality is not an issue. I’m simply after the simplest techniques possible.

I think it’s probably going to be easier to draw it in openGL defining all the vertices individually, perhaps using some gluPrimitives.

Is there any other easier method than drawing it in this way? Thanks again.

With a few ellipsoids (glScale on gluSphere), you can model a plane in a “toon” style.
Or a simple textured quad (with alpha) with an airplane photograph from above.

Whatever works for you, of course. However, if you find a free plane model you really like (e.g. in 3ds), don’t re-invent the wheel and write your own 3ds loader (unless you want to for fun). Just convert it to an easy-to-read format or to your format directly.

One easy way to do that is to convert it to .obj or .osg. Grab OpenSceneGraph, build it, and then use its osgconv tool to convert from the source format to .obj or .osg (e.g. “osgconv model.3ds model.osg”).

Both are really simple formats, and the latter is just a text dump of the scene graph, with vertex attribute arrays and primitives ready to grab and stuff into your own format (note that .osg contains the entire scene graph, so if you want to just snarf the vertex data, or if you want to keep the mode/attribute material state too, go for it). osgconv also optimizes the scene graph by default so you should have reasonably efficient vertex data. Hard to get much simpler than that. You can also use osgviewer (also built-in) to preview the model. You could also write a little OSG plug-in to write any OSG scene graph to your engine’s format, and then you can just osgconv directly to your format – that’s not too hard either.

PolyTrans is a commercial model converter you can consider if needed, but I think you’ll get a lot of miles off osgconv.

For the OBJ format spec, go here, and select the “OBJ: Wavefront Object files” link.

Thanks again for both of your replies.

I think I’m going to make it out of a mixture of gluCylinders and GL quads. It seems the only way I can do it quickly (time is a big issue!).

I’ve drawn a mock up model from about 4 cylinders a sphere and several quads. The problem is I’ve hard coded the position of the vertices into the program, if I wanted to move the plane at all it’s all going to screw up because I will have to change all of them which is going to be a pain because it will have to rotate as well as translate.

Is there anyway I can define the vertices of the plane seperately and create a single object from it so to speak, then I can simply call the object and apply the transformations required to the single object (rather than every single vertex)?If that makes any sense?!!


Read the OpenGL Red Book chapter entitled “Viewing”. In particular, focus on the part mentioning the “modeling” transform.

Sure there’s a way. You can transform the vertices easily like this per object:

// object #1
glPushMatrix ();
glTranslatef (30.0f, 0.0f, 0.0f); // Move to x direction
glScalef (1.0f, 4.0f, 1.0f); // Scale height
drawVerticesObj1 ();
glPopMatrix ();

// object #2
glPushMatrix ();
glTranslatef (0.0f, 0.0f, -30.0f); // Move to z direction
glRotatef (45.0f, 0, 1, 0); // Rotate around Y axis (yaw)
drawVerticesObj2 ();
glPopMatrix ();

The problem with rotating the plane’s part individually is they respond differently. For example, if I draw a simple 2D square and a sphere using the following commands:


	glTexCoord2f(0.0, 0.0); glVertex3f(50.0, 50.0, -10.0); 
	glTexCoord2f(0.0, 1.0); glVertex3f(50.0, 55.0, -10.0);
	glTexCoord2f(1.0, 1.0); glVertex3f(51.0, 55.0, -10.0);
	glTexCoord2f(1.0, 0.0); glVertex3f(51.0, 50.0, -10.0);	

The rotations perform differently - the sphere rotates around it’s centre, so it doesnt actually move onscreen, whereas the square rotates around something else (0,0,0 I think???) so moves on screen.

What I want to do is draw the all the different elements sepearately (e.g. like the sphere and square above) then group all the individual elements together into one “object” so when I perform a rotation or translation on this new “object” the different elements all perform together as a single unit.

Is this possible or am I going to need to change the way I’m going to draw the plane?

I’ve had a look throught the redbook again Dark Photon but I couldn’t really see anything about how objects can be grouped/drawn etc. It seems more about explaining how the camera system works and how the rotations are performed using matrix multiplication.

Thanks again for any advice.

do this:

glTranslate to where you want the object
glRotate for the entire object.
//now for each different part, eg an arm on a robot
glTranslate to where you want it
glRotate the part
//now do the same for the next part.

about getting 3d models. try Blender at blender.org
it’s free. also for model loading try the wavefront obj file format. It is very straight forward and I use it for my engine

Thanks Nyad, I gave that ago but it’s still not working, now all the objects on screen rotate constantly never staying still! I forgot to mention that I have another object on screen that I want to control seperately. Here’s the code I have at the minute, it’s probably easier to explain that way:


void camera (void) {


void display (void){



        //****Draw map****

	glColorPointer(3, GL_FLOAT, 0, colors);
	glVertexPointer(3, GL_FLOAT, 0, vertices);

	glDrawElements(GL_TRIANGLES, indexSize, GL_UNSIGNED_INT, index);


        //****Draw Plane****
        glRotatef(xrotP,1.0,0.0,0.0); //This is supposed to rotate just the plane

	//Main part of plane
	glRotatef(90.0,0.0,1.0,0.0); //Rotate it to be parallel with ground
	glRotatef(90.0,1.0,0.0,0.0); //Face North
	//Front of plane

	glTexCoord2f(0.0, 0.0); glVertex3f(50700.0, 47000.0, -10000.0); 
	glTexCoord2f(0.0, 1.0); glVertex3f(50700.0, 49000.0, -10000.0); 
	glTexCoord2f(1.0, 1.0); glVertex3f(57000.0, 50500.0, -10000.0); 
	glTexCoord2f(1.0, 0.0); glVertex3f(57000.0, 48500.0, -10000.0); 



The first half of the display function displays the map, the second half displays the plane (well only a few parts of it at the minute!). The map is rotated and translated using the camera function which moves the map based on the keys pressed on the keyboard. This half works fine.

Now the second half is the problem, I basically want to acheive the same thing, use another ‘camera’ type function which allows me translate/rotate the plane independently - without moving the map. I also want to apply these translations/rotations to the entire plane model, not each part individually.

First off, is this possible? Secondly, if so, what have I done wrong/what do I need to change?

Thanks again for any help, its very much appreciated. :slight_smile: