Creating POD Files
Cocos3D is able to directly import files formatted in the PowerVR POD file format from Imagination Technologies, the supplier of the GPU used in iOS devices. The POD format is a dense binary format, suitable for the fast loading and minimal memory requirements of a mobile device.
This article describes how to generate a POD file, either by exporting directly from one of several popular 3D editors, or by converting a COLLADA file previously exported from a 3D editor. COLLADA is an industry-standard exchange format for specifying 3D model data, and most 3D editors support exporting into the COLLADA file format.
The PowerVR SDK from Imagination Technologies includes several useful tools for working with POD assets. You can download the SDK here. You will need to register and log-in to the PowerVR site (it’s a free registration), before clicking on this SDK link. You can choose the types of tools and components that you want to download. Once the download is complete, unzip the contents.
PVRGeoPOD tool is used to generate POD files. In the unzipped download, it can be found in the
PVRGeoPOD directory. There are three ways to use this converter:
As a plug-in (or add-in) to several popular 3D graphic editors. Currently the following editors are supported, and each can be found in the
PVRGeoPODsubdirectory bearing its name:
- 3DS Max
As a standalone GUI tool (
PVRGeoPODGUI) that converts COLLADA files to POD files. This tool can be found in the
As a standalone command-line tool (
PVRGeoPODCL) that converts COLLADA files to POD files. This tool can be found in the
If you have the option, using one of the 3D editor plug-ins is the preferred choice, because it eliminates the COLLADA middle-man. Instructions for using the
PVRGeoPOD tool, and for installing it as a plug-in to one of the above 3D editors can be found in the PVRGeoPOD.User Manual.pdf document in the
For a step-by-step guide to downloading the
PVRGeoPOD converter, and installing it into Blender, view Harry Dart-O’Flynn’s Starting Cocos3d – 5 – Blender & PVRGeoPOD Exporter video tutorial.
####Generating the COLLADA File for Standalone PVRGeoPODGUI & PVRGeoPODCL
If you are using either the
PVRGeoPODGUI standalone GUI tool, or the
PVRGeoPODCL standalone command-line tool, the first step is to generate a COLLADA file from your 3D editor. Most 3D editors are capable of exporting COLLADA files for use by the
There are several evolutionary versions of the COLLADA file format. Creating POD files from COLLADA version 1.4 files has been well tested, but you may experiment with other COLLADA versions as well, if your editor supports exporting to those versions.
There are a number of configuration options to help you generate what you need. When running the
PVRGeoPOD tool as a 3D editor plug-in, or as the
PVRGeoPODGUI standalone GUI application, these are presented to you in a configuration GUI. The plug-in or GUI application is the best way to get started, then once you’re familiar with the structure and configuration options, you can switch to the command line utility if you prefer that mode of operation.
If you are running the
PVRGeoPOD tool as a 3D editor plugin, select the models in your 3D editor that you want to export to a POD file, and run the
PVRGeoPOD exporter plug-in (typically it will be a File/Export menu choice).
If you are running the standalone
PVRGeoPODGUI tool, once the tool is open, use the Open… menu to locate the COLLADA (
*.dae) file that you want to convert.
PVRGeoPOD tool has one main configuration window with several tabs as follows:
The Geometry tab.
The Materials tab.
The Transformations tab.
These screenshots illustrate suitable settings for importing into Cocos3D.
The PVRGeoPOD.User Manual.pdf document in the
PVRGeoPOD/Documentation directory explains each of these configuration options, and you can hover your mouse pointer over any of the fields for more information.
You can play with some of these settings, but to avoid frustration, keep in mind the following points regarding how Cocos3D interacts with these configuration settings:
Pay particular attention to the Invert transparency checkbox on the Materials tab. If your model is not visible in Cocos3D when you load your POD file, the first thing you should check is the setting used in the Invert transparency checkbox in the
If your textures appear upside down on the model, you can set the Flip V Co-ordinate flag to flip the texture coordinates in the model during the export or conversion.
The PVR GPU is optimized for floating point operations on vertex coordinates. So, on the Geometry tab, make sure the data types for Position, Normal and texture Export mapping channels are set to
To save memory, if your model contains per-vertex color information, you should set the data type of the Color component to
If you have constructed your model to perform soft-body mesh deformations using [skeletal animation] (Meshes#SkeletalAnimation), turn the Export skinning data option on. The Matrix palette size setting indicates the number of matrices available for mesh deformation, and is limited by the GPU in the device. When running OpenGL ES 1.1, on the PowerVR MBX GPU found on earlier iPod Touch and iPhone models, the matrix palette size is 9, and on the PowerVR SGX GPU found on all later devices, the size of the matrix palette is 11. When running OpenGL ES 2.0 or OpenGL, there is no fixed limit on the matrix palette size, and you can set this value significantly higher. The practical limit will be determined by the number of matrices you can efficiently pass to your shaders, but matrix palettes of size 20 or above are possible under a shader-based programmable pipeline.
Cocos3D currently expects that each POD file only contains one soft-body model, so if you are using skeletal animation as described in the previous point, you should ensure that each such model is stored in its own POD file.
Cocos3D can work with either interleaved, or non-interleaved data. Both Apple and Imagination Technologies recommend interleaving for performance, but you can choose not to, if appropriate for your model. Use the Interleave vertex data flag to make this choice. The Align vertex data (to 32 bit) flag does what is says, and will improve performance somewhat, at the cost of increased file size and memory requirements.
For the Primitive Type option, Cocos3D can make use of triangle lists or triangle strips, either indexed or not. Imagination Technologies recommends that Indexed triangle list is the fastest choice, and that sorting by PVRTGeometrySort is the most efficient way of presenting the geometry to the GPU.
If the file includes animation information, you can choose to include it by turning on the Export animations flag, and Cocos3D will make use of it to animate your models. To engage animation, you need to set up the appropriate
CC3Animateaction. See the
CC3DemoMashUpexample application in the Cocos3D distribution for an example of how to do this.
Be sure to leave the Export transformations as matrices option unselected. Cocos3D does not support animation using exported matrix data.
Leave the Add position unpack matrix option unselected.
Once you have all your settings configured, hit the Export… button, and choose the location and name of the output POD file (
*.pod). The main window will display a log of the conversion results. Hit the Okay button to get back the configurations settings.
Finally, drag the resulting POD file to the Resources group in your Xcode project window, and select the option to copy the file to your project directory from the resulting dialog box.
Different 3D editors will use different coordinate systems (left-handed or right-handed), and may orient your model space so that any of the X,Y or Z axes represents the world ‘up’ direction.
Please also note that the
PVRGeoPOD tool rotates data so that the Z-axis is ‘up’. Since the OpenGL ES default is to have the Y-axis as ‘up’, and the camera looking down the negative Z-axis, it is usually more convenient to use the OpenGL orientation in Cocos3D (although there’s nothing stopping you from rotating everything by 90 degrees within Cocos3D).
With this in mind, in your 3D editor, orient your model world so that ‘up’ is along the Z-axis. The
PVRGeoPOD tool will then rotate the axes so that ‘up’ is along the Y-axis when the model is imported into Cocos3D. However, depending on your 3D editor, you may need to play with this to get the right combination of 3D editor, COLLADA,
PVRGeoPOD, Cocos3D, and OpenGL orientations.