Close up shadows on the tree. Notice that leaves (modeled by alpha-test texture) also cast correct shadows.
Water reflections by optimized GeneratedCubeMapTexture
Mirrors by RenderedTexture, by Victor Amat

Scene graph (X3D)


1. What is X3D

X3D (and it's older version, VRML) is a file format for 3D models. Various 3D modeling applications can export to it, for example Blender includes an X3D exporter (see also our Blender exporting notes).

To try it out, just create some X3D models (or download them from the Internet, or grab our demo models) and open them with our view3dscene.

As a 3D file format, X3D is quite unique, as

Note that our engine supports many other 3D and 2D file formats too, like glTF, Collada, Wavefront OBJ, Spine JSON... They are all loaded into a graph of X3D nodes. So X3D is our scene graph, but it's absolutely not the only file format that we support.

Learning X3D: Use this part of the documentation to learn about the available X3D nodes and their fields.

2. X3D in Pascal

When we say that "X3D is our scene graph", what it means in practice is that you have a graph of X3D nodes inside the RootNode property of any TCastleScene instance. The TCastleScene is our central class to render and animate 3D and 2D content, see the manual about TCastleScene.

This way you can edit (or even build from scratch) a graph of X3D nodes using Pascal, to create any content you like. You are not limited to only loading the content from X3D files (or Collada, or Wavefront OBJ...).

For example, consider an X3D node Box (API reference) (this is a link to the X3D specification about it). This node in X3D has fields size (the X3D type is SFVec3f) and solid (the X3D type is SFBool). In Pascal, this node corresponds to the class TBoxNode, with properties Size (type TVector3) and Solid (type Boolean). You can create and edit instances of TBoxNode and use TCastleScene to render them.

This section of the Castle Game Engine documentation describes all X3D nodes (often by referring you to the X3D specification for details), and it shows various examples how to create and edit X3D graph using Pascal. See for example:

You can also pre-process the loaded scene (e.g. change the texture), by changing the X3D nodes graph (see this forum post for details).