COLLADA – A powerful file format for digital content creation

COLLADA is an XML file schema, which allows users to exchange 3D assets between various DCC applications like “Autodesk® 3ds Max®“, “Autodesk® Maya®” or “SOFTIMAGE®|XSI™” and other interactive 3D applications. It was originally initiated by Sony Computer Entertainment® America (SCEA) to create a development format for “PlayStation® 3” and “PlayStation® Portable” projects and became a standard of The Khronos Group, which also holds the OpenGL standard.

There are a lot of problems to transfer data from one 3D application to another, because every software uses proprietary file formats, which are optimally suited to the features the application supports. Most programs also support other file formats like “Wavefront Object“, which however can only store a small set from the features list. That way it is often only possible to convert model data like polygon meshes with a single texture coordinate set and more complex data like multiple texture sets or animations get lost. Even commercial converters are not able to translate every asset completely.
So for realtime 3D or game development programmers were forced to abstain from features, which were not supported by the file formats their team was using but which became more and more important with increasing game quality. Or you had to write an exporter or importer for every 3D application, which the artists were using. Just a single im- or exporter can be a lot of work.

A solution would be a standard file format that every application can read from and write to. The first attempt was “FBX®“, which is now owned by Autodesk®. It became free to use but a long time it does not solve important issues like exchanging multi-textures between programs because the existing plug-ins were not able to do that, even though the format itself could handle it. And there is no source code to extend the plug-ins by yourself. You still had to write your own for every application.
Today “FBX®” is the most common format for asset exchange between DCC applications but not important for game programming.

In October 2006 the COLLADA format had been published. It was and is open source, easily readable XML and extendable. But there were no plug-ins and no programming kits. Because “FBX®” has got a C++ SDK it was easier to write im- and exporters for that format than for COLLADA at this time. Fortunately some month later a SDK was released and the first plug-ins for programs appeared. Today many 3D applications support the format but not all major ones like “LightWave 3D®“, which we are using. However native support is announced unofficially for the current main version.

We have already implement a COLLADA file loader into a character animation plug-in for “Viz|Artist 3.0™” called “Action Model“. And currently I am using COLLADA as standard development format for “TigerHeart” II projects.
Files are being read using the SDK and converted to “TigerHeart” objects. These can now be modified using C++ and will also be changeable in a editor later. After that object data can be stored back without destroying original COLLADA data that was not converted or modified. In doing so multiple applications can access a COLLADA file, modifying its data without loosing something that was useless for a program. A sound editor may use some 3D data for setting effects but it cannot utilize textures. Although it does not destroy those texture objects by overwriting the original file at export time, because only new and modified data is updated to the COLLADA file database. That is no standard behavior for the COLLADA runtime but can be easily integrated using the SDK.

COLLADA has got also disadvantages. Because the format is very flexible, diverse programs can store their data differently. The programmer has to adapt his software for every utilized application. And even then an update of an application or its plug-in can force him to change his code. But this is being done lots of times faster than to write an im-/exporter for every proprietary file format.
Many common file formats have got the second downside. They are very slow to load and save because much data has to be interpreted multiple times. It does not really matter at editing time but loading time is essential for interactive programs and games. Programmers are able to accelerate reading texture file content using an own format and they also are able to do it with all other data. Generally speaking it is important to convert as few as possible and often to minimize bandwidth.
COLLADA files and other development assets could be converted before they are regularly used by the project or when they are finalized. That depends on the time you are saving during the development. In any case they should be converted before the product is delivered to the customer.

I believe that COLLADA will become the standard game development format one day, if no other competitive format occurs. Currently it is already utilized by some big names like Sony®, Google™, “3ds Max®”, “Maya®”, “Unreal® Engine” or “XSI™”.

TigerHeart II: First impressions on OpenGL

I am currently implementing some classes for the new “TigerHeart” graphics engine using the OpenGL pipeline. And it is the right way because I am a beginner in OpenGL, which is a little bit more different from Direct3D than I thought. Since I am a professional in programming with Direct3D I can judge how to design interfaces, classes and their interaction so they can be used for both APIs.
A good example is shader programming: In Direct3D vertex and pixel shaders can be applied roughly independent from another. But using OpenGL you have to create a program object, to which multiple shaders can be attached. Afterwards this “program” must be linked and applied to utilize the shaders.

per vertex lighting per pixel lighting

You can see my current progression state at both images above. It is a cube model with shared, rounded vertex normals, what is not a reasonable assignment but a good test. The first one shows the common per vertex diffuse and specular lighting. It has got a poor quality because both lighting colors have to be linearly interpolated between the eight vertices.
On the second image you can see the same calculations but relocated to the pixel shader. There is no need for a normal map unless you want to add details to the object without appending vertices. The quality seams to be nearly perfect.

The mesh is rendered using vertex buffer objects (VBO), which is the fastest way to draw complex models using OpenGL, and shaders are compiled with GLSL. This language is comparable to Microsoft’s HLSL but have got some design differences. For example the compiler is integrated into the graphics driver and there is no possibility to specify shader model targets.

TigerHeart II: OpenGL vs. Direct3D

I wrote that the second version of “TigerHeart” should be able to use OpenGL and Direct3D for rendering. But why do we need to support both APIs today? It is a lot of work, which has to be done twice.

Currently some hardware vendors haven’t got good OpenGL drivers. So you can get problems to run your software on some graphics cards. But as a game developer you need the widest possible hardware range, which is able to execute your software without any difficulty. For this reason it is a good decision to choose Direct3D because its behavior is obviously more matchable. Moreover you get better support for older hardware since a lot of features can be simulated by the CPU when the GPU does not support it and HLSL shaders can be compiled to Shader Model 1, what is not possible with GLSL.
Media Seasons is not only developing games but also graphics software for television. Therefore a requirement is to output the rendered graphics on the SDI channels of a “NVIDIA Quadro FX” card. We use the SDI SDK to accomplish this. Unfortunately that software development kit only supports OpenGL, what is comparable to the Quadro drivers, which are optimized for OpenGL because it is still the standard API for professional products. So we are forced to implement a rendering path for it. But we do not have to make our TV software compatible for further graphics cards because in this market segment the developer is able to exactly specify the required hardware.

TigerHeart II: Objectives for the graphics engine

The 3D engine is the largest and most addressed extension of the first “TigerHeart” version. Because it is possible to use it not only for three-dimensional presentation but also for hardware-accelerated flat, 2D drawing the notation will be changed to the more indicative term ‘graphics engine’.
Following characteristics should be achieved:

  1. API base: It must be able to utilize Direct3D and OpenGL for hardware-accelerated display.
  2. Standardization: The objects should be accessible and modifiable independently from the graphics API, which is currently active. So a scene, which is created with DirectX, can be rendered with OpenGL and vice versa and tools and helper functions have to be created only once. Anyway the engine gains specialized interfaces, methods and attributes for particular API functionalities and performance issues.
  3. Object types: There are two major kinds of objects. Displayable ones (like graph nodes and polygon meshes) are unilaterally interdependent, transformable and have got the ability to be rendered and attributes like bounding volumes and a position vector. They use states (like shaders and textures), which are the second kind and on a par, for rendering. Besides octrees will help for culling and collision detection, fonts are being used by text objects to show letters, animations to transform nodes by presets, cameras for view manipulation and light sources for illumination.
  4. Multi-pass: Displayable objects should have the ability to be rendered multiple times using different sets of states. This is important for generating shadows, effects and complex lighting.
  5. Streaming: Rendering operations are stored into buffers, which can be sorted to reduce state changes and to meet other, hardware-dependent conditions for performance increases. These stream buffers can be processed in another thread than the generating one. That way the scenery is being modifiable for the next frame while the previous one is still being drawn.

XML for engineering

The Extensible Markup Language (XML) can be used to store any given data. I am using it to design functions, interfaces, classes and other types for the second TigerHeart engine.

Besides pure XML files, which store names, parameters, result types, derivations and so on, there are also a schema (XSD) and transformation files (XSLT).
The first one defines basic types and valid elements, attributes, groups and sequences for the XML files. So their syntax is checked for mistakes. Both kind of files are free from programming language specifications like class or virtual for C++.
For that XSLT is available to assemble files that are usable for coding. The greatest benefit of the whole system is the convertibility of the XML files into various languages and even multiple files of the same language (e.g. .h[pp] and .c[pp] for C). It is also possible to automatically generate bindings of functions and variables for scripting languages and to build a documentation in HTML or whatever you want. For TigerHeart II C++ headers, source code files and Lua bindings are formed. Maybe there will be a time when XSLTs for C# are added but they are not currently planned.

XML: schema XML: sample XML: transformation XML: result

After the transformations I can add content to the created source code. If I have to change a type name or a definition later, then I only need to do it once in an XML file and not at every appearance in the code.

TigerHeart II: Objectives for the core

The first important step in the planning phase of a new software project is to set the objectives. Here are the ones that should be achieved for the second version of the “TigerHeart” engine core:

  1. Classes and interfaces: C++ classes are accessed externally via interfaces similar to COM. Furthermore methods can be called and attributes can be retrieved and modified using special functions (e.g. for script utilization).
  2. Derivation: It is possible to use existing classes as base for new ones. But those extensions should be accessed by non-derived interfaces.
  3. Object and library management: TigerHeart manages object creation from classes, which are provided by static and dynamic libraries.
  4. Data access and storage: Files from directories and archives are loaded and saved using wrappers. Data can be stored into memory and files with a standard interface and compression.
  5. Meta data: Every class is able to retain user-defined attributes.
  6. Design: Construction of functions, classes and interfaces happens in XML files, which are transformed into various header, source code, script files and what ever is needed. These files will be enhanced by own code.
    Maybe the handling is simplified by an editor later.
  7. Threads: There is a native support for processing on multiple cores.
  8. x86 / x64: Code has to be compilable to 32 and 64 bit executables for Microsoft Windows XP and Vista. Compatibility with other platforms is optional.

TigerHeart

After my first game “FutureTrade” had been published I started to learn 3D programming, which was a wise decision because I needed it for my first commercial graphics engine some month later. It was developed for “BomberFun” and also used for a winter sports game called “Winterspiele 2002” and its successor “WinterSports Extreme“. But in the development time I began to realize that the design was not very good. Even it was object-orientated it was made up of one giant class for the game and one giant derivation for the editor. The engine was fast but inflexible especially using shaders and it was no real fun to program with it.

Early in 2002 I started the planning of a new engine. It should be really object-orientated, perform more common tasks than only graphics and be nice to use. The design was adopted from “Microsoft DirectX” because I love how the objects live up to their names. I started the implementation after “BomberFun” was finished and a new project was started in late summer and named the project “TigerHeart” because it is a good name for an engine.
The base of the system is the main engine, which is responsible for object management like COM but platform-independent, loading extension libraries like a plug-in and data storage and access. Meanwhile some extensions have gathered but the first and most important is the 3D engine using “Direct3D“. Different from the previous one there are a lot of classes for the various functions and attributes: renderers (frames, bodies, meshes), states (textures, materials, shaders), animation data (animations, sets, blenders) and some more. They are used to build a hierarchy, which can be processed or rendered with one command.
Next I created an extension for scripting and one derivation for “Lua” support. It is completely independent from the 3D engine but can be combined with it smoothly because of the “TigerHeart” design. There is the possibility to add support for another language, which is applicable immediately without the need for a change of the target program. But up to now there was no demand for it.

TigerHeart sample TigerHeart sample TigerHeart sample

For our bowling, card and air hockey games I implemented a compilation of class, which were based on the “TigerHeart” engine. But they were not flexible enough and not clearly separated from the games themselves. So I started to implement a game engine base as an extension library for the main engine at the beginning of 2005. It handles initialization, standard scene management, script access, multi-threaded loading, some user interface functions, console support for development, input processing and sound output.
The first use was for “Uli Stein – Summer Games” and later for “Balko”. We also developed our broadcast applications for the “Four Hills Tournament” 2005/06 and “tvVAT3D” as an add-on for it.

TigerHeart sample

Every now and then there a some design issues and some missing features, for which time was lacking. But we still currently use the “TigerHeart” engine and extensions for the development of a casual game selection. Anyway the planning phase of the second version has just begun and I will use this weblog to keep you informed. Maybe that would help you to design an engine or maybe there are times when you are able to help me in difficult situations.