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. You will find that virtually any 3D modeling program 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 Collada, Wavefront OBJ, Spine JSON, and (soon) glTF. 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, that has fields size (type SFVec3f) and solid (type SFBool). In Pascal, this nodes 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 is 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 Pascal example of creating a 3D mesh (TIndexedFaceSetNode), Pascal example of seting up 2D rectangle and lines.