Castle Game EngineIntroduction Units Class Hierarchy Classes, Interfaces, Objects and Records Types Variables Constants Functions and Procedures Identifiers |
Unit X3DLoad
Description
Loading 3D models as X3D.
Every format except VRML/X3D is handled by converting it into X3D nodes graph. This allows to use our great X3D renderer, tools, saving to X3D and such, on every 3D model.
Basic guide for adding a new 3D format:
Particular formats are implemented inside various X3DLoadInternalXxx units. Implementation of this unit calls them. In the future, a mechanism that allows you to "register" an importer, without modifying this unit's implementation, may be done — report if needed.
3D formats are also listed in the file filters constants: see Load3D_FileFilters and Load3DSequence_FileFilters. Each format has a file filter to specifically choose this format, and also is added to the "All 3D models" filter.
Enable view3dscene to associate with this file format on freedesktops (GNOME, and other following freedesktop.org specs). For this,
1. Update view3dscene MIME database. Simply add appopriate element to ../../../view3dscene/desktop/view3dscene.xml. Format of that MIME xml file is self-explanatory. It's good idea to google first to search for standard MIME type for your model format (e.g. wikipedia shows mime types for formats). If none is found, just use application/x-???, where ??? is some short name for your format.
2. After adding to MIME database, you want to also add format to ../../../view3dscene/desktop/view3dscene.desktop, to indicate that view3dscene handles this MIME type.
3. Finally, also add this to ../../../view3dscene/desktop/install_thumbnailer.sh, so that GNOME nautilus thumbnailers for this MIME types can be installed.
You probably also want to extend documentation. At least view3dscene.php, it has a "Features" section that lists all supported 3D formats.
Uses
Overview
Functions and Procedures
function Load3D(const URL: string; AllowStdIn: boolean = false; NilOnUnrecognizedFormat: boolean = false): TX3DRootNode; |
procedure Load3DSequence( const URL: string; AllowStdIn: boolean; RootNodes: TX3DNodeList; Times: TSingleList; out ScenesPerTime: Cardinal; out EqualityEpsilon: Single; out TimeLoop, TimeBackwards: boolean); |
Constants
Load3D_FileFilters =
'All Files|*|' +
'*All 3D models|*.wrl;*.wrl.gz;*.wrz;*.x3d;*.x3dz;*.x3d.gz;*.x3dv;*.x3dvz;*.x3dv.gz;*.dae;*.iv;*.3ds;*.md3;*.obj;*.geo|' +
'VRML (*.wrl, *.wrl.gz, *.wrz)|*.wrl;*.wrl.gz;*.wrz|' +
'X3D XML (*.x3d, *.x3dz, *.x3d.gz)|*.x3d;*.x3dz;*.x3d.gz|' +
'X3D classic (*.x3dv, *.x3dvz, *.x3dv.gz)|*.x3dv;*.x3dvz;*.x3dv.gz|' +
'Collada (*.dae)|*.dae|' +
'Inventor (*.iv)|*.iv|' +
'3D Studio (*.3ds)|*.3ds|' +
'Quake 3 engine models (*.md3)|*.md3|' +
'Wavefront (*.obj)|*.obj|' +
'Videoscape (*.geo)|*.geo'; |
Load3DSequence_FileFilters =
'All Files|*|' +
'*All 3D models|*.wrl;*.wrl.gz;*.wrz;*.x3d;*.x3dz;*.x3d.gz;*.x3dv;*.x3dvz;*.x3dv.gz;*.kanim;*.dae;*.iv;*.3ds;*.md3;*.obj;*.geo|' +
'VRML (*.wrl, *.wrl.gz, *.wrz)|*.wrl;*.wrl.gz;*.wrz|' +
'X3D XML (*.x3d, *.x3dz, *.x3d.gz)|*.x3d;*.x3dz;*.x3d.gz|' +
'X3D classic (*.x3dv, *.x3dvz, *.x3dv.gz)|*.x3dv;*.x3dvz;*.x3dv.gz|' +
'Castle Game Engine animations (*.kanim)|*.kanim|' +
'Collada (*.dae)|*.dae|' +
'Inventor (*.iv)|*.iv|' +
'3D Studio (*.3ds)|*.3ds|' +
'Quake 3 engine models (*.md3)|*.md3|' +
'Wavefront (*.obj)|*.obj|' +
'Videoscape (*.geo)|*.geo'; |
Description
Functions and Procedures
function Load3D(const URL: string; AllowStdIn: boolean = false; NilOnUnrecognizedFormat: boolean = false): TX3DRootNode; |
Load 3D model. Guess model format based on URL extension. VRML/X3D formats are loaded directly, other model formats are converted under the hood to VRML/X3D.
URL is downloaded using CastleDownload unit. If you all you care about is loading normal files, then just pass a normal filename (absolute or relative to the current directory) as the URL parameter.
Parameters
- AllowStdIn
- If AllowStdIn and URL = '-' then it will load a VRML/X3D file from StdInStream (using current working directory as BaseUrl).
|
procedure Load3DSequence( const URL: string; AllowStdIn: boolean; RootNodes: TX3DNodeList; Times: TSingleList; out ScenesPerTime: Cardinal; out EqualityEpsilon: Single; out TimeLoop, TimeBackwards: boolean); |
Load various model formats as animation expressed by VRML/X3D sequence.
For model formats that cannot express animations (like GEO or Wavefront OBJ) or that express animations in a single file (like VRML/X3D >= 2.0) we load them exactly like Load3D, adding exactly one item to RootNodes. So this function handles at least the same model formats as Load3D.
Additionally:
We load kanim format. It can only be loaded to a sequence of files, so Load3D cannot deal with it at all.
We load MD3 format in a little different (usually more efficient) way: to a sequence of frames. In comparison, Load3D loads MD3 into an interpolated animation.
Parameters
- RootNodes
- Sequence of root nodes will be stored there. Pass here some created and empty instance of TX3DNodeList.
- ATimes
- Sequence of time values. Pass here some created and empty instance of TSingleList.
|
Constants
Load3D_FileFilters =
'All Files|*|' +
'*All 3D models|*.wrl;*.wrl.gz;*.wrz;*.x3d;*.x3dz;*.x3d.gz;*.x3dv;*.x3dvz;*.x3dv.gz;*.dae;*.iv;*.3ds;*.md3;*.obj;*.geo|' +
'VRML (*.wrl, *.wrl.gz, *.wrz)|*.wrl;*.wrl.gz;*.wrz|' +
'X3D XML (*.x3d, *.x3dz, *.x3d.gz)|*.x3d;*.x3dz;*.x3d.gz|' +
'X3D classic (*.x3dv, *.x3dvz, *.x3dv.gz)|*.x3dv;*.x3dvz;*.x3dv.gz|' +
'Collada (*.dae)|*.dae|' +
'Inventor (*.iv)|*.iv|' +
'3D Studio (*.3ds)|*.3ds|' +
'Quake 3 engine models (*.md3)|*.md3|' +
'Wavefront (*.obj)|*.obj|' +
'Videoscape (*.geo)|*.geo'; |
File filters for files loaded by Load3D, suitable for TFileFilterList.AddFiltersFromString and TCastleWindowCustom.FileDialog.
|
Load3DSequence_FileFilters =
'All Files|*|' +
'*All 3D models|*.wrl;*.wrl.gz;*.wrz;*.x3d;*.x3dz;*.x3d.gz;*.x3dv;*.x3dvz;*.x3dv.gz;*.kanim;*.dae;*.iv;*.3ds;*.md3;*.obj;*.geo|' +
'VRML (*.wrl, *.wrl.gz, *.wrz)|*.wrl;*.wrl.gz;*.wrz|' +
'X3D XML (*.x3d, *.x3dz, *.x3d.gz)|*.x3d;*.x3dz;*.x3d.gz|' +
'X3D classic (*.x3dv, *.x3dvz, *.x3dv.gz)|*.x3dv;*.x3dvz;*.x3dv.gz|' +
'Castle Game Engine animations (*.kanim)|*.kanim|' +
'Collada (*.dae)|*.dae|' +
'Inventor (*.iv)|*.iv|' +
'3D Studio (*.3ds)|*.3ds|' +
'Quake 3 engine models (*.md3)|*.md3|' +
'Wavefront (*.obj)|*.obj|' +
'Videoscape (*.geo)|*.geo'; |
File filters for files loaded by Load3DSequence, suitable for TFileFilterList.AddFiltersFromString and TCastleWindowCustom.FileDialog.
|
Generated by PasDoc 0.13.0 on 2014-10-26 05:15:16
|