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:
- X_ITE that can render X3D in a web browser,
- X3DOM, again able to render X3D in a web browser,
- FreeWRL,
- Our Castle Model Viewer,
- Our Castle Model Viewer Mobile,
- see X3D Resources for more tools. Many of them are free and/or open-source.
- 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
orexport.stl
in thedata
directory of your project. This is comfortable, just double-click on it to open it in Castle Model Viewer. -
TCastleScene
is exported (as X3DInline
node wrapped in the appropriateTransform
node). -
Transformation hierarchy (
TCastleTransform
) is naturally exported asTransform
nodes hierarchy. -
All the lights. E.g.
TCastlePointLight
is exported as X3DPointLight
node. -
All the primitives:
TCastleBox
,TCastleSphere
,TCastleCone
,TCastleCylinder
are exported as X3DBox
,Sphere
,Cone
,Cylinder
nodes. -
Text is exported (
TCastleText
to X3DText
withFontStyle
). -
Cameras (
TCastleCamera
) are exported as X3DViewpoint
orOrthoViewpoint
nodes, depending on the projection type. -
Background (
TCastleBackground
) is exported as X3DBackground
node. -
Our navigation components, like
TCastleWalkNavigation
andTCastleExamineNavigation
result in an X3DNavigationInfo
node. The X3D node offers a subset of functionality from our engine components. -
Fog (
TCastleFog
) is exported as X3DFog
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.
- 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
andTCastleWalkNavigation
)… -
…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!
Start the discussion at Castle Game Engine Forum