-2

We know a 3D plane is built by 3 points. Now in delphi I use GLScene there is a plane in which you cant see any arbitrary point to create a plan. My question is how to set a plane by 3 given points. According to SO rules I write my TGLPlane source code.

  TGLPlane = class(TGLSceneObject)
  private
    { Private Declarations }
    FXOffset, FYOffset: TGLFloat;
    FXScope, FYScope: TGLFloat;
    FWidth, FHeight: TGLFloat;
    FXTiles, FYTiles: Cardinal;
    FStyle: TGLPlaneStyles;
    FMesh: array of array of TVertexRec;
  protected
    { Protected Declarations }
    procedure SetHeight(const aValue: Single);
    procedure SetWidth(const aValue: Single);
    procedure SetXOffset(const Value: TGLFloat);
    procedure SetXScope(const Value: TGLFloat);
    function StoreXScope: Boolean;
    procedure SetXTiles(const Value: Cardinal);
    procedure SetYOffset(const Value: TGLFloat);
    procedure SetYScope(const Value: TGLFloat);
    function StoreYScope: Boolean;
    procedure SetYTiles(const Value: Cardinal);
    procedure SetStyle(const val: TGLPlaneStyles);

  public
    { Public Declarations }
    constructor Create(AOwner: TComponent); override;

    procedure Assign(Source: TPersistent); override;

    procedure BuildList(var rci: TRenderContextInfo); override;
    function GenerateSilhouette(const silhouetteParameters
      : TGLSilhouetteParameters): TGLSilhouette; override;

    function AxisAlignedDimensionsUnscaled: TVector; override;
    function RayCastIntersect(const rayStart, rayVector: TVector;
      intersectPoint: PVector = nil; intersectNormal: PVector = nil)
      : Boolean; override;
    { : Computes the screen coordinates of the smallest rectangle encompassing the plane.<p>
      Returned extents are NOT limited to any physical screen extents. }
    function ScreenRect(aBuffer: TGLSceneBuffer): TGLRect;

    { : Computes the signed distance to the point.<p>
      Point coordinates are expected in absolute coordinates. }
    function PointDistance(const aPoint: TVector): Single;

  published
    { Public Declarations }
    property Height: TGLFloat read FHeight write SetHeight;
    property Width: TGLFloat read FWidth write SetWidth;
    property XOffset: TGLFloat read FXOffset write SetXOffset;
    property XScope: TGLFloat read FXScope write SetXScope stored StoreXScope;
    property XTiles: Cardinal read FXTiles write SetXTiles default 1;
    property YOffset: TGLFloat read FYOffset write SetYOffset;
    property YScope: TGLFloat read FYScope write SetYScope stored StoreYScope;
    property YTiles: Cardinal read FYTiles write SetYTiles default 1;
    property Style: TGLPlaneStyles read FStyle write SetStyle
      default [psSingleQuad, psTileTexture];
  end;
naser daneshi
  • 284
  • 1
  • 10
  • Have you read the documentation at all? Or even the source code. Please don't tell us you did not. I would expect that if you do either you'll find a constructor for the plane object that accepts three points. – David Heffernan Nov 08 '15 at 20:58
  • Please do not use an answer to comment on others comments. That is not how SO works (refer to [help](http://stackoverflow.com/help) for more information. Said this, @DavidHeffernan's comment is totally valid. If the source code you show is all there is for `TGLPlane` then the answer you look for is obvious. – Guillem Vicens Nov 09 '15 at 07:19
  • 1
    The GLScene plane object that I found docs for had a constructor that accepted three points (vertices) in the plane. The Delphi class that akser provided does not. I don't know why not. – David Heffernan Nov 09 '15 at 07:28
  • I tried to copy the codes but that was a limitation words to write down. – naser daneshi Nov 09 '15 at 07:34
  • please remove your negative vote. – naser daneshi Nov 09 '15 at 07:41
  • Can you tell me where did you get your GLSCene component having 3 points in constructor ? I wanna this. – naser daneshi Nov 09 '15 at 11:35
  • Websearch gave it up. But the Delphi wrapper doesn't seem to. So you'll have to do some basic maths – David Heffernan Nov 10 '15 at 07:09

1 Answers1

0

In GLScene, a plane is determined by its position and direction, not directly by three points.

Let's label the points A, B, and C. Choose A to be the position. The cross product of vectors AB and AC will give you the normal vector. Use those results to set the plane's AbsolutePosition and AbsoluteDirection properties.

Rob Kennedy
  • 161,384
  • 21
  • 275
  • 467