Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
1.0.0:models [2023/02/23 11:52] – [The Better Loading] admin1.0.0:models [2023/02/28 15:21] (current) – [Sketchfab Import] admin
Line 57: Line 57:
   - All model data will be stored inside the *.fmx file of your form   - All model data will be stored inside the *.fmx file of your form
  
-The IDE will show up a loading window while it's setting up the model.+{{:1.0.0:g3d-ide-loadopts.jpg?nolink|}} 
 + 
 +When the loading options dialog appears you can configure the import process.  
 +But not all options are available for all formats. 
 + 
 +  * Ignore importing animations 
 +  * Animation caching settings 
 +  * Ignore importing lights or cameras 
 +  * Directly import additional animation files without an extra call 
 +  * Limit texture size, in case you have a memory-sensitive application 
 + 
 +Afterwards the IDE will show up a loading window while importing. 
 Because the data + textures are stored in the *.fmx of your form, it can become very large. Because the data + textures are stored in the *.fmx of your form, it can become very large.
 This may slow down the performance of the IDE. This may slow down the performance of the IDE.
  
-**WARNING***: Your IDE memory is limited to 3GB, which can be exceeded very fast due to cached data by the IDE and model data with textures.+**WARNING***: Your IDE memory is limited to 3GB, which can be exceeded very fast due to cached model data with textures.
  
 ==== Using Packages ==== ==== Using Packages ====
Line 85: Line 97:
 The data is not stored again in the formular *.fmx file, it only restores it from package information. The data is not stored again in the formular *.fmx file, it only restores it from package information.
  
-**WARNING***: Your IDE memory is limited to 3GB, which can be exceeded very fast due to cached data by the IDE.+**WARNING***: Your IDE memory is limited to 3GB, which can be exceeded very fast due to cached model data.
  
  
Line 113: Line 125:
  
 __NOTICE:__ Not all models on Sketchfab are fully compatible. The platform automatically converts models to glTF format, which sometimes destroys the model data. __NOTICE:__ Not all models on Sketchfab are fully compatible. The platform automatically converts models to glTF format, which sometimes destroys the model data.
 +
 +
 +<WRAP center round alert 60%>
 +**WARNING**: (2023-02-28) Due to some security issues we had to disable the Sketchfab plugin. We are sorry and we will try to fix the problem with the next update.
 +</WRAP>
 ===== Runtime ===== ===== Runtime =====
  
Line 325: Line 342:
 To adopt the behaviour used in the IDE at design time, you can load model data from assets package To adopt the behaviour used in the IDE at design time, you can load model data from assets package
 also at runtime by the following method. also at runtime by the following method.
 +
 +__NOTICE:__ This will trigger design time dialogs on loading data. If you don't want that dialogs to appear, please use LoadNewModelFromFile() or LoadFromFile().
  
 <file pascal Form1.pas> <file pascal Form1.pas>
Line 455: Line 474:
 ==== TGorillaModel ==== ==== TGorillaModel ====
  
-A TGorillaModel is the head component for loaded models from file/asset. Even it's inherited from TGorillaMesh, it's not renderable. Instead it is just a container, managing+A TGorillaModel is the "headcomponent for loaded models from file, stream or asset. Even it's inherited from TGorillaMesh, it's not renderable. Instead it is just a container, managing
 sub-meshes, animations and materials. So a TGorillaModel needs to contain at least one TGorillaMesh in it's Meshes list. sub-meshes, animations and materials. So a TGorillaModel needs to contain at least one TGorillaMesh in it's Meshes list.
  
Line 530: Line 549:
  
  
-===== Instancing / Model duplication =====+===== Instancing / Cloning =====
  
 ==== Instanced Rendering ==== ==== Instanced Rendering ====
Line 538: Line 557:
 Use this method to render for example grass or trees. It is not recommended to use it for animated charaters, Use this method to render for example grass or trees. It is not recommended to use it for animated charaters,
 because they would be rendered the same (with the same animation frame). because they would be rendered the same (with the same animation frame).
- 
-You can simply setup instanced rendering in your TGorillaModel or TGorillaMesh object. 
  
 {{youtube>WoJXVVjRHO0?large}} {{youtube>WoJXVVjRHO0?large}}
 +
 +
 +
 +=== At DesignTime ===
 +
 +We offer a collection property called "Instances" in the TGorillaModel/TGorillaMesh component.
 +
 +You can simply add instances at design time with their transformation information.
 +
 +__NOTICE:__ The transformation information (position, rotation and scale) is absolute and not depending on the owner mesh.
 +
 +
 +=== At Runtime ===
 +
 +For better usability TGorillaMesh/TGorillaModel components provide the collection property "Instances".
 +Internally it will be cached in buffer for fast GPU transmission.
 +
 +This brings new opportunities, especially for instancing a very large number, f.e. you don't want to setup a single TCollectionItem to render 100.000 grass blades.
 +
 +In that case you want to ignore the collection and simply add those instances to the buffer. Therefore please use the AddInstance() method
 +
 +<file pascal>
 +function AddInstance(const ATransform : TMatrix3D; const ACreateItem : Boolean;
 +        AName : String = '') : Integer;
 +</file>
  
 <file pascal> <file pascal>
 /// we create 4 instances in a row /// we create 4 instances in a row
-GorillaModel1.AddInstance(TMatrix3D.CreateTranslation(Point3D(-10, 0, 0))); +GorillaModel1.AddInstance(TMatrix3D.CreateTranslation(Point3D(-10, 0, 0)), false); 
-GorillaModel1.AddInstance(TMatrix3D.CreateTranslation(Point3D(-5, 0, 0))); +GorillaModel1.AddInstance(TMatrix3D.CreateTranslation(Point3D(-5, 0, 0)), false); 
-GorillaModel1.AddInstance(TMatrix3D.CreateTranslation(Point3D(5, 0, 0))); +GorillaModel1.AddInstance(TMatrix3D.CreateTranslation(Point3D(5, 0, 0)), false); 
-GorillaModel1.AddInstance(TMatrix3D.CreateTranslation(Point3D(10, 0, 0)));+GorillaModel1.AddInstance(TMatrix3D.CreateTranslation(Point3D(10, 0, 0)), false);
  
 /// afterwards we can modify a specific instance /// afterwards we can modify a specific instance
Line 559: Line 601:
 </file> </file>
  
 +__WARNING:__ Only use one of the functionalities: Collection / Buffering. When adding collection items again, the instance buffer will be refreshed and previously added instances will be cleared.
 +==== Cloning ====
 +
 +Instancing can be done by GPU and providing different transformation matrices like above or by cloning the visual component with all of it's data.
 +Both ways have their advantages and disadvantages.
  
-==== Instancing by template (TModelDef====+  * Use instancing if you want to re-render a mesh multiple times 
 +  * Use cloning if you need different visual feedback (like animations or materials), but if you want to reuse the vertex data itself
  
-Since 0.8.3.1966+ we've refactored the way to instanciate models. The previous method was incomplete in handling animated models. 
 In the following example we show how to load a complex animated model with multiple meshes and animations. In the following example we show how to load a complex animated model with multiple meshes and animations.
 We will load up a template (TModelDef), which will be used for duplication. The template (TModelDef) itself will not be rendered in our example, but of course that's possible too. We will load up a template (TModelDef), which will be used for duplication. The template (TModelDef) itself will not be rendered in our example, but of course that's possible too.
Line 636: Line 683:
 end; end;
 </file> </file>
-===== Plugins ===== 
-