3D Game Builder SDK

SDK Functions

gameDrawModel( int id )

Description

Draw a 3D model that was created using 3D Model Builder.

Specification

void gameDrawModel( int id )

int id

= the id number of the open model

return value

= void (nothing)

Notes

This function draws a 3D model that was created using 3D Model Builder.

Open a 3D model using the gameOpenModel( char * name ) function.

3D Model Builder software is included with the 3D Graphics 101 and 3D Graphics 102 course. For more information visit www.3dgraphics101.com.

Be sure to create an appropriate view and model matrix before drawing your 3D model.

You can create either a parallel view or a perspective view.

To reset the projection view matrix use these OpenGL functions:

glMatrixMode( GL_PROJECTION );

glLoadIdentity();

This will create a parallel view volume that is 1 wide, 1 high x 1 deep.

To create a parallel view matrix you will then want to adjust for the screen ratio using this OpenGL function:

glScalef( (272.0f/480.0f), 1.0f, 1.0f );

This will modify the volume to (approximately) 1.7 wide x 1 high x 1 deep.

If, for example, you have a 3D cube model with a size of 10x10x10 you will want to create a volume that will easily fit this into the screen. A view volume of 20x20x20 would fit this nicely so we could multiply our scale by 1/20 (that is "current volume" divided by the "target volume") like this:

glScalef( 1.0f/20.0f, 1.0f/20.0f, 1.0f/20.0f );

This will result in a volume that is 20 wide, 20 high x 20 deep.

To do the same, but with a perspective view, we can use this GLU (OpenGL Utility Toolkit) function to create a perspective view and move the eye position away from the origin using the OpenGL translate function:

gluPerspective( 30.0f, (480.0f/272.0f), 1.0f, 100.0f );

glTranslatef( 0.0f, 0.0f, -50.0f );

This will result in a perspective view looking down from 0,0,50 with a field of view angle of 30 degrees and a volume depth of 100.

When you have finished with your 3D model you can close it using the gameCloseModel( int id ) function.

For Example


			

See Also

  gameOpenModel( char * name )
  gameCloseModel( int id )
  gameDrawModel( int id )
  gameFlushModels( void )
  gameSetModelLighting( int on )

Go Back

SDK Functions