Explorar el Código

Christmas and Material Preview updated

GLScene hace 2 años
padre
commit
3b89ee043e

+ 0 - 8
Source/FRColorEditor.pas

@@ -45,7 +45,6 @@ type
     procedure PAPreviewDblClick(Sender: TObject);
     procedure ColorEditorPaintBoxPaint(Sender: TObject);
     procedure FrameResize(Sender: TObject);
-    procedure RTrackBarEdit1EditChange(Sender: TObject);
     procedure ColorEditorPaintBoxMouseDown(Sender: TObject;
       Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
     procedure ColorEditorPaintBoxMouseMove(Sender: TObject;
@@ -187,13 +186,6 @@ begin
   GreenEdit.Height := 18;
   BlueEdit.Height := 18;
   AlphaEdit.Height := 18;
-
-end;
-
-procedure TRColorEditor.RTrackBarEdit1EditChange(Sender: TObject);
-begin
-//  RTrackBarEdit1.EditChange(Sender);
-
 end;
 
 function ColorValueToColorViewPosition(ColorValue : integer) : integer;

+ 0 - 33
Source/FRFaceEditor.dfm

@@ -67,16 +67,6 @@ object RFaceEditor: TRFaceEditor
           ExplicitWidth = 341
           ExplicitHeight = 98
         end
-        inherited Panel1: TPanel
-          Left = 52
-          Top = 3
-          ExplicitLeft = 52
-          ExplicitTop = 3
-        end
-        inherited ColorDialog: TColorDialog
-          Left = 264
-          Top = 72
-        end
       end
     end
     object TSSpecular: TTabSheet
@@ -117,29 +107,6 @@ object RFaceEditor: TRFaceEditor
       ExplicitLeft = 160
     end
   end
-  object TrackBar: TTrackBar
-    Left = 69
-    Top = 213
-    Width = 150
-    Height = 20
-    Max = 128
-    PageSize = 10
-    Frequency = 16
-    TabOrder = 2
-    ThumbLength = 10
-    TickMarks = tmTopLeft
-    OnChange = TrackBarChange
-  end
-  object Edit: TEdit
-    Left = 222
-    Top = 213
-    Width = 41
-    Height = 28
-    TabOrder = 3
-    Text = '0'
-    OnChange = EditChange
-    OnExit = TrackBarChange
-  end
   object ImageList: TImageList
     Left = 264
     Top = 8

+ 6 - 25
Source/FRFaceEditor.pas

@@ -21,10 +21,11 @@ uses
   VCL.Controls,
   VCL.Graphics,
 
+  FRTrackBarEdit,
   FRColorEditor,
   GLS.Texture,
   GLS.Material,
-  GLS.State, FRTrackBarEdit;
+  GLS.State;
 
 type
   TRFaceEditor = class(TFrame)
@@ -35,14 +36,11 @@ type
     TSSpecular: TTabSheet;
     CEAmbiant: TRColorEditor;
     Label1: TLabel;
+    TBEShininess: TRTrackBarEdit;
     ImageList: TImageList;
     CEDiffuse: TRColorEditor;
     CEEmission: TRColorEditor;
     CESpecular: TRColorEditor;
-    TrackBar: TTrackBar;
-    Edit: TEdit;
-    procedure TrackBarChange(Sender: TObject);
-    procedure EditChange(Sender: TObject);
     procedure TBEShininessTrackBarChange(Sender: TObject);
   private
     FOnChange: TNotifyEvent;
@@ -81,18 +79,6 @@ begin
   inherited;
 end;
 
-procedure TRFaceEditor.EditChange(Sender: TObject);
-var
-  i: Integer;
-begin
-  try
-    i := StrToInt(Edit.Text);
-    TrackBar.Position := i;
-  except
-    // ignore
-  end;
-end;
-
 procedure TRFaceEditor.OnColorChange(Sender: TObject);
 var
   bmp: TBitmap;
@@ -139,18 +125,13 @@ procedure TRFaceEditor.TBEShininessTrackBarChange(Sender: TObject);
 begin
   if not Updating then
   begin
-//    TBEShininess.TrackBarChange(Sender);
-    FFaceProperties.Shininess := TrackBar.Position;  // TBEShininess.Value;
+    TBEShininess.TrackBarChange(Sender);
+    FFaceProperties.Shininess := TBEShininess.Value;
     if Assigned(FOnChange) then
       FOnChange(Self);
   end;
 end;
 
-procedure TRFaceEditor.TrackBarChange(Sender: TObject);
-begin
-  Edit.Text := IntToStr(TrackBar.Position);
-end;
-
 procedure TRFaceEditor.SetGLFaceProperties(const val: TGLFaceProperties);
 begin
   Updating := True;
@@ -159,7 +140,7 @@ begin
     CEDiffuse.Color := val.Diffuse.Color;
     CEEmission.Color := val.Emission.Color;
     CESpecular.Color := val.Specular.Color;
-///    TBEShininess.Value := val.Shininess;
+    TBEShininess.Value := val.Shininess;
   finally
     Updating := False;
   end;

+ 16 - 26
Source/FRMaterialPreview.dfm

@@ -2,22 +2,9 @@ object RMaterialPreview: TRMaterialPreview
   Left = 0
   Top = 0
   Width = 202
-  Height = 230
+  Height = 229
   AutoSize = True
   TabOrder = 0
-  object GLSceneViewer: TGLSceneViewer
-    Left = 0
-    Top = 27
-    Width = 202
-    Height = 203
-    Camera = Camera
-    FieldOfView = 71.615516662597660000
-    PenAsTouch = False
-    OnMouseDown = SceneViewerMouseDown
-    OnMouseMove = SceneViewerMouseMove
-    OnMouseWheel = SceneViewerMouseWheel
-    TabOrder = 2
-  end
   object CBObject: TComboBox
     Left = 0
     Top = 0
@@ -29,7 +16,6 @@ object RMaterialPreview: TRMaterialPreview
     Items.Strings = (
       'Cube'
       'Sphere'
-      'Cone'
       'Teapot')
   end
   object CBBackground: TComboBox
@@ -48,6 +34,16 @@ object RMaterialPreview: TRMaterialPreview
       'on a red background'
       'on a green background')
   end
+  object GLSceneViewer: TGLSceneViewer
+    Left = 0
+    Top = 26
+    Width = 202
+    Height = 203
+    Camera = Camera
+    FieldOfView = 71.615516662597660000
+    PenAsTouch = False
+    TabOrder = 2
+  end
   object GLScene: TGLScene
     ObjectsSorting = osNone
     Left = 24
@@ -140,12 +136,6 @@ object RMaterialPreview: TRMaterialPreview
         Material.LibMaterialName = 'LibMaterial'
         Radius = 0.800000011920929000
       end
-      object Cone: TGLCone
-        Material.MaterialLibrary = GLMaterialLibrary
-        Material.LibMaterialName = 'LibMaterial'
-        BottomRadius = 0.500000000000000000
-        Height = 1.000000000000000000
-      end
       object Teapot: TGLTeapot
         Material.MaterialLibrary = GLMaterialLibrary
         Material.LibMaterialName = 'LibMaterial'
@@ -155,11 +145,6 @@ object RMaterialPreview: TRMaterialPreview
     object Light: TGLDummyCube
       Position.Coordinates = {0000000000004040000020410000803F}
       CubeSize = 1.000000000000000000
-      object LightSource: TGLLightSource
-        ConstAttenuation = 1.000000000000000000
-        Specular.Color = {0000803F0000803F0000803F0000803F}
-        SpotCutOff = 180.000000000000000000
-      end
       object FireSphere: TGLSphere
         Material.BackProperties.Shininess = 47
         Material.FrontProperties.Ambient.Color = {A3A2223FCDCC4C3ECDCC4C3E0000803F}
@@ -172,6 +157,11 @@ object RMaterialPreview: TRMaterialPreview
       FocalLength = 140.000000000000000000
       TargetObject = Cube
       Position.Coordinates = {0000000000000000000020410000803F}
+      object LightSource: TGLLightSource
+        ConstAttenuation = 1.000000000000000000
+        Specular.Color = {0000803F0000803F0000803F0000803F}
+        SpotCutOff = 180.000000000000000000
+      end
     end
   end
   object GLMaterialLibrary: TGLMaterialLibrary

+ 1 - 3
Source/FRMaterialPreview.pas

@@ -41,7 +41,6 @@ type
     LightSource: TGLLightSource;
     CBBackground: TComboBox;
     BackGroundSprite: TGLHUDSprite;
-    Cone: TGLCone;
     Teapot: TGLTeapot;
     World: TGLDummyCube;
     Light: TGLDummyCube;
@@ -98,8 +97,7 @@ begin
   i := CBObject.ItemIndex;
   Cube.Visible := i = 0;
   Sphere.Visible := i = 1;
-  Cone.Visible := i = 2;
-  Teapot.Visible := i = 3;
+  Teapot.Visible := i = 2;
 end;
 
 procedure TRMaterialPreview.CBBackgroundChange(Sender: TObject);

+ 14 - 25
Source/FmMaterialEditor.dfm

@@ -11,6 +11,7 @@ object GLMaterialEditorForm: TGLMaterialEditorForm
   Font.Height = -11
   Font.Name = 'MS Sans Serif'
   Font.Style = []
+  Position = poScreenCenter
   ShowHint = True
   TextHeight = 13
   object Label1: TLabel
@@ -41,11 +42,11 @@ object GLMaterialEditorForm: TGLMaterialEditorForm
         Left = 0
         Top = 0
         Width = 305
-        Height = 241
+        Height = 227
         AutoSize = True
         TabOrder = 0
         ExplicitWidth = 305
-        ExplicitHeight = 241
+        ExplicitHeight = 227
         inherited Label1: TLabel
           Width = 45
           Height = 13
@@ -53,17 +54,18 @@ object GLMaterialEditorForm: TGLMaterialEditorForm
           ExplicitHeight = 13
         end
         inherited PageControl: TPageControl
+          ActivePage = FEFront.TSAmbient
           inherited TSAmbient: TTabSheet
-            ExplicitTop = 24
-            ExplicitHeight = 102
+            ExplicitTop = 25
+            ExplicitHeight = 101
           end
           inherited TSDiffuse: TTabSheet
             ExplicitTop = 24
             ExplicitHeight = 102
           end
           inherited TSEmission: TTabSheet
-            ExplicitTop = 25
-            ExplicitHeight = 101
+            ExplicitTop = 24
+            ExplicitHeight = 102
           end
           inherited TSSpecular: TTabSheet
             ExplicitTop = 24
@@ -76,10 +78,6 @@ object GLMaterialEditorForm: TGLMaterialEditorForm
             ExplicitHeight = 21
           end
         end
-        inherited Edit: TEdit
-          Height = 21
-          ExplicitHeight = 21
-        end
         inherited ImageList: TImageList
           Top = 0
         end
@@ -92,11 +90,11 @@ object GLMaterialEditorForm: TGLMaterialEditorForm
         Left = 0
         Top = 0
         Width = 305
-        Height = 241
+        Height = 227
         AutoSize = True
         TabOrder = 0
         ExplicitWidth = 305
-        ExplicitHeight = 241
+        ExplicitHeight = 227
         inherited Label1: TLabel
           Width = 45
           Height = 13
@@ -127,10 +125,6 @@ object GLMaterialEditorForm: TGLMaterialEditorForm
             ExplicitHeight = 21
           end
         end
-        inherited Edit: TEdit
-          Height = 21
-          ExplicitHeight = 21
-        end
       end
     end
     object TSTexture: TTabSheet
@@ -240,7 +234,7 @@ object GLMaterialEditorForm: TGLMaterialEditorForm
       Left = 16
       Top = 22
       Width = 202
-      Height = 230
+      Height = 229
       AutoSize = True
       TabOrder = 0
       ExplicitLeft = 16
@@ -265,10 +259,6 @@ object GLMaterialEditorForm: TGLMaterialEditorForm
             Material.MaterialLibrary = nil
             Material.LibMaterialName = ''
           end
-          inherited Cone: TGLCone
-            Material.MaterialLibrary = nil
-            Material.LibMaterialName = ''
-          end
           inherited Teapot: TGLTeapot
             Material.MaterialLibrary = nil
             Material.LibMaterialName = ''
@@ -277,10 +267,6 @@ object GLMaterialEditorForm: TGLMaterialEditorForm
         end
         inherited Light: TGLDummyCube
           Position.Coordinates = {0000000000004040000020410000803F}
-          inherited LightSource: TGLLightSource
-            Position.Coordinates = {0000000000004040000020410000803F}
-            Specular.Color = {0000803F0000803F0000803F0000803F}
-          end
           inherited FireSphere: TGLSphere
             Material.FrontProperties.Ambient.Color = {A3A2223FCDCC4C3ECDCC4C3E0000803F}
             Material.FrontProperties.Emission.Color = {D3D2523FA1A0203F000000000000803F}
@@ -288,6 +274,9 @@ object GLMaterialEditorForm: TGLMaterialEditorForm
         end
         inherited Camera: TGLCamera
           Position.Coordinates = {0000000000000000000020410000803F}
+          inherited LightSource: TGLLightSource
+            Specular.Color = {0000803F0000803F0000803F0000803F}
+          end
         end
       end
       inherited GLMaterialLibrary: TGLMaterialLibrary

+ 25 - 17
Source/FmMaterialEditor.pas

@@ -3,7 +3,7 @@
 //
 unit FmMaterialEditor;
 
-(*  Editor window for a material (with preview) *)
+(* Editor window for a material (with preview) *)
 
 interface
 
@@ -22,6 +22,7 @@ uses
   GLS.State,
   GLS.Material,
   GLS.Texture,
+  FRTrackBarEdit,
   FRMaterialPreview,
   FRColorEditor,
   FRFaceEditor,
@@ -53,9 +54,10 @@ type
 function GLMaterialEditorForm: TGLMaterialEditorForm;
 procedure ReleaseMaterialEditorForm;
 
-//----------------------------------------------
+// ----------------------------------------------
 implementation
-//----------------------------------------------
+
+// ----------------------------------------------
 
 {$R *.dfm}
 
@@ -78,16 +80,15 @@ begin
   end;
 end;
 
-
 constructor TGLMaterialEditorForm.Create(AOwner: TComponent);
 var
   I: Integer;
 begin
   inherited;
-  for i := 0 to Integer(High(TGLBlendingMode)) do
-    CBBlending.Items.Add(GetEnumName(TypeInfo(TGLBlendingMode), i));
-  for i := 0 to Integer(High(TGLPolygonMode)) do
-    CBPolygonMode.Items.Add(GetEnumName(TypeInfo(TGLPolygonMode), i));
+  for I := 0 to Integer(High(TGLBlendingMode)) do
+    CBBlending.Items.Add(GetEnumName(TypeInfo(TGLBlendingMode), I));
+  for I := 0 to Integer(High(TGLPolygonMode)) do
+    CBPolygonMode.Items.Add(GetEnumName(TypeInfo(TGLPolygonMode), I));
 
   FEFront.OnChange := OnMaterialChanged;
   FEBack.OnChange := OnMaterialChanged;
@@ -101,7 +102,7 @@ begin
     FEFront.FaceProperties := FrontProperties;
     FEBack.FaceProperties := BackProperties;
     RTextureEdit.Texture := Texture;
-    CBPolygonMode.ItemIndex:=Integer(PolygonMode);
+    CBPolygonMode.ItemIndex := Integer(PolygonMode);
     CBBlending.ItemIndex := Integer(BlendingMode);
   end;
   MPPreview.Material := AMaterial;
@@ -115,28 +116,35 @@ begin
       BlendingMode := TGLBlendingMode(CBBlending.ItemIndex);
       PolygonMode := TGLPolygonMode(CBPolygonMode.ItemIndex);
     end;
+
 end;
 
 procedure TGLMaterialEditorForm.OnMaterialChanged(Sender: TObject);
 begin
-  with MPPreview.Material do
+  with MPPreview do
   begin
-    FrontProperties := FEFront.FaceProperties;
-    BackProperties := FEBack.FaceProperties;
-    Texture := RTextureEdit.Texture;
-    BlendingMode := TGLBlendingMode(CBBlending.ItemIndex);
-    PolygonMode := TGLPolygonMode(CBPolygonMode.ItemIndex);
+    Material.FrontProperties := FEFront.FaceProperties;
+    Material.BackProperties := FEBack.FaceProperties;
+    Material.Texture := RTextureEdit.Texture;
+    Material.BlendingMode := TGLBlendingMode(CBBlending.ItemIndex);
+    Material.PolygonMode := TGLPolygonMode(CBPolygonMode.ItemIndex);
+    Cube.Material := Material;
+    Sphere.Material := Material;
+    TeaPot.Material := Material;
+
   end;
+
   MPPreview.GLSceneViewer.Invalidate;
+
 end;
 
 // ------------------------------------------------------------------
 initialization
+
 // ------------------------------------------------------------------
 
 finalization
 
-  ReleaseMaterialEditorForm;
+ReleaseMaterialEditorForm;
 
 end.
-