Goals

This document describes the implementation of a 3D engine based on the VRML and X3D languages.

The VRML language is used to define 3D worlds. X3D is simply VRML 3.0, also supported by our engine (since May 2008). We will have some introduction to the language in Chapter 1, Overview of VRML. VRML has many advantages over other 3D languages:

  • The specification of the language is open.

  • The language is implementation-neutral, which means that it's not tied to any particular rendering method or library. It's suitable for real-time rendering (e.g. using OpenGL or DirectX), it's also suitable for various software methods like ray-tracing. This neutrality includes the material and lighting model described in VRML 2.0 specification.

    Inventor, an ancestor of the VRML, lacked such neutrality. Inventor was closely tied to the OpenGL rendering methods, including the OpenGL lighting model.

  • The language is quite popular and many 3D authoring programs can import and export models in this format. Some well-known open-source 3D modeling programs that can export to VRML are Blender and Art Of Illusion. White Dune is a modeller especially oriented towards VRML.

  • The language can describe geometry of 3D objects with all typical properties like materials, textures and normal vectors. More advanced features like multi-texturing, environment cube map texturing, shaders (in GLSL, NVidia Cg, HLSL) are also available in newest version (X3D).

  • The language is not limited to 3D objects. Other important environment properties, like lights, the sky, the fog, viewpoints, collision properties and many other can be expressed. Events mechanism allows to describe animations and user interactions with the scene.

  • The language is easy to extend. You can easily add your own nodes and fields (and I did, see the list of my VRML extensions).

Implementation goals were to make an engine that

  • Uses VRML / X3D. Some other 3D file formats are also supported (like 3DS, MD3, Wavefront OBJ and Collada) by silently converting them to VRML/X3D graph.

  • Allows to make a general-purpose VRML browser. See view3dscene.

  • Allows to make more specialized programs, that use the engine and VRML models as part of their job. For example, a game can use VRML models for various parts of the world:

    • Static environment parts (like the ground and the sky) can be stored and rendered as one VRML model.

    • Each creature, each item, each dynamic object of the world (door that can open, building that can explode etc.) can be stored and rendered as a separate VRML model.

    When rendering, all these VRML objects can be rendered within the same frame, so that user sees the complete world with all objects.

    Example game that uses my engine this way is The Castle.

  • Using the engine should be as easy as possible, but at the same time OpenGL rendering must be as fast as possible. This means that a programmer gets some control over how the engine will optimize given VRML model (or part of it). Different world parts may require entirely different optimization methods:

    • static parts of the scene,

    • parts of the scene that move (or rotate or scale etc.) only relatively to the static parts,

    • parts of the scene that frequently change inside (e.g. a texture changes or creature's arm rotates).

    All details about optimization and animation methods will be given in later chapters (see Chapter 6, OpenGL rendering and Chapter 7, Animation).

  • The primary focus of the engine was always on 3D games, but, as described above, VRML models can be used and combined in various ways. This makes the engine suitable for various 3D simulation programs (oh, and various game types).

  • The engine is free open-source software (licensed on GNU General Public License).

  • Developed in object-oriented language. For me, the language of choice is ObjectPascal, as implemented in the Free Pascal compiler.