This is an old revision of the document!


Prefabs

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;