unit Frost.Scenes;

interface

uses
  Frost.Forms,
  Frost.RenderEngine,
  Frost.GameObjects,
//  Frost.Particles,
  Frost.Renderers;

type
TScene = class
    private
      FCamera: TCamera;
      FObjectTree: TObjectTree;
      FRenderEngine: TRenderEngine;
//      FParticleEngine: TParticleRendererLayer;
    protected
      property MainCamera: TCamera read FCamera;
    public
      constructor Create;
      destructor Destroy; override;
      procedure Awake;
      procedure OnSceneUpdate(delta: Double);
      procedure OnStart;  virtual;
      procedure OnUpdate(delta: Double); virtual;
      procedure OnDestroy;virtual;
  end;

implementation

{$REGION 'TScene'}
constructor TScene.Create;
begin

end;

procedure TScene.Awake;
var
  CameraController: TGameObject;
begin
  FObjectTree := TObjectTree.Create;

  CameraController := TGameObject.Create(nil);
  CameraController.Name := 'MainCamera';
  FCamera := TCamera.Create(CameraController);
  FRenderEngine := TRenderEngine.Create(FCamera);  

  FRenderEngine.AddLayer(TMeshRendererLayer.Create);
//  FParticleEngine := TParticleRendererLayer.Create;
//  FRenderEngine.AddLayer(FParticleEngine);

  OnStart;
end;

procedure TScene.OnSceneUpdate(Delta: Double);
begin                   
  OnUpdate(delta);
  FObjectTree.Update(Delta);
//  FParticleEngine.UpdateParticles(Delta, FCamera);
  FRenderEngine.Render;   
end;

procedure TScene.OnStart;
begin

end;

procedure TScene.OnUpdate;
begin

end;

procedure TScene.OnDestroy;
begin

end;

destructor TScene.Destroy;
begin
  FObjectTree.Free;
  inherited;
end;
{$ENDREGION}

end.
