Cube Source Code

The Cube Port is based on the content and code available from Cube “Final” (August 2005) at http://sourceforge.net/project/showfiles.php?group_id=91993

Download iphone Cube source v1.6 - 300Kb Note: This only includes the source code

The code is provided as-is with no warranty.

Please feel free to Contact us if you wish to discuss commercial support.

Content Conversion

  1. All content is renamed so as to have lower case names
  2. Music ”.ogg” files were converted to ”.mp3” using Sox Wrap
  3. Image ”.jpg” and ”.png” files were resized if necessary to have power-of-two dimensions, and restricted to 256×256 size
    • The ”.jpg” files (with the exception of sky textures) were then made square, and compressed to pvrtc format (2bpp, mipmaps) using Apple's texturetool. The raw data stored in custom named ”.pmt” file, with a header byte indicating the original aspect ratio. To aid this process we wrote a simple program: pvrtc - 3Kb
  4. The “data/newchars.png” texture was removed and instead it is generated at runtime from the system bold font
  5. The menus were modified:
    • “Quit” option is removed
    • “Sound…” is added - which brings up an extra menu to set music/effects volume
    • “Command…” is added - which brings up the virtual keyboard

Compiling

  1. The content of the converted (see above) Cube data/ and packages/ folders are to be copied into the project's data/ and packages/ folders
  2. The Cube enet .h and .c files are to be copied into the project's /enet folder
  3. A new identifier (Targets > Cube > “get info” > Properties) will need to be added
  4. Code signing info will need to be added for deployment on a device

Source Changes

Some detail about the source changes can be found on the Cube page, and so far as possible source changes are marked with:

// RbrtPntn - ...

The code that interfaces the Cube C++ to the interface Objective-C is held in “iphone.m” and “iphone.h”. Within the header are a few useful #defines - in particular all iphone specific code is surrounded by:

#ifdef IPHONE

and in theory (and for initial testing) the code can be built as a desktop application by undefining this (note: you'll have to provide the original ”.jpg” files as a desktop application won't be able to decompress the pvrtc data).

SDL Libraries

SDL in terms of keyboard/mouse/window interfacing was replaced by Objective-C.

SDL_image was redundant as CoreImage loads images quite nicely, and we have custom loading code for our ”.pmt” files.

SDL_mixer was replaced by a version of Apple's SoundEngine code as found in their CrashLanding sample code. The SoundEngine code was enhanced to give multiple channels for effects.

SDL_thread was replaced by basic pthread equivalents.

ServerBrowser

Lurking threading bugs resulted in this code being replaced by a backport of some Sauerbraten code.

Rendering

Geometry is batched by texture and texture axis to minimise state change. Generates triangle soup (Note: potential memory overflow bugs here). Texture coordinates are generated by passing in the vertices as texture coordinates and setting up an appropriate textxure matrix so as to do emulate glTexGen - this simplifies much of the code and reduces the work load on the CPU.

MD2

Optimise the vertices upon loading, and cache as much as possible in VBOs. Frame interpolation is disabled if models are too far away and it instead uses the nearest frame.

 
iphone/cube/source_code.txt · Last modified: 2009/07/21 15:04 by robert
©fernLightning 2008 Recent changes RSS feed Powered by PHP Made on a Mac Valid XHTML 1.0 Valid CSS Terms Of Use/Privacy/Credits