Browse Source

Fixed paths in skeletal demos

GLScene 2 years ago
parent
commit
6f541abef1

+ 1 - 0
Demos/meshes/skeletal/fSkeletalC.cpp

@@ -29,6 +29,7 @@ __fastcall TForm1::TForm1(TComponent* Owner)
 void __fastcall TForm1::FormCreate(TObject *Sender)
 {
    TFileName Path = GetCurrentAssetPath();
+	SetCurrentDir(Path + "\\modelext");
    // We load the SMD model here
    // Note the actor was linked to a material library, and textures are loaded
    // automatically (4 textures are used by this model)

+ 0 - 2
Demos/meshes/skeletal/fSkeletalC.dfm

@@ -10,10 +10,8 @@ object Form1: TForm1
   Font.Height = -11
   Font.Name = 'Tahoma'
   Font.Style = []
-  OldCreateOrder = False
   OnCreate = FormCreate
   OnMouseWheel = FormMouseWheel
-  PixelsPerInch = 96
   TextHeight = 13
   object GLSceneViewer1: TGLSceneViewer
     Left = 0

+ 21 - 13
Demos/meshes/skeletal/fSkeletalD.dfm

@@ -2,8 +2,8 @@ object FormSkeletal: TFormSkeletal
   Left = 237
   Top = 105
   Caption = 'Skeletal Animation'
-  ClientHeight = 401
-  ClientWidth = 515
+  ClientHeight = 467
+  ClientWidth = 629
   Color = clBtnFace
   Font.Charset = DEFAULT_CHARSET
   Font.Color = clWindowText
@@ -17,23 +17,25 @@ object FormSkeletal: TFormSkeletal
   object GLSceneViewer1: TGLSceneViewer
     Left = 0
     Top = 0
-    Width = 408
-    Height = 360
+    Width = 522
+    Height = 426
     Camera = GLCamera1
     Buffer.BackgroundColor = clSilver
     Buffer.Lighting = False
-    FieldOfView = 148.951782226562500000
+    FieldOfView = 153.578933715820300000
     PenAsTouch = False
     Align = alClient
     OnMouseDown = GLSceneViewer1MouseDown
     OnMouseMove = GLSceneViewer1MouseMove
     TabOrder = 0
+    ExplicitWidth = 468
+    ExplicitHeight = 397
   end
   object Panel1: TPanel
-    Left = 408
+    Left = 522
     Top = 0
     Width = 107
-    Height = 360
+    Height = 426
     Align = alRight
     BevelOuter = bvNone
     Font.Charset = ANSI_CHARSET
@@ -43,12 +45,14 @@ object FormSkeletal: TFormSkeletal
     Font.Style = []
     ParentFont = False
     TabOrder = 1
+    ExplicitLeft = 408
+    ExplicitHeight = 360
     DesignSize = (
       107
-      360)
+      426)
     object LabelFPS: TLabel
       Left = 32
-      Top = 24
+      Top = 30
       Width = 26
       Height = 16
       Alignment = taCenter
@@ -60,6 +64,7 @@ object FormSkeletal: TFormSkeletal
       Font.Name = 'Arial'
       Font.Style = []
       ParentFont = False
+      ExplicitTop = 24
     end
     object BULongJump: TButton
       Left = 16
@@ -113,19 +118,21 @@ object FormSkeletal: TFormSkeletal
   end
   object Panel2: TPanel
     Left = 0
-    Top = 360
-    Width = 515
+    Top = 426
+    Width = 629
     Height = 41
     Align = alBottom
     BevelOuter = bvNone
     TabOrder = 2
+    ExplicitTop = 360
+    ExplicitWidth = 515
     DesignSize = (
-      515
+      629
       41)
     object TrackBar1: TTrackBar
       Left = 64
       Top = 0
-      Width = 451
+      Width = 565
       Height = 34
       Anchors = [akLeft, akTop, akRight, akBottom]
       Max = 100
@@ -133,6 +140,7 @@ object FormSkeletal: TFormSkeletal
       TabOrder = 0
       TickMarks = tmBoth
       OnChange = TrackBar1Change
+      ExplicitWidth = 451
     end
     object CBBlend: TCheckBox
       Left = 8

+ 80 - 80
Demos/meshes/skeletal/fSkeletalD.pas

@@ -23,7 +23,7 @@ uses
   GLS.SceneViewer,
   GLS.Graph,
   GLS.FileSMD,
- 
+
   GLS.Material,
   GLS.Coordinates,
   GLS.BaseClasses,
@@ -54,29 +54,25 @@ type
     TrackBar1: TTrackBar;
     CBBlend: TCheckBox;
     procedure FormCreate(Sender: TObject);
-    procedure GLSceneViewer1MouseMove(Sender: TObject; Shift: TShiftState;
+    procedure GLSceneViewer1MouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
+    procedure GLSceneViewer1MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState;
       X, Y: Integer);
-    procedure GLSceneViewer1MouseDown(Sender: TObject;
-      Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
     procedure Timer1Timer(Sender: TObject);
     procedure BULongJumpClick(Sender: TObject);
     procedure CheckBox1Click(Sender: TObject);
-    procedure GLCadencer1Progress(Sender: TObject; const deltaTime,
-      newTime: Double);
+    procedure GLCadencer1Progress(Sender: TObject; const deltaTime, newTime: Double);
     procedure Actor1EndFrameReached(Sender: TObject);
     procedure BUHighJumpClick(Sender: TObject);
     procedure RBWalkClick(Sender: TObject);
     procedure RBRunClick(Sender: TObject);
     procedure TrackBar1Change(Sender: TObject);
     procedure CBBlendClick(Sender: TObject);
-    procedure FormMouseWheel(Sender: TObject; Shift: TShiftState;
-      WheelDelta: Integer; MousePos: TPoint; var Handled: Boolean);
+    procedure FormMouseWheel(Sender: TObject; Shift: TShiftState; WheelDelta: Integer;
+      MousePos: TPoint; var Handled: Boolean);
   private
-     
   public
-     
-    baseAnimation : String;
-    mx, my : Integer;
+    baseAnimation: String;
+    mx, my: Integer;
   end;
 
 var
@@ -88,39 +84,39 @@ implementation
 
 procedure TFormSkeletal.FormCreate(Sender: TObject);
 begin
-   var Path: TFileName := GetCurrentAssetPath();
-   SetCurrentDir(Path  + '\model');
-   // We load the SMD model here
-   // Note the actor was linked to a material library, and textures are loaded
-   // automatically (4 textures are used by this model)
-   //
-   // Kind thanks to ~A.u.s.t.i.n. & Neal 'Guplik' Corbett for the model
-   // and allowing its use ;)
-   Actor1.LoadFromFile('trinityRage.smd');
-   // Now we load the walk & run animations and "fix" their translation
-   // (HL walk/run animations have a built-in "slide" that we don't want here)
-   Actor1.AddDataFromFile('walk.smd');
-   Actor1.Animations[1].MakeSkeletalTranslationStatic;
-   Actor1.AddDataFromFile('run.smd');
-   Actor1.Animations[2].MakeSkeletalTranslationStatic;
-   // Then load the two jumps
-   Actor1.AddDataFromFile('long_jump.smd');
-   Actor1.AddDataFromFile('jump.smd');
-   // And the 'look_left_right' blending animations, that we immediately
-   // assign to the controler. The MakeSkeletalRotationDelta removes absolute
-   // information from the SMD (which HL may use, but GLScene doesn't)
-   Actor1.AddDataFromFile('look_left_right.smd');
-   Actor1.Animations[5].MakeSkeletalRotationDelta;
-   AnimationControler1.AnimationName:='look_left_right';
-   // Skeleton visible, and start with walk animation
-   // (pseudo-animation 0 is for the static model in its default attitude)
-   Actor1.OverlaySkeleton:=True;
-   baseAnimation:='walk';
-   Actor1.SwitchToAnimation(baseAnimation);
+  var Path: TFileName := GetCurrentAssetPath();
+  SetCurrentDir(Path + '\modelext');
+  // We load the SMD model here
+  // Note the actor was linked to a material library, and textures are loaded
+  // automatically (4 textures are used by this model)
+  //
+  // Kind thanks to ~A.u.s.t.i.n. & Neal 'Guplik' Corbett for the model
+  // and allowing its use ;)
+  Actor1.LoadFromFile('trinityRage.smd');
+  // Now we load the walk & run animations and "fix" their translation
+  // (HL walk/run animations have a built-in "slide" that we don't want here)
+  Actor1.AddDataFromFile('walk.smd');
+  Actor1.Animations[1].MakeSkeletalTranslationStatic;
+  Actor1.AddDataFromFile('run.smd');
+  Actor1.Animations[2].MakeSkeletalTranslationStatic;
+  // Then load the two jumps
+  Actor1.AddDataFromFile('long_jump.smd');
+  Actor1.AddDataFromFile('jump.smd');
+  // And the 'look_left_right' blending animations, that we immediately
+  // assign to the controler. The MakeSkeletalRotationDelta removes absolute
+  // information from the SMD (which HL may use, but GLScene doesn't)
+  Actor1.AddDataFromFile('look_left_right.smd');
+  Actor1.Animations[5].MakeSkeletalRotationDelta;
+  AnimationControler1.AnimationName := 'look_left_right';
+  // Skeleton visible, and start with walk animation
+  // (pseudo-animation 0 is for the static model in its default attitude)
+  Actor1.OverlaySkeleton := True;
+  baseAnimation := 'walk';
+  Actor1.SwitchToAnimation(baseAnimation);
 end;
 
-procedure TFormSkeletal.FormMouseWheel(Sender: TObject; Shift: TShiftState;
-  WheelDelta: Integer; MousePos: TPoint; var Handled: Boolean);
+procedure TFormSkeletal.FormMouseWheel(Sender: TObject; Shift: TShiftState; WheelDelta: Integer;
+  MousePos: TPoint; var Handled: Boolean);
 begin
   GLCamera1 := GLSceneViewer1.Camera;
   GLCamera1.AdjustDistanceToTarget(Power(1.1, WheelDelta / 120));
@@ -128,86 +124,90 @@ end;
 
 procedure TFormSkeletal.RBWalkClick(Sender: TObject);
 begin
-   // user requested 'walk'
-   baseAnimation:='walk';
-   Actor1.SwitchToAnimation(baseAnimation, True);
+  // user requested 'walk'
+  baseAnimation := 'walk';
+  Actor1.SwitchToAnimation(baseAnimation, True);
 end;
 
 procedure TFormSkeletal.RBRunClick(Sender: TObject);
 begin
-   // user requested 'run'
-   baseAnimation:='run';
-   Actor1.SwitchToAnimation(baseAnimation, True);
+  // user requested 'run'
+  baseAnimation := 'run';
+  Actor1.SwitchToAnimation(baseAnimation, True);
 end;
 
 procedure TFormSkeletal.BULongJumpClick(Sender: TObject);
 begin
-   // Smoothly switch to Long Jump
-   Actor1.SwitchToAnimation(3, True);
+  // Smoothly switch to Long Jump
+  Actor1.SwitchToAnimation(3, True);
 end;
 
 procedure TFormSkeletal.BUHighJumpClick(Sender: TObject);
 begin
-   // Smoothly switch to High Jump
-   Actor1.SwitchToAnimation(4, True);
+  // Smoothly switch to High Jump
+  Actor1.SwitchToAnimation(4, True);
 end;
 
 procedure TFormSkeletal.Actor1EndFrameReached(Sender: TObject);
 begin
-   // If we weren't walking, switch back to walk
-   if Actor1.CurrentAnimation<>baseAnimation then
-      Actor1.SwitchToAnimation(baseAnimation, True);
+  // If we weren't walking, switch back to walk
+  if Actor1.CurrentAnimation <> baseAnimation then
+    Actor1.SwitchToAnimation(baseAnimation, True);
 end;
 
 procedure TFormSkeletal.CBBlendClick(Sender: TObject);
 begin
-   // Enable/disable blending by binding or unbinding the animation controler
-   // to the actor 
-   if CBBlend.Checked then begin
-      AnimationControler1.Actor:=Actor1;
-      TrackBar1Change(Self);
-   end else AnimationControler1.Actor:=nil;
+  // Enable/disable blending by binding or unbinding the animation controler
+  // to the actor
+  if CBBlend.Checked then
+  begin
+    AnimationControler1.Actor := Actor1;
+    TrackBar1Change(Self);
+  end
+  else
+    AnimationControler1.Actor := nil;
 end;
 
 procedure TFormSkeletal.TrackBar1Change(Sender: TObject);
 begin
-   // Blending along the controler's animation is just a matter of adjusting
-   // the ratio, with 0 = first frame and 1 = last frame.
-   AnimationControler1.Ratio:=TrackBar1.Position*0.01;
+  // Blending along the controler's animation is just a matter of adjusting
+  // the ratio, with 0 = first frame and 1 = last frame.
+  AnimationControler1.Ratio := TrackBar1.Position * 0.01;
 end;
 
 // Nothing fancy below, just the same old stuff
 
 procedure TFormSkeletal.CheckBox1Click(Sender: TObject);
 begin
-   Actor1.OverlaySkeleton:=CheckBox1.Checked;
+  Actor1.OverlaySkeleton := CheckBox1.Checked;
 end;
 
-procedure TFormSkeletal.GLSceneViewer1MouseDown(Sender: TObject;
-  Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
+procedure TFormSkeletal.GLSceneViewer1MouseDown(Sender: TObject; Button: TMouseButton;
+  Shift: TShiftState; X, Y: Integer);
 begin
-   mx:=x; my:=y;
+  mx := X;
+  my := Y;
 end;
 
-procedure TFormSkeletal.GLSceneViewer1MouseMove(Sender: TObject;
-  Shift: TShiftState; X, Y: Integer);
+procedure TFormSkeletal.GLSceneViewer1MouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
 begin
-   if Shift<>[] then begin
-      GLCamera1.MoveAroundTarget(my-y, mx-x);
-      mx:=x; my:=y;
-   end;
+  if Shift <> [] then
+  begin
+    GLCamera1.MoveAroundTarget(my - Y, mx - X);
+    mx := X;
+    my := Y;
+  end;
 end;
 
 procedure TFormSkeletal.Timer1Timer(Sender: TObject);
 begin
-   LabelFPS.Caption:=Format('%.1f FPS', [GLSceneViewer1.FramesPerSecond]);
-   GLSceneViewer1.ResetPerformanceMonitor;
+  LabelFPS.Caption := Format('%.1f FPS', [GLSceneViewer1.FramesPerSecond]);
+  GLSceneViewer1.ResetPerformanceMonitor;
 end;
 
-procedure TFormSkeletal.GLCadencer1Progress(Sender: TObject; const deltaTime,
-  newTime: Double);
+procedure TFormSkeletal.GLCadencer1Progress(Sender: TObject; const deltaTime, newTime: Double);
 begin
-   GLScene1.NotifyChange(nil);
+  GLScene1.NotifyChange(nil);
 end;
 
 end.