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
Next revisionBoth sides next revision
0.8.4:cameras [2022/07/20 14:33] – [Smooth Camera Controller] admin0.8.4:cameras [2022/07/20 14:37] – [Creating a Smooth Controller at Runtime] admin
Line 178: Line 178:
  
 ^Function^ ^Function^
-|function GetDesignCamera() : TCamera; virtual;| +|function GetDesignCamera() : TCamera;| 
-|function GetDesignCameraController() : TGorillaSmoothCameraController; virtual;|+|function GetDesignCameraController() : TGorillaSmoothCameraController;|
  
 ==== Creating a Smooth Controller at Runtime ==== ==== Creating a Smooth Controller at Runtime ====
Line 190: Line 190:
  
 In the following code snippet we modify rotation manually in user-specific mouse events. In the following code snippet we modify rotation manually in user-specific mouse events.
 +We're also blocking shifting, because we only want to rotate the camera.
  
 <file pascal> <file pascal>
Line 223: Line 224:
   GorillaViewport1.OnMouseMove := DoOnViewportMouseMove;   GorillaViewport1.OnMouseMove := DoOnViewportMouseMove;
      
 +  /// Create a smooth camera controller
   FCameraCtrl := TGorillaSmoothCameraController.Create(GorillaViewport1);   FCameraCtrl := TGorillaSmoothCameraController.Create(GorillaViewport1);
   FCameraCtrl.Parent := GorillaViewport;   FCameraCtrl.Parent := GorillaViewport;
-  FCameraCtrl.Types := [];+   
 +  /// NOTICE: Enable only rotation. Disable zooming and shifting 
 +  FCameraCtrl.Types := [TGorillaSmoothCameraControlType.scctRotateY, TGorillaSmoothCameraControlType.scctMoveY];
  
 +  /// Create our own camera for this controller
   FMyCamera := TGorillaCamera.Create(FCameraCtrl);   FMyCamera := TGorillaCamera.Create(FCameraCtrl);
   FMyCamera.Parent := FCameraCtrl;   FMyCamera.Parent := FCameraCtrl;
  
 +  /// Link the camera to the controller
   FCameraCtrl.Camera := FMyCamera;   FCameraCtrl.Camera := FMyCamera;
 +  
 +  /// Activate the camera for rendering
 +  GorillaViewport1.Camera := FMyCamera;
 +  GorillaViewport1.UsingDesignCamera := FALSE;
      
   [...]   [...]