2
// This unit is part of the GLScene Engine https://github.com/glscene
5
Classes and functions that make integration between verlets and glscene
9
23/08/10 - Yar - Added "VectorTypes.pas" unit to uses
10
13/04/04 - MF - Verlet call now uses TVerletProgressTimes
11
06/03/04 - MF - Creation
19
GLVerletTypes, GLVectorGeometry, GLScene, GLObjects, GLVectorTypes;
24
{ Specialized verlet node that can be anchored to a GLScene object. If it's
25
anchored and has the property "NailedDown" set, it will remain in the same
26
relative position to the GLScene object.}
27
TGLVerletNode = class(TVerletNode)
29
FRelativePosition: TAffineVector;
30
FGLBaseSceneObject: TGLBaseSceneObject;
31
procedure SetGLBaseSceneObject(const Value: TGLBaseSceneObject);
33
procedure SetLocation(const Value: TAffineVector);override;
35
procedure Verlet(const vpt : TVerletProgressTimes); override;
37
property GLBaseSceneObject : TGLBaseSceneObject read FGLBaseSceneObject write SetGLBaseSceneObject;
38
property RelativePosition : TAffineVector read FRelativePosition write FRelativePosition;
41
function CreateVCPlaneFromGLPlane(Plane : TGLPlane; VerletWorld : TGLVerletWorld; Offset : single) : TVCFloor;
42
//-------------------------------------------------------------------------------------------
43
//-------------------------------------------------------------------------------------------
45
//-------------------------------------------------------------------------------------------
46
//-------------------------------------------------------------------------------------------
48
function CreateVCPlaneFromGLPlane(Plane : TGLPlane; VerletWorld : TGLVerletWorld; Offset : single) : TVCFloor;
50
result := TVCFloor.Create(VerletWorld);
53
Normal := VectorNormalize(Plane.Direction.AsAffineVector);
55
Location := VectorAdd(Plane.Position.AsAffineVector, VectorScale(Normal, Offset));
61
procedure TGLVerletNode.SetGLBaseSceneObject(
62
const Value: TGLBaseSceneObject);
64
FGLBaseSceneObject := Value;
66
if Assigned(GLBaseSceneObject) and NailedDown then
67
FRelativePosition := AffineVectorMake(GLBaseSceneObject.AbsoluteToLocal(VectorMake(FLocation, 1)));
70
procedure TGLVerletNode.SetLocation(const Value: TAffineVector);
73
if Assigned(GLBaseSceneObject) and NailedDown then
74
FRelativePosition := GLBaseSceneObject.AbsoluteToLocal(Value);
77
procedure TGLVerletNode.Verlet(const vpt : TVerletProgressTimes);
79
if Assigned(GLBaseSceneObject) and NailedDown then
81
FLocation := GLBaseSceneObject.LocalToAbsolute(FRelativePosition);