Cheetah 3D and OpenGL ES

Cheetah 3D and OpenGL ES

Cheetah 3D ( a great program for modeling 3D objects. Perhaps even more interesting to iPhone developers is the program's export option to create a header (.h) file with the vertices, normals, and texture coordinates for use in an iPhone application. Below is a screenshot of Cheetah 3D and a model of a StarCraft II Battlecruiser.

To export a header file after creating an object in Cheetah 3D, simply choose file >> export and select the .h option. This will save a header file to the directory of your choosing.

There is one caveat to this export. To actually use the header file out of the box, one must manually replace the vertices arrays in the file from type 'int' to type 'GLushort'. After that, you can easily import the file into your Application and render the objet using calls like:

// Render and Texture Proceedure for gun1





glVertexPointer(3, GL_FLOAT, sizeof(vertexStruct), &gun1_vertex[0][5]);

glTexCoordPointer(2, GL_FLOAT, sizeof(vertexStruct), &gun1_vertex[0][0]);

glNormalPointer(GL_FLOAT, sizeof(vertexStruct), &gun1_vertex[0][2]);


To actually render the object in the iPhone simulator or device itself, you need to add this struct to your code:

typedef struct _vertexStruct


GLfloat texcoord[2];

GLfloat normal[3];

GLfloat position[3];

} vertexStruct;

I've written a small (and ugly) Python script to convert the ints to GLushorts for you and print to file the drawing calls for easy copy / paste and modification in your iPhone project. Simply edit the file and change the 'name' line to the name of the header file and run the file in the working directory. It will output the fixed header file as well as a file named 'glcalls.txt' that contains the drawing calls for quick copy / paste into your project.

Here are a few examples of the Battlecruiser in the iphone simulator with some texture.

Feel free to leave feedback - happy coding!

ClassyBits 2020