AC3D lib usage
Watch screencasts:

Initial Xcode steps
1.  Add ac3d_reader.h, ac3d_reader.m, AC3DTexture.h and AC3DTexture.m to your iPhone project
2.  Add .ac files and textures to the project
3.  Add CoreGraphics.framework to project
4.  Enable depthbuffer
5.  Enable lighting

Load model
char *err = NULL;
AC3DFile *acFile = read_ac3d_file("", &err);
if (err)
  NSLog(@"AC3D error: %s", err);

Draw model
// Save matrix

// Setup position and orientation
glTranslatef(...); // Position
glRotatef(...);    // Rotate

// Draw it

// Restore matrix

Cleanup functions
free_ac3d_textures(); // Removes all textures, no rendering should be done after

Running in simulator outputs info during loading
Tris: 372
Created tri strips: 69
Points removed: 162

Loading a model from a thread
@implementation EAGLView

// Thread method
- (void)load_models:(id)sender 
  char *err = NULL; 
  NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; 
  acFile = read_ac3d_file("", &err);
  if (err)  
    NSLog(@"AC3D error: %s", err); 
  [pool release]; 

- (void)awakeFromNib
  // Start thread
  [NSThread detachNewThreadSelector:@selector(load_models:) 

- (void)drawView 
  // Draw model when available
  if (acFile)


Modify materials in runtime
1. Get the material index that will be used by looking in the material section 
   first in a .ac file. Counting from 0

2. If you need to reset the values, read them with the function
   get_ac3d_material(..) and store them for later use

3. Set a materials settings with the set_ac3d_material(..)

Modify textures in runtime
Use the functions set_ac3d_texture(..) or set_ac3d_texture_named(..)
to set new textures in a model. The first is used when a texture id is available
from a previous glGenTextures(..) call and the second when a new file is to replace
a texture.

To reset a texture back to the inital texture use the function reset_ac3d_texture(..)

Prepare AC3D model for iPhone usage
1. Make sure to Commit Subdivision in AC3D
2. Prepare for tristrip optimization by triangulating the model in AC3D
3. Change texture sizes to be a power of 2 ie 128x128, 512x256 

Copyright © 2010 Memention AB