Export 3D or 2D world designed in Castle Game Engine editor to X3D or STL

export_to_x3d_stl

This is a cool new feature that allows you to use our editor in a bit non-standard way. Use the new menu item “Data -> Export Viewport to X3D, STL” to export the contents of the TCastleViewport to X3D or STL file.

To be clear, the main purpose of our editor remains to save the design to a Castle Game Engine-specific format (*.castle-user-interface, which is a JSON serialization of engine components, that can be later read back using CastleComponentSerialize routines). But this new feature allows to use our editor for other purposes. You can design a 3D or 2D world, export it to X3D or STL, and use it with a plethora of other 3D software. For example, you can:

  • Open the X3D file in other X3D viewers, including viewers that can render X3D in a browser. Here’s a non-exhaustive list of software that can “consume” X3D files:
  • Import the resulting X3D or STL files into other 3D software, like Blender.

Try it out! Just download the engine, create a new project (or open one of the examples) and use “Data -> Export Viewport to X3D, STL” to see what happens. Try out the new project template like “3D FPS Game”. Add there more engine components (see our documentation and in particular overview of components useful in the viewport) and have fun 🙂

In case of X3D, remember that:

  1. The resulting file will refer to the resources (like models loaded in TCastleScene or textures) using relative paths. So you should keep the directory structure of the exported files intact, or adjust the paths in the X3D file manually.

  2. The exported X3D files may use some X3D extensions, specific to our engine. You can just remove them as necessary to make the models compatible with other X3D browsers.

  3. While you can load the resulting X3D back inside the engine editor, this will be just a single component TCastleScene, not all the components you exported. Solution: If you want to use CGE editor for authoring X3D or other model formats, just keep the original CGE editor files (.castle-user-interface) around, as the “source” version of your 3D / 2D world and export it to X3D as many times as you wish.

All the features supported by the export are listed below:

An additional use-case of this feature is to debug what some engine routines are doing.

  • While in some cases we create X3D nodes during the export (e.g. for viewpoints and navigation info, in which case we have somewhat similar but far from identical functionality offered by our components like TCastleCamera and TCastleWalkNavigation)…

  • …but in other cases the export just “reveals” the actual nodes used to to render given things (this is the case with e.g. lights, primitives, fog and background).

Have fun with Castle Game Engine and X3D!