ExampleObjects.pas
上传用户:ctlcnc
上传日期:2021-12-10
资源大小:4933k
文件大小:2k
源码类别:

2D图形编程

开发平台:

Delphi

  1. unit ExampleObjects;
  2. //---------------------------------------------------------------------------
  3. interface
  4. //---------------------------------------------------------------------------
  5. uses
  6.  Vectors3, Matrices4, AsphyreMeshes, AsphyreBasicShaders, AsphyreMinimalShader,
  7.  AsphyrePhysics, CookTorranceFx;
  8. //---------------------------------------------------------------------------
  9. type
  10.  TExampleBox = class(TNewtonCustomBox)
  11.  private
  12.   FSpecular: Single;
  13.  protected
  14.   procedure DoDraw(const DrawMtx: TMatrix4); override;
  15.  public
  16.   property Specular: Single read FSpecular write FSpecular;
  17.  end;
  18. //---------------------------------------------------------------------------
  19.  TExampleSphere = class(TNewtonCustomSphere)
  20.  private
  21.  protected
  22.   procedure DoDraw(const DrawMtx: TMatrix4); override;
  23.  end;
  24. //---------------------------------------------------------------------------
  25. var
  26.  Shader : TCookTorranceFx;
  27. // Shader    : TAsphyreBasicShader = nil;
  28. // Shader    : TAsphyreMinimalShader = nil;
  29.  MeshBox   : TAsphyreCustomMesh = nil;
  30.  MeshSphere: TAsphyreCustomMesh = nil;
  31. //---------------------------------------------------------------------------
  32. implementation
  33. //---------------------------------------------------------------------------
  34. procedure TExampleBox.DoDraw(const DrawMtx: TMatrix4);
  35. begin
  36.  Shader.Draw(MeshBox, DrawMtx, Color, 0.1, FSpecular, 0.85, 0.9);
  37. end;
  38. //---------------------------------------------------------------------------
  39. procedure TExampleSphere.DoDraw(const DrawMtx: TMatrix4);
  40. begin
  41.  Shader.Draw(MeshSphere, ScaleMtx4(Vector3(2.0, 2.0, 2.0)) * DrawMtx, Color,
  42.   0.2, 1.0, 0.85, 0.9);
  43. end;
  44. //---------------------------------------------------------------------------
  45. end.