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);
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');
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' .
|