Warning: Undefined array key "translationlc" in /usr/www/users/fabook/_diggets/doc/v2/lib/plugins/translation/action.php on line 237

Warning: Cannot modify header information - headers already sent by (output started at /usr/www/users/fabook/_diggets/doc/v2/lib/plugins/translation/action.php:237) in /usr/www/users/fabook/_diggets/doc/v2/inc/Action/Export.php on line 104

Warning: Cannot modify header information - headers already sent by (output started at /usr/www/users/fabook/_diggets/doc/v2/lib/plugins/translation/action.php:237) in /usr/www/users/fabook/_diggets/doc/v2/inc/Action/Export.php on line 104

Warning: Cannot modify header information - headers already sent by (output started at /usr/www/users/fabook/_diggets/doc/v2/lib/plugins/translation/action.php:237) in /usr/www/users/fabook/_diggets/doc/v2/inc/Action/Export.php on line 104
====== Prefabs ====== Prefabs are containers with a number of components and presets. They are comparable to *.fmx files in regular Delphi applications. Prefabs are very helpful on storing and reusing sceneries in projects. You can store complex component hierarchies like in a default FMX formular file (*.fmx). We use the read/write mechanisms for prefabs with some additional functionality. So it is also possible to store complete models with textures and animations. To unify the structure within a prefab, all components are grouped within a parent TGorillaGroup component inside the prefab file. Therefore you need to create a corresponding TGorillaGroup component to load data into. ===== TGorillaPrefabSystem ===== Is a simple management component to prepare prefab loading. You can setup prefabs with their corresponding file location and load them on running the application. var LList : TObjectList; LList := TObjectList.Create(false); try GorillaPrefabSystem1.LoadAllPrefabs(LList); finally FreeAndNil(LList); end; ===== Runtime Usage ===== When projects getting very large, prefabs need to be loaded at runtime. Take a look at the following function on how to do it. uses Gorilla.Prefab, Gorilla.Group, Gorilla.Model; procedure TForm1.FormCreate(Sender: TObject); var LPrefab : TGorillaPrefab; LGroup : TGorillaGroup; LModel : TGorillaModel; begin // create a group, because models inside the prefabs are stored within a group LGroup := TGorillaGroup.Create(GorillaViewport1); LGroup.Parent := GorillaViewport1; // load firemonkey from prefab file by creating a prefab in the prefab-system LPrefab := GorillaPrefabSystem1.AddPrefab('Firemonkey', LGroup, 'C:\Users\Public\Downloads\e6e820751021493fb350d190c279e8aa.prefabz'); // then we load the prefab, which will generate a TGorillaModel instance for us LPrefab.Load(); // afterwards we try to find the instance LModel := LGroup.FindComponentDeepSearchByClass(TGorillaModel) as TGorillaModel; if not Assigned(LModel) then Exit; // at last rotate and scale the model to suit our view LModel.RotationAngle.X := 180; LModel.WrapMode := TMeshWrapMode.Fit; LModel.Scale.Point := Point3D(5, 5, 5); // check if animations are available if not (LModel.AnimationManager.Animations.Count > 0) then Exit; // execute the animation found LModel.AnimationManager.Current.Start; end; ===== Assets Store (Beta) ===== During development process prefabs became very handy and useful. Like in other 3D DevTools (Unity, Unreal, ...) it is common to share those over a platform. We present **[[https://my.gorilla3d.de/prefabs/]]** to you! {{:0.8.3:g3d-assetsstore-web.jpg?nolink&600|}} In our assets store you can download prefabs and integrate them in your application. On downloading a prefab you will receive a *.prefab or a *.prefabz file. Both types can be integrated in the TGorillaPrefabSystem. Have a look at the code snippets above. **WARNING**: Please take care of licensing restrictions before publishing them. **WARNING:** //The assets store is still in beta mode! Errors may occur!// ===== Embedded AssetsStore (Beta) ===== Since 0.8.3.2265 we integrated the assets store also directly in the Delphi IDE. - Drop a TGorillaPrefabSystem component onto your form. - Right-Click on the component in the object inspector - Click "AssetsStore" to open the embedded formular - Browse through the assets and click to directly embed them in your form {{:0.8.3:g3d-assetsstore-ide.jpg?nolink&600|}} **WARNING**: Please take care of licensing restrictions before publishing them. **WARNING: Some prefabs are very large in size or produce large output due to textures or animations. This can exceed your memory in IDE very fast!** **WARNING:** //The assets store is still in beta mode! Errors may occur!// Next step: [[android|Android]]