Posts tagged as:

Cheetah3D

Some folks have asked me for examples of how my Cheetah3D -> iPhone header converter works. To help you out, I’m posting an Xcode project that I’m using to test the converter.

You can get it here: C3DConverterTest.tgz

This project renders four different shapes generated in Cheetah3D. It’s pretty simple; a lot of the code is from the Xcode’s standard OpenGL ES project template. I’ve added lighting to show that the normals work properly, though.

Some notable files:

  • 4 shapes.jas — the Cheetah3D project
  • 4 shapes.h — the header file exported from Cheetah3D. You can run this through the converter yourself if you like.
  • 4 shapes_iphone.h — the header file made by my converter
  • pure_colors.jpg — A simple texture. Replace this with your own for a different look.

I hope this helps!  Let me know if you have questions or comments.

0 comments

I’ve updated the Cheetah3D -> iPhone header file converter to version 2.0.1.  This version corrects object names from Cheetah3D that aren’t valid in Objective-C.  (Example: “Box.1″ is renamed to “Box_1″).  Thanks to reader Scott for pointing out the problem and a solution.

Download version 2.0.1 here: c3d_to_iphone.pl (zipped)

Please comment or contact me with any feedback!

0 comments

Cheetah3D header file converter for iPhone

by Rob Bajorek on May 9, 2009

[Update 2009/06/04: Version 2.0.1 released.  Bug fix release, see here for more information.]

It’s ready!  The promised Cheetah3D -> iPhone header converter is right here:

c3d_to_iphone_h.pl (zipped)

With this program you can convert exported Cheetah3D OpenGL .h files to an iPhone-compatible format.

Please read the comments at the top of the program file for usage information.  I tested this on Mac OS X 10.5.6, but it should work on any system with Perl 5.  I purposely did not use any external modules (no messing with CPAN here.)

The software is free, licensed under GPL 3.  If you try it, please send feedback or respond in the comments.  Thanks!

9 comments

After starting down the road of OpenGL development on the iPhone, I knew I needed a 3D modeling application to do anything fancier than spheres and cubes. My first try at an application was Blender. Blender has a lot of fans, but it’s also quite complicated. Just going through the tutorials was a chore. I didn’t want to learn how to draw fancy shapes like monkeys; simple polygons were sufficient.

After getting some basic models together in Blender, I had difficulty exporting into a usable format for the iPhone. The Wavefront OBJ format is the generic 3D model standard, and there is an importer for iPhone out there. It’s not feature complete, and doesn’t support UV texture mapping at this time. That’s a big hole for my purposes.

I played with Blender for a couple of days, but I struggled getting textured Blender objects into my iPhone project. Other people do it, so I’m sure it’s my lack of knowledge in that field. However, I don’t plan on being a 3d modeler; I’m the software architect. I need to spend my time on my area of expertise. But my needs were simple (mostly basic textured polygons), so I still preferred to do it myself.

What did I do? I ended up buying Cheetah3D, made my shapes quickly (and easily!), and exported it to a .h file in under 15 minutes. Now that’s what was looking for from Blender!

All done? Close, but not quite. Cheetah3D’s .h export feature makes an OpenGL-compatible file, not an OpenGL ES one. But, it took under an hour to hammer out a Perl program to convert the header file into an iPhone-usable one. Now I just run my Perl program over Cheetah’s exports and *poof*! Add the new header file to my iPhone project, import it at the appropriate place, and it Just Works.

End result? Cheetah3D is doing everything I need in a 3D tool. Not to say that Blender is a bad program. Far from it; it has an enormous amount of power and it’s free. But just like you won’t recommend Photoshop to get rid of red-eye, for my basic needs Cheetah3D does the job.

I have some requests for my Perl program, so as soon as I clean it up I’ll put it out for you to use.

[Update 2009/05/09] The Cheetah3D -> iPhone header converter has been posted.

3 comments