Google Code offered in: English - Español - 日本語 - 한국어 - Português - Pусский - 中文(简体) - 中文(繁體)
This chapter describes the sample COLLADA Converter, which is used to export COLLADA files for O3D from digital content creation tools such as 3ds Max, Maya, and SketchUp. This sample converter can be used, for example, to import COLLADA files created using one of the following applications:
The sample COLLADA Converter can also be used as a model as you develop your own converter and/or loader for O3D. Please note that O3D is still in the development phase, and this material is subject to change.
Download the sample COLLADA Converter.
This section describes how to use the sample COLLADA Converter with content created using Google SketchUp, Autodesk 3ds Max, and Autodesk Maya.
To export from Google SketchUp, select "Collada (.DAE)" as the export type.
Since SketchUp uses two-sided materials and COLLADA supports only single-sided materials, meshes are exported twice: once with the front material, and once with the back material (they share vertex data). In some cases, the inner material is not exported correctly from SketchUp, which causes the model to appear incorrectly in O3D.
In order to export COLLADA files from 3ds Max, download the ColladaMax plug-in for 3ds Max from the colladamaya project on SourceForge. After installation, under the "File/Export" menu, select "COLLADA (DAE)" as the export type. Note that you may see "Autodesk FBX/DAE" listed as an export type: this is the FBX plug-in from Autodesk, which exports only a limited subset of the COLLADA file format, does not support shaders, and is not recommended for use with O3D.
The following material types are currently supported by O3D: Standard/Phong and
The shaders accepted by O3D should be written in the .FX file format, containing HLSL shaders. This format is a subset of Cg, containing no interfaces, unsized arrays, or scripting. There must be a single ShaderModel2 technique, containing a single pass, comprised of a vs 2.0 vertex shader, and a ps 2.0 pixel shader. See O3D Shading Language for further details.
To shade existing objects with programmable shaders in 3ds Max:
In order to export COLLADA files from Maya, download the ColladaMaya plug-in from the colladamaya project on SourceForge. After installing the plug-in, choose either "File/Export All..." or "File/Export Selected...", and select "COLLADA exporter (*.dae, *.xml)" in the file type selector.
After exporting a scene from your content creation tool, you will have a single .dae file containing the geometry. This .dae file may reference one or more texture files, and one or more shader (.fx) files, often using local path names. In order to prepare your scene for delivery to the O3D plug-in, you will have to package all the files up as a single .tgz archive. The sample COLLADA Converter can perform this task for you. It resolves all absolute file references into relative URLs and converts the .dae file into a file called scene.json in the archive.
For imported files, the O3D Converter uses one of two default modes for wrapping textures when the u, v texture coordinates fall outside of the 0 to 1 range. For 2D textures, the default for Sampler.AddressMode is WRAP. For cube map textures (environment maps), the default is CLAMP.
O3D provides a sample implementation of a converter and an archive reader for COLLADA files. You can implement your own reader (in JavaScript) for your own file format. This section explains some of the considerations addressed in the sample code that may help you develop your own converter and reader.
The O3D plug-in has support for reading compressed (gzipped) tar archives to help you with delivery of your file format in a compact form.
To be clear, you don't need to use this format, or even use the sample reader code to read your assets. In the end, this format is simply converted to calls to the O3D API, which you could generate on your own from any input you choose. If you want to read your own format, you will need to write your own import code in JavaScript that calls the O3D API calls to construct a scene graph with your data.
The files that the sample JavaScript scene loader (o3djs.scene.loadScene()) reads are gzip-compressed tar archives (.tgz files) which contain:
aaaaaaaa.o3d). This file is required.
This file is simply to prevent O3D from opening arbitrary .tgz files. If this file isn't the first file in the archive, O3D won't open the file. The file is three characters long, and contains the letters "o3d".
scene.json file is an example of this kind of file.The JSON file is just a JSON representation of the scene graph in O3D, and it is what the sample JavaScript scene loader code reads to construct a scene graph from the archive file. It is what references the other assets in the archive.
The binary blobs are indexed in the JSON file by file name, offset and length, and the rest of the archive contents are referenced by name. The binary blobs are there because they are more efficient to load than the same data encoded as JSON strings. You could also define the data as text in the JSON file (but it would be slower to load and larger).
Shader files are text files containing the shader code referenced by the JSON file.
Image files can be JPG files, DDS (DirectX SDK) files, or RGB PNG files (greyscale PNG files aren't yet supported).