commit
b30b5fda29
26 changed files with 27494 additions and 847 deletions
|
|
@ -29,6 +29,7 @@ Kraft Physics Engine has the following features:
|
|||
- Ray casting
|
||||
- Sleeping of inactive rigid bodies
|
||||
- Island-based multithreading
|
||||
- It can be used also for 1D and 2D physics, and not only for 3D physics
|
||||
- SIMD optimizations for x86-32 (later also for x86-64)
|
||||
|
||||
## Future possibly possible features
|
||||
|
|
@ -42,6 +43,10 @@ Kraft Physics Engine has the following features:
|
|||
|
||||
The Kraft Physics Engine is released under the open-source [ZLib license](http://opensource.org/licenses/zlib).
|
||||
|
||||
## PasMP
|
||||
|
||||
For to use Kraft with PasMP, you must set a project global define called KraftPasMP (or use -dKraftPasMP as compiler command line parameter)
|
||||
|
||||
## Documentation
|
||||
|
||||
Later . . .
|
||||
|
|
|
|||
90
sandbox/UnitDemoScene.pas
Normal file
90
sandbox/UnitDemoScene.pas
Normal file
|
|
@ -0,0 +1,90 @@
|
|||
unit UnitDemoScene;
|
||||
|
||||
{$MODE Delphi}
|
||||
|
||||
{$j+}
|
||||
|
||||
interface
|
||||
|
||||
uses SysUtils,Classes,LCLIntf, LCLType, LMessages, kraft;
|
||||
|
||||
type TDemoScene=class;
|
||||
|
||||
TDemoSceneClass=class of TDemoScene;
|
||||
|
||||
TDemoScene=class
|
||||
public
|
||||
fKraftPhysics:TKraft;
|
||||
GarbageCollector:TList;
|
||||
MeshGarbageCollector:TList;
|
||||
ConvexHullGarbageCollector:TList;
|
||||
constructor Create(const AKraftPhysics:TKraft); virtual;
|
||||
destructor Destroy; override;
|
||||
procedure Step(const DeltaTime:double); virtual;
|
||||
property KraftPhysics:TKraft read fKraftPhysics;
|
||||
end;
|
||||
|
||||
var DemoScenes:TStringList;
|
||||
|
||||
procedure RegisterDemoScene(const Name:string;const DemoSceneClass:TDemoSceneClass);
|
||||
|
||||
implementation
|
||||
|
||||
uses UnitFormMain;
|
||||
|
||||
constructor TDemoScene.Create(const AKraftPhysics:TKraft);
|
||||
begin
|
||||
inherited Create;
|
||||
fKraftPhysics:=AKraftPhysics;
|
||||
GarbageCollector:=TList.Create;
|
||||
MeshGarbageCollector:=TList.Create;
|
||||
ConvexHullGarbageCollector:=TList.Create;
|
||||
end;
|
||||
|
||||
destructor TDemoScene.Destroy;
|
||||
var Index:longint;
|
||||
begin
|
||||
//wglMakeCurrent(FormGL.hDCGL,FormGL.hGL);
|
||||
|
||||
for Index:=0 to GarbageCollector.Count-1 do begin
|
||||
TObject(GarbageCollector[Index]).Free;
|
||||
end;
|
||||
GarbageCollector.Free;
|
||||
|
||||
while assigned(fKraftPhysics.RigidBodyFirst) do begin
|
||||
fKraftPhysics.RigidBodyFirst.Free;
|
||||
end;
|
||||
|
||||
while assigned(fKraftPhysics.ConstraintFirst) do begin
|
||||
fKraftPhysics.ConstraintFirst.Free;
|
||||
end;
|
||||
|
||||
for Index:=0 to MeshGarbageCollector.Count-1 do begin
|
||||
TObject(MeshGarbageCollector[Index]).Free;
|
||||
end;
|
||||
MeshGarbageCollector.Free;
|
||||
|
||||
for Index:=0 to ConvexHullGarbageCollector.Count-1 do begin
|
||||
TObject(ConvexHullGarbageCollector[Index]).Free;
|
||||
end;
|
||||
ConvexHullGarbageCollector.Free;
|
||||
|
||||
//wglMakeCurrent(0,0);
|
||||
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
procedure TDemoScene.Step(const DeltaTime:double);
|
||||
begin
|
||||
end;
|
||||
|
||||
procedure RegisterDemoScene(const Name:string;const DemoSceneClass:TDemoSceneClass);
|
||||
begin
|
||||
DemoScenes.AddObject(Name,pointer(DemoSceneClass));
|
||||
end;
|
||||
|
||||
initialization
|
||||
DemoScenes:=TStringList.Create;
|
||||
finalization
|
||||
DemoScenes.Free;
|
||||
end.
|
||||
58
sandbox/UnitDemoSceneBoxOnPlane.pas
Normal file
58
sandbox/UnitDemoSceneBoxOnPlane.pas
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
unit UnitDemoSceneBoxOnPlane;
|
||||
|
||||
{$MODE Delphi}
|
||||
|
||||
interface
|
||||
|
||||
uses Kraft,UnitDemoScene;
|
||||
|
||||
type TDemoSceneBoxOnPlane=class(TDemoScene)
|
||||
public
|
||||
RigidBodyFloor:TKraftRigidBody;
|
||||
ShapeFloorPlane:TKraftShapePlane;
|
||||
RigidBodyBox:TKraftRigidBody;
|
||||
ShapeBox:TKraftShapeBox;
|
||||
constructor Create(const AKraftPhysics:TKraft); override;
|
||||
destructor Destroy; override;
|
||||
procedure Step(const DeltaTime:double); override;
|
||||
end;
|
||||
|
||||
implementation
|
||||
|
||||
uses UnitFormMain;
|
||||
|
||||
constructor TDemoSceneBoxOnPlane.Create(const AKraftPhysics:TKraft);
|
||||
begin
|
||||
inherited Create(AKraftPhysics);
|
||||
|
||||
RigidBodyFloor:=TKraftRigidBody.Create(KraftPhysics);
|
||||
RigidBodyFloor.SetRigidBodyType(krbtSTATIC);
|
||||
ShapeFloorPlane:=TKraftShapePlane.Create(KraftPhysics,RigidBodyFloor,Plane(Vector3Norm(Vector3(0.0,1.0,0.0)),0.0));
|
||||
ShapeFloorPlane.Restitution:=0.3;
|
||||
RigidBodyFloor.Finish;
|
||||
RigidBodyFloor.SetWorldTransformation(Matrix4x4Translate(0.0,0.0,0.0));
|
||||
RigidBodyFloor.CollisionGroups:=[0];
|
||||
|
||||
RigidBodyBox:=TKraftRigidBody.Create(KraftPhysics);
|
||||
RigidBodyBox.SetRigidBodyType(krbtDYNAMIC);
|
||||
ShapeBox:=TKraftShapeBox.Create(KraftPhysics,RigidBodyBox,Vector3(1.0,1.0,1.0));
|
||||
ShapeBox.Restitution:=0.3;
|
||||
ShapeBox.Density:=100.0;
|
||||
RigidBodyBox.Finish;
|
||||
RigidBodyBox.SetWorldTransformation(Matrix4x4Translate(0.0,8.0,0.0));
|
||||
RigidBodyBox.CollisionGroups:=[0];
|
||||
|
||||
end;
|
||||
|
||||
destructor TDemoSceneBoxOnPlane.Destroy;
|
||||
begin
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
procedure TDemoSceneBoxOnPlane.Step(const DeltaTime:double);
|
||||
begin
|
||||
end;
|
||||
|
||||
initialization
|
||||
RegisterDemoScene('Box on plane',TDemoSceneBoxOnPlane);
|
||||
end.
|
||||
65
sandbox/UnitDemoSceneBoxPyramidStacking.pas
Normal file
65
sandbox/UnitDemoSceneBoxPyramidStacking.pas
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
unit UnitDemoSceneBoxPyramidStacking;
|
||||
|
||||
{$MODE Delphi}
|
||||
|
||||
interface
|
||||
|
||||
uses Kraft,UnitDemoScene;
|
||||
|
||||
type TDemoSceneBoxPyramidStacking=class(TDemoScene)
|
||||
public
|
||||
RigidBodyFloor:TKraftRigidBody;
|
||||
ShapeFloorPlane:TKraftShapePlane;
|
||||
RigidBodyBox:TKraftRigidBody;
|
||||
ShapeBox:TKraftShapeBox;
|
||||
constructor Create(const AKraftPhysics:TKraft); override;
|
||||
destructor Destroy; override;
|
||||
procedure Step(const DeltaTime:double); override;
|
||||
end;
|
||||
|
||||
implementation
|
||||
|
||||
uses UnitFormMain;
|
||||
|
||||
constructor TDemoSceneBoxPyramidStacking.Create(const AKraftPhysics:TKraft);
|
||||
const Height=10;
|
||||
var i,j:longint;
|
||||
begin
|
||||
inherited Create(AKraftPhysics);
|
||||
|
||||
RigidBodyFloor:=TKraftRigidBody.Create(KraftPhysics);
|
||||
RigidBodyFloor.SetRigidBodyType(krbtSTATIC);
|
||||
ShapeFloorPlane:=TKraftShapePlane.Create(KraftPhysics,RigidBodyFloor,Plane(Vector3Norm(Vector3(0.0,1.0,0.0)),0.0));
|
||||
ShapeFloorPlane.Restitution:=0.4;
|
||||
RigidBodyFloor.Finish;
|
||||
RigidBodyFloor.SetWorldTransformation(Matrix4x4Translate(0.0,0.0,0.0));
|
||||
RigidBodyFloor.CollisionGroups:=[0];
|
||||
|
||||
for i:=0 to Height-1 do begin
|
||||
for j:=0 to i do begin
|
||||
RigidBodyBox:=TKraftRigidBody.Create(KraftPhysics);
|
||||
RigidBodyBox.SetRigidBodyType(krbtDYNAMIC);
|
||||
ShapeBox:=TKraftShapeBox.Create(KraftPhysics,RigidBodyBox,Vector3(0.25,0.25,0.25));
|
||||
ShapeBox.Restitution:=0.4;
|
||||
ShapeBox.Density:=100.0;
|
||||
// RigidBodyBox.ForcedMass:=1.0;
|
||||
RigidBodyBox.Finish;
|
||||
RigidBodyBox.SetWorldTransformation(Matrix4x4Translate((j-(i*0.5))*(ShapeBox.Extents.x*2.05),ShapeBox.Extents.y+((Height-(i+1))*(ShapeBox.Extents.y*2.0)),0.0));
|
||||
RigidBodyBox.CollisionGroups:=[0];
|
||||
end;
|
||||
end;
|
||||
|
||||
end;
|
||||
|
||||
destructor TDemoSceneBoxPyramidStacking.Destroy;
|
||||
begin
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
procedure TDemoSceneBoxPyramidStacking.Step(const DeltaTime:double);
|
||||
begin
|
||||
end;
|
||||
|
||||
initialization
|
||||
RegisterDemoScene('Box pyramid stacking',TDemoSceneBoxPyramidStacking);
|
||||
end.
|
||||
61
sandbox/UnitDemoSceneBoxStacking.pas
Normal file
61
sandbox/UnitDemoSceneBoxStacking.pas
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
unit UnitDemoSceneBoxStacking;
|
||||
|
||||
{$MODE Delphi}
|
||||
|
||||
interface
|
||||
|
||||
uses Kraft,UnitDemoScene;
|
||||
|
||||
type TDemoSceneBoxStacking=class(TDemoScene)
|
||||
public
|
||||
RigidBodyFloor:TKraftRigidBody;
|
||||
ShapeFloorPlane:TKraftShapePlane;
|
||||
RigidBodyBox:TKraftRigidBody;
|
||||
ShapeBox:TKraftShapeBox;
|
||||
constructor Create(const AKraftPhysics:TKraft); override;
|
||||
destructor Destroy; override;
|
||||
procedure Step(const DeltaTime:double); override;
|
||||
end;
|
||||
|
||||
implementation
|
||||
|
||||
uses UnitFormMain;
|
||||
|
||||
constructor TDemoSceneBoxStacking.Create(const AKraftPhysics:TKraft);
|
||||
var i:longint;
|
||||
begin
|
||||
inherited Create(AKraftPhysics);
|
||||
|
||||
RigidBodyFloor:=TKraftRigidBody.Create(KraftPhysics);
|
||||
RigidBodyFloor.SetRigidBodyType(krbtSTATIC);
|
||||
ShapeFloorPlane:=TKraftShapePlane.Create(KraftPhysics,RigidBodyFloor,Plane(Vector3Norm(Vector3(0.0,1.0,0.0)),0.0));
|
||||
ShapeFloorPlane.Restitution:=0.4;
|
||||
RigidBodyFloor.Finish;
|
||||
RigidBodyFloor.SetWorldTransformation(Matrix4x4Translate(0.0,0.0,0.0));
|
||||
RigidBodyFloor.CollisionGroups:=[0];
|
||||
|
||||
for i:=0 to 9 do begin
|
||||
RigidBodyBox:=TKraftRigidBody.Create(KraftPhysics);
|
||||
RigidBodyBox.SetRigidBodyType(krbtDYNAMIC);
|
||||
ShapeBox:=TKraftShapeBox.Create(KraftPhysics,RigidBodyBox,Vector3(0.25,0.25,0.25));
|
||||
ShapeBox.Restitution:=0.4;
|
||||
ShapeBox.Density:=100.0;
|
||||
RigidBodyBox.Finish;
|
||||
RigidBodyBox.SetWorldTransformation(Matrix4x4Translate(0.0,ShapeBox.Extents.y+(i*(ShapeBox.Extents.y*2.0)),0.0));
|
||||
RigidBodyBox.CollisionGroups:=[0];
|
||||
end;
|
||||
|
||||
end;
|
||||
|
||||
destructor TDemoSceneBoxStacking.Destroy;
|
||||
begin
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
procedure TDemoSceneBoxStacking.Step(const DeltaTime:double);
|
||||
begin
|
||||
end;
|
||||
|
||||
initialization
|
||||
RegisterDemoScene('Box stacking',TDemoSceneBoxStacking);
|
||||
end.
|
||||
68
sandbox/UnitDemoSceneBrickWall.pas
Normal file
68
sandbox/UnitDemoSceneBrickWall.pas
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
unit UnitDemoSceneBrickWall;
|
||||
|
||||
{$MODE Delphi}
|
||||
|
||||
interface
|
||||
|
||||
uses Kraft,UnitDemoScene;
|
||||
|
||||
type TDemoSceneBrickWall=class(TDemoScene)
|
||||
public
|
||||
RigidBodyFloor:TKraftRigidBody;
|
||||
ShapeFloorPlane:TKraftShapePlane;
|
||||
RigidBodyBox:TKraftRigidBody;
|
||||
ShapeBox:TKraftShapeBox;
|
||||
constructor Create(const AKraftPhysics:TKraft); override;
|
||||
destructor Destroy; override;
|
||||
procedure Step(const DeltaTime:double); override;
|
||||
end;
|
||||
|
||||
implementation
|
||||
|
||||
uses UnitFormMain;
|
||||
|
||||
constructor TDemoSceneBrickWall.Create(const AKraftPhysics:TKraft);
|
||||
const Height=10;
|
||||
var i,j:longint;
|
||||
begin
|
||||
inherited Create(AKraftPhysics);
|
||||
|
||||
RigidBodyFloor:=TKraftRigidBody.Create(KraftPhysics);
|
||||
RigidBodyFloor.SetRigidBodyType(krbtSTATIC);
|
||||
ShapeFloorPlane:=TKraftShapePlane.Create(KraftPhysics,RigidBodyFloor,Plane(Vector3Norm(Vector3(0.0,1.0,0.0)),0.0));
|
||||
ShapeFloorPlane.Restitution:=0.4;
|
||||
RigidBodyFloor.Finish;
|
||||
RigidBodyFloor.SetWorldTransformation(Matrix4x4Translate(0.0,0.0,0.0));
|
||||
RigidBodyFloor.CollisionGroups:=[0];
|
||||
|
||||
for i:=0 to Height-1 do begin
|
||||
for j:=0 to Height-1 do begin
|
||||
if (i+j)>0 then begin
|
||||
RigidBodyBox:=TKraftRigidBody.Create(KraftPhysics);
|
||||
RigidBodyBox.SetRigidBodyType(krbtDYNAMIC);
|
||||
ShapeBox:=TKraftShapeBox.Create(KraftPhysics,RigidBodyBox,Vector3(1.0,0.5,0.25));
|
||||
ShapeBox.Restitution:=0.4;
|
||||
ShapeBox.Density:=10.0;
|
||||
// RigidBodyBox.ForcedMass:=1.0;
|
||||
RigidBodyBox.Finish;
|
||||
RigidBodyBox.SetWorldTransformation(Matrix4x4Translate(((j+((i and 1)*0.5))-(Height*0.5))*(ShapeBox.Extents.x*2.0),ShapeBox.Extents.y+((Height-(i+1))*(ShapeBox.Extents.y*2.0)),-8.0));
|
||||
RigidBodyBox.CollisionGroups:=[0];
|
||||
RigidBodyBox.SetToSleep;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
end;
|
||||
|
||||
destructor TDemoSceneBrickWall.Destroy;
|
||||
begin
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
procedure TDemoSceneBrickWall.Step(const DeltaTime:double);
|
||||
begin
|
||||
end;
|
||||
|
||||
initialization
|
||||
RegisterDemoScene('Brick wall',TDemoSceneBrickWall);
|
||||
end.
|
||||
72
sandbox/UnitDemoSceneBridge.pas
Normal file
72
sandbox/UnitDemoSceneBridge.pas
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
unit UnitDemoSceneBridge;
|
||||
|
||||
{$MODE Delphi}
|
||||
|
||||
interface
|
||||
|
||||
uses Kraft,UnitDemoScene;
|
||||
|
||||
type TDemoSceneBridge=class(TDemoScene)
|
||||
public
|
||||
RigidBodyFloor:TKraftRigidBody;
|
||||
ShapeFloorPlane:TKraftShapePlane;
|
||||
constructor Create(const AKraftPhysics:TKraft); override;
|
||||
destructor Destroy; override;
|
||||
procedure Step(const DeltaTime:double); override;
|
||||
end;
|
||||
|
||||
implementation
|
||||
|
||||
uses UnitFormMain;
|
||||
|
||||
constructor TDemoSceneBridge.Create(const AKraftPhysics:TKraft);
|
||||
const Count=11;
|
||||
Spacing=0.125;
|
||||
var Index:longint;
|
||||
RigidBodyBox:array[0..Count-1] of TKraftRigidBody;
|
||||
ShapeBox:TKraftShapeBox;
|
||||
begin
|
||||
inherited Create(AKraftPhysics);
|
||||
|
||||
RigidBodyFloor:=TKraftRigidBody.Create(KraftPhysics);
|
||||
RigidBodyFloor.SetRigidBodyType(krbtSTATIC);
|
||||
ShapeFloorPlane:=TKraftShapePlane.Create(KraftPhysics,RigidBodyFloor,Plane(Vector3Norm(Vector3(0.0,1.0,0.0)),0.0));
|
||||
ShapeFloorPlane.Restitution:=0.3;
|
||||
RigidBodyFloor.Finish;
|
||||
RigidBodyFloor.SetWorldTransformation(Matrix4x4Translate(0.0,0.0,0.0));
|
||||
RigidBodyFloor.CollisionGroups:=[0];
|
||||
|
||||
for Index:=0 to Count-1 do begin
|
||||
RigidBodyBox[Index]:=TKraftRigidBody.Create(KraftPhysics);
|
||||
if (Index=0) or (Index=(Count-1)) then begin
|
||||
RigidBodyBox[Index].SetRigidBodyType(krbtSTATIC);
|
||||
end else begin
|
||||
RigidBodyBox[Index].SetRigidBodyType(krbtDYNAMIC);
|
||||
end;
|
||||
ShapeBox:=TKraftShapeBox.Create(KraftPhysics,RigidBodyBox[Index],Vector3(0.5,0.1,1.0));
|
||||
ShapeBox.Restitution:=0.3;
|
||||
ShapeBox.Density:=100.0;
|
||||
RigidBodyBox[Index].Finish;
|
||||
RigidBodyBox[Index].SetWorldTransformation(Matrix4x4Translate(((ShapeBox.Extents.x*2.0)+Spacing)*(Index-((Count-1)*0.5)),5.0,-4.0));
|
||||
RigidBodyBox[Index].CollisionGroups:=[0];
|
||||
end;
|
||||
|
||||
for Index:=1 to Count-1 do begin
|
||||
TKraftConstraintJointBallSocket.Create(KraftPhysics,RigidBodyBox[Index-1],RigidBodyBox[Index],Vector3(ShapeBox.Extents.x+(Spacing*0.5),0.0,-ShapeBox.Extents.z),Vector3(-(ShapeBox.Extents.x+(Spacing*0.5)),0.0,-ShapeBox.Extents.z));
|
||||
TKraftConstraintJointBallSocket.Create(KraftPhysics,RigidBodyBox[Index-1],RigidBodyBox[Index],Vector3(ShapeBox.Extents.x+(Spacing*0.5),0.0,ShapeBox.Extents.z),Vector3(-(ShapeBox.Extents.x+(Spacing*0.5)),0.0,ShapeBox.Extents.z));
|
||||
end;
|
||||
|
||||
end;
|
||||
|
||||
destructor TDemoSceneBridge.Destroy;
|
||||
begin
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
procedure TDemoSceneBridge.Step(const DeltaTime:double);
|
||||
begin
|
||||
end;
|
||||
|
||||
initialization
|
||||
RegisterDemoScene('Bridge',TDemoSceneBridge);
|
||||
end.
|
||||
142
sandbox/UnitDemoSceneCar.pas
Normal file
142
sandbox/UnitDemoSceneCar.pas
Normal file
|
|
@ -0,0 +1,142 @@
|
|||
unit UnitDemoSceneCar;
|
||||
|
||||
{$MODE Delphi}
|
||||
|
||||
interface
|
||||
|
||||
uses Math,Kraft,UnitDemoScene;
|
||||
|
||||
type TDemoSceneCar=class(TDemoScene)
|
||||
public
|
||||
RigidBodyFloor:TKraftRigidBody;
|
||||
ShapeFloorPlane:TKraftShapePlane;
|
||||
ChassisRigidBody:TKraftRigidBody;
|
||||
WheelRigidBodies:array[0..1,0..1] of TKraftRigidBody;
|
||||
WheelHingeJointConstraints:array[0..1,0..1] of TKraftConstraintJointHinge;
|
||||
CarSteering:double;
|
||||
CarSpeed:double;
|
||||
Time:double;
|
||||
constructor Create(const AKraftPhysics:TKraft); override;
|
||||
destructor Destroy; override;
|
||||
procedure Step(const DeltaTime:double); override;
|
||||
end;
|
||||
|
||||
implementation
|
||||
|
||||
uses UnitFormMain;
|
||||
|
||||
const CarWidth=2.0;
|
||||
CarLength=4.0;
|
||||
|
||||
CarHalfWidth=CarWidth*0.5;
|
||||
|
||||
constructor TDemoSceneCar.Create(const AKraftPhysics:TKraft);
|
||||
const WheelPositions:array[0..1,0..1] of TKraftVector3=(((x:CarHalfWidth;y:0.75;z:-CarLength),
|
||||
(x:-CarHalfWidth;y:0.75;z:-CarLength)),
|
||||
((x:CarHalfWidth;y:0.75;z:0.0),
|
||||
(x:-CarHalfWidth;y:0.75;z:0.0)));
|
||||
var Index,x,y:longint;
|
||||
Shape:TKraftShape;
|
||||
begin
|
||||
inherited Create(AKraftPhysics);
|
||||
|
||||
CarSteering:=0.0;
|
||||
Time:=0.0;
|
||||
|
||||
RigidBodyFloor:=TKraftRigidBody.Create(KraftPhysics);
|
||||
RigidBodyFloor.SetRigidBodyType(krbtSTATIC);
|
||||
ShapeFloorPlane:=TKraftShapePlane.Create(KraftPhysics,RigidBodyFloor,Plane(Vector3Norm(Vector3(0.0,1.0,0.0)),0.0));
|
||||
ShapeFloorPlane.Restitution:=0.3;
|
||||
RigidBodyFloor.Finish;
|
||||
RigidBodyFloor.SetWorldTransformation(Matrix4x4Translate(0.0,0.0,0.0));
|
||||
RigidBodyFloor.CollisionGroups:=[0];
|
||||
|
||||
begin
|
||||
ChassisRigidBody:=TKraftRigidBody.Create(KraftPhysics);
|
||||
ChassisRigidBody.SetRigidBodyType(krbtDYNAMIC);
|
||||
Shape:=TKraftShapeBox.Create(KraftPhysics,ChassisRigidBody,Vector3(1.0,0.5,3.0));
|
||||
Shape.Restitution:=0.3;
|
||||
Shape.Density:=10.0;
|
||||
Shape.LocalTransform:=Matrix4x4Translate(0.0,0.25,0.0);
|
||||
Shape:=TKraftShapeBox.Create(KraftPhysics,ChassisRigidBody,Vector3(1.0,1.0,2.0));
|
||||
Shape.Restitution:=0.3;
|
||||
Shape.Density:=10.0;
|
||||
Shape.LocalTransform:=Matrix4x4Translate(0.0,1.75,1.0);
|
||||
ChassisRigidBody.Finish;
|
||||
ChassisRigidBody.SetWorldTransformation(Matrix4x4Translate(0.0,1.25,-2.0));
|
||||
ChassisRigidBody.CollisionGroups:=[0];
|
||||
ChassisRigidBody.AngularVelocityDamp:=10.0;
|
||||
ChassisRigidBody.LinearVelocityDamp:=0.05;
|
||||
end;
|
||||
|
||||
for y:=0 to 1 do begin
|
||||
|
||||
for x:=0 to 1 do begin
|
||||
|
||||
WheelRigidBodies[y,x]:=TKraftRigidBody.Create(KraftPhysics);
|
||||
WheelRigidBodies[y,x].SetRigidBodyType(krbtDYNAMIC);
|
||||
Shape:=TKraftShapeSphere.Create(KraftPhysics,WheelRigidBodies[y,x],0.75);
|
||||
Shape.Restitution:=0.3;
|
||||
Shape.Density:=1.0;
|
||||
WheelRigidBodies[y,x].Finish;
|
||||
WheelRigidBodies[y,x].SetWorldTransformation(Matrix4x4Translate(WheelPositions[y,x]));
|
||||
WheelRigidBodies[y,x].CollisionGroups:=[0];
|
||||
WheelRigidBodies[y,x].AngularVelocityDamp:=10.0;
|
||||
WheelRigidBodies[y,x].LinearVelocityDamp:=0.05;
|
||||
|
||||
WheelHingeJointConstraints[y,x]:=TKraftConstraintJointHinge.Create(KraftPhysics,
|
||||
ChassisRigidBody,
|
||||
WheelRigidBodies[y,x],
|
||||
WheelPositions[y,x],
|
||||
Vector3Norm(Vector3(1.0,0.0,0.0)),
|
||||
false,
|
||||
false,
|
||||
-1.0,
|
||||
1.0,
|
||||
1.0,
|
||||
0.0,
|
||||
false);
|
||||
|
||||
end;
|
||||
end;
|
||||
|
||||
end;
|
||||
|
||||
destructor TDemoSceneCar.Destroy;
|
||||
begin
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
procedure TDemoSceneCar.Step(const DeltaTime:double);
|
||||
const Signs:array[0..1] of longint=(1,-1);
|
||||
var x,y:longint;
|
||||
CarAngle,Radius:double;
|
||||
SideRadius:array[0..1] of single;
|
||||
AxisVectors:array[0..1,0..1] of TKraftVector3;
|
||||
begin
|
||||
Time:=Time+DeltaTime;
|
||||
CarSteering:=sin((Time*0.015625)*(2.0*pi))*10.0;
|
||||
CarSpeed:=4.0;
|
||||
CarAngle:=Min(Max(CarSteering,-1.0),1.0)*30.0;
|
||||
if abs(CarAngle)>EPSILON then begin
|
||||
Radius:=tan(CarAngle*DEG2RAD);
|
||||
end else begin
|
||||
Radius:=tan(EPSILON*DEG2RAD);
|
||||
end;
|
||||
Radius:=CarLength/Radius;
|
||||
SideRadius[0]:=arctan(CarLength/(Radius-CarHalfWidth));
|
||||
SideRadius[1]:=arctan(CarLength/(Radius+CarHalfWidth));
|
||||
for y:=0 to 1 do begin
|
||||
for x:=0 to 1 do begin
|
||||
AxisVectors[y,x]:=Vector3TermMatrixMulBasis(Vector3Norm(Vector3(cos(SideRadius[x]),0.0,sin(SideRadius[x])*Signs[y])),ChassisRigidBody.WorldTransform);
|
||||
WheelHingeJointConstraints[y,x].SetWorldRotationAxis(AxisVectors[y,x]);
|
||||
WheelRigidBodies[y,x].SetWorldAngularVelocity(Vector3TermMatrixMul(Vector3ScalarMul(AxisVectors[y,x],-CarSpeed),WheelRigidBodies[y,x].WorldInverseInertiaTensor),kfmVelocity);
|
||||
WheelRigidBodies[y,x].SetToAwake;
|
||||
end;
|
||||
end;
|
||||
ChassisRigidBody.SetToAwake;
|
||||
end;
|
||||
|
||||
initialization
|
||||
RegisterDemoScene('Car',TDemoSceneCar);
|
||||
end.
|
||||
187
sandbox/UnitDemoSceneCarousel.pas
Normal file
187
sandbox/UnitDemoSceneCarousel.pas
Normal file
|
|
@ -0,0 +1,187 @@
|
|||
unit UnitDemoSceneCarousel;
|
||||
|
||||
{$MODE Delphi}
|
||||
|
||||
interface
|
||||
|
||||
uses Kraft,UnitDemoScene;
|
||||
|
||||
type TDemoSceneCarousel=class(TDemoScene)
|
||||
public
|
||||
RigidBodyFloor:TKraftRigidBody;
|
||||
ShapeFloorPlane:TKraftShapePlane;
|
||||
RigidBodyCarouselTopBasis:TKraftRigidBody;
|
||||
constructor Create(const AKraftPhysics:TKraft); override;
|
||||
destructor Destroy; override;
|
||||
procedure Step(const DeltaTime:double); override;
|
||||
end;
|
||||
|
||||
implementation
|
||||
|
||||
uses UnitFormMain;
|
||||
|
||||
constructor TDemoSceneCarousel.Create(const AKraftPhysics:TKraft);
|
||||
const Count=4;
|
||||
Spacing=0.125;
|
||||
CarouselDownBasisPointsPerCircle=16;
|
||||
CarouselDownBasisCircleRadius=1.5;
|
||||
CarouselDownBasisHeight=0.5;
|
||||
CarouselTopBasisPointsPerCircle=16;
|
||||
CarouselTopBasisCircleRadius=3.0;
|
||||
CarouselTopBasisHeight=0.25;
|
||||
CountChainSpheres=4;
|
||||
var Index,EdgeIndex,SubIndex:longint;
|
||||
RigidBody:array[0..CountChainSpheres-1] of TKraftRigidBody;
|
||||
RigidBodySphere:TKraftRigidBody;
|
||||
RigidBodySeat:TKraftRigidBody;
|
||||
ShapeSphere:TKraftShapeSphere;
|
||||
ShapeBox:TKraftShapeBox;
|
||||
ShapeCapsule:TKraftShapeCapsule;
|
||||
ShapeCarouselDownBasis,ShapeCarouselTopBasis:TKraftShapeConvexHull;
|
||||
RigidBodyCarouselDownBasis:TKraftRigidBody;
|
||||
ConvexHullCarouselDownBasis,ConvexHullCarouselTopBasis:TKraftConvexHull;
|
||||
v:TKraftScalar;
|
||||
m:TKraftMatrix4x4;
|
||||
vFrom,vTo:TKraftVector3;
|
||||
begin
|
||||
inherited Create(AKraftPhysics);
|
||||
|
||||
RigidBodyFloor:=TKraftRigidBody.Create(KraftPhysics);
|
||||
RigidBodyFloor.SetRigidBodyType(krbtSTATIC);
|
||||
ShapeFloorPlane:=TKraftShapePlane.Create(KraftPhysics,RigidBodyFloor,Plane(Vector3Norm(Vector3(0.0,1.0,0.0)),0.0));
|
||||
ShapeFloorPlane.Restitution:=0.3;
|
||||
RigidBodyFloor.Finish;
|
||||
RigidBodyFloor.SetWorldTransformation(Matrix4x4Translate(0.0,0.0,0.0));
|
||||
RigidBodyFloor.CollisionGroups:=[0];
|
||||
|
||||
RigidBodyCarouselDownBasis:=TKraftRigidBody.Create(KraftPhysics);
|
||||
RigidBodyCarouselDownBasis.SetRigidBodyType(krbtSTATIC);
|
||||
ConvexHullCarouselDownBasis:=TKraftConvexHull.Create(KraftPhysics);
|
||||
ConvexHullGarbageCollector.Add(ConvexHullCarouselDownBasis);
|
||||
for Index:=0 to CarouselDownBasisPointsPerCircle-1 do begin
|
||||
v:=(Index/CarouselDownBasisPointsPerCircle)*(pi*2.0);
|
||||
ConvexHullCarouselDownBasis.AddVertex(Vector3(sin(v)*CarouselDownBasisCircleRadius,-(CarouselDownBasisHeight*0.5),cos(v)*CarouselDownBasisCircleRadius));
|
||||
ConvexHullCarouselDownBasis.AddVertex(Vector3(sin(v)*CarouselDownBasisCircleRadius,CarouselDownBasisHeight*0.5,cos(v)*CarouselDownBasisCircleRadius));
|
||||
end;
|
||||
ConvexHullCarouselDownBasis.Build;
|
||||
ConvexHullCarouselDownBasis.Finish;
|
||||
ShapeCarouselDownBasis:=TKraftShapeConvexHull.Create(KraftPhysics,RigidBodyCarouselDownBasis,ConvexHullCarouselDownBasis);
|
||||
ShapeCarouselDownBasis.Restitution:=0.3;
|
||||
ShapeCarouselDownBasis.Density:=1.0;
|
||||
ShapeCarouselDownBasis.Finish;
|
||||
RigidBodyCarouselDownBasis.Finish;
|
||||
RigidBodyCarouselDownBasis.SetWorldTransformation(Matrix4x4Translate(0.0,CarouselDownBasisHeight*0.5,0.0));
|
||||
RigidBodyCarouselDownBasis.CollisionGroups:=[0];
|
||||
|
||||
RigidBodyCarouselTopBasis:=TKraftRigidBody.Create(KraftPhysics);
|
||||
RigidBodyCarouselTopBasis.SetRigidBodyType(krbtDYNAMIC);
|
||||
ConvexHullCarouselTopBasis:=TKraftConvexHull.Create(KraftPhysics);
|
||||
ConvexHullGarbageCollector.Add(ConvexHullCarouselTopBasis);
|
||||
for Index:=0 to CarouselTopBasisPointsPerCircle-1 do begin
|
||||
v:=(Index/CarouselTopBasisPointsPerCircle)*(pi*2.0);
|
||||
ConvexHullCarouselTopBasis.AddVertex(Vector3(sin(v)*CarouselTopBasisCircleRadius,-(CarouselTopBasisHeight*0.5),cos(v)*CarouselTopBasisCircleRadius));
|
||||
ConvexHullCarouselTopBasis.AddVertex(Vector3(sin(v)*CarouselTopBasisCircleRadius,CarouselTopBasisHeight*0.5,cos(v)*CarouselTopBasisCircleRadius));
|
||||
end;
|
||||
ConvexHullCarouselTopBasis.Build;
|
||||
ConvexHullCarouselTopBasis.Finish;
|
||||
ShapeCarouselTopBasis:=TKraftShapeConvexHull.Create(KraftPhysics,RigidBodyCarouselTopBasis,ConvexHullCarouselTopBasis);
|
||||
ShapeCarouselTopBasis.Restitution:=0.3;
|
||||
ShapeCarouselTopBasis.Density:=1.0;
|
||||
ShapeCarouselTopBasis.Friction:=1.0;
|
||||
ShapeCarouselTopBasis.Finish;
|
||||
ShapeCarouselTopBasis:=TKraftShapeConvexHull.Create(KraftPhysics,RigidBodyCarouselTopBasis,ConvexHullCarouselTopBasis);
|
||||
ShapeCarouselTopBasis.Restitution:=0.3;
|
||||
ShapeCarouselTopBasis.Density:=1.0;
|
||||
ShapeCarouselTopBasis.LocalTransform:=Matrix4x4Translate(0.0,2.75,0.0);
|
||||
ShapeCarouselTopBasis.Finish;
|
||||
begin
|
||||
ShapeCapsule:=TKraftShapeCapsule.Create(KraftPhysics,RigidBodyCarouselTopBasis,0.75,3.0);
|
||||
ShapeCapsule.LocalTransform:=Matrix4x4Translate(0.0,1.5,0.0);
|
||||
ShapeCapsule.Finish;
|
||||
end;
|
||||
{for Index:=0 to 7 do begin
|
||||
v:=(Index/8)*(pi*2.0);
|
||||
ShapeBox:=TKraftShapeBox.Create(KraftPhysics,RigidBodyCarouselTopBasis,Vector3(0.015625,1.5,0.125));
|
||||
ShapeBox.LocalTransform:=Matrix4x4TermMul(Matrix4x4Translate(CarouselTopBasisCircleRadius-0.25,1.5,0.0),Matrix4x4RotateY(v));
|
||||
ShapeBox.Finish;
|
||||
end;{}
|
||||
RigidBodyCarouselTopBasis.ForcedMass:=100.0;
|
||||
RigidBodyCarouselTopBasis.Finish;
|
||||
RigidBodyCarouselTopBasis.SetWorldTransformation(Matrix4x4Translate(0.0,CarouselDownBasisHeight+(CarouselTopBasisHeight*0.5),0.0));
|
||||
RigidBodyCarouselTopBasis.CollisionGroups:=[0];
|
||||
|
||||
TKraftConstraintJointHinge.Create(KraftPhysics,RigidBodyCarouselDownBasis,RigidBodyCarouselTopBasis,Vector3(0.0,CarouselDownBasisHeight,0.0),Vector3(0.0,1.0,0.0));
|
||||
|
||||
for Index:=0 to 7 do begin
|
||||
v:=(Index/8)*(pi*2.0);
|
||||
RigidBodySeat:=TKraftRigidBody.Create(KraftPhysics);
|
||||
RigidBodySeat.SetRigidBodyType(krbtDYNAMIC);
|
||||
ShapeBox:=TKraftShapeBox.Create(KraftPhysics,RigidBodySeat,Vector3(0.25,0.0625,0.25));
|
||||
ShapeBox.Finish;
|
||||
ShapeBox:=TKraftShapeBox.Create(KraftPhysics,RigidBodySeat,Vector3(0.0625,0.25,0.25));
|
||||
ShapeBox.LocalTransform:=Matrix4x4Translate(0.0625-0.25,0.0625+0.25,0.0);
|
||||
ShapeBox.Finish;
|
||||
ShapeBox:=TKraftShapeBox.Create(KraftPhysics,RigidBodySeat,Vector3(0.25,0.0625,0.03125));
|
||||
ShapeBox.LocalTransform:=Matrix4x4Translate(0.0,0.0625+0.0625,0.03125-0.25);
|
||||
ShapeBox.Finish;
|
||||
ShapeBox:=TKraftShapeBox.Create(KraftPhysics,RigidBodySeat,Vector3(0.25,0.0625,0.03125));
|
||||
ShapeBox.LocalTransform:=Matrix4x4Translate(0.0,0.0625+0.0625,-(0.03125-0.25));
|
||||
ShapeBox.Finish;
|
||||
RigidBodySeat.ForcedMass:=5.0;
|
||||
RigidBodySeat.Finish;
|
||||
m:=Matrix4x4TermMul(Matrix4x4Translate(0.0,CarouselDownBasisHeight+CarouselTopBasisHeight+0.5,CarouselTopBasisCircleRadius-1.0),Matrix4x4RotateY(v));
|
||||
RigidBodySeat.SetWorldTransformation(m);
|
||||
for EdgeIndex:=0 to 3 do begin
|
||||
case EdgeIndex of
|
||||
0:begin
|
||||
vFrom:=Vector3TermMatrixMul(Vector3(0.25,2.0,0.25),m);
|
||||
vTo:=Vector3TermMatrixMul(Vector3(0.25,0.5,0.25),m);
|
||||
end;
|
||||
1:begin
|
||||
vFrom:=Vector3TermMatrixMul(Vector3(-0.25,2.0,0.25),m);
|
||||
vTo:=Vector3TermMatrixMul(Vector3(-0.25,0.5,0.25),m);
|
||||
end;
|
||||
2:begin
|
||||
vFrom:=Vector3TermMatrixMul(Vector3(-0.25,2.0,-0.25),m);
|
||||
vTo:=Vector3TermMatrixMul(Vector3(-0.25,0.5,-0.25),m);
|
||||
end;
|
||||
else begin
|
||||
vFrom:=Vector3TermMatrixMul(Vector3(0.25,2.0,-0.25),m);
|
||||
vTo:=Vector3TermMatrixMul(Vector3(0.25,0.5,-0.25),m);
|
||||
end;
|
||||
end;
|
||||
for SubIndex:=0 to CountChainSpheres-1 do begin
|
||||
RigidBody[SubIndex]:=TKraftRigidBody.Create(KraftPhysics);
|
||||
RigidBody[SubIndex].SetRigidBodyType(krbtDYNAMIC);
|
||||
ShapeSphere:=TKraftShapeSphere.Create(KraftPhysics,RigidBody[SubIndex],0.1);
|
||||
ShapeSphere.Restitution:=0.3;
|
||||
ShapeSphere.Density:=1.0;
|
||||
RigidBody[SubIndex].Finish;
|
||||
RigidBody[SubIndex].SetWorldTransformation(Matrix4x4Translate(Vector3Lerp(vTo,vFrom,SubIndex/CountChainSpheres)));
|
||||
RigidBody[SubIndex].CollisionGroups:=[0];
|
||||
end;
|
||||
for SubIndex:=1 to CountChainSpheres-1 do begin
|
||||
TKraftConstraintJointBallSocket.Create(KraftPhysics,RigidBody[SubIndex-1],RigidBody[SubIndex],Vector3Lerp(PKraftVector3(pointer(@RigidBody[SubIndex].WorldTransform[3,0]))^,PKraftVector3(pointer(@RigidBody[SubIndex-1].WorldTransform[3,0]))^,0.5),true);
|
||||
end;
|
||||
TKraftConstraintJointBallSocket.Create(KraftPhysics,RigidBodyCarouselTopBasis,RigidBody[CountChainSpheres-1],vFrom,true);
|
||||
TKraftConstraintJointBallSocket.Create(KraftPhysics,RigidBodySeat,RigidBody[0],vTo,false);
|
||||
end;
|
||||
RigidBodySeat.CollisionGroups:=[0];
|
||||
end;
|
||||
|
||||
end;
|
||||
|
||||
destructor TDemoSceneCarousel.Destroy;
|
||||
begin
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
procedure TDemoSceneCarousel.Step(const DeltaTime:double);
|
||||
begin
|
||||
RigidBodyCarouselTopBasis.SetBodyTorque(Vector3(0.0,1.25,0.0),kfmAcceleration);
|
||||
end;
|
||||
|
||||
initialization
|
||||
RegisterDemoScene('Carousel',TDemoSceneCarousel);
|
||||
end.
|
||||
|
||||
114
sandbox/UnitDemoSceneCatapult.pas
Normal file
114
sandbox/UnitDemoSceneCatapult.pas
Normal file
|
|
@ -0,0 +1,114 @@
|
|||
unit UnitDemoSceneCatapult;
|
||||
|
||||
{$MODE Delphi}
|
||||
|
||||
interface
|
||||
|
||||
uses Kraft,UnitDemoScene;
|
||||
|
||||
type TDemoSceneCatapult=class(TDemoScene)
|
||||
public
|
||||
RigidBodyFloor:TKraftRigidBody;
|
||||
ShapeFloorPlane:TKraftShapePlane;
|
||||
constructor Create(const AKraftPhysics:TKraft); override;
|
||||
destructor Destroy; override;
|
||||
procedure Step(const DeltaTime:double); override;
|
||||
end;
|
||||
|
||||
implementation
|
||||
|
||||
uses UnitFormMain;
|
||||
|
||||
constructor TDemoSceneCatapult.Create(const AKraftPhysics:TKraft);
|
||||
const Count=4;
|
||||
Spacing=0.125;
|
||||
var Index:longint;
|
||||
RigidBodyBox:array[0..Count-1] of TKraftRigidBody;
|
||||
ShapeBox:TKraftShapeBox;
|
||||
RigidBodyCapsule:TKraftRigidBody;
|
||||
ShapeCapsule:TKraftShapeCapsule;
|
||||
|
||||
begin
|
||||
inherited Create(AKraftPhysics);
|
||||
|
||||
RigidBodyFloor:=TKraftRigidBody.Create(KraftPhysics);
|
||||
RigidBodyFloor.SetRigidBodyType(krbtSTATIC);
|
||||
ShapeFloorPlane:=TKraftShapePlane.Create(KraftPhysics,RigidBodyFloor,Plane(Vector3Norm(Vector3(0.0,1.0,0.0)),0.0));
|
||||
ShapeFloorPlane.Restitution:=0.3;
|
||||
RigidBodyFloor.Finish;
|
||||
RigidBodyFloor.SetWorldTransformation(Matrix4x4Translate(0.0,0.0,0.0));
|
||||
RigidBodyFloor.CollisionGroups:=[0];
|
||||
|
||||
RigidBodyCapsule:=TKraftRigidBody.Create(KraftPhysics);
|
||||
RigidBodyCapsule.SetRigidBodyType(krbtSTATIC);
|
||||
ShapeCapsule:=TKraftShapeCapsule.Create(KraftPhysics,RigidBodyCapsule,0.25,2.0);
|
||||
ShapeCapsule.Restitution:=0.3;
|
||||
RigidBodyCapsule.Finish;
|
||||
RigidBodyCapsule.CollisionGroups:=[0];
|
||||
RigidBodyCapsule.SetWorldTransformation(Matrix4x4TermMul(Matrix4x4RotateX(0.5*pi),Matrix4x4Translate(0.0,0.5,0.0)));
|
||||
|
||||
RigidBodyBox[0]:=TKraftRigidBody.Create(KraftPhysics);
|
||||
RigidBodyBox[0].SetRigidBodyType(krbtDYNAMIC);
|
||||
ShapeBox:=TKraftShapeBox.Create(KraftPhysics,RigidBodyBox[0],Vector3(2.0,0.1,1.0));
|
||||
ShapeBox.Restitution:=0.3;
|
||||
//ShapeBox.Density:=100.0;
|
||||
RigidBodyBox[0].Finish;
|
||||
RigidBodyBox[0].SetWorldTransformation(Matrix4x4Translate(0.0,1.0,0.0));
|
||||
RigidBodyBox[0].CollisionGroups:=[0];
|
||||
|
||||
RigidBodyBox[1]:=TKraftRigidBody.Create(KraftPhysics);
|
||||
RigidBodyBox[1].SetRigidBodyType(krbtDYNAMIC);
|
||||
ShapeBox:=TKraftShapeBox.Create(KraftPhysics,RigidBodyBox[1],Vector3(0.5,0.5,0.5));
|
||||
ShapeBox.Restitution:=0.3;
|
||||
ShapeBox.Density:=50.0;
|
||||
RigidBodyBox[1].Finish;
|
||||
RigidBodyBox[1].SetWorldTransformation(Matrix4x4Translate(1.5,8.0,0.0));
|
||||
RigidBodyBox[1].CollisionGroups:=[0];
|
||||
|
||||
RigidBodyBox[2]:=TKraftRigidBody.Create(KraftPhysics);
|
||||
RigidBodyBox[2].SetRigidBodyType(krbtDYNAMIC);
|
||||
ShapeBox:=TKraftShapeBox.Create(KraftPhysics,RigidBodyBox[2],Vector3(0.25,0.25,0.25));
|
||||
ShapeBox.Restitution:=0.3;
|
||||
ShapeBox.Density:=50.0;
|
||||
RigidBodyBox[2].Finish;
|
||||
RigidBodyBox[2].SetWorldTransformation(Matrix4x4Translate(-1.5,1.25,0.0));
|
||||
RigidBodyBox[2].CollisionGroups:=[0];
|
||||
|
||||
TKraftConstraintJointHinge.Create(KraftPhysics,RigidBodyCapsule,RigidBodyBox[0],Vector3(0.0,0.5,0.0),Vector3(0.0,0.0,1.0));
|
||||
|
||||
{for Index:=0 to Count-1 do begin
|
||||
RigidBodyBox[Index]:=TKraftRigidBody.Create(KraftPhysics);
|
||||
if (Index=0) or (Index=(Count-1)) then begin
|
||||
RigidBodyBox[Index].SetRigidBodyType(krbtSTATIC);
|
||||
end else begin
|
||||
RigidBodyBox[Index].SetRigidBodyType(krbtDYNAMIC);
|
||||
end;
|
||||
ShapeBox:=TKraftShapeBox.Create(KraftPhysics,RigidBodyBox[Index],Vector3(0.5,0.1,1.0));
|
||||
ShapeBox.Restitution:=0.3;
|
||||
ShapeBox.Density:=100.0;
|
||||
RigidBodyBox[Index].Finish;
|
||||
RigidBodyBox[Index].SetWorldTransformation(Matrix4x4Translate(((ShapeBox.Extents.x*2.0)+Spacing)*(Index-((Count-1)*0.5)),5.0,-4.0));
|
||||
RigidBodyBox[Index].CollisionGroups:=[0];
|
||||
end;}
|
||||
|
||||
{
|
||||
for Index:=1 to Count-1 do begin
|
||||
TKraftConstraintJointBallSocket.Create(KraftPhysics,RigidBodyBox[Index-1],RigidBodyBox[Index],Vector3(ShapeBox.Extents.x+(Spacing*0.5),0.0,-ShapeBox.Extents.z),Vector3(-(ShapeBox.Extents.x+(Spacing*0.5)),0.0,-ShapeBox.Extents.z));
|
||||
TKraftConstraintJointBallSocket.Create(KraftPhysics,RigidBodyBox[Index-1],RigidBodyBox[Index],Vector3(ShapeBox.Extents.x+(Spacing*0.5),0.0,ShapeBox.Extents.z),Vector3(-(ShapeBox.Extents.x+(Spacing*0.5)),0.0,ShapeBox.Extents.z));
|
||||
end;
|
||||
{}
|
||||
|
||||
end;
|
||||
|
||||
destructor TDemoSceneCatapult.Destroy;
|
||||
begin
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
procedure TDemoSceneCatapult.Step(const DeltaTime:double);
|
||||
begin
|
||||
end;
|
||||
|
||||
initialization
|
||||
RegisterDemoScene('Catapult',TDemoSceneCatapult);
|
||||
end.
|
||||
85
sandbox/UnitDemoSceneChain.pas
Normal file
85
sandbox/UnitDemoSceneChain.pas
Normal file
|
|
@ -0,0 +1,85 @@
|
|||
unit UnitDemoSceneChain;
|
||||
|
||||
{$MODE Delphi}
|
||||
|
||||
interface
|
||||
|
||||
uses Kraft,UnitDemoScene;
|
||||
|
||||
type TDemoSceneChain=class(TDemoScene)
|
||||
public
|
||||
RigidBodyFloor:TKraftRigidBody;
|
||||
ShapeFloorPlane:TKraftShapePlane;
|
||||
constructor Create(const AKraftPhysics:TKraft); override;
|
||||
destructor Destroy; override;
|
||||
procedure Step(const DeltaTime:double); override;
|
||||
end;
|
||||
|
||||
implementation
|
||||
|
||||
uses UnitFormMain;
|
||||
|
||||
constructor TDemoSceneChain.Create(const AKraftPhysics:TKraft);
|
||||
const Count=11;
|
||||
Spacing=0.125;
|
||||
var Index:longint;
|
||||
RigidBody:array[0..Count-1] of TKraftRigidBody;
|
||||
Shape:TKraftShape;
|
||||
begin
|
||||
inherited Create(AKraftPhysics);
|
||||
|
||||
RigidBodyFloor:=TKraftRigidBody.Create(KraftPhysics);
|
||||
RigidBodyFloor.SetRigidBodyType(krbtSTATIC);
|
||||
ShapeFloorPlane:=TKraftShapePlane.Create(KraftPhysics,RigidBodyFloor,Plane(Vector3Norm(Vector3(0.0,1.0,0.0)),0.0));
|
||||
ShapeFloorPlane.Restitution:=0.3;
|
||||
RigidBodyFloor.Finish;
|
||||
RigidBodyFloor.SetWorldTransformation(Matrix4x4Translate(0.0,0.0,0.0));
|
||||
RigidBodyFloor.CollisionGroups:=[0];
|
||||
|
||||
for Index:=0 to Count-1 do begin
|
||||
RigidBody[Index]:=TKraftRigidBody.Create(KraftPhysics);
|
||||
if (Index=0) or (Index=(Count-1)) then begin
|
||||
RigidBody[Index].SetRigidBodyType(krbtSTATIC);
|
||||
end else begin
|
||||
RigidBody[Index].SetRigidBodyType(krbtDYNAMIC);
|
||||
end;
|
||||
Shape:=TKraftShapeSphere.Create(KraftPhysics,RigidBody[Index],1.0);
|
||||
Shape.Restitution:=0.3;
|
||||
Shape.Density:=1.0;
|
||||
RigidBody[Index].Finish;
|
||||
RigidBody[Index].SetWorldTransformation(Matrix4x4Translate((Index-((Count-1)*0.5))*2.25,7.0,-4.0));
|
||||
RigidBody[Index].CollisionGroups:=[0];
|
||||
end;
|
||||
|
||||
for Index:=1 to Count-1 do begin
|
||||
|
||||
// This is the most cheap way to construct a chain
|
||||
TKraftConstraintJointBallSocket.Create(KraftPhysics,RigidBody[Index-1],RigidBody[Index],Vector3(1.25,0.0,0.0),Vector3(-1.25,0.0,0.0),true);
|
||||
|
||||
{ // This is a better way to construct a chain, but attention:
|
||||
// TKraftConstraintJointDistance needs soft constraint damping and frequency constants fine tuning and a comparably high world update frequency,
|
||||
// but the soft constraint frequency must be smaller than the half of the world update frequency, because of the Nyquist theorem.
|
||||
TKraftConstraintJointDistance.Create(KraftPhysics,RigidBody[Index-1],RigidBody[Index],Vector3(1.0,0.0,0.0),Vector3(-1.0,0.0,0.0),10.0,1.0,true);
|
||||
{}
|
||||
|
||||
{ // This is also a better way to construct a chain, but attention:
|
||||
// TKraftConstraintJointRope needs high counts of velocity and position iterations at a so such long chain, for to being stable!
|
||||
TKraftConstraintJointRope.Create(KraftPhysics,RigidBody[Index-1],RigidBody[Index],Vector3(1.0,0.0,0.0),Vector3(-1.0,0.0,0.0),0.5,true);
|
||||
{}
|
||||
|
||||
end;
|
||||
|
||||
end;
|
||||
|
||||
destructor TDemoSceneChain.Destroy;
|
||||
begin
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
procedure TDemoSceneChain.Step(const DeltaTime:double);
|
||||
begin
|
||||
end;
|
||||
|
||||
initialization
|
||||
RegisterDemoScene('Chain',TDemoSceneChain);
|
||||
end.
|
||||
141
sandbox/UnitDemoSceneChairAndTable.pas
Normal file
141
sandbox/UnitDemoSceneChairAndTable.pas
Normal file
|
|
@ -0,0 +1,141 @@
|
|||
unit UnitDemoSceneChairAndTable;
|
||||
|
||||
{$MODE Delphi}
|
||||
|
||||
interface
|
||||
|
||||
uses Kraft,UnitDemoScene;
|
||||
|
||||
type TDemoSceneChairAndTable=class(TDemoScene)
|
||||
public
|
||||
RigidBodyFloor:TKraftRigidBody;
|
||||
ShapeFloorPlane:TKraftShapePlane;
|
||||
constructor Create(const AKraftPhysics:TKraft); override;
|
||||
destructor Destroy; override;
|
||||
procedure Step(const DeltaTime:double); override;
|
||||
end;
|
||||
|
||||
implementation
|
||||
|
||||
uses UnitFormMain;
|
||||
|
||||
constructor TDemoSceneChairAndTable.Create(const AKraftPhysics:TKraft);
|
||||
var RigidBody:TKraftRigidBody;
|
||||
Shape:TKraftShape;
|
||||
begin
|
||||
inherited Create(AKraftPhysics);
|
||||
|
||||
RigidBodyFloor:=TKraftRigidBody.Create(KraftPhysics);
|
||||
RigidBodyFloor.SetRigidBodyType(krbtSTATIC);
|
||||
ShapeFloorPlane:=TKraftShapePlane.Create(KraftPhysics,RigidBodyFloor,Plane(Vector3Norm(Vector3(0.0,1.0,0.0)),0.0));
|
||||
ShapeFloorPlane.Restitution:=0.3;
|
||||
RigidBodyFloor.Finish;
|
||||
RigidBodyFloor.SetWorldTransformation(Matrix4x4Translate(0.0,0.0,0.0));
|
||||
RigidBodyFloor.CollisionGroups:=[0];
|
||||
|
||||
begin
|
||||
RigidBody:=TKraftRigidBody.Create(KraftPhysics);
|
||||
RigidBody.SetRigidBodyType(krbtDYNAMIC);
|
||||
|
||||
Shape:=TKraftShapeBox.Create(KraftPhysics,RigidBody,Vector3(0.25,1.0,0.25));
|
||||
Shape.Restitution:=0.3;
|
||||
Shape.Density:=1.0;
|
||||
Shape.LocalTransform:=Matrix4x4Translate(-0.75,0.0,0.75);
|
||||
|
||||
Shape:=TKraftShapeBox.Create(KraftPhysics,RigidBody,Vector3(0.25,1.0,0.25));
|
||||
Shape.Restitution:=0.3;
|
||||
Shape.Density:=1.0;
|
||||
Shape.LocalTransform:=Matrix4x4Translate(0.75,0.0,0.75);
|
||||
|
||||
Shape:=TKraftShapeBox.Create(KraftPhysics,RigidBody,Vector3(0.25,1.0,0.25));
|
||||
Shape.Restitution:=0.3;
|
||||
Shape.Density:=1.0;
|
||||
Shape.LocalTransform:=Matrix4x4Translate(-0.75,0.0,-0.75);
|
||||
|
||||
Shape:=TKraftShapeBox.Create(KraftPhysics,RigidBody,Vector3(0.25,1.0,0.25));
|
||||
Shape.Restitution:=0.3;
|
||||
Shape.Density:=1.0;
|
||||
Shape.LocalTransform:=Matrix4x4Translate(0.75,0.0,-0.75);
|
||||
|
||||
Shape:=TKraftShapeBox.Create(KraftPhysics,RigidBody,Vector3(1.0,0.25,1.0));
|
||||
Shape.Restitution:=0.3;
|
||||
Shape.Density:=1.0;
|
||||
Shape.LocalTransform:=Matrix4x4Translate(0.0,1.25,0.0);
|
||||
|
||||
Shape:=TKraftShapeBox.Create(KraftPhysics,RigidBody,Vector3(0.25,1.0,0.25));
|
||||
Shape.Restitution:=0.3;
|
||||
Shape.Density:=1.0;
|
||||
Shape.LocalTransform:=Matrix4x4Translate(-0.75,2.5,-0.75);
|
||||
|
||||
Shape:=TKraftShapeBox.Create(KraftPhysics,RigidBody,Vector3(0.25,1.0,0.25));
|
||||
Shape.Restitution:=0.3;
|
||||
Shape.Density:=1.0;
|
||||
Shape.LocalTransform:=Matrix4x4Translate(0.75,2.5,-0.75);
|
||||
|
||||
Shape:=TKraftShapeBox.Create(KraftPhysics,RigidBody,Vector3(0.25,1.0,0.25));
|
||||
Shape.Restitution:=0.3;
|
||||
Shape.Density:=1.0;
|
||||
Shape.LocalTransform:=Matrix4x4Translate(0.0,2.5,-0.75);
|
||||
|
||||
Shape:=TKraftShapeBox.Create(KraftPhysics,RigidBody,Vector3(1.0,0.25,0.25));
|
||||
Shape.Restitution:=0.3;
|
||||
Shape.Density:=1.0;
|
||||
Shape.LocalTransform:=Matrix4x4Translate(0.0,3.75,-0.75);
|
||||
|
||||
RigidBody.ForcedMass:=10.0;
|
||||
|
||||
RigidBody.Finish;
|
||||
RigidBody.SetWorldTransformation(Matrix4x4Translate(0.0,1.0,-2.0));
|
||||
RigidBody.CollisionGroups:=[0];
|
||||
|
||||
end;
|
||||
|
||||
begin
|
||||
RigidBody:=TKraftRigidBody.Create(KraftPhysics);
|
||||
RigidBody.SetRigidBodyType(krbtDYNAMIC);
|
||||
|
||||
Shape:=TKraftShapeBox.Create(KraftPhysics,RigidBody,Vector3(0.25,1.625,0.25));
|
||||
Shape.Restitution:=0.3;
|
||||
Shape.Density:=1.0;
|
||||
Shape.LocalTransform:=Matrix4x4Translate(-2.75,0.0,1.75);
|
||||
|
||||
Shape:=TKraftShapeBox.Create(KraftPhysics,RigidBody,Vector3(0.25,1.625,0.25));
|
||||
Shape.Restitution:=0.3;
|
||||
Shape.Density:=1.0;
|
||||
Shape.LocalTransform:=Matrix4x4Translate(2.75,0.0,1.75);
|
||||
|
||||
Shape:=TKraftShapeBox.Create(KraftPhysics,RigidBody,Vector3(0.25,1.625,0.25));
|
||||
Shape.Restitution:=0.3;
|
||||
Shape.Density:=1.0;
|
||||
Shape.LocalTransform:=Matrix4x4Translate(-2.75,0.0,-1.75);
|
||||
|
||||
Shape:=TKraftShapeBox.Create(KraftPhysics,RigidBody,Vector3(0.25,1.625,0.25));
|
||||
Shape.Restitution:=0.3;
|
||||
Shape.Density:=1.0;
|
||||
Shape.LocalTransform:=Matrix4x4Translate(2.75,0.0,-1.75);
|
||||
|
||||
Shape:=TKraftShapeBox.Create(KraftPhysics,RigidBody,Vector3(3.0,0.25,2.0));
|
||||
Shape.Restitution:=0.3;
|
||||
Shape.Density:=1.0;
|
||||
Shape.LocalTransform:=Matrix4x4Translate(0.0,1.875,0.0);
|
||||
|
||||
RigidBody.Finish;
|
||||
RigidBody.SetWorldTransformation(Matrix4x4Translate(0.0,1.625,0.0));
|
||||
RigidBody.CollisionGroups:=[0];
|
||||
|
||||
end;
|
||||
|
||||
end;
|
||||
|
||||
destructor TDemoSceneChairAndTable.Destroy;
|
||||
begin
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
procedure TDemoSceneChairAndTable.Step(const DeltaTime:double);
|
||||
begin
|
||||
end;
|
||||
|
||||
initialization
|
||||
RegisterDemoScene('Chair and table',TDemoSceneChairAndTable);
|
||||
end.
|
||||
319
sandbox/UnitDemoSceneCombinedShapes.pas
Normal file
319
sandbox/UnitDemoSceneCombinedShapes.pas
Normal file
|
|
@ -0,0 +1,319 @@
|
|||
unit UnitDemoSceneCombinedShapes;
|
||||
|
||||
{$MODE Delphi}
|
||||
|
||||
interface
|
||||
|
||||
uses Kraft,UnitDemoScene;
|
||||
|
||||
type TDemoSceneCombinedShapes=class(TDemoScene)
|
||||
public
|
||||
RigidBodyFloor:TKraftRigidBody;
|
||||
ShapeFloorPlane:TKraftShapePlane;
|
||||
constructor Create(const AKraftPhysics:TKraft); override;
|
||||
destructor Destroy; override;
|
||||
procedure Step(const DeltaTime:double); override;
|
||||
end;
|
||||
|
||||
implementation
|
||||
|
||||
uses UnitFormMain;
|
||||
|
||||
constructor TDemoSceneCombinedShapes.Create(const AKraftPhysics:TKraft);
|
||||
var RigidBody:TKraftRigidBody;
|
||||
Shape:TKraftShape;
|
||||
begin
|
||||
inherited Create(AKraftPhysics);
|
||||
|
||||
RigidBodyFloor:=TKraftRigidBody.Create(KraftPhysics);
|
||||
RigidBodyFloor.SetRigidBodyType(krbtSTATIC);
|
||||
ShapeFloorPlane:=TKraftShapePlane.Create(KraftPhysics,RigidBodyFloor,Plane(Vector3Norm(Vector3(0.0,1.0,0.0)),0.0));
|
||||
ShapeFloorPlane.Restitution:=0.3;
|
||||
RigidBodyFloor.Finish;
|
||||
RigidBodyFloor.SetWorldTransformation(Matrix4x4Translate(0.0,0.0,0.0));
|
||||
RigidBodyFloor.CollisionGroups:=[0];
|
||||
|
||||
begin
|
||||
RigidBody:=TKraftRigidBody.Create(KraftPhysics);
|
||||
RigidBody.SetRigidBodyType(krbtDYNAMIC);
|
||||
|
||||
Shape:=TKraftShapeBox.Create(KraftPhysics,RigidBody,Vector3(1.0,1.0,1.0));
|
||||
Shape.Restitution:=0.3;
|
||||
Shape.Density:=1.0;
|
||||
Shape.LocalTransform:=Matrix4x4Translate(0.0,0.0,0.0);
|
||||
|
||||
Shape:=TKraftShapeBox.Create(KraftPhysics,RigidBody,Vector3(0.5,0.5,0.5));
|
||||
Shape.Restitution:=0.3;
|
||||
Shape.Density:=1.0;
|
||||
Shape.LocalTransform:=Matrix4x4Translate(0.0,1.0,0.0);
|
||||
|
||||
Shape:=TKraftShapeBox.Create(KraftPhysics,RigidBody,Vector3(0.5,0.5,0.5));
|
||||
Shape.Restitution:=0.3;
|
||||
Shape.Density:=1.0;
|
||||
Shape.LocalTransform:=Matrix4x4Translate(0.0,-1.0,0.0);
|
||||
|
||||
Shape:=TKraftShapeBox.Create(KraftPhysics,RigidBody,Vector3(0.5,0.5,0.5));
|
||||
Shape.Restitution:=0.3;
|
||||
Shape.Density:=1.0;
|
||||
Shape.LocalTransform:=Matrix4x4Translate(1.0,0.0,0.0);
|
||||
|
||||
Shape:=TKraftShapeBox.Create(KraftPhysics,RigidBody,Vector3(0.5,0.5,0.5));
|
||||
Shape.Restitution:=0.3;
|
||||
Shape.Density:=1.0;
|
||||
Shape.LocalTransform:=Matrix4x4Translate(-1.0,0.0,0.0);
|
||||
|
||||
Shape:=TKraftShapeBox.Create(KraftPhysics,RigidBody,Vector3(0.5,0.5,0.5));
|
||||
Shape.Restitution:=0.3;
|
||||
Shape.Density:=1.0;
|
||||
Shape.LocalTransform:=Matrix4x4Translate(0.0,0.0,1.0);
|
||||
|
||||
Shape:=TKraftShapeBox.Create(KraftPhysics,RigidBody,Vector3(0.5,0.5,0.5));
|
||||
Shape.Restitution:=0.3;
|
||||
Shape.Density:=1.0;
|
||||
Shape.LocalTransform:=Matrix4x4Translate(0.0,0.0,-1.0);
|
||||
|
||||
Shape:=TKraftShapeSphere.Create(KraftPhysics,RigidBody,0.5);
|
||||
Shape.Restitution:=0.3;
|
||||
Shape.Density:=1.0;
|
||||
Shape.LocalTransform:=Matrix4x4Translate(0.0,1.5,0.0);
|
||||
|
||||
Shape:=TKraftShapeSphere.Create(KraftPhysics,RigidBody,0.5);
|
||||
Shape.Restitution:=0.3;
|
||||
Shape.Density:=1.0;
|
||||
Shape.LocalTransform:=Matrix4x4Translate(0.0,-1.5,0.0);
|
||||
|
||||
Shape:=TKraftShapeSphere.Create(KraftPhysics,RigidBody,0.5);
|
||||
Shape.Restitution:=0.3;
|
||||
Shape.Density:=1.0;
|
||||
Shape.LocalTransform:=Matrix4x4Translate(1.5,0.0,0.0);
|
||||
|
||||
Shape:=TKraftShapeSphere.Create(KraftPhysics,RigidBody,0.5);
|
||||
Shape.Restitution:=0.3;
|
||||
Shape.Density:=1.0;
|
||||
Shape.LocalTransform:=Matrix4x4Translate(-1.5,0.0,0.0);
|
||||
|
||||
Shape:=TKraftShapeSphere.Create(KraftPhysics,RigidBody,0.5);
|
||||
Shape.Restitution:=0.3;
|
||||
Shape.Density:=1.0;
|
||||
Shape.LocalTransform:=Matrix4x4Translate(0.0,0.0,1.5);
|
||||
|
||||
Shape:=TKraftShapeSphere.Create(KraftPhysics,RigidBody,0.5);
|
||||
Shape.Restitution:=0.3;
|
||||
Shape.Density:=1.0;
|
||||
Shape.LocalTransform:=Matrix4x4Translate(0.0,0.0,-1.5);
|
||||
|
||||
RigidBody.Finish;
|
||||
RigidBody.SetWorldTransformation(Matrix4x4Translate(-3.0,2.5,0.0));
|
||||
RigidBody.CollisionGroups:=[0];
|
||||
|
||||
end;
|
||||
|
||||
begin
|
||||
RigidBody:=TKraftRigidBody.Create(KraftPhysics);
|
||||
RigidBody.SetRigidBodyType(krbtDYNAMIC);
|
||||
|
||||
Shape:=TKraftShapeSphere.Create(KraftPhysics,RigidBody,1.0);
|
||||
Shape.Restitution:=0.3;
|
||||
Shape.Density:=1.0;
|
||||
Shape.LocalTransform:=Matrix4x4Translate(0.0,0.0,0.0);
|
||||
|
||||
Shape:=TKraftShapeCapsule.Create(KraftPhysics,RigidBody,0.5,3.0);
|
||||
Shape.Restitution:=0.3;
|
||||
Shape.Density:=1.0;
|
||||
Shape.LocalTransform:=Matrix4x4Translate(0.0,0.0,0.0);
|
||||
|
||||
Shape:=TKraftShapeCapsule.Create(KraftPhysics,RigidBody,0.5,3.0);
|
||||
Shape.Restitution:=0.3;
|
||||
Shape.Density:=1.0;
|
||||
Shape.LocalTransform:=Matrix4x4RotateX(0.5*pi);
|
||||
|
||||
Shape:=TKraftShapeCapsule.Create(KraftPhysics,RigidBody,0.5,3.0);
|
||||
Shape.Restitution:=0.3;
|
||||
Shape.Density:=1.0;
|
||||
Shape.LocalTransform:=Matrix4x4RotateZ(0.5*pi);
|
||||
|
||||
Shape:=TKraftShapeCapsule.Create(KraftPhysics,RigidBody,0.25,3.0);
|
||||
Shape.Restitution:=0.3;
|
||||
Shape.Density:=1.0;
|
||||
Shape.LocalTransform:=Matrix4x4RotateX(0.25*pi);
|
||||
|
||||
Shape:=TKraftShapeCapsule.Create(KraftPhysics,RigidBody,0.25,3.0);
|
||||
Shape.Restitution:=0.3;
|
||||
Shape.Density:=1.0;
|
||||
Shape.LocalTransform:=Matrix4x4RotateX(0.75*pi);
|
||||
|
||||
Shape:=TKraftShapeCapsule.Create(KraftPhysics,RigidBody,0.25,3.0);
|
||||
Shape.Restitution:=0.3;
|
||||
Shape.Density:=1.0;
|
||||
Shape.LocalTransform:=Matrix4x4RotateZ(0.25*pi);
|
||||
|
||||
Shape:=TKraftShapeCapsule.Create(KraftPhysics,RigidBody,0.25,3.0);
|
||||
Shape.Restitution:=0.3;
|
||||
Shape.Density:=1.0;
|
||||
Shape.LocalTransform:=Matrix4x4RotateZ(0.75*pi);
|
||||
|
||||
RigidBody.Finish;
|
||||
RigidBody.SetWorldTransformation(Matrix4x4Translate(3.0,2.5,0.0));
|
||||
RigidBody.CollisionGroups:=[0];
|
||||
|
||||
end;
|
||||
|
||||
begin
|
||||
RigidBody:=TKraftRigidBody.Create(KraftPhysics);
|
||||
RigidBody.SetRigidBodyType(krbtDYNAMIC);
|
||||
|
||||
Shape:=TKraftShapeCapsule.Create(KraftPhysics,RigidBody,0.25,1.0);
|
||||
Shape.Restitution:=0.3;
|
||||
Shape.Density:=1.0;
|
||||
Shape.LocalTransform:=Matrix4x4TermMul(Matrix4x4RotateZ(0.5*pi),Matrix4x4Translate(0.0,0.0,0.5));
|
||||
|
||||
Shape:=TKraftShapeCapsule.Create(KraftPhysics,RigidBody,0.25,1.0);
|
||||
Shape.Restitution:=0.3;
|
||||
Shape.Density:=1.0;
|
||||
Shape.LocalTransform:=Matrix4x4TermMul(Matrix4x4RotateZ(0.5*pi),Matrix4x4Translate(0.0,0.0,-0.5));
|
||||
|
||||
Shape:=TKraftShapeCapsule.Create(KraftPhysics,RigidBody,0.25,1.0);
|
||||
Shape.Restitution:=0.3;
|
||||
Shape.Density:=1.0;
|
||||
Shape.LocalTransform:=Matrix4x4TermMul(Matrix4x4TermMul(Matrix4x4RotateZ(0.5*pi),Matrix4x4Translate(0.0,0.0,0.5)),Matrix4x4RotateY(0.5*pi));
|
||||
|
||||
Shape:=TKraftShapeCapsule.Create(KraftPhysics,RigidBody,0.25,1.0);
|
||||
Shape.Restitution:=0.3;
|
||||
Shape.Density:=1.0;
|
||||
Shape.LocalTransform:=Matrix4x4TermMul(Matrix4x4TermMul(Matrix4x4RotateZ(0.5*pi),Matrix4x4Translate(0.0,0.0,-0.5)),Matrix4x4RotateY(0.5*pi));
|
||||
|
||||
RigidBody.Finish;
|
||||
RigidBody.SetWorldTransformation(Matrix4x4Translate(0.0,1.0,-3.0));
|
||||
RigidBody.CollisionGroups:=[0];
|
||||
|
||||
end;
|
||||
|
||||
begin
|
||||
RigidBody:=TKraftRigidBody.Create(KraftPhysics);
|
||||
RigidBody.SetRigidBodyType(krbtDYNAMIC);
|
||||
|
||||
Shape:=TKraftShapeCapsule.Create(KraftPhysics,RigidBody,0.25,1.5);
|
||||
Shape.Restitution:=0.3;
|
||||
Shape.Density:=1.0;
|
||||
Shape.LocalTransform:=Matrix4x4RotateZ(0.5*pi);
|
||||
|
||||
Shape:=TKraftShapeSphere.Create(KraftPhysics,RigidBody,0.5);
|
||||
Shape.Restitution:=0.3;
|
||||
Shape.Density:=1.0;
|
||||
Shape.LocalTransform:=Matrix4x4Translate(-1.0,0.0,0.0);
|
||||
|
||||
Shape:=TKraftShapeSphere.Create(KraftPhysics,RigidBody,0.5);
|
||||
Shape.Restitution:=0.3;
|
||||
Shape.Density:=1.0;
|
||||
Shape.LocalTransform:=Matrix4x4Translate(1.0,0.0,0.0);
|
||||
|
||||
RigidBody.Finish;
|
||||
RigidBody.SetWorldTransformation(Matrix4x4Translate(0.0,1.0,0.0));
|
||||
RigidBody.CollisionGroups:=[0];
|
||||
|
||||
end;
|
||||
|
||||
begin
|
||||
RigidBody:=TKraftRigidBody.Create(KraftPhysics);
|
||||
RigidBody.SetRigidBodyType(krbtDYNAMIC);
|
||||
|
||||
Shape:=TKraftShapeCapsule.Create(KraftPhysics,RigidBody,0.25,3.0);
|
||||
Shape.Restitution:=0.3;
|
||||
Shape.Density:=0.5;
|
||||
Shape.LocalTransform:=Matrix4x4RotateZ(0.5*pi);
|
||||
|
||||
Shape:=TKraftShapeSphere.Create(KraftPhysics,RigidBody,2.0);
|
||||
Shape.Restitution:=0.3;
|
||||
Shape.Density:=0.5;
|
||||
Shape.LocalTransform:=Matrix4x4Translate(-3.0,0.0,0.0);
|
||||
|
||||
Shape:=TKraftShapeSphere.Create(KraftPhysics,RigidBody,2.0);
|
||||
Shape.Restitution:=0.3;
|
||||
Shape.Density:=1.0;
|
||||
Shape.LocalTransform:=Matrix4x4Translate(3.0,0.0,0.0);
|
||||
|
||||
RigidBody.Finish;
|
||||
RigidBody.SetWorldTransformation(Matrix4x4Translate(0.0,2.5,-8.0));
|
||||
RigidBody.CollisionGroups:=[0];
|
||||
|
||||
end;
|
||||
|
||||
begin
|
||||
RigidBody:=TKraftRigidBody.Create(KraftPhysics);
|
||||
RigidBody.SetRigidBodyType(krbtDYNAMIC);
|
||||
|
||||
Shape:=TKraftShapeCapsule.Create(KraftPhysics,RigidBody,0.25,3.0);
|
||||
Shape.Restitution:=0.3;
|
||||
Shape.Density:=0.5;
|
||||
Shape.LocalTransform:=Matrix4x4RotateZ(0.5*pi);
|
||||
|
||||
Shape:=TKraftShapeSphere.Create(KraftPhysics,RigidBody,2.0);
|
||||
Shape.Restitution:=0.3;
|
||||
Shape.Density:=0.5;
|
||||
Shape.LocalTransform:=Matrix4x4Translate(-3.0,0.0,0.0);
|
||||
|
||||
Shape:=TKraftShapeSphere.Create(KraftPhysics,RigidBody,2.0);
|
||||
Shape.Restitution:=0.3;
|
||||
Shape.Density:=1.0;
|
||||
Shape.LocalTransform:=Matrix4x4Translate(3.0,0.0,0.0);
|
||||
|
||||
RigidBody.Finish;
|
||||
RigidBody.SetWorldTransformation(Matrix4x4Translate(0.0,2.5,-12.0));
|
||||
RigidBody.CollisionGroups:=[0];
|
||||
|
||||
end;
|
||||
|
||||
begin
|
||||
RigidBody:=TKraftRigidBody.Create(KraftPhysics);
|
||||
RigidBody.SetRigidBodyType(krbtDYNAMIC);
|
||||
|
||||
Shape:=TKraftShapeBox.Create(KraftPhysics,RigidBody,Vector3(0.9,0.5,2.75));
|
||||
Shape.Friction:=0.8;
|
||||
Shape.Restitution:=0.3;
|
||||
Shape.Density:=1.0;
|
||||
Shape.LocalTransform:=Matrix4x4Translate(0.0,0.75,0.0);
|
||||
|
||||
Shape:=TKraftShapeBox.Create(KraftPhysics,RigidBody,Vector3(0.9,0.5,2.75));
|
||||
Shape.Friction:=0.8;
|
||||
Shape.Restitution:=0.3;
|
||||
Shape.Density:=1.0;
|
||||
Shape.LocalTransform:=Matrix4x4Translate(0.0,-0.75,0.0);
|
||||
|
||||
Shape:=TKraftShapeBox.Create(KraftPhysics,RigidBody,Vector3(0.9,1.25,1.75));
|
||||
Shape.Friction:=0.8;
|
||||
Shape.Restitution:=0.3;
|
||||
Shape.Density:=1.0;
|
||||
Shape.LocalTransform:=Matrix4x4Translate(0.0,0.0,0.0);
|
||||
|
||||
Shape:=TKraftShapeBox.Create(KraftPhysics,RigidBody,Vector3(0.9,1.25,0.5));
|
||||
Shape.Friction:=0.8;
|
||||
Shape.Restitution:=0.3;
|
||||
Shape.Density:=1.0;
|
||||
Shape.LocalTransform:=Matrix4x4Translate(0.0,0.0,2.75);
|
||||
|
||||
Shape:=TKraftShapeBox.Create(KraftPhysics,RigidBody,Vector3(0.9,1.25,0.5));
|
||||
Shape.Friction:=0.8;
|
||||
Shape.Restitution:=0.3;
|
||||
Shape.Density:=1.0;
|
||||
Shape.LocalTransform:=Matrix4x4Translate(0.0,0.0,-2.75);
|
||||
|
||||
RigidBody.Finish;
|
||||
RigidBody.SetWorldTransformation(Matrix4x4Translate(0.0,2.5,-10.0));
|
||||
RigidBody.CollisionGroups:=[0];
|
||||
|
||||
end;
|
||||
|
||||
end;
|
||||
|
||||
destructor TDemoSceneCombinedShapes.Destroy;
|
||||
begin
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
procedure TDemoSceneCombinedShapes.Step(const DeltaTime:double);
|
||||
begin
|
||||
end;
|
||||
|
||||
initialization
|
||||
RegisterDemoScene('Combined shapes',TDemoSceneCombinedShapes);
|
||||
end.
|
||||
71
sandbox/UnitDemoSceneConvexHull.pas
Normal file
71
sandbox/UnitDemoSceneConvexHull.pas
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
unit UnitDemoSceneConvexHull;
|
||||
|
||||
{$MODE Delphi}
|
||||
|
||||
interface
|
||||
|
||||
uses Kraft,UnitDemoScene;
|
||||
|
||||
type TDemoSceneConvexHull=class(TDemoScene)
|
||||
public
|
||||
RigidBodyFloor:TKraftRigidBody;
|
||||
ShapeFloorPlane:TKraftShapePlane;
|
||||
constructor Create(const AKraftPhysics:TKraft); override;
|
||||
destructor Destroy; override;
|
||||
procedure Step(const DeltaTime:double); override;
|
||||
end;
|
||||
|
||||
implementation
|
||||
|
||||
uses UnitFormMain;
|
||||
|
||||
const ConvexHullPoints:array[0..5] of TKraftVector3=((x:-2.0;y:1.0;z:1.0{$ifdef SIMD};w:0.0{$endif}),
|
||||
(x:2.0;y:0.0;z:0.0{$ifdef SIMD};w:0.0{$endif}),
|
||||
(x:1.0;y:-2.0;z:1.0{$ifdef SIMD};w:0.0{$endif}),
|
||||
(x:0.0;y:2.0;z:0.0{$ifdef SIMD};w:0.0{$endif}),
|
||||
(x:1.0;y:1.0;z:-2.0{$ifdef SIMD};w:0.0{$endif}),
|
||||
(x:0.0;y:0.0;z:2.0{$ifdef SIMD};w:0.0{$endif}));{}
|
||||
|
||||
constructor TDemoSceneConvexHull.Create(const AKraftPhysics:TKraft);
|
||||
var RigidBody:TKraftRigidBody;
|
||||
Shape:TKraftShape;
|
||||
ConvexHull:TKraftConvexHull;
|
||||
begin
|
||||
inherited Create(AKraftPhysics);
|
||||
|
||||
RigidBodyFloor:=TKraftRigidBody.Create(KraftPhysics);
|
||||
RigidBodyFloor.SetRigidBodyType(krbtSTATIC);
|
||||
ShapeFloorPlane:=TKraftShapePlane.Create(KraftPhysics,RigidBodyFloor,Plane(Vector3Norm(Vector3(0.0,1.0,0.0)),0.0));
|
||||
ShapeFloorPlane.Restitution:=0.3;
|
||||
RigidBodyFloor.Finish;
|
||||
RigidBodyFloor.SetWorldTransformation(Matrix4x4Translate(0.0,0.0,0.0));
|
||||
RigidBodyFloor.CollisionGroups:=[0];
|
||||
|
||||
RigidBody:=TKraftRigidBody.Create(KraftPhysics);
|
||||
RigidBody.SetRigidBodyType(krbtDYNAMIC);
|
||||
ConvexHull:=TKraftConvexHull.Create(KraftPhysics);
|
||||
ConvexHullGarbageCollector.Add(ConvexHull);
|
||||
ConvexHull.Load(pointer(@ConvexHullPoints),length(ConvexHullPoints));
|
||||
ConvexHull.Build;
|
||||
ConvexHull.Finish;
|
||||
Shape:=TKraftShapeConvexHull.Create(KraftPhysics,RigidBody,ConvexHull);
|
||||
Shape.Restitution:=0.3;
|
||||
Shape.Density:=1.0;
|
||||
RigidBody.Finish;
|
||||
RigidBody.SetWorldTransformation(Matrix4x4TermMul(Matrix4x4RotateZ(pi*0.25),Matrix4x4Translate(0.0,4.0,0.0)));
|
||||
RigidBody.CollisionGroups:=[0];
|
||||
|
||||
end;
|
||||
|
||||
destructor TDemoSceneConvexHull.Destroy;
|
||||
begin
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
procedure TDemoSceneConvexHull.Step(const DeltaTime:double);
|
||||
begin
|
||||
end;
|
||||
|
||||
initialization
|
||||
RegisterDemoScene('Convex hull',TDemoSceneConvexHull);
|
||||
end.
|
||||
79
sandbox/UnitDemoSceneDomino.pas
Normal file
79
sandbox/UnitDemoSceneDomino.pas
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
unit UnitDemoSceneDomino;
|
||||
|
||||
{$MODE Delphi}
|
||||
|
||||
interface
|
||||
|
||||
uses Kraft,UnitDemoScene;
|
||||
|
||||
type TDemoSceneDomino=class(TDemoScene)
|
||||
public
|
||||
RigidBodyFloor:TKraftRigidBody;
|
||||
ShapeFloorPlane:TKraftShapePlane;
|
||||
constructor Create(const AKraftPhysics:TKraft); override;
|
||||
destructor Destroy; override;
|
||||
procedure Step(const DeltaTime:double); override;
|
||||
end;
|
||||
|
||||
implementation
|
||||
|
||||
uses UnitFormMain;
|
||||
|
||||
constructor TDemoSceneDomino.Create(const AKraftPhysics:TKraft);
|
||||
const Count=64;
|
||||
var i:longint;
|
||||
RigidBody:TKraftRigidBody;
|
||||
Shape:TKraftShape;
|
||||
begin
|
||||
inherited Create(AKraftPhysics);
|
||||
|
||||
RigidBodyFloor:=TKraftRigidBody.Create(KraftPhysics);
|
||||
RigidBodyFloor.SetRigidBodyType(krbtSTATIC);
|
||||
ShapeFloorPlane:=TKraftShapePlane.Create(KraftPhysics,RigidBodyFloor,Plane(Vector3Norm(Vector3(0.0,1.0,0.0)),0.0));
|
||||
ShapeFloorPlane.Restitution:=0.4;
|
||||
RigidBodyFloor.Finish;
|
||||
RigidBodyFloor.SetWorldTransformation(Matrix4x4Translate(0.0,0.0,0.0));
|
||||
RigidBodyFloor.CollisionGroups:=[0];
|
||||
|
||||
for i:=0 to Count-1 do begin
|
||||
RigidBody:=TKraftRigidBody.Create(KraftPhysics);
|
||||
RigidBody.SetRigidBodyType(krbtDYNAMIC);
|
||||
Shape:=TKraftShapeBox.Create(KraftPhysics,RigidBody,Vector3(0.125,1.0,0.5));
|
||||
Shape.Restitution:=0.4;
|
||||
Shape.Density:=1.0;
|
||||
RigidBody.ForcedMass:=1.0;
|
||||
RigidBody.Finish;
|
||||
RigidBody.SetWorldTransformation(Matrix4x4TermMul(Matrix4x4TermMul(Matrix4x4Translate(0.0,TKraftShapeBox(Shape).Extents.y,-8.0-((i/Count)*4.0)),Matrix4x4RotateY((i-((Count-1)*0.5))*(pi/Count)*2.0)),Matrix4x4Translate(0.0,0.0,-12.0)));
|
||||
RigidBody.CollisionGroups:=[0];
|
||||
RigidBody.Gravity.Vector:=Vector3(0.0,-9.81*4.0,0.0);
|
||||
RigidBody.Flags:=RigidBody.Flags+[krbfHasOwnGravity];
|
||||
end;
|
||||
|
||||
RigidBody:=TKraftRigidBody.Create(KraftPhysics);
|
||||
RigidBody.SetRigidBodyType(krbtDYNAMIC);
|
||||
Shape:=TKraftShapeSphere.Create(KraftPhysics,RigidBody,0.5);
|
||||
Shape.Restitution:=0.4;
|
||||
Shape.Density:=1.0;
|
||||
RigidBody.ForcedMass:=1.0;
|
||||
RigidBody.Finish;
|
||||
i:=Count;
|
||||
RigidBody.SetWorldTransformation(Matrix4x4TermMul(Matrix4x4TermMul(Matrix4x4Translate(0.0,TKraftShapeSphere(Shape).Radius,-12.0),Matrix4x4RotateY((i-((Count-1)*0.5))*(pi/Count)*2.0)),Matrix4x4Translate(4.0,0.0,-12.0)));
|
||||
RigidBody.CollisionGroups:=[0];
|
||||
RigidBody.Gravity.Vector:=Vector3(0.0,-9.81*4.0,0.0);
|
||||
RigidBody.Flags:=RigidBody.Flags+[krbfHasOwnGravity];
|
||||
RigidBody.SetWorldForce(Vector3(-8.0,0.0,0.0),kfmVelocity);
|
||||
|
||||
end;
|
||||
|
||||
destructor TDemoSceneDomino.Destroy;
|
||||
begin
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
procedure TDemoSceneDomino.Step(const DeltaTime:double);
|
||||
begin
|
||||
end;
|
||||
|
||||
initialization
|
||||
RegisterDemoScene('Domino',TDemoSceneDomino);
|
||||
end.
|
||||
123
sandbox/UnitDemoSceneRoundabout.pas
Normal file
123
sandbox/UnitDemoSceneRoundabout.pas
Normal file
|
|
@ -0,0 +1,123 @@
|
|||
unit UnitDemoSceneRoundabout;
|
||||
|
||||
{$MODE Delphi}
|
||||
|
||||
interface
|
||||
|
||||
uses Kraft,UnitDemoScene;
|
||||
|
||||
type TDemoSceneRoundabout=class(TDemoScene)
|
||||
public
|
||||
RigidBodyFloor:TKraftRigidBody;
|
||||
ShapeFloorPlane:TKraftShapePlane;
|
||||
constructor Create(const AKraftPhysics:TKraft); override;
|
||||
destructor Destroy; override;
|
||||
procedure Step(const DeltaTime:double); override;
|
||||
end;
|
||||
|
||||
implementation
|
||||
|
||||
uses UnitFormMain;
|
||||
|
||||
constructor TDemoSceneRoundabout.Create(const AKraftPhysics:TKraft);
|
||||
const Count=4;
|
||||
Spacing=0.125;
|
||||
RoundaboutDownBasisPointsPerCircle=16;
|
||||
RoundaboutDownBasisCircleRadius=1.0;
|
||||
RoundaboutDownBasisHeight=0.5;
|
||||
RoundaboutTopBasisPointsPerCircle=16;
|
||||
RoundaboutTopBasisCircleRadius=2.0;
|
||||
RoundaboutTopBasisHeight=0.25;
|
||||
var Index:longint;
|
||||
RigidBodySphere:TKraftRigidBody;
|
||||
ShapeSphere:TKraftShapeSphere;
|
||||
ShapeBox:TKraftShapeBox;
|
||||
ShapeRoundaboutDownBasis,ShapeRoundaboutTopBasis:TKraftShapeConvexHull;
|
||||
RigidBodyRoundaboutDownBasis,RigidBodyRoundaboutTopBasis:TKraftRigidBody;
|
||||
ConvexHullRoundaboutDownBasis,ConvexHullRoundaboutTopBasis:TKraftConvexHull;
|
||||
v:TKraftScalar;
|
||||
begin
|
||||
inherited Create(AKraftPhysics);
|
||||
|
||||
RigidBodyFloor:=TKraftRigidBody.Create(KraftPhysics);
|
||||
RigidBodyFloor.SetRigidBodyType(krbtSTATIC);
|
||||
ShapeFloorPlane:=TKraftShapePlane.Create(KraftPhysics,RigidBodyFloor,Plane(Vector3Norm(Vector3(0.0,1.0,0.0)),0.0));
|
||||
ShapeFloorPlane.Restitution:=0.3;
|
||||
RigidBodyFloor.Finish;
|
||||
RigidBodyFloor.SetWorldTransformation(Matrix4x4Translate(0.0,0.0,0.0));
|
||||
RigidBodyFloor.CollisionGroups:=[0];
|
||||
|
||||
RigidBodyRoundaboutDownBasis:=TKraftRigidBody.Create(KraftPhysics);
|
||||
RigidBodyRoundaboutDownBasis.SetRigidBodyType(krbtSTATIC);
|
||||
ConvexHullRoundaboutDownBasis:=TKraftConvexHull.Create(KraftPhysics);
|
||||
ConvexHullGarbageCollector.Add(ConvexHullRoundaboutDownBasis);
|
||||
for Index:=0 to RoundaboutDownBasisPointsPerCircle-1 do begin
|
||||
v:=(Index/RoundaboutDownBasisPointsPerCircle)*(pi*2.0);
|
||||
ConvexHullRoundaboutDownBasis.AddVertex(Vector3(sin(v)*RoundaboutDownBasisCircleRadius,-(RoundaboutDownBasisHeight*0.5),cos(v)*RoundaboutDownBasisCircleRadius));
|
||||
ConvexHullRoundaboutDownBasis.AddVertex(Vector3(sin(v)*RoundaboutDownBasisCircleRadius,RoundaboutDownBasisHeight*0.5,cos(v)*RoundaboutDownBasisCircleRadius));
|
||||
end;
|
||||
ConvexHullRoundaboutDownBasis.Build;
|
||||
ConvexHullRoundaboutDownBasis.Finish;
|
||||
ShapeRoundaboutDownBasis:=TKraftShapeConvexHull.Create(KraftPhysics,RigidBodyRoundaboutDownBasis,ConvexHullRoundaboutDownBasis);
|
||||
ShapeRoundaboutDownBasis.Restitution:=0.3;
|
||||
ShapeRoundaboutDownBasis.Density:=1.0;
|
||||
RigidBodyRoundaboutDownBasis.Finish;
|
||||
RigidBodyRoundaboutDownBasis.SetWorldTransformation(Matrix4x4Translate(0.0,RoundaboutDownBasisHeight*0.5,0.0));
|
||||
RigidBodyRoundaboutDownBasis.CollisionGroups:=[0];
|
||||
|
||||
RigidBodyRoundaboutTopBasis:=TKraftRigidBody.Create(KraftPhysics);
|
||||
RigidBodyRoundaboutTopBasis.SetRigidBodyType(krbtDYNAMIC);
|
||||
ConvexHullRoundaboutTopBasis:=TKraftConvexHull.Create(KraftPhysics);
|
||||
ConvexHullGarbageCollector.Add(ConvexHullRoundaboutTopBasis);
|
||||
for Index:=0 to RoundaboutTopBasisPointsPerCircle-1 do begin
|
||||
v:=(Index/RoundaboutTopBasisPointsPerCircle)*(pi*2.0);
|
||||
ConvexHullRoundaboutTopBasis.AddVertex(Vector3(sin(v)*RoundaboutTopBasisCircleRadius,-(RoundaboutTopBasisHeight*0.5),cos(v)*RoundaboutTopBasisCircleRadius));
|
||||
ConvexHullRoundaboutTopBasis.AddVertex(Vector3(sin(v)*RoundaboutTopBasisCircleRadius,RoundaboutTopBasisHeight*0.5,cos(v)*RoundaboutTopBasisCircleRadius));
|
||||
end;
|
||||
ConvexHullRoundaboutTopBasis.Build;
|
||||
ConvexHullRoundaboutTopBasis.Finish;
|
||||
ShapeRoundaboutTopBasis:=TKraftShapeConvexHull.Create(KraftPhysics,RigidBodyRoundaboutTopBasis,ConvexHullRoundaboutTopBasis);
|
||||
ShapeRoundaboutTopBasis.Restitution:=0.3;
|
||||
ShapeRoundaboutTopBasis.Density:=1.0;
|
||||
begin
|
||||
ShapeBox:=TKraftShapeBox.Create(KraftPhysics,RigidBodyRoundaboutTopBasis,Vector3(0.125,0.5,0.125));
|
||||
ShapeBox.LocalTransform:=Matrix4x4Translate(0.0,0.5,0.0);
|
||||
ShapeBox.Finish;
|
||||
end;
|
||||
for Index:=0 to 7 do begin
|
||||
v:=(Index/8)*(pi*2.0);
|
||||
ShapeBox:=TKraftShapeBox.Create(KraftPhysics,RigidBodyRoundaboutTopBasis,Vector3(0.125,0.5,0.5));
|
||||
ShapeBox.LocalTransform:=Matrix4x4TermMul(Matrix4x4Translate(RoundaboutTopBasisCircleRadius-0.25,0.5,0.0),Matrix4x4RotateY(v));
|
||||
ShapeBox.Finish;
|
||||
end;
|
||||
RigidBodyRoundaboutTopBasis.Finish;
|
||||
RigidBodyRoundaboutTopBasis.SetWorldTransformation(Matrix4x4Translate(0.0,RoundaboutDownBasisHeight+(RoundaboutTopBasisHeight*0.5),0.0));
|
||||
RigidBodyRoundaboutTopBasis.CollisionGroups:=[0];
|
||||
|
||||
TKraftConstraintJointHinge.Create(KraftPhysics,RigidBodyRoundaboutDownBasis,RigidBodyRoundaboutTopBasis,Vector3(0.0,RoundaboutDownBasisHeight,0.0),Vector3(0.0,1.0,0.0));
|
||||
|
||||
RigidBodySphere:=TKraftRigidBody.Create(KraftPhysics);
|
||||
RigidBodySphere.SetRigidBodyType(krbtDYNAMIC);
|
||||
ShapeSphere:=TKraftShapeSphere.Create(KraftPhysics,RigidBodySphere,0.5);
|
||||
ShapeSphere.Finish;
|
||||
RigidBodySphere.Finish;
|
||||
RigidBodySphere.SetWorldTransformation(Matrix4x4Translate(0.0,RoundaboutDownBasisHeight+RoundaboutTopBasisHeight+0.5,RoundaboutTopBasisCircleRadius-0.5));
|
||||
RigidBodySphere.CollisionGroups:=[0];
|
||||
|
||||
RigidBodyRoundaboutTopBasis.AddBodyTorque(Vector3(0.0,3000.0,0.0));
|
||||
|
||||
end;
|
||||
|
||||
destructor TDemoSceneRoundabout.Destroy;
|
||||
begin
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
procedure TDemoSceneRoundabout.Step(const DeltaTime:double);
|
||||
begin
|
||||
end;
|
||||
|
||||
initialization
|
||||
RegisterDemoScene('Roundabout',TDemoSceneRoundabout);
|
||||
end.
|
||||
|
||||
623
sandbox/UnitDemoSceneSandBox.pas
Normal file
623
sandbox/UnitDemoSceneSandBox.pas
Normal file
|
|
@ -0,0 +1,623 @@
|
|||
unit UnitDemoSceneSandBox;
|
||||
|
||||
{$MODE Delphi}
|
||||
|
||||
{$j+}
|
||||
|
||||
interface
|
||||
|
||||
uses Kraft,UnitDemoScene;
|
||||
|
||||
type TDemoSceneSandBox=class(TDemoScene)
|
||||
public
|
||||
RigidBody:TKraftRigidBody;
|
||||
|
||||
RagdollOffset:TKraftMatrix4x4;
|
||||
|
||||
RigidBodyFloor:TKraftRigidBody;
|
||||
// ShapeFloorBoxes:array[0..5] of TKraftShapeBox;
|
||||
ShapeFloorPlane:TKraftShapePlane;
|
||||
|
||||
RigidBodyMesh:TKraftRigidBody;
|
||||
Mesh:TKraftMesh;
|
||||
ShapeMesh:TKraftShapeMesh;
|
||||
|
||||
ConvexHull:TKraftConvexHull;
|
||||
|
||||
ObjectRigidBody:array[0..18] of TKraftRigidBody;
|
||||
ObjectShape:array[0..19] of TKraftShape;
|
||||
|
||||
pp:array[0..4,0..1] of TKraftVector3;
|
||||
// WorldPlaneDistanceConstraints:array[0..4] of TKraftConstraintJointWorldPlaneDistance;
|
||||
|
||||
RopeConstraints:array[0..3] of TKraftConstraint;
|
||||
|
||||
HingeConstraints:array[0..3] of TKraftConstraint;
|
||||
|
||||
SliderConstraints:array[0..3] of TKraftConstraint;
|
||||
|
||||
RagdollRigidBody:array[0..1+2+2+5] of TKraftRigidBody;
|
||||
RagdollShape:array[0..1+2+2+5] of TKraftShape;
|
||||
RagdollConstraints:array[0..9] of TKraftConstraint;
|
||||
|
||||
constructor Create(const AKraftPhysics:TKraft); override;
|
||||
destructor Destroy; override;
|
||||
procedure Step(const DeltaTime:double); override;
|
||||
end;
|
||||
|
||||
implementation
|
||||
|
||||
uses UnitFormMain,sandboxfile;
|
||||
|
||||
const ConvexHullPoints:array[0..5] of TKraftVector3=((x:-2.0;y:1.0;z:1.0),
|
||||
(x:2.0;y:0.0;z:0.0),
|
||||
(x:1.0;y:-2.0;z:1.0),
|
||||
(x:0.0;y:2.0;z:0.0),
|
||||
(x:1.0;y:1.0;z:-2.0),
|
||||
(x:0.0;y:0.0;z:2.0));{}
|
||||
|
||||
constructor TDemoSceneSandBox.Create(const AKraftPhysics:TKraft);
|
||||
const ScaleRagDoll=4.0;
|
||||
BODYPART_PELVIS=0;
|
||||
BODYPART_SPINE=1;
|
||||
BODYPART_HEAD=2;
|
||||
BODYPART_LEFT_UPPER_LEG=3;
|
||||
BODYPART_LEFT_LOWER_LEG=4;
|
||||
BODYPART_RIGHT_UPPER_LEG=5;
|
||||
BODYPART_RIGHT_LOWER_LEG=6;
|
||||
BODYPART_LEFT_UPPER_ARM=7;
|
||||
BODYPART_LEFT_LOWER_ARM=8;
|
||||
BODYPART_RIGHT_UPPER_ARM=9;
|
||||
BODYPART_RIGHT_LOWER_ARM=10;
|
||||
BODY_BASE_X=-16.0;
|
||||
BODY_BASE_Y=6.0;
|
||||
BODY_BASE_Z=2.0;
|
||||
begin
|
||||
inherited Create(AKraftPhysics);
|
||||
|
||||
RigidBodyFloor:=TKraftRigidBody.Create(KraftPhysics);
|
||||
RigidBodyFloor.SetRigidBodyType(krbtSTATIC);
|
||||
ShapeFloorPlane:=TKraftShapePlane.Create(KraftPhysics,RigidBodyFloor,Plane(Vector3Norm(Vector3(0.0,1.0,0.0)),0.0));
|
||||
{ShapeFloorBoxes[0]:=TKraftShapeBox.Create(KraftPhysics,RigidBodyFloor,Vector3(50.0,25.0,50.0));
|
||||
ShapeFloorBoxes[0].LocalTransform:=Matrix4x4Translate(0.0,-25.0,0.0);
|
||||
ShapeFloorBoxes[0].Friction:=0.4;
|
||||
ShapeFloorBoxes[0].Restitution:=0.2;
|
||||
ShapeFloorBoxes[1]:=TKraftShapeBox.Create(KraftPhysics,RigidBodyFloor,Vector3(50.0,25.0,50.0));
|
||||
ShapeFloorBoxes[1].LocalTransform:=Matrix4x4Translate(0.0,50.0,0.0);
|
||||
ShapeFloorBoxes[2]:=TKraftShapeBox.Create(KraftPhysics,RigidBodyFloor,Vector3(50.0,50.0,25.0));
|
||||
ShapeFloorBoxes[2].LocalTransform:=Matrix4x4Translate(0.0,25.0,50.0);
|
||||
ShapeFloorBoxes[3]:=TKraftShapeBox.Create(KraftPhysics,RigidBodyFloor,Vector3(50.0,50.0,25.0));
|
||||
ShapeFloorBoxes[3].LocalTransform:=Matrix4x4Translate(0.0,25.0,-50.0);
|
||||
ShapeFloorBoxes[4]:=TKraftShapeBox.Create(KraftPhysics,RigidBodyFloor,Vector3(25.0,50.0,50.0));
|
||||
ShapeFloorBoxes[4].LocalTransform:=Matrix4x4Translate(50.0,25.0,0);
|
||||
ShapeFloorBoxes[5]:=TKraftShapeBox.Create(KraftPhysics,RigidBodyFloor,Vector3(25.0,50.0,50.0));
|
||||
ShapeFloorBoxes[5].LocalTransform:=Matrix4x4Translate(-50.0,25.0,0);}
|
||||
RigidBodyFloor.Finish;
|
||||
RigidBodyFloor.SetWorldTransformation(Matrix4x4Translate(0.0,-8.0,0.0));
|
||||
RigidBodyFloor.CollisionGroups:=[0];
|
||||
|
||||
RigidBodyMesh:=TKraftRigidBody.Create(KraftPhysics);
|
||||
RigidBodyMesh.SetRigidBodyType(krbtSTATIC);
|
||||
Mesh:=TKraftMesh.Create(KraftPhysics);
|
||||
MeshGarbageCollector.Add(Mesh);
|
||||
Mesh.Load(@sandboxData,sandboxSize);
|
||||
Mesh.Scale(0.1);
|
||||
Mesh.Finish;
|
||||
ShapeMesh:=TKraftShapeMesh.Create(KraftPhysics,RigidBodyMesh,Mesh);
|
||||
ShapeMesh.Friction:=0.5;
|
||||
ShapeMesh.Restitution:=0.0;
|
||||
ShapeMesh.Density:=1.0;
|
||||
ShapeMesh.Finish;
|
||||
RigidBodyMesh.Finish;
|
||||
RigidBodyMesh.SetWorldTransformation(Matrix4x4Translate(0.0,-4.0,0.0));
|
||||
RigidBodyMesh.CollisionGroups:=[0];{}
|
||||
|
||||
{ObjectRigidBody[5]:=TKraftRigidBody.Create(KraftPhysics);
|
||||
ObjectRigidBody[5].SetRigidBodyType(krbtDYNAMIC);
|
||||
ObjectShape[5]:=TKraftShapeSphere.Create(KraftPhysics,ObjectRigidBody[5],1.0);
|
||||
//ObjectShape[5]:=TKraftShapeTriangle.Create(KraftPhysics,ObjectRigidBody[5],Vector3(15.0,0.0,-8.0),Vector3(-15.0,0.0,-8.0),Vector3(-15.0,15.0,-8.0));
|
||||
ObjectShape[5].Friction:=0.4;
|
||||
ObjectShape[5].Restitution:=0.2;
|
||||
ObjectShape[5].Density:=1.0;
|
||||
/// ObjectRigidBody[5].ForcedMass:=1.0;
|
||||
ObjectRigidBody[5].Finish;
|
||||
// ObjectRigidBody[5].SetWorldTransformation(Matrix4x4Translate(-37.3,24.0,-36.0));
|
||||
// ObjectRigidBody[5].SetWorldTransformation(Matrix4x4Translate(-35.0,30.0,-26.0));
|
||||
ObjectRigidBody[5].SetWorldTransformation(Matrix4x4Translate(-35.0,30.0,-25.0));
|
||||
ObjectRigidBody[5].SetToAwake;{}
|
||||
|
||||
(**)
|
||||
ObjectRigidBody[0]:=TKraftRigidBody.Create(KraftPhysics);
|
||||
ObjectRigidBody[0].SetRigidBodyType(krbtDYNAMIC);
|
||||
ObjectShape[0]:=TKraftShapeSphere.Create(KraftPhysics,ObjectRigidBody[0],3.0);
|
||||
//ObjectShape[0]:=TKraftShapeSphere.Create(KraftPhysics,ObjectRigidBody[0],5.0);
|
||||
//ObjectShape:=TKraftShapeBox.Create(KraftPhysics,ObjectRigidBody,Vector3(5.0,5.0,5.0));
|
||||
ObjectShape[0].Friction:=0.4;
|
||||
ObjectShape[0].Restitution:=0.2;
|
||||
ObjectShape[0].Density:=1.0;
|
||||
//ObjectRigidBody.ForcedMass:=1.0;
|
||||
ObjectRigidBody[0].Finish;
|
||||
ObjectRigidBody[0].SetWorldTransformation(Matrix4x4Translate(10.0,5.0,5.0));
|
||||
ObjectRigidBody[0].AngularVelocity:=Vector3Origin;
|
||||
ObjectRigidBody[0].SetToAwake;
|
||||
|
||||
ObjectRigidBody[1]:=TKraftRigidBody.Create(KraftPhysics);
|
||||
ObjectRigidBody[1].SetRigidBodyType(krbtDYNAMIC);
|
||||
// ObjectShape[2]:=TKraftShapeSphere.Create(KraftPhysics,ObjectRigidBody[1],1.0);
|
||||
ObjectShape[1]:=TKraftShapeBox.Create(KraftPhysics,ObjectRigidBody[1],Vector3(1.0,1.0,1.0));
|
||||
ObjectShape[1].Friction:=0.4;
|
||||
ObjectShape[1].Restitution:=0.5;
|
||||
ObjectShape[1].Density:=1.0;
|
||||
//ObjectRigidBody[1].ForcedMass:=1;
|
||||
ObjectRigidBody[1].Finish;
|
||||
ObjectRigidBody[1].SetWorldTransformation(Matrix4x4Translate(4.0,4.0,0.0));
|
||||
// ObjectRigidBody[1].SetWorldTransformation(Matrix4x4Translate(2.0,2.0,-12.0));
|
||||
ObjectRigidBody[1].SetToAwake;
|
||||
ObjectRigidBody[1].CollisionGroups:=[2];
|
||||
|
||||
ObjectRigidBody[18]:=TKraftRigidBody.Create(KraftPhysics);
|
||||
ObjectRigidBody[18].SetRigidBodyType(krbtDYNAMIC);
|
||||
// ObjectShape[2]:=TKraftShapeSphere.Create(KraftPhysics,ObjectRigidBody[18],1.0);
|
||||
ObjectShape[18]:=TKraftShapeBox.Create(KraftPhysics,ObjectRigidBody[18],Vector3(1.0,1.0,1.0));
|
||||
ObjectShape[18].Friction:=0.4;
|
||||
ObjectShape[18].Restitution:=0.5;
|
||||
ObjectShape[18].Density:=1.0;
|
||||
ObjectShape[19]:=TKraftShapeSphere.Create(KraftPhysics,ObjectRigidBody[18],1.0);
|
||||
ObjectShape[19].LocalTransform:=Matrix4x4Translate(0.0,1.0,0.0);
|
||||
ObjectShape[19].Friction:=0.4;
|
||||
ObjectShape[19].Restitution:=0.5;
|
||||
ObjectShape[19].Density:=1.0;
|
||||
//ObjectRigidBody[18].ForcedMass:=1;
|
||||
ObjectRigidBody[18].Finish;
|
||||
ObjectRigidBody[18].SetWorldTransformation(Matrix4x4Translate(4.0,4.0,2.0));
|
||||
// ObjectRigidBody[18].SetWorldTransformation(Matrix4x4Translate(2.0,2.0,-12.0));
|
||||
ObjectRigidBody[18].SetToAwake;
|
||||
ObjectRigidBody[18].CollisionGroups:=[2];
|
||||
|
||||
{}ObjectRigidBody[2]:=TKraftRigidBody.Create(KraftPhysics);
|
||||
ObjectRigidBody[2].SetRigidBodyType(krbtDYNAMIC);
|
||||
ObjectShape[2]:=TKraftShapeSphere.Create(KraftPhysics,ObjectRigidBody[2],1.0);
|
||||
//ObjectShape[2]:=TKraftShapeBox.Create(KraftPhysics,ObjectRigidBody[2],Vector3(1.0,1.0,1.0));
|
||||
ObjectShape[2].Friction:=0.4;
|
||||
ObjectShape[2].Restitution:=0.2;
|
||||
ObjectShape[2].Density:=1.0;
|
||||
//ObjectRigidBody[1].ForcedMass:=1;
|
||||
ObjectRigidBody[2].Finish;
|
||||
ObjectRigidBody[2].SetWorldTransformation(Matrix4x4Translate(-2.0,2.0,-12.0));
|
||||
// ObjectRigidBody[2].SetWorldTransformation(Matrix4x4Translate(-2.0,16.0,0.0));
|
||||
ObjectRigidBody[2].SetToAwake;{}
|
||||
|
||||
{}ObjectRigidBody[3]:=TKraftRigidBody.Create(KraftPhysics);
|
||||
ObjectRigidBody[3].SetRigidBodyType(krbtDYNAMIC);
|
||||
ObjectShape[3]:=TKraftShapeCapsule.Create(KraftPhysics,ObjectRigidBody[3],1.0,4.0); // Cylinder
|
||||
ObjectShape[3].Friction:=0.4;
|
||||
ObjectShape[3].Restitution:=0.2;
|
||||
ObjectShape[3].Density:=1.0;
|
||||
//ObjectRigidBody[1].ForcedMass:=1;
|
||||
ObjectRigidBody[3].Finish;
|
||||
ObjectRigidBody[3].SetWorldTransformation(Matrix4x4TermMul(Matrix4x4RotateX(pi*0.0),Matrix4x4Translate(-2.0,11.0,-20.0)));
|
||||
//ObjectRigidBody[3].SetWorldTransformation(Matrix4x4TermMul(Matrix4x4RotateX(pi*0.0),Matrix4x4Translate(-5.0,4.0,5.0)));
|
||||
ObjectRigidBody[3].SetToAwake;{}
|
||||
|
||||
{}ObjectRigidBody[4]:=TKraftRigidBody.Create(KraftPhysics);
|
||||
ObjectRigidBody[4].SetRigidBodyType(krbtDYNAMIC);
|
||||
ObjectShape[4]:=TKraftShapeCapsule.Create(KraftPhysics,ObjectRigidBody[4],1.0,4.0);
|
||||
ObjectShape[4].Friction:=0.4;
|
||||
ObjectShape[4].Restitution:=0.2;
|
||||
ObjectShape[4].Density:=1.0;
|
||||
//ObjectRigidBody[1].ForcedMass:=1;
|
||||
ObjectRigidBody[4].Finish;
|
||||
ObjectRigidBody[4].SetWorldTransformation(Matrix4x4TermMul(Matrix4x4RotateX(pi*0.5),Matrix4x4Translate(-3.0,1.0,5.0)));
|
||||
ObjectRigidBody[4].SetToAwake;{}
|
||||
|
||||
{}ObjectRigidBody[5]:=TKraftRigidBody.Create(KraftPhysics);
|
||||
ObjectRigidBody[5].SetRigidBodyType(krbtDYNAMIC);
|
||||
ObjectShape[5]:=TKraftShapeSphere.Create(KraftPhysics,ObjectRigidBody[5],1.0);
|
||||
//ObjectShape[5]:=TKraftShapeTriangle.Create(KraftPhysics,ObjectRigidBody[5],Vector3(15.0,0.0,-8.0),Vector3(-15.0,0.0,-8.0),Vector3(-15.0,15.0,-8.0));
|
||||
ObjectShape[5].Friction:=0.4;
|
||||
ObjectShape[5].Restitution:=0.7;
|
||||
ObjectShape[5].Density:=1.0;
|
||||
//ObjectRigidBody[1].ForcedMass:=1;
|
||||
ObjectRigidBody[5].Finish;
|
||||
// ObjectRigidBody[5].SetWorldTransformation(Matrix4x4Translate(-37.3,24.0,-36.0));
|
||||
// ObjectRigidBody[5].SetWorldTransformation(Matrix4x4Translate(-35.0,30.0,-26.0));
|
||||
ObjectRigidBody[5].SetWorldTransformation(Matrix4x4Translate(-35.0,30.0,-25.0));
|
||||
ObjectRigidBody[5].SetToAwake;{}
|
||||
|
||||
{}ObjectRigidBody[6]:=TKraftRigidBody.Create(KraftPhysics);
|
||||
ObjectRigidBody[6].SetRigidBodyType(krbtDYNAMIC);
|
||||
ObjectShape[6]:=TKraftShapeCapsule.Create(KraftPhysics,ObjectRigidBody[6],1.0,4.0);
|
||||
ObjectShape[6].Friction:=0.4;
|
||||
ObjectShape[6].Restitution:=0.2;
|
||||
ObjectShape[6].Density:=1.0;
|
||||
//ObjectRigidBody[1].ForcedMass:=1;
|
||||
ObjectRigidBody[6].Finish;
|
||||
ObjectRigidBody[6].SetWorldTransformation(Matrix4x4TermMul(Matrix4x4TermMul(Matrix4x4RotateX(pi*0.5),Matrix4x4RotateY(pi*0.5)),Matrix4x4Translate(-10.0,1.0,-4.5)));
|
||||
ObjectRigidBody[6].SetToAwake;{}
|
||||
|
||||
{}ObjectRigidBody[7]:=TKraftRigidBody.Create(KraftPhysics);
|
||||
ObjectRigidBody[7].SetRigidBodyType(krbtDYNAMIC);
|
||||
ObjectShape[7]:=TKraftShapeCapsule.Create(KraftPhysics,ObjectRigidBody[7],1.0,4.0);
|
||||
//ObjectShape[7]:=TKraftShapeCone.Create(KraftPhysics,ObjectRigidBody[7],1.0,4.0);
|
||||
ObjectShape[7].Friction:=0.4;
|
||||
ObjectShape[7].Restitution:=0.2;
|
||||
ObjectShape[7].Density:=1.0;
|
||||
//ObjectRigidBody[1].ForcedMass:=1;
|
||||
ObjectRigidBody[7].Finish;
|
||||
ObjectRigidBody[7].SetWorldTransformation(Matrix4x4TermMul(Matrix4x4RotateX(pi*0.0),Matrix4x4Translate(-8.0,1.0,5.0)));
|
||||
// ObjectRigidBody[7].SetWorldTransformation(Matrix4x4TermMul(Matrix4x4RotateX(pi*0.5),Matrix4x4Translate(-8.0,1.0,5.0)));
|
||||
ObjectRigidBody[7].SetToAwake;{}
|
||||
|
||||
{}ObjectRigidBody[8]:=TKraftRigidBody.Create(KraftPhysics);
|
||||
ObjectRigidBody[8].SetRigidBodyType(krbtDYNAMIC);
|
||||
// ObjectShape[8]:=TKraftShapeSphere.Create(KraftPhysics,ObjectRigidBody[8],1.0);
|
||||
ConvexHull:=TKraftConvexHull.Create(KraftPhysics);
|
||||
ConvexHullGarbageCollector.Add(ConvexHull);
|
||||
ConvexHull.Load(pointer(@ConvexHullPoints),length(ConvexHullPoints));
|
||||
ConvexHull.Build;
|
||||
ConvexHull.Finish;
|
||||
// Dump1(ConvexHull);
|
||||
{DumpFile(@ConvexHull.Vertices[0],length(ConvexHull.Vertices)*sizeof(ConvexHull.Vertices[0]),'hbv');
|
||||
DumpFaces(ConvexHull.Faces,'hbf');
|
||||
DumpFile(@ConvexHull.Edges[0],length(ConvexHull.Edges)*sizeof(ConvexHull.Edges[0]),'hbe');
|
||||
DumpFile(@ConvexHull.AABB,sizeof(ConvexHull.AABB),'hb_aabb');
|
||||
DumpFile(@ConvexHull.MassData,sizeof(ConvexHull.MassData),'hb_massdata'); {}
|
||||
//
|
||||
//
|
||||
ObjectShape[8]:=TKraftShapeConvexHull.Create(KraftPhysics,ObjectRigidBody[8],ConvexHull);{
|
||||
ObjectShape[8]:=TKraftShapeConvexHull.Create(KraftPhysics,ObjectRigidBody[8],pointer(@ConvexHullPoints),length(ConvexHullPoints));{}
|
||||
ObjectShape[8].Friction:=0.4;
|
||||
ObjectShape[8].Restitution:=0.2;
|
||||
ObjectShape[8].Density:=1.0;
|
||||
//ObjectRigidBody[1].ForcedMass:=1;
|
||||
ObjectRigidBody[8].Finish;
|
||||
{DumpFile(@ObjectShape[8].Vertices[0],length(ObjectShape[8].Vertices)*sizeof(ObjectShape[8].Vertices[0]),'hav');
|
||||
DumpFaces(ObjectShape[8].Faces,'haf');
|
||||
DumpFile(@ObjectShape[8].Edges[0],length(ObjectShape[8].Edges)*sizeof(ObjectShape[8].Edges[0]),'hae');{}
|
||||
//Dump2(ObjectShape[8]);
|
||||
// ObjectRigidBody[8].SetWorldTransformation(Matrix4x4TermMul(Matrix4x4RotateX(pi*0.125),Matrix4x4Translate(0.0,3.0,0.0)));
|
||||
ObjectRigidBody[8].SetWorldTransformation(Matrix4x4TermMul(Matrix4x4RotateX(pi*0.125),Matrix4x4Translate(5.0,-1.5,5.0)));
|
||||
//ObjectRigidBody[8].SetWorldTransformation(Matrix4x4TermMul(Matrix4x4RotateX(pi*0.125),Matrix4x4Translate(0.0,1.0,8.0)));
|
||||
ObjectRigidBody[8].SetToAwake;{}
|
||||
|
||||
ObjectRigidBody[9]:=TKraftRigidBody.Create(KraftPhysics);
|
||||
ObjectRigidBody[9].SetRigidBodyType(krbtSTATIC);
|
||||
ObjectShape[9]:=TKraftShapeSphere.Create(KraftPhysics,ObjectRigidBody[9],0.1);
|
||||
ObjectRigidBody[9].Finish;
|
||||
ObjectRigidBody[9].SetWorldTransformation(Matrix4x4TermMul(Matrix4x4RotateX(pi*0.0),Matrix4x4Translate(-8.0,8.0,15.0)));
|
||||
ObjectRigidBody[9].SetToAwake;
|
||||
|
||||
ObjectRigidBody[10]:=TKraftRigidBody.Create(KraftPhysics);
|
||||
ObjectRigidBody[10].SetRigidBodyType(krbtDYNAMIC);
|
||||
ObjectShape[10]:=TKraftShapeSphere.Create(KraftPhysics,ObjectRigidBody[10],1.0);
|
||||
ObjectRigidBody[10].Finish;
|
||||
ObjectRigidBody[10].SetWorldTransformation(Matrix4x4TermMul(Matrix4x4RotateX(pi*0.0),Matrix4x4Translate(-8.0,6.5,15.0)));
|
||||
ObjectRigidBody[10].SetToAwake;
|
||||
|
||||
ObjectRigidBody[11]:=TKraftRigidBody.Create(KraftPhysics);
|
||||
ObjectRigidBody[11].SetRigidBodyType(krbtDYNAMIC);
|
||||
ObjectShape[11]:=TKraftShapeSphere.Create(KraftPhysics,ObjectRigidBody[11],1.0);
|
||||
ObjectRigidBody[11].Finish;
|
||||
ObjectRigidBody[11].SetWorldTransformation(Matrix4x4TermMul(Matrix4x4RotateX(pi*0.0),Matrix4x4Translate(-8.0,5.0,15.0)));
|
||||
ObjectRigidBody[11].SetToAwake;
|
||||
|
||||
ObjectRigidBody[12]:=TKraftRigidBody.Create(KraftPhysics);
|
||||
ObjectRigidBody[12].SetRigidBodyType(krbtDYNAMIC);
|
||||
ObjectShape[12]:=TKraftShapeSphere.Create(KraftPhysics,ObjectRigidBody[12],1.0);
|
||||
ObjectRigidBody[12].Finish;
|
||||
ObjectRigidBody[12].SetWorldTransformation(Matrix4x4TermMul(Matrix4x4RotateX(pi*0.0),Matrix4x4Translate(-8.0,3.5,15.0)));
|
||||
ObjectRigidBody[12].SetToAwake;
|
||||
|
||||
ObjectRigidBody[13]:=TKraftRigidBody.Create(KraftPhysics);
|
||||
ObjectRigidBody[13].SetRigidBodyType(krbtDYNAMIC);
|
||||
ObjectShape[13]:=TKraftShapeSphere.Create(KraftPhysics,ObjectRigidBody[13],1.0);
|
||||
ObjectRigidBody[13].Finish;
|
||||
ObjectRigidBody[13].SetWorldTransformation(Matrix4x4TermMul(Matrix4x4RotateX(pi*0.0),Matrix4x4Translate(-8.0,1.0,15.0)));
|
||||
ObjectRigidBody[13].SetToAwake;
|
||||
|
||||
ObjectRigidBody[14]:=TKraftRigidBody.Create(KraftPhysics);
|
||||
ObjectRigidBody[14].SetRigidBodyType(krbtSTATIC);
|
||||
ObjectShape[14]:=TKraftShapeSphere.Create(KraftPhysics,ObjectRigidBody[14],1.0);
|
||||
ObjectRigidBody[14].Finish;
|
||||
ObjectRigidBody[14].SetWorldTransformation(Matrix4x4TermMul(Matrix4x4RotateX(pi*0.0),Matrix4x4Translate(-12.0,6.0,15.0)));
|
||||
ObjectRigidBody[14].SetToAwake;
|
||||
|
||||
ObjectRigidBody[15]:=TKraftRigidBody.Create(KraftPhysics);
|
||||
ObjectRigidBody[15].SetRigidBodyType(krbtDYNAMIC);
|
||||
ObjectShape[15]:=TKraftShapeSphere.Create(KraftPhysics,ObjectRigidBody[15],1.0);
|
||||
ObjectRigidBody[15].Finish;
|
||||
ObjectRigidBody[15].SetWorldTransformation(Matrix4x4TermMul(Matrix4x4RotateX(pi*0.0),Matrix4x4Translate(-12.0,3.0,15.0)));
|
||||
ObjectRigidBody[15].SetToAwake;
|
||||
|
||||
ObjectRigidBody[16]:=TKraftRigidBody.Create(KraftPhysics);
|
||||
ObjectRigidBody[16].SetRigidBodyType(krbtSTATIC);
|
||||
ObjectShape[16]:=TKraftShapeSphere.Create(KraftPhysics,ObjectRigidBody[16],1.0);
|
||||
ObjectRigidBody[16].Finish;
|
||||
ObjectRigidBody[16].SetWorldTransformation(Matrix4x4TermMul(Matrix4x4RotateX(pi*0.0),Matrix4x4Translate(-16.0,6.0,15.0)));
|
||||
ObjectRigidBody[16].SetToAwake;
|
||||
|
||||
ObjectRigidBody[17]:=TKraftRigidBody.Create(KraftPhysics);
|
||||
ObjectRigidBody[17].SetRigidBodyType(krbtDYNAMIC);
|
||||
ObjectShape[17]:=TKraftShapeSphere.Create(KraftPhysics,ObjectRigidBody[17],1.0);
|
||||
ObjectRigidBody[17].Finish;
|
||||
ObjectRigidBody[17].SetWorldTransformation(Matrix4x4TermMul(Matrix4x4RotateX(pi*0.0),Matrix4x4Translate(-16.0,6.0,12.0)));
|
||||
ObjectRigidBody[17].SetToAwake;
|
||||
|
||||
{Constraints[0]:=TKraftConstraintJointDistance.Create(KraftPhysics,ObjectRigidBody[9],ObjectRigidBody[10],Vector3(-8.0,7.0,15.0),Vector3(-8.0,7.0,15.0),4.0,0.5);
|
||||
Constraints[1]:=TKraftConstraintJointDistance.Create(KraftPhysics,ObjectRigidBody[10],ObjectRigidBody[11],Vector3(-8.0,5.0,15.0),Vector3(-8.0,5.0,15.0),4.0,0.5);
|
||||
{}
|
||||
|
||||
{Constraints[0]:=TKraftConstraintJointDistance.Create(KraftPhysics,ObjectRigidBody[9],ObjectRigidBody[10],Vector3(0.0,0.01,0),Vector3(0.0,-0.01,0.0),4.0,0.5);
|
||||
Constraints[1]:=TKraftConstraintJointDistance.Create(KraftPhysics,ObjectRigidBody[10],ObjectRigidBody[11],Vector3(0.0,0.01,0),Vector3(0.0,-0.01,0.0),4.0,0.5);
|
||||
{}
|
||||
|
||||
{WorldPlaneDistanceConstraints[0]:=TKraftConstraintJointWorldPlaneDistance.Create(KraftPhysics,ObjectRigidBody[1],Vector3(0.0,-1.0,0.0),Plane(Vector3(0.0,1.0,0.0),-1.0),false,4.0,kclbLimitMinimumDistance,1.0,0.5);
|
||||
WorldPlaneDistanceConstraints[1]:=TKraftConstraintJointWorldPlaneDistance.Create(KraftPhysics,ObjectRigidBody[1],Vector3(-0.65,-1.0,-0.65),Plane(Vector3(0.0,1.0,0.0),-1.0),false,4.0,kclbLimitMinimumDistance,1.0,0.5);
|
||||
WorldPlaneDistanceConstraints[2]:=TKraftConstraintJointWorldPlaneDistance.Create(KraftPhysics,ObjectRigidBody[1],Vector3(0.65,-1.0,-0.65),Plane(Vector3(0.0,1.0,0.0),-1.0),false,4.0,kclbLimitMinimumDistance,1.0,0.5);
|
||||
WorldPlaneDistanceConstraints[3]:=TKraftConstraintJointWorldPlaneDistance.Create(KraftPhysics,ObjectRigidBody[1],Vector3(-0.65,-1.0,0.65),Plane(Vector3(0.0,1.0,0.0),-1.0),false,4.0,kclbLimitMinimumDistance,1.0,0.5);
|
||||
WorldPlaneDistanceConstraints[4]:=TKraftConstraintJointWorldPlaneDistance.Create(KraftPhysics,ObjectRigidBody[1],Vector3(0.65,-1.0,0.65),Plane(Vector3(0.0,1.0,0.0),-1.0),false,4.0,kclbLimitMinimumDistance,1.0,0.5);{}
|
||||
//Exclude(ObjectRigidBody[1].Flags,krbfAllowSleep);
|
||||
|
||||
{}
|
||||
RopeConstraints[0]:=TKraftConstraintJointRope.Create(KraftPhysics,ObjectRigidBody[9],ObjectRigidBody[10],Vector3(0.0,-0.55,0),Vector3(0.0,0.55,0.0),1.0,true);
|
||||
RopeConstraints[1]:=TKraftConstraintJointRope.Create(KraftPhysics,ObjectRigidBody[10],ObjectRigidBody[11],Vector3(0.0,-0.55,0),Vector3(0.0,0.55,0.0),1.0,true);
|
||||
RopeConstraints[2]:=TKraftConstraintJointRope.Create(KraftPhysics,ObjectRigidBody[11],ObjectRigidBody[12],Vector3(0.0,-0.55,0),Vector3(0.0,0.55,0.0),1.0,true);
|
||||
RopeConstraints[3]:=TKraftConstraintJointRope.Create(KraftPhysics,ObjectRigidBody[12],ObjectRigidBody[13],Vector3(0.0,-0.55,0),Vector3(0.0,0.55,0.0),1.0,true);
|
||||
//Constraints[3]:=TKraftConstraintJointFixed.Create(KraftPhysics,ObjectRigidBody[12],ObjectRigidBody[13],Vector3(-8.0,3.0,15.0));
|
||||
{}
|
||||
|
||||
//HingeConstraints[0]:=TKraftConstraintJointBallSocket.Create(KraftPhysics,ObjectRigidBody[14],ObjectRigidBody[15],Vector3(-12.0,4.5,18.0));
|
||||
//HingeConstraints[0]:=TKraftConstraintJointFixed.Create(KraftPhysics,ObjectRigidBody[14],ObjectRigidBody[15],Vector3(-12.0,4.5,18.0));
|
||||
HingeConstraints[0]:=TKraftConstraintJointHinge.Create(KraftPhysics,ObjectRigidBody[14],ObjectRigidBody[15],Vector3(-12.0,4.5,15.0),Vector3Norm(Vector3(1.0,0.0,0.0)),false,false,-1.0,1.0,0.0,0.0,true);
|
||||
|
||||
SliderConstraints[0]:=TKraftConstraintJointSlider.Create(KraftPhysics,ObjectRigidBody[16],ObjectRigidBody[17],Vector3(-16.0,6.0,13.5),Vector3Norm(Vector3(0.0,0.0,1.0)),true,false,-0.5,0.5,0.0,0.0,true);
|
||||
|
||||
{
|
||||
Constraints[0]:=TKraftConstraintJointVelocityBasedDistance.Create(KraftPhysics,ObjectRigidBody[9],ObjectRigidBody[10],2.0);
|
||||
Constraints[1]:=TKraftConstraintJointVelocityBasedDistance.Create(KraftPhysics,ObjectRigidBody[10],ObjectRigidBody[11],2.0);
|
||||
{}
|
||||
|
||||
{
|
||||
Constraints[0]:=TKraftConstraintJointVelocityBasedBall.Create(KraftPhysics,ObjectRigidBody[9],ObjectRigidBody[10],Vector3(0.0,-1.01,0.0),Vector3(0.0,1.01,0.0));
|
||||
Constraints[1]:=TKraftConstraintJointVelocityBasedBall.Create(KraftPhysics,ObjectRigidBody[10],ObjectRigidBody[11],Vector3(0.0,-1.01,0.0),Vector3(0.0,1.01,0.0));
|
||||
|
||||
//Constraints[0]:=TKraftConstraintJointVelocityBasedDistance.Create(KraftPhysics,ObjectRigidBody[9],ObjectRigidBody[10],4.0);
|
||||
//Constraints[1]:=TKraftConstraintJointVelocityBasedDistance.Create(KraftPhysics,ObjectRigidBody[10],ObjectRigidBody[11],4.0);
|
||||
|
||||
begin
|
||||
end;
|
||||
|
||||
(**)
|
||||
|
||||
{ObjectRigidBody[0]:=TKraftRigidBody.Create(KraftPhysics);
|
||||
ObjectRigidBody[0].SetRigidBodyType(krbtDYNAMIC);
|
||||
ObjectShape[0]:=TKraftShapeSphere.Create(KraftPhysics,ObjectRigidBody[0],1.0);
|
||||
//ObjectShape[0]:=TKraftShapeTriangle.Create(KraftPhysics,ObjectRigidBody[5],Vector3(15.0,0.0,-8.0),Vector3(-15.0,0.0,-8.0),Vector3(-15.0,15.0,-8.0));
|
||||
ObjectShape[0].Friction:=0.4;
|
||||
ObjectShape[0].Restitution:=0.2;
|
||||
ObjectShape[0].Density:=1.0;
|
||||
//ObjectRigidBody[0].ForcedMass:=1;
|
||||
ObjectRigidBody[0].Finish;
|
||||
// ObjectRigidBody[0].SetWorldTransformation(Matrix4x4Translate(-37.3,24.0,-36.0));
|
||||
ObjectRigidBody[0].SetWorldTransformation(Matrix4x4Translate(-35.0,30.0,-25.0));
|
||||
ObjectRigidBody[0].SetToAwake;{}
|
||||
|
||||
{ObjectRigidBody[0]:=TKraftRigidBody.Create(KraftPhysics);
|
||||
ObjectRigidBody[0].SetRigidBodyType(krbtDYNAMIC);
|
||||
ObjectShape[0]:=TKraftShapeSphere.Create(KraftPhysics,ObjectRigidBody[0],1.0);
|
||||
//ObjectShape[0]:=TKraftShapeTriangle.Create(KraftPhysics,ObjectRigidBody[0],Vector3(15.0,0.0,-8.0),Vector3(-15.0,0.0,-8.0),Vector3(-15.0,15.0,-8.0));
|
||||
ObjectShape[0].Friction:=0.4;
|
||||
ObjectShape[0].Restitution:=0.2;
|
||||
ObjectShape[0].Density:=1.0;
|
||||
//ObjectRigidBody[1].ForcedMass:=1;
|
||||
ObjectRigidBody[0].Finish;
|
||||
// ObjectRigidBody[0].SetWorldTransformation(Matrix4x4Translate(-37.3,24.0,-36.0));
|
||||
// ObjectRigidBody[0].SetWorldTransformation(Matrix4x4Translate(-35.0,30.0,-26.0));
|
||||
ObjectRigidBody[0].SetWorldTransformation(Matrix4x4Translate(-35.0,30.0,-25.0));
|
||||
ObjectRigidBody[0].SetToAwake;{}
|
||||
|
||||
|
||||
|
||||
{ObjectRigidBody[0]:=TKraftRigidBody.Create(KraftPhysics);
|
||||
ObjectRigidBody[0].SetRigidBodyType(krbtDYNAMIC);
|
||||
// ObjectShape[8]:=TKraftShapeSphere.Create(KraftPhysics,ObjectRigidBody[8],1.0);
|
||||
ConvexHull:=TKraftConvexHull.Create(KraftPhysics);
|
||||
ConvexHull.Load(pointer(@ConvexHullPoints),length(ConvexHullPoints));
|
||||
ConvexHull.Build;
|
||||
ConvexHull.Finish;
|
||||
ObjectShape[0]:=TKraftShapeConvexHull.Create(KraftPhysics,ObjectRigidBody[0],ConvexHull);
|
||||
ObjectShape[0].Friction:=0.4;
|
||||
ObjectShape[0].Restitution:=0.2;
|
||||
ObjectShape[0].Density:=1.0;
|
||||
ObjectRigidBody[0].Finish;
|
||||
ObjectRigidBody[0].SetWorldTransformation(Matrix4x4TermMul(Matrix4x4RotateX(pi*0.125),Matrix4x4Translate(5.0,-1.5,5.0)));
|
||||
ObjectRigidBody[0].SetToAwake;{}
|
||||
|
||||
(**)
|
||||
begin
|
||||
|
||||
RagdollOffset:=Matrix4x4Translate(BODY_BASE_X,BODY_BASE_Y,BODY_BASE_Z);
|
||||
|
||||
RagdollRigidBody[BODYPART_PELVIS]:=TKraftRigidBody.Create(KraftPhysics);
|
||||
RagdollRigidBody[BODYPART_PELVIS].SetRigidBodyType(krbtDYNAMIC);
|
||||
RagdollShape[BODYPART_PELVIS]:=TKraftShapeCapsule.Create(KraftPhysics,RagdollRigidBody[BODYPART_PELVIS],ScaleRagDoll*0.15,ScaleRagDoll*0.20);
|
||||
RagdollRigidBody[BODYPART_PELVIS].Finish;
|
||||
RagdollRigidBody[BODYPART_PELVIS].SetWorldTransformation(Matrix4x4TermMul(Matrix4x4TermMul(Matrix4x4RotateX(pi*0.0),Matrix4x4Translate(0.0,ScaleRagDoll*1.0,0.0)),RagdollOffset));
|
||||
RagdollRigidBody[BODYPART_PELVIS].SetToAwake;
|
||||
RagdollRigidBody[BODYPART_PELVIS].Flags:=RagdollRigidBody[BODYPART_PELVIS].Flags-[krbfContinuous];
|
||||
|
||||
RagdollRigidBody[BODYPART_SPINE]:=TKraftRigidBody.Create(KraftPhysics);
|
||||
RagdollRigidBody[BODYPART_SPINE].SetRigidBodyType(krbtDYNAMIC);
|
||||
RagdollShape[BODYPART_SPINE]:=TKraftShapeCapsule.Create(KraftPhysics,RagdollRigidBody[BODYPART_SPINE],ScaleRagDoll*0.15,ScaleRagDoll*0.28);
|
||||
RagdollRigidBody[BODYPART_SPINE].Finish;
|
||||
RagdollRigidBody[BODYPART_SPINE].SetWorldTransformation(Matrix4x4TermMul(Matrix4x4TermMul(Matrix4x4RotateX(pi*0.0),Matrix4x4Translate(0.0,ScaleRagDoll*1.2,0.0)),RagdollOffset));
|
||||
RagdollRigidBody[BODYPART_SPINE].SetToAwake;
|
||||
RagdollRigidBody[BODYPART_SPINE].Flags:=RagdollRigidBody[BODYPART_SPINE].Flags-[krbfContinuous];
|
||||
|
||||
RagdollRigidBody[BODYPART_HEAD]:=TKraftRigidBody.Create(KraftPhysics);
|
||||
RagdollRigidBody[BODYPART_HEAD].SetRigidBodyType(krbtDYNAMIC);
|
||||
RagdollShape[BODYPART_HEAD]:=TKraftShapeCapsule.Create(KraftPhysics,RagdollRigidBody[BODYPART_HEAD],ScaleRagDoll*0.10,ScaleRagDoll*0.05);
|
||||
RagdollRigidBody[BODYPART_HEAD].Finish;
|
||||
RagdollRigidBody[BODYPART_HEAD].SetWorldTransformation(Matrix4x4TermMul(Matrix4x4TermMul(Matrix4x4RotateX(pi*0.0),Matrix4x4Translate(0.0,ScaleRagDoll*1.6,0.0)),RagdollOffset));
|
||||
RagdollRigidBody[BODYPART_HEAD].SetToAwake;
|
||||
RagdollRigidBody[BODYPART_HEAD].Flags:=RagdollRigidBody[BODYPART_HEAD].Flags-[krbfContinuous];
|
||||
|
||||
RagdollRigidBody[BODYPART_LEFT_UPPER_LEG]:=TKraftRigidBody.Create(KraftPhysics);
|
||||
RagdollRigidBody[BODYPART_LEFT_UPPER_LEG].SetRigidBodyType(krbtDYNAMIC);
|
||||
RagdollShape[BODYPART_LEFT_UPPER_LEG]:=TKraftShapeCapsule.Create(KraftPhysics,RagdollRigidBody[BODYPART_LEFT_UPPER_LEG],ScaleRagDoll*0.07,ScaleRagDoll*0.45);
|
||||
RagdollRigidBody[BODYPART_LEFT_UPPER_LEG].Finish;
|
||||
RagdollRigidBody[BODYPART_LEFT_UPPER_LEG].SetWorldTransformation(Matrix4x4TermMul(Matrix4x4TermMul(Matrix4x4RotateX(pi*0.0),Matrix4x4Translate(ScaleRagDoll*(-0.18),ScaleRagDoll*0.65,0.0)),RagdollOffset));
|
||||
RagdollRigidBody[BODYPART_LEFT_UPPER_LEG].SetToAwake;
|
||||
RagdollRigidBody[BODYPART_LEFT_UPPER_LEG].Flags:=RagdollRigidBody[BODYPART_LEFT_UPPER_LEG].Flags-[krbfContinuous];
|
||||
|
||||
RagdollRigidBody[BODYPART_LEFT_LOWER_LEG]:=TKraftRigidBody.Create(KraftPhysics);
|
||||
RagdollRigidBody[BODYPART_LEFT_LOWER_LEG].SetRigidBodyType(krbtDYNAMIC);
|
||||
RagdollShape[BODYPART_LEFT_LOWER_LEG]:=TKraftShapeCapsule.Create(KraftPhysics,RagdollRigidBody[BODYPART_LEFT_LOWER_LEG],ScaleRagDoll*0.05,ScaleRagDoll*0.37);
|
||||
RagdollRigidBody[BODYPART_LEFT_LOWER_LEG].Finish;
|
||||
RagdollRigidBody[BODYPART_LEFT_LOWER_LEG].SetWorldTransformation(Matrix4x4TermMul(Matrix4x4TermMul(Matrix4x4RotateX(pi*0.0),Matrix4x4Translate(ScaleRagDoll*(-0.18),ScaleRagDoll*(-0.2),0.0)),RagdollOffset));
|
||||
RagdollRigidBody[BODYPART_LEFT_LOWER_LEG].SetToAwake;
|
||||
RagdollRigidBody[BODYPART_LEFT_LOWER_LEG].Flags:=RagdollRigidBody[BODYPART_LEFT_LOWER_LEG].Flags-[krbfContinuous];
|
||||
|
||||
RagdollRigidBody[BODYPART_RIGHT_UPPER_LEG]:=TKraftRigidBody.Create(KraftPhysics);
|
||||
RagdollRigidBody[BODYPART_RIGHT_UPPER_LEG].SetRigidBodyType(krbtDYNAMIC);
|
||||
RagdollShape[BODYPART_RIGHT_UPPER_LEG]:=TKraftShapeCapsule.Create(KraftPhysics,RagdollRigidBody[BODYPART_RIGHT_UPPER_LEG],ScaleRagDoll*0.07,ScaleRagDoll*0.45);
|
||||
RagdollRigidBody[BODYPART_RIGHT_UPPER_LEG].Finish;
|
||||
RagdollRigidBody[BODYPART_RIGHT_UPPER_LEG].SetWorldTransformation(Matrix4x4TermMul(Matrix4x4TermMul(Matrix4x4RotateX(pi*0.0),Matrix4x4Translate(ScaleRagDoll*(0.18),ScaleRagDoll*0.65,0.0)),RagdollOffset));
|
||||
RagdollRigidBody[BODYPART_RIGHT_UPPER_LEG].SetToAwake;
|
||||
RagdollRigidBody[BODYPART_RIGHT_UPPER_LEG].Flags:=RagdollRigidBody[BODYPART_RIGHT_UPPER_LEG].Flags-[krbfContinuous];
|
||||
|
||||
RagdollRigidBody[BODYPART_RIGHT_LOWER_LEG]:=TKraftRigidBody.Create(KraftPhysics);
|
||||
RagdollRigidBody[BODYPART_RIGHT_LOWER_LEG].SetRigidBodyType(krbtDYNAMIC);
|
||||
RagdollShape[BODYPART_RIGHT_LOWER_LEG]:=TKraftShapeCapsule.Create(KraftPhysics,RagdollRigidBody[BODYPART_RIGHT_LOWER_LEG],ScaleRagDoll*0.05,ScaleRagDoll*0.37);
|
||||
RagdollRigidBody[BODYPART_RIGHT_LOWER_LEG].Finish;
|
||||
RagdollRigidBody[BODYPART_RIGHT_LOWER_LEG].SetWorldTransformation(Matrix4x4TermMul(Matrix4x4TermMul(Matrix4x4RotateX(pi*0.0),Matrix4x4Translate(ScaleRagDoll*(0.18),ScaleRagDoll*(-0.2),0.0)),RagdollOffset));
|
||||
RagdollRigidBody[BODYPART_RIGHT_LOWER_LEG].SetToAwake;
|
||||
RagdollRigidBody[BODYPART_RIGHT_LOWER_LEG].Flags:=RagdollRigidBody[BODYPART_RIGHT_LOWER_LEG].Flags-[krbfContinuous];
|
||||
|
||||
RagdollRigidBody[BODYPART_LEFT_UPPER_ARM]:=TKraftRigidBody.Create(KraftPhysics);
|
||||
RagdollRigidBody[BODYPART_LEFT_UPPER_ARM].SetRigidBodyType(krbtDYNAMIC);
|
||||
RagdollShape[BODYPART_LEFT_UPPER_ARM]:=TKraftShapeCapsule.Create(KraftPhysics,RagdollRigidBody[BODYPART_LEFT_UPPER_ARM],ScaleRagDoll*0.05,ScaleRagDoll*0.33);
|
||||
RagdollRigidBody[BODYPART_LEFT_UPPER_ARM].Finish;
|
||||
RagdollRigidBody[BODYPART_LEFT_UPPER_ARM].SetWorldTransformation(Matrix4x4TermMul(Matrix4x4TermMul(Matrix4x4RotateZ(pi*0.5),Matrix4x4Translate(ScaleRagDoll*(-0.35),ScaleRagDoll*1.45,0.0)),RagdollOffset));
|
||||
RagdollRigidBody[BODYPART_LEFT_UPPER_ARM].SetToAwake;
|
||||
RagdollRigidBody[BODYPART_LEFT_UPPER_ARM].Flags:=RagdollRigidBody[BODYPART_LEFT_UPPER_ARM].Flags-[krbfContinuous];
|
||||
|
||||
RagdollRigidBody[BODYPART_LEFT_LOWER_ARM]:=TKraftRigidBody.Create(KraftPhysics);
|
||||
RagdollRigidBody[BODYPART_LEFT_LOWER_ARM].SetRigidBodyType(krbtDYNAMIC);
|
||||
RagdollShape[BODYPART_LEFT_LOWER_ARM]:=TKraftShapeCapsule.Create(KraftPhysics,RagdollRigidBody[BODYPART_LEFT_LOWER_ARM],ScaleRagDoll*0.04,ScaleRagDoll*0.25);
|
||||
RagdollRigidBody[BODYPART_LEFT_LOWER_ARM].Finish;
|
||||
RagdollRigidBody[BODYPART_LEFT_LOWER_ARM].SetWorldTransformation(Matrix4x4TermMul(Matrix4x4TermMul(Matrix4x4RotateZ(pi*0.5),Matrix4x4Translate(ScaleRagDoll*(-0.7),ScaleRagDoll*1.45,0.0)),RagdollOffset));
|
||||
RagdollRigidBody[BODYPART_LEFT_LOWER_ARM].SetToAwake;
|
||||
RagdollRigidBody[BODYPART_LEFT_LOWER_ARM].Flags:=RagdollRigidBody[BODYPART_LEFT_LOWER_ARM].Flags-[krbfContinuous];
|
||||
|
||||
RagdollRigidBody[BODYPART_RIGHT_UPPER_ARM]:=TKraftRigidBody.Create(KraftPhysics);
|
||||
RagdollRigidBody[BODYPART_RIGHT_UPPER_ARM].SetRigidBodyType(krbtDYNAMIC);
|
||||
RagdollShape[BODYPART_RIGHT_UPPER_ARM]:=TKraftShapeCapsule.Create(KraftPhysics,RagdollRigidBody[BODYPART_RIGHT_UPPER_ARM],ScaleRagDoll*0.05,ScaleRagDoll*0.33);
|
||||
RagdollRigidBody[BODYPART_RIGHT_UPPER_ARM].Finish;
|
||||
RagdollRigidBody[BODYPART_RIGHT_UPPER_ARM].SetWorldTransformation(Matrix4x4TermMul(Matrix4x4TermMul(Matrix4x4RotateZ(-(pi*0.5)),Matrix4x4Translate(ScaleRagDoll*(0.35),ScaleRagDoll*1.45,0.0)),RagdollOffset));
|
||||
RagdollRigidBody[BODYPART_RIGHT_UPPER_ARM].SetToAwake;
|
||||
RagdollRigidBody[BODYPART_RIGHT_UPPER_ARM].Flags:=RagdollRigidBody[BODYPART_RIGHT_UPPER_ARM].Flags-[krbfContinuous];
|
||||
|
||||
RagdollRigidBody[BODYPART_RIGHT_LOWER_ARM]:=TKraftRigidBody.Create(KraftPhysics);
|
||||
RagdollRigidBody[BODYPART_RIGHT_LOWER_ARM].SetRigidBodyType(krbtDYNAMIC);
|
||||
RagdollShape[BODYPART_RIGHT_LOWER_ARM]:=TKraftShapeCapsule.Create(KraftPhysics,RagdollRigidBody[BODYPART_RIGHT_LOWER_ARM],ScaleRagDoll*0.04,ScaleRagDoll*0.25);
|
||||
RagdollRigidBody[BODYPART_RIGHT_LOWER_ARM].Finish;
|
||||
RagdollRigidBody[BODYPART_RIGHT_LOWER_ARM].SetWorldTransformation(Matrix4x4TermMul(Matrix4x4TermMul(Matrix4x4RotateZ(-(pi*0.5)),Matrix4x4Translate(ScaleRagDoll*(0.7),ScaleRagDoll*1.45,0.0)),RagdollOffset));
|
||||
RagdollRigidBody[BODYPART_RIGHT_LOWER_ARM].SetToAwake;
|
||||
RagdollRigidBody[BODYPART_RIGHT_LOWER_ARM].Flags:=RagdollRigidBody[BODYPART_RIGHT_LOWER_ARM].Flags-[krbfContinuous];
|
||||
|
||||
/// ******* PELVIS ******** ///
|
||||
RagdollConstraints[0]:=TKraftConstraintJointBallSocket.Create(KraftPhysics,
|
||||
RagdollRigidBody[BODYPART_PELVIS],
|
||||
RagdollRigidBody[BODYPART_SPINE],
|
||||
Vector3(0.0,0.15*ScaleRagdoll,0.0),
|
||||
Vector3(0.0,-(0.15*ScaleRagdoll),0.0));
|
||||
|
||||
/// ******* SPINE HEAD ******** ///
|
||||
RagdollConstraints[1]:=TKraftConstraintJointBallSocket.Create(KraftPhysics,
|
||||
RagdollRigidBody[BODYPART_SPINE],
|
||||
RagdollRigidBody[BODYPART_HEAD],
|
||||
Vector3(0.0,0.25*ScaleRagdoll,0.0),
|
||||
Vector3(0.0,-(0.15*ScaleRagdoll),0.0),
|
||||
true);
|
||||
|
||||
/// ******* LEFT HIP ******** ///
|
||||
RagdollConstraints[2]:=TKraftConstraintJointBallSocket.Create(KraftPhysics,
|
||||
RagdollRigidBody[BODYPART_PELVIS],
|
||||
RagdollRigidBody[BODYPART_LEFT_UPPER_LEG],
|
||||
Vector3(-(0.18*ScaleRagdoll),-(0.10*ScaleRagdoll),0.0),
|
||||
Vector3(0.0*ScaleRagdoll,0.225*ScaleRagdoll,0.0));
|
||||
|
||||
/// ******* LEFT KNEE ******** ///
|
||||
RagdollConstraints[3]:=TKraftConstraintJointBallSocket.Create(KraftPhysics,
|
||||
RagdollRigidBody[BODYPART_LEFT_UPPER_LEG],
|
||||
RagdollRigidBody[BODYPART_LEFT_LOWER_LEG],
|
||||
Vector3(0.0,-(0.225*ScaleRagdoll),0.0),
|
||||
Vector3(0.0*ScaleRagdoll,0.185*ScaleRagdoll,0.0));
|
||||
|
||||
/// ******* RIGHT HIP ******** ///
|
||||
RagdollConstraints[4]:=TKraftConstraintJointBallSocket.Create(KraftPhysics,
|
||||
RagdollRigidBody[BODYPART_PELVIS],
|
||||
RagdollRigidBody[BODYPART_RIGHT_UPPER_LEG],
|
||||
Vector3(0.18*ScaleRagdoll,-(0.10*ScaleRagdoll),0.0),
|
||||
Vector3(0.0*ScaleRagdoll,0.225*ScaleRagdoll,0.0));
|
||||
|
||||
/// ******* RIGHT KNEE ******** ///
|
||||
RagdollConstraints[5]:=TKraftConstraintJointBallSocket.Create(KraftPhysics,
|
||||
RagdollRigidBody[BODYPART_RIGHT_UPPER_LEG],
|
||||
RagdollRigidBody[BODYPART_RIGHT_LOWER_LEG],
|
||||
Vector3(0.0,-(0.225*ScaleRagdoll),0.0),
|
||||
Vector3(0.0*ScaleRagdoll,0.185*ScaleRagdoll,0.0));
|
||||
/// ******* LEFT SHOULDER ******** ///
|
||||
RagdollConstraints[6]:=TKraftConstraintJointBallSocket.Create(KraftPhysics,
|
||||
RagdollRigidBody[BODYPART_SPINE],
|
||||
RagdollRigidBody[BODYPART_LEFT_UPPER_ARM],
|
||||
Vector3(-(0.2*ScaleRagdoll),0.15*ScaleRagdoll,0.0),
|
||||
Vector3(0.0*ScaleRagdoll,-(0.18*ScaleRagdoll),0.0));
|
||||
|
||||
/// ******* LEFT ELBOW ******** ///
|
||||
RagdollConstraints[7]:=TKraftConstraintJointBallSocket.Create(KraftPhysics,
|
||||
RagdollRigidBody[BODYPART_LEFT_UPPER_ARM],
|
||||
RagdollRigidBody[BODYPART_LEFT_LOWER_ARM],
|
||||
Vector3(0.0,0.18*ScaleRagdoll,0.0),
|
||||
Vector3(0.0,-(0.14*ScaleRagdoll),0.0));
|
||||
|
||||
/// ******* RIGHT SHOULDER ******** ///
|
||||
RagdollConstraints[8]:=TKraftConstraintJointBallSocket.Create(KraftPhysics,
|
||||
RagdollRigidBody[BODYPART_SPINE],
|
||||
RagdollRigidBody[BODYPART_RIGHT_UPPER_ARM],
|
||||
Vector3(0.2*ScaleRagdoll,0.15*ScaleRagdoll,0.0),
|
||||
Vector3(0.0*ScaleRagdoll,-(0.18*ScaleRagdoll),0.0));
|
||||
|
||||
/// ******* RIGHT ELBOW ******** ///
|
||||
RagdollConstraints[9]:=TKraftConstraintJointBallSocket.Create(KraftPhysics,
|
||||
RagdollRigidBody[BODYPART_RIGHT_UPPER_ARM],
|
||||
RagdollRigidBody[BODYPART_RIGHT_LOWER_ARM],
|
||||
Vector3(0.0,0.18*ScaleRagdoll,0.0),
|
||||
Vector3(0.0,-(0.14*ScaleRagdoll),0.0));
|
||||
|
||||
{
|
||||
/// ******* RIGHT SHOULDER ******** ///
|
||||
RagdollConstraints[8]:=TKraftConstraintJointBallSocket.Create(KraftPhysics,RagdollRigidBody[BODYPART_SPINE],RagdollRigidBody[BODYPART_RIGHT_UPPER_ARM],Vector3(0.25*ScaleRagdoll,0.15*ScaleRagdoll,0.0),Vector3(0.0,-(0.18*ScaleRagdoll),0.0));
|
||||
|
||||
/// ******* RIGHT ELBOW ******** ///
|
||||
RagdollConstraints[9]:=TKraftConstraintJointBallSocket.Create(KraftPhysics,RagdollRigidBody[BODYPART_RIGHT_UPPER_ARM],RagdollRigidBody[BODYPART_RIGHT_LOWER_ARM],Vector3(0.0,0.18*ScaleRagdoll,0.0),Vector3(0.0,-(0.25*ScaleRagdoll),0.0));
|
||||
|
||||
}
|
||||
end;
|
||||
end;
|
||||
|
||||
destructor TDemoSceneSandBox.Destroy;
|
||||
begin
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
procedure TDemoSceneSandBox.Step(const DeltaTime:double);
|
||||
begin
|
||||
end;
|
||||
|
||||
initialization
|
||||
RegisterDemoScene('Sand box',TDemoSceneSandBox);
|
||||
end.
|
||||
|
||||
|
||||
71
sandbox/UnitDemoSceneStrainedChain.pas
Normal file
71
sandbox/UnitDemoSceneStrainedChain.pas
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
unit UnitDemoSceneStrainedChain;
|
||||
|
||||
{$MODE Delphi}
|
||||
|
||||
interface
|
||||
|
||||
uses Kraft,UnitDemoScene;
|
||||
|
||||
type TDemoSceneStrainedChain=class(TDemoScene)
|
||||
public
|
||||
RigidBodyFloor:TKraftRigidBody;
|
||||
ShapeFloorPlane:TKraftShapePlane;
|
||||
constructor Create(const AKraftPhysics:TKraft); override;
|
||||
destructor Destroy; override;
|
||||
procedure Step(const DeltaTime:double); override;
|
||||
end;
|
||||
|
||||
implementation
|
||||
|
||||
uses UnitFormMain;
|
||||
|
||||
constructor TDemoSceneStrainedChain.Create(const AKraftPhysics:TKraft);
|
||||
const Count=11;
|
||||
Spacing=0.125;
|
||||
var Index:longint;
|
||||
RigidBody:array[0..Count-1] of TKraftRigidBody;
|
||||
Shape:TKraftShape;
|
||||
begin
|
||||
inherited Create(AKraftPhysics);
|
||||
|
||||
RigidBodyFloor:=TKraftRigidBody.Create(KraftPhysics);
|
||||
RigidBodyFloor.SetRigidBodyType(krbtSTATIC);
|
||||
ShapeFloorPlane:=TKraftShapePlane.Create(KraftPhysics,RigidBodyFloor,Plane(Vector3Norm(Vector3(0.0,1.0,0.0)),0.0));
|
||||
ShapeFloorPlane.Restitution:=0.3;
|
||||
RigidBodyFloor.Finish;
|
||||
RigidBodyFloor.SetWorldTransformation(Matrix4x4Translate(0.0,0.0,0.0));
|
||||
RigidBodyFloor.CollisionGroups:=[0];
|
||||
|
||||
for Index:=0 to Count-1 do begin
|
||||
RigidBody[Index]:=TKraftRigidBody.Create(KraftPhysics);
|
||||
if (Index=0) or (Index=(Count-1)) then begin
|
||||
RigidBody[Index].SetRigidBodyType(krbtSTATIC);
|
||||
end else begin
|
||||
RigidBody[Index].SetRigidBodyType(krbtDYNAMIC);
|
||||
end;
|
||||
Shape:=TKraftShapeSphere.Create(KraftPhysics,RigidBody[Index],1.0);
|
||||
Shape.Restitution:=0.3;
|
||||
Shape.Density:=1.0;
|
||||
RigidBody[Index].Finish;
|
||||
RigidBody[Index].SetWorldTransformation(Matrix4x4Translate((Index-((Count-1)*0.5))*2.5,4.0,-4.0));
|
||||
RigidBody[Index].CollisionGroups:=[0];
|
||||
end;
|
||||
|
||||
for Index:=1 to Count-1 do begin
|
||||
TKraftConstraintJointBallSocket.Create(KraftPhysics,RigidBody[Index-1],RigidBody[Index],Vector3(1.125,0.0,0.0),Vector3(-1.125,0.0,0.0),true);
|
||||
end;
|
||||
|
||||
end;
|
||||
|
||||
destructor TDemoSceneStrainedChain.Destroy;
|
||||
begin
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
procedure TDemoSceneStrainedChain.Step(const DeltaTime:double);
|
||||
begin
|
||||
end;
|
||||
|
||||
initialization
|
||||
RegisterDemoScene('Strained chain',TDemoSceneStrainedChain);
|
||||
end.
|
||||
406
sandbox/UnitFormMain.lfm
Normal file
406
sandbox/UnitFormMain.lfm
Normal file
|
|
@ -0,0 +1,406 @@
|
|||
object FormMain: TFormMain
|
||||
Left = 0
|
||||
Height = 675
|
||||
Top = 266
|
||||
Width = 945
|
||||
Caption = 'Kraft physics engine sandbox - Copyright (C) 2015-2016, Benjamin ''BeRo'' Rosseaux'
|
||||
ClientHeight = 655
|
||||
ClientWidth = 945
|
||||
Color = clBtnFace
|
||||
Font.Color = clWindowText
|
||||
Font.Height = -11
|
||||
Font.Name = 'MS Sans Serif'
|
||||
KeyPreview = True
|
||||
Menu = MainMenu1
|
||||
OnCreate = FormCreate
|
||||
OnDestroy = FormDestroy
|
||||
OnShow = FormShow
|
||||
Position = poScreenCenter
|
||||
LCLVersion = '1.6.0.4'
|
||||
WindowState = wsMaximized
|
||||
object sSplitter1: TSplitter
|
||||
Left = 305
|
||||
Height = 655
|
||||
Top = 0
|
||||
Width = 5
|
||||
ResizeStyle = rsLine
|
||||
end
|
||||
object sSplitter3: TSplitter
|
||||
Left = 755
|
||||
Height = 655
|
||||
Top = 0
|
||||
Width = 5
|
||||
Align = alRight
|
||||
ResizeAnchor = akRight
|
||||
ResizeStyle = rsLine
|
||||
end
|
||||
object sPanelLeft: TPanel
|
||||
Left = 0
|
||||
Height = 655
|
||||
Top = 0
|
||||
Width = 305
|
||||
Align = alLeft
|
||||
BevelOuter = bvNone
|
||||
ClientHeight = 655
|
||||
ClientWidth = 305
|
||||
TabOrder = 0
|
||||
object sSplitter2: TSplitter
|
||||
Cursor = crVSplit
|
||||
Left = 0
|
||||
Height = 6
|
||||
Top = 297
|
||||
Width = 305
|
||||
Align = alTop
|
||||
ResizeAnchor = akTop
|
||||
ResizeStyle = rsLine
|
||||
end
|
||||
object sPanelLeftTop: TPanel
|
||||
Left = 0
|
||||
Height = 297
|
||||
Top = 0
|
||||
Width = 305
|
||||
Align = alTop
|
||||
BevelOuter = bvNone
|
||||
ClientHeight = 297
|
||||
ClientWidth = 305
|
||||
TabOrder = 0
|
||||
object sGroupBoxTree: TGroupBox
|
||||
Left = 0
|
||||
Height = 297
|
||||
Top = 0
|
||||
Width = 305
|
||||
Align = alClient
|
||||
Caption = 'Tree'
|
||||
ClientHeight = 279
|
||||
ClientWidth = 301
|
||||
TabOrder = 0
|
||||
object sTreeViewMain: TTreeView
|
||||
Left = 0
|
||||
Height = 279
|
||||
Top = 0
|
||||
Width = 301
|
||||
Align = alClient
|
||||
Color = clWhite
|
||||
DefaultItemHeight = 16
|
||||
Font.Color = clBlack
|
||||
Font.Height = -11
|
||||
Font.Name = 'MS Sans Serif'
|
||||
HideSelection = False
|
||||
Indent = 19
|
||||
ParentFont = False
|
||||
ReadOnly = True
|
||||
TabOrder = 0
|
||||
OnChange = sTreeViewMainChange
|
||||
Options = [tvoAutoItemHeight, tvoKeepCollapsedNodes, tvoReadOnly, tvoShowButtons, tvoShowLines, tvoShowRoot, tvoToolTips, tvoThemedDraw]
|
||||
end
|
||||
end
|
||||
end
|
||||
object sPanelLeftBottom: TPanel
|
||||
Left = 0
|
||||
Height = 352
|
||||
Top = 303
|
||||
Width = 305
|
||||
Align = alClient
|
||||
BevelOuter = bvNone
|
||||
ClientHeight = 352
|
||||
ClientWidth = 305
|
||||
TabOrder = 1
|
||||
object sGroupBoxPropertyEditor: TGroupBox
|
||||
Left = 0
|
||||
Height = 352
|
||||
Top = 0
|
||||
Width = 305
|
||||
Align = alClient
|
||||
Caption = 'Property editor'
|
||||
TabOrder = 0
|
||||
end
|
||||
end
|
||||
end
|
||||
object sPanelRight: TPanel
|
||||
Left = 760
|
||||
Height = 655
|
||||
Top = 0
|
||||
Width = 185
|
||||
Align = alRight
|
||||
BevelOuter = bvNone
|
||||
ClientHeight = 655
|
||||
ClientWidth = 185
|
||||
TabOrder = 1
|
||||
object sGroupBoxDemos: TGroupBox
|
||||
Left = 0
|
||||
Height = 655
|
||||
Top = 0
|
||||
Width = 185
|
||||
Align = alClient
|
||||
Caption = 'Demos'
|
||||
ClientHeight = 637
|
||||
ClientWidth = 181
|
||||
TabOrder = 0
|
||||
object sTreeViewDemos: TTreeView
|
||||
Left = 0
|
||||
Height = 637
|
||||
Top = 0
|
||||
Width = 181
|
||||
Align = alClient
|
||||
Color = clWhite
|
||||
DefaultItemHeight = 16
|
||||
Font.Color = clBlack
|
||||
Font.Height = -11
|
||||
Font.Name = 'MS Sans Serif'
|
||||
HideSelection = False
|
||||
Indent = 19
|
||||
ParentFont = False
|
||||
ReadOnly = True
|
||||
TabOrder = 0
|
||||
OnDblClick = sTreeViewDemosDblClick
|
||||
OnKeyPress = sTreeViewDemosKeyPress
|
||||
Options = [tvoAutoItemHeight, tvoKeepCollapsedNodes, tvoReadOnly, tvoShowButtons, tvoShowLines, tvoShowRoot, tvoToolTips, tvoThemedDraw]
|
||||
end
|
||||
end
|
||||
end
|
||||
object sPanelMiddle: TPanel
|
||||
Left = 310
|
||||
Height = 655
|
||||
Top = 0
|
||||
Width = 445
|
||||
Align = alClient
|
||||
BevelOuter = bvNone
|
||||
ClientHeight = 655
|
||||
ClientWidth = 445
|
||||
FullRepaint = False
|
||||
TabOrder = 2
|
||||
object sSplitter4: TSplitter
|
||||
Cursor = crVSplit
|
||||
Left = 0
|
||||
Height = 6
|
||||
Top = 481
|
||||
Width = 445
|
||||
Align = alBottom
|
||||
ResizeAnchor = akBottom
|
||||
ResizeStyle = rsLine
|
||||
end
|
||||
object sPanelMiddleBottom: TPanel
|
||||
Left = 0
|
||||
Height = 168
|
||||
Top = 487
|
||||
Width = 445
|
||||
Align = alBottom
|
||||
BevelOuter = bvNone
|
||||
ClientHeight = 168
|
||||
ClientWidth = 445
|
||||
TabOrder = 0
|
||||
object sPageControl1: TPageControl
|
||||
Left = 0
|
||||
Height = 168
|
||||
Top = 0
|
||||
Width = 445
|
||||
ActivePage = sTabSheetInfo
|
||||
Align = alClient
|
||||
TabIndex = 0
|
||||
TabOrder = 0
|
||||
object sTabSheetInfo: TTabSheet
|
||||
Caption = 'Info'
|
||||
ClientHeight = 142
|
||||
ClientWidth = 437
|
||||
object sMemoInfo: TMemo
|
||||
Left = 0
|
||||
Height = 142
|
||||
Top = 0
|
||||
Width = 437
|
||||
Align = alClient
|
||||
Color = clWhite
|
||||
Font.Color = clBlack
|
||||
Font.Height = -11
|
||||
Font.Name = 'MS Sans Serif'
|
||||
Lines.Strings = (
|
||||
'Left button = rotate, OR (due to Delphi''s OnMouseDown limitations), right button = Grab and '
|
||||
'rotate'
|
||||
'Cursor keys / WASD = Move forwards, backwards and sidewars '
|
||||
'PageUp/PageDown R/F = Move upwards and downwards'
|
||||
'Space = Fire a sphere'
|
||||
''
|
||||
'Attention: Some demo scenes needs higher count of velocity iterations and/or position '
|
||||
'iterations and/or a higher world update frequency, for to being (more) stable.'
|
||||
)
|
||||
ParentFont = False
|
||||
ReadOnly = True
|
||||
TabOrder = 0
|
||||
end
|
||||
end
|
||||
object sTabSheetPerformance: TTabSheet
|
||||
Caption = 'Performance'
|
||||
ClientHeight = 0
|
||||
ClientWidth = 0
|
||||
object sLabelBroadPhaseTime: TLabel
|
||||
Left = 8
|
||||
Height = 13
|
||||
Top = 8
|
||||
Width = 657
|
||||
AutoSize = False
|
||||
Caption = '0 '
|
||||
ParentColor = False
|
||||
end
|
||||
object sLabelMidPhaseTime: TLabel
|
||||
Left = 8
|
||||
Height = 13
|
||||
Top = 24
|
||||
Width = 721
|
||||
AutoSize = False
|
||||
Caption = '0 '
|
||||
ParentColor = False
|
||||
end
|
||||
object sLabelNarrowPhaseTime: TLabel
|
||||
Left = 8
|
||||
Height = 13
|
||||
Top = 40
|
||||
Width = 721
|
||||
AutoSize = False
|
||||
Caption = '0 '
|
||||
ParentColor = False
|
||||
end
|
||||
object sLabelSolverTime: TLabel
|
||||
Left = 8
|
||||
Height = 13
|
||||
Top = 56
|
||||
Width = 721
|
||||
AutoSize = False
|
||||
Caption = '0 '
|
||||
ParentColor = False
|
||||
end
|
||||
object sLabelContinuousTime: TLabel
|
||||
Left = 8
|
||||
Height = 13
|
||||
Top = 72
|
||||
Width = 721
|
||||
AutoSize = False
|
||||
Caption = '0 '
|
||||
ParentColor = False
|
||||
end
|
||||
object sLabelTotalTime: TLabel
|
||||
Left = 8
|
||||
Height = 13
|
||||
Top = 88
|
||||
Width = 721
|
||||
AutoSize = False
|
||||
Caption = '0 '
|
||||
ParentColor = False
|
||||
end
|
||||
end
|
||||
object sTabSheetSettings: TTabSheet
|
||||
Caption = 'Settings'
|
||||
ClientHeight = 142
|
||||
ClientWidth = 437
|
||||
object sCheckBoxDrawDynamicAABBTree: TCheckBox
|
||||
Left = 8
|
||||
Height = 19
|
||||
Top = 8
|
||||
Width = 142
|
||||
Caption = 'Draw dynamic AABB tree '
|
||||
TabOrder = 0
|
||||
end
|
||||
object sCheckBoxDrawContacts: TCheckBox
|
||||
Left = 8
|
||||
Height = 19
|
||||
Top = 32
|
||||
Width = 89
|
||||
Caption = 'Draw contacts'
|
||||
Checked = True
|
||||
State = cbChecked
|
||||
TabOrder = 1
|
||||
end
|
||||
object sCheckBoxDrawWireFrame: TCheckBox
|
||||
Left = 8
|
||||
Height = 19
|
||||
Top = 56
|
||||
Width = 93
|
||||
Caption = 'Draw wireframe'
|
||||
TabOrder = 2
|
||||
end
|
||||
object sCheckBoxDrawSolid: TCheckBox
|
||||
Left = 8
|
||||
Height = 19
|
||||
Top = 80
|
||||
Width = 69
|
||||
Caption = 'Draw solid'
|
||||
Checked = True
|
||||
State = cbChecked
|
||||
TabOrder = 3
|
||||
end
|
||||
object sCheckBoxDrawConstraints: TCheckBox
|
||||
Left = 8
|
||||
Height = 19
|
||||
Top = 104
|
||||
Width = 99
|
||||
Caption = 'Draw constraints'
|
||||
Checked = True
|
||||
State = cbChecked
|
||||
TabOrder = 4
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
object sPageControl2: TPageControl
|
||||
Left = 0
|
||||
Height = 481
|
||||
Top = 0
|
||||
Width = 445
|
||||
ActivePage = sTabSheetWorld
|
||||
Align = alClient
|
||||
TabIndex = 0
|
||||
TabOrder = 1
|
||||
object sTabSheetWorld: TTabSheet
|
||||
Caption = 'World'
|
||||
ClientHeight = 455
|
||||
ClientWidth = 437
|
||||
object OpenGLControlWorld: TOpenGLControl
|
||||
Left = 0
|
||||
Height = 455
|
||||
Top = 0
|
||||
Width = 437
|
||||
Align = alClient
|
||||
OpenGLMajorVersion = 2
|
||||
OnEnter = OpenGLControlWorldEnter
|
||||
OnExit = OpenGLControlWorldExit
|
||||
OnKeyDown = OpenGLControlWorldKeyDown
|
||||
OnKeyUp = OpenGLControlWorldKeyUp
|
||||
OnMouseDown = OpenGLControlWorldMouseDown
|
||||
OnMouseMove = OpenGLControlWorldMouseMove
|
||||
OnMouseUp = OpenGLControlWorldMouseUp
|
||||
OnMouseWheel = OpenGLControlWorldMouseWheel
|
||||
OnPaint = OpenGLControlWorldPaint
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
object MainMenu1: TMainMenu
|
||||
left = 392
|
||||
top = 80
|
||||
object N1: TMenuItem
|
||||
Caption = '&File'
|
||||
object N2: TMenuItem
|
||||
Caption = '&Quit'
|
||||
ShortCut = 32883
|
||||
OnClick = N2Click
|
||||
end
|
||||
end
|
||||
object N3: TMenuItem
|
||||
Caption = '&Settings'
|
||||
Visible = False
|
||||
object Skinned1: TMenuItem
|
||||
Caption = '&Skinned'
|
||||
OnClick = Skinned1Click
|
||||
end
|
||||
end
|
||||
end
|
||||
object TimerPerformance: TTimer
|
||||
Interval = 20
|
||||
OnTimer = TimerPerformanceTimer
|
||||
left = 547
|
||||
top = 424
|
||||
end
|
||||
object TimerFPS: TTimer
|
||||
OnTimer = TimerFPSTimer
|
||||
left = 624
|
||||
top = 424
|
||||
end
|
||||
end
|
||||
1371
sandbox/UnitFormMain.pas
Normal file
1371
sandbox/UnitFormMain.pas
Normal file
File diff suppressed because it is too large
Load diff
BIN
sandbox/kraftsandbox.exe
Normal file
BIN
sandbox/kraftsandbox.exe
Normal file
Binary file not shown.
269
sandbox/kraftsandbox.lpi
Normal file
269
sandbox/kraftsandbox.lpi
Normal file
|
|
@ -0,0 +1,269 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<CONFIG>
|
||||
<ProjectOptions>
|
||||
<Version Value="10"/>
|
||||
<PathDelim Value="\"/>
|
||||
<General>
|
||||
<Flags>
|
||||
<MainUnitHasUsesSectionForAllUnits Value="False"/>
|
||||
<MainUnitHasCreateFormStatements Value="False"/>
|
||||
<MainUnitHasTitleStatement Value="False"/>
|
||||
</Flags>
|
||||
<SessionStorage Value="InProjectDir"/>
|
||||
<MainUnit Value="0"/>
|
||||
<Title Value="kraftsandbox"/>
|
||||
<UseAppBundle Value="False"/>
|
||||
<ResourceType Value="res"/>
|
||||
</General>
|
||||
<i18n>
|
||||
<EnableI18N LFM="False"/>
|
||||
</i18n>
|
||||
<BuildModes Count="3">
|
||||
<Item1 Name="Default" Default="True"/>
|
||||
<Item2 Name="Debug">
|
||||
<CompilerOptions>
|
||||
<Version Value="11"/>
|
||||
<PathDelim Value="\"/>
|
||||
<SearchPaths>
|
||||
<IncludeFiles Value="..\src;..\..\..\PASMP.github\trunk\src;$(ProjOutDir)"/>
|
||||
<OtherUnitFiles Value="..\src;..\..\..\PASMP.github\trunk\src"/>
|
||||
</SearchPaths>
|
||||
<Parsing>
|
||||
<SyntaxOptions>
|
||||
<SyntaxMode Value="Delphi"/>
|
||||
<IncludeAssertionCode Value="True"/>
|
||||
</SyntaxOptions>
|
||||
</Parsing>
|
||||
<CodeGeneration>
|
||||
<Checks>
|
||||
<IOChecks Value="True"/>
|
||||
<RangeChecks Value="True"/>
|
||||
<OverflowChecks Value="True"/>
|
||||
<StackChecks Value="True"/>
|
||||
</Checks>
|
||||
</CodeGeneration>
|
||||
<Linking>
|
||||
<Debugging>
|
||||
<DebugInfoType Value="dsDwarf2Set"/>
|
||||
<UseHeaptrc Value="True"/>
|
||||
<UseExternalDbgSyms Value="True"/>
|
||||
</Debugging>
|
||||
<Options>
|
||||
<Win32>
|
||||
<GraphicApplication Value="True"/>
|
||||
</Win32>
|
||||
</Options>
|
||||
</Linking>
|
||||
<Other>
|
||||
<CustomOptions Value="-ddebugdraw
|
||||
-dPasMP
|
||||
-dKraftPasMP"/>
|
||||
<OtherDefines Count="3">
|
||||
<Define0 Value="debugdraw"/>
|
||||
<Define1 Value="PasMP"/>
|
||||
<Define2 Value="KraftPasMP"/>
|
||||
</OtherDefines>
|
||||
</Other>
|
||||
</CompilerOptions>
|
||||
</Item2>
|
||||
<Item3 Name="Release">
|
||||
<CompilerOptions>
|
||||
<Version Value="11"/>
|
||||
<PathDelim Value="\"/>
|
||||
<SearchPaths>
|
||||
<IncludeFiles Value="..\src;..\..\..\PASMP.github\trunk\src;$(ProjOutDir)"/>
|
||||
<OtherUnitFiles Value="..\src;..\..\..\PASMP.github\trunk\src"/>
|
||||
</SearchPaths>
|
||||
<Parsing>
|
||||
<SyntaxOptions>
|
||||
<SyntaxMode Value="Delphi"/>
|
||||
</SyntaxOptions>
|
||||
</Parsing>
|
||||
<CodeGeneration>
|
||||
<SmartLinkUnit Value="True"/>
|
||||
<TargetCPU Value="i386"/>
|
||||
<Optimizations>
|
||||
<OptimizationLevel Value="4"/>
|
||||
</Optimizations>
|
||||
</CodeGeneration>
|
||||
<Linking>
|
||||
<Debugging>
|
||||
<GenerateDebugInfo Value="False"/>
|
||||
</Debugging>
|
||||
<LinkSmart Value="True"/>
|
||||
<Options>
|
||||
<Win32>
|
||||
<GraphicApplication Value="True"/>
|
||||
</Win32>
|
||||
</Options>
|
||||
</Linking>
|
||||
<Other>
|
||||
<CustomOptions Value="-ddebugdraw
|
||||
-dPasMP
|
||||
-dKraftPasMP"/>
|
||||
<OtherDefines Count="3">
|
||||
<Define0 Value="debugdraw"/>
|
||||
<Define1 Value="PasMP"/>
|
||||
<Define2 Value="KraftPasMP"/>
|
||||
</OtherDefines>
|
||||
</Other>
|
||||
</CompilerOptions>
|
||||
</Item3>
|
||||
</BuildModes>
|
||||
<PublishOptions>
|
||||
<Version Value="2"/>
|
||||
</PublishOptions>
|
||||
<RunParams>
|
||||
<local>
|
||||
<FormatVersion Value="1"/>
|
||||
</local>
|
||||
</RunParams>
|
||||
<RequiredPackages Count="3">
|
||||
<Item1>
|
||||
<PackageName Value="IDEIntf"/>
|
||||
</Item1>
|
||||
<Item2>
|
||||
<PackageName Value="LazOpenGLContext"/>
|
||||
</Item2>
|
||||
<Item3>
|
||||
<PackageName Value="LCL"/>
|
||||
</Item3>
|
||||
</RequiredPackages>
|
||||
<Units Count="22">
|
||||
<Unit0>
|
||||
<Filename Value="kraftsandbox.lpr"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
</Unit0>
|
||||
<Unit1>
|
||||
<Filename Value="UnitFormMain.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<ComponentName Value="FormMain"/>
|
||||
<HasResources Value="True"/>
|
||||
<ResourceBaseClass Value="Form"/>
|
||||
</Unit1>
|
||||
<Unit2>
|
||||
<Filename Value="..\src\kraft.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
</Unit2>
|
||||
<Unit3>
|
||||
<Filename Value="UnitDemoScene.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
</Unit3>
|
||||
<Unit4>
|
||||
<Filename Value="UnitDemoSceneBoxOnPlane.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
</Unit4>
|
||||
<Unit5>
|
||||
<Filename Value="UnitDemoSceneSandBox.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
</Unit5>
|
||||
<Unit6>
|
||||
<Filename Value="UnitDemoSceneBoxStacking.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
</Unit6>
|
||||
<Unit7>
|
||||
<Filename Value="UnitDemoSceneBoxPyramidStacking.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
</Unit7>
|
||||
<Unit8>
|
||||
<Filename Value="UnitDemoSceneBridge.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
</Unit8>
|
||||
<Unit9>
|
||||
<Filename Value="UnitDemoSceneCombinedShapes.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
</Unit9>
|
||||
<Unit10>
|
||||
<Filename Value="UnitDemoSceneChain.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
</Unit10>
|
||||
<Unit11>
|
||||
<Filename Value="UnitDemoSceneStrainedChain.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
</Unit11>
|
||||
<Unit12>
|
||||
<Filename Value="UnitDemoSceneBrickWall.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
</Unit12>
|
||||
<Unit13>
|
||||
<Filename Value="UnitDemoSceneDomino.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
</Unit13>
|
||||
<Unit14>
|
||||
<Filename Value="UnitDemoSceneChairAndTable.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
</Unit14>
|
||||
<Unit15>
|
||||
<Filename Value="UnitDemoSceneConvexHull.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
</Unit15>
|
||||
<Unit16>
|
||||
<Filename Value="UnitDemoSceneCar.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
</Unit16>
|
||||
<Unit17>
|
||||
<Filename Value="..\..\..\PASMP.github\trunk\src\PasMP.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
</Unit17>
|
||||
<Unit18>
|
||||
<Filename Value="sandboxfile.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
</Unit18>
|
||||
<Unit19>
|
||||
<Filename Value="UnitDemoSceneCatapult.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
</Unit19>
|
||||
<Unit20>
|
||||
<Filename Value="UnitDemoSceneRoundabout.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
</Unit20>
|
||||
<Unit21>
|
||||
<Filename Value="UnitDemoSceneCarousel.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
</Unit21>
|
||||
</Units>
|
||||
</ProjectOptions>
|
||||
<CompilerOptions>
|
||||
<Version Value="11"/>
|
||||
<PathDelim Value="\"/>
|
||||
<SearchPaths>
|
||||
<IncludeFiles Value="..\src;..\..\..\PASMP.github\trunk\src;$(ProjOutDir)"/>
|
||||
<OtherUnitFiles Value="..\src;..\..\..\PASMP.github\trunk\src"/>
|
||||
</SearchPaths>
|
||||
<Parsing>
|
||||
<SyntaxOptions>
|
||||
<SyntaxMode Value="Delphi"/>
|
||||
</SyntaxOptions>
|
||||
</Parsing>
|
||||
<Linking>
|
||||
<Options>
|
||||
<Win32>
|
||||
<GraphicApplication Value="True"/>
|
||||
</Win32>
|
||||
</Options>
|
||||
</Linking>
|
||||
<Other>
|
||||
<CustomOptions Value="-ddebugdraw
|
||||
-dPasMP
|
||||
-dKraftPasMP"/>
|
||||
<OtherDefines Count="3">
|
||||
<Define0 Value="debugdraw"/>
|
||||
<Define1 Value="PasMP"/>
|
||||
<Define2 Value="KraftPasMP"/>
|
||||
</OtherDefines>
|
||||
</Other>
|
||||
</CompilerOptions>
|
||||
<Debugging>
|
||||
<Exceptions Count="3">
|
||||
<Item1>
|
||||
<Name Value="EAbort"/>
|
||||
</Item1>
|
||||
<Item2>
|
||||
<Name Value="ECodetoolError"/>
|
||||
</Item2>
|
||||
<Item3>
|
||||
<Name Value="EFOpenError"/>
|
||||
</Item3>
|
||||
</Exceptions>
|
||||
</Debugging>
|
||||
</CONFIG>
|
||||
43
sandbox/kraftsandbox.lpr
Normal file
43
sandbox/kraftsandbox.lpr
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
program kraftsandbox;
|
||||
|
||||
{$MODE Delphi}
|
||||
|
||||
uses
|
||||
{$ifdef unix}
|
||||
cthreads,
|
||||
{$endif}
|
||||
SysUtils,
|
||||
Forms, Interfaces,
|
||||
UnitFormMain in 'UnitFormMain.pas' {FormMain},
|
||||
kraft in '..\src\kraft.pas',
|
||||
{$ifdef KraftPasMP}
|
||||
PasMP in '..\..\..\PASMP.github\trunk\src\PasMP.pas',
|
||||
{$endif}
|
||||
UnitDemoScene in 'UnitDemoScene.pas',
|
||||
UnitDemoSceneCatapult,
|
||||
UnitDemoSceneRoundabout,
|
||||
UnitDemoSceneCarousel,
|
||||
UnitDemoSceneBoxOnPlane in 'UnitDemoSceneBoxOnPlane.pas',
|
||||
UnitDemoSceneSandBox in 'UnitDemoSceneSandBox.pas',
|
||||
UnitDemoSceneBoxStacking in 'UnitDemoSceneBoxStacking.pas',
|
||||
UnitDemoSceneBoxPyramidStacking in 'UnitDemoSceneBoxPyramidStacking.pas',
|
||||
UnitDemoSceneBridge in 'UnitDemoSceneBridge.pas',
|
||||
UnitDemoSceneCombinedShapes in 'UnitDemoSceneCombinedShapes.pas',
|
||||
UnitDemoSceneChain in 'UnitDemoSceneChain.pas',
|
||||
UnitDemoSceneStrainedChain in 'UnitDemoSceneStrainedChain.pas',
|
||||
UnitDemoSceneBrickWall in 'UnitDemoSceneBrickWall.pas',
|
||||
UnitDemoSceneDomino in 'UnitDemoSceneDomino.pas',
|
||||
UnitDemoSceneChairAndTable in 'UnitDemoSceneChairAndTable.pas',
|
||||
UnitDemoSceneConvexHull in 'UnitDemoSceneConvexHull.pas',
|
||||
UnitDemoSceneCar in 'UnitDemoSceneCar.pas';
|
||||
|
||||
{$R *.res}
|
||||
|
||||
begin
|
||||
FormatSettings.DecimalSeparator:='.';
|
||||
FormatSettings.ThousandSeparator:=',';
|
||||
//Application.UpdateFormatSettings:=false;
|
||||
Application.Initialize;
|
||||
Application.CreateForm(TFormMain, FormMain);
|
||||
Application.Run;
|
||||
end.
|
||||
BIN
sandbox/kraftsandbox.res
Normal file
BIN
sandbox/kraftsandbox.res
Normal file
Binary file not shown.
21050
sandbox/sandboxfile.pas
Normal file
21050
sandbox/sandboxfile.pas
Normal file
File diff suppressed because it is too large
Load diff
2860
src/kraft.pas
2860
src/kraft.pas
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue