Unit X3DLoad

Classes, Interfaces, Objects and Records
Types

Description

Loading scenes as X3D nodes.

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 model.

Basic guide for adding a new format:

Uses

Overview

Functions and Procedures

function LoadNode(const URL: string; const NilOnUnrecognizedFormat: boolean = false): TX3DRootNode;
function Load3D(const URL: string; const AllowStdIn: boolean = false; const NilOnUnrecognizedFormat: boolean = false): TX3DRootNode; deprecated 'use LoadNode, and note it has one less parameter (AllowStdIn is not implemented anymore)';
function LoadScene_FileFilters: String;
function Load3D_FileFilters: String; deprecated 'use LoadScene_FileFilters';
procedure Load3DSequence( const URL: string; const AllowStdIn: boolean; const KeyNodes: TX3DNodeList; const KeyTimes: TSingleList; out ScenesPerTime: Cardinal; out Epsilon: Single; out TimeLoop, TimeBackwards: boolean); deprecated 'use LoadNode instead of Load3DSequence';
function Load3DSequence_FileFilters: String; deprecated 'use LoadScene_FileFilters, and use LoadNode instead of Load3DSequence';

Constants

SaveX3D_FileFilters = 'All files|*|' + '*X3D XML (*.x3d)|*.x3d|' + 'X3D XML (compressed) (*.x3dz, *.x3d.gz)|*.x3dz;*.x3d.gz|' + 'X3D classic (*.x3dv)|*.x3dv|' + 'X3D classic (compressed) (*.x3dvz, *.x3dv.gz)|*.x3dvz;*.x3dv.gz';
DefaultBakedAnimationSmoothness = 1;

Variables

BakedAnimationSmoothness: Single = DefaultBakedAnimationSmoothness;

Description

Functions and Procedures

function LoadNode(const URL: string; const NilOnUnrecognizedFormat: boolean = false): TX3DRootNode;

Load a scene as X3D node. Guesses scene format based on the URL extension. We load a large number of formats, see https://castle-engine.io/creating_data_model_formats.php .

All the scene formats are loaded as a graph of X3D nodes.

URL is downloaded using the CastleDownload unit, so it supports files, http resources and more. See https://castle-engine.io/manual_network.php about supported URL schemes. 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.

To actually display, animate and do many other things with the loaded model, you usually want to load it to TCastleScene, using the TCastleSceneCore.Load method. Like this:

var
  RootNode: TX3DRootNode;
  Scene: TCastleScene;
begin
  RootNode := LoadNode('my_model.x3d');
  Scene := TCastleScene.Create(Application);
  Scene.Load(RootNode, true);
  // The 2nd parameter of Load says that Scene owns RootNode
end;

Actually, in most cases you don't need to use LoadNode (and this unit, X3DLoad) at all, and you can simply load from an URL:

var
  Scene: TCastleScene;
begin
  Scene := TCastleScene.Create(Application);
  Scene.Load('my_model.x3d');
  // you can access Scene.RootNode after loading, if needed
end;

Note that usually you want to load models from the game data, so you would actually use 'castle-data:/my_model.x3d' URL instead of 'my_model.x3d'.

function Load3D(const URL: string; const AllowStdIn: boolean = false; const NilOnUnrecognizedFormat: boolean = false): TX3DRootNode; deprecated 'use LoadNode, and note it has one less parameter (AllowStdIn is not implemented anymore)';

Warning: this symbol is deprecated: use LoadNode, and note it has one less parameter (AllowStdIn is not implemented anymore)

 
function LoadScene_FileFilters: String;

File filters for files loaded by TCastleSceneCore.Load and LoadNode. Suitable for TFileFilterList.AddFiltersFromString and TCastleWindowBase.FileDialog.

function Load3D_FileFilters: String; deprecated 'use LoadScene_FileFilters';

Warning: this symbol is deprecated: use LoadScene_FileFilters

File filters for files loaded by TCastleSceneCore.Load and LoadNode. Suitable for TFileFilterList.AddFiltersFromString and TCastleWindowBase.FileDialog.

procedure Load3DSequence( const URL: string; const AllowStdIn: boolean; const KeyNodes: TX3DNodeList; const KeyTimes: TSingleList; out ScenesPerTime: Cardinal; out Epsilon: Single; out TimeLoop, TimeBackwards: boolean); deprecated 'use LoadNode instead of Load3DSequence';

Warning: this symbol is deprecated: use LoadNode instead of Load3DSequence

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 LoadNode, adding exactly one item to KeyNodes. So this function handles at least the same model formats as LoadNode.

Additionally, we load castle-anim-frames and MD3 formats to a sequence of frames.

Parameters
KeyNodes
Sequence of root nodes will be stored there. Pass here some created and empty instance of TX3DNodeList.
KeyTimes
Sequence of time values. Pass here some created and empty instance of TSingleList.
function Load3DSequence_FileFilters: String; deprecated 'use LoadScene_FileFilters, and use LoadNode instead of Load3DSequence';

Warning: this symbol is deprecated: use LoadScene_FileFilters, and use LoadNode instead of Load3DSequence

File filters for files loaded by Load3DSequence, suitable for TFileFilterList.AddFiltersFromString and TCastleWindowBase.FileDialog.

Constants

SaveX3D_FileFilters = 'All files|*|' + '*X3D XML (*.x3d)|*.x3d|' + 'X3D XML (compressed) (*.x3dz, *.x3d.gz)|*.x3dz;*.x3d.gz|' + 'X3D classic (*.x3dv)|*.x3dv|' + 'X3D classic (compressed) (*.x3dvz, *.x3dv.gz)|*.x3dvz;*.x3dv.gz';
 
DefaultBakedAnimationSmoothness = 1;
 

Variables

BakedAnimationSmoothness: Single = DefaultBakedAnimationSmoothness;

A smoothness value for "baked" animations loaded from castle-anim-frames files. This is multiplied by the scenes_per_time value recorded in castle-anim-frames file (30 by default), and determines the number of extra frames we add to the baked animation (between key frames).


Generated by PasDoc 0.16.0.