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:
- 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.
-
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.
-
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:
- It can export to any format supported by the engine, which means X3D (classic or XML) and STL right now. We plan to support also saving to glTF.
-
Exported file by default is saved as export.x3d
or export.stl
in the data
directory of your project. This is comfortable, just double-click on it to open it in Castle Model Viewer.
-
TCastleScene
is exported (as X3D Inline
node wrapped in the appropriate Transform
node).
-
Transformation hierarchy (TCastleTransform
) is naturally exported as Transform
nodes hierarchy.
-
All the lights. E.g. TCastlePointLight
is exported as X3D PointLight
node.
-
All the primitives: TCastleBox
, TCastleSphere
, TCastleCone
, TCastleCylinder
are exported as X3D Box
, Sphere
, Cone
, Cylinder
nodes.
-
Text is exported (TCastleText
to X3D Text
with FontStyle
).
-
Cameras (TCastleCamera
) are exported as X3D Viewpoint
or OrthoViewpoint
nodes, depending on the projection type.
-
Background (TCastleBackground
) is exported as X3D Background
node.
-
Our navigation components, like TCastleWalkNavigation
and TCastleExamineNavigation
result in an X3D NavigationInfo
node. The X3D node offers a subset of functionality from our engine components.
-
Fog (TCastleFog
) is exported as X3D Fog
node.
-
Tiled maps, that is TCastleTiledMap
, is exported as a collection of X3D nodes that express given map.
-
Terrain (TCastleTerrain
, see our demo examples/terrain) is exported.
-
Images in the viewport (TCastleImageTransform
) are exported.
An additional use-case of this feature is to debug what some engine routines are doing.
Have fun with Castle Game Engine and X3D!