📄 oxnewtonjoint.pas
字号:
unit oxNewtonJoint;
{******************************************************************************}
// [15-9-2007]: oxNewtonJoint last change by Dave Gravel. //
{******************************************************************************}
{===============================================================================
Version: MPL 1.1
The contents of this file are subject to the Mozilla Public License Version
1.1 (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.mozilla.org/MPL/
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
for the specific language governing rights and limitations under the
License.
The Original Code is "oxNewton opengl-Dynamics-delphi-component".
The Initial Developer of the Original Code is
Dave Gravel, OrionX3D Opengl & Delphi Programming, dave.gravel@cgocable.ca.
http://www.Dave.ServeUsers.com
http://www.k00m.sexidude.com
Portions created by Dave Gravel are Copyright (C) 2004 - 2006.
Dave Gravel. All Rights Reserved.
Contributor(s): GLScene (http://www.glscene.org) -
Julio Jerez and Alain Suero (http://www.newtondynamics.com) -
Sascha Willems (www.delphigl.de)
================================================================================
oxNewton v1.55 by Dave Gravel.
PS: I request only one thing from the users of my oxNewton Component,
it is to put on your about or your help a comment saying you using the
oxNewton Component with my name Dave Gravel and my
e-mail: dave.gravel@cgocable.ca
Don't modify or remove any comment or information on my file
if you do some modification on my code please contact me.
Read the Newton license too, it is realy important.
================================================================================}
interface
{******************************************************************************}
// [15-9-2007]: oxNewtonJoint last change by Dave Gravel. //
{******************************************************************************}
uses
// Windows
Forms, Windows, Classes, Messages, SysUtils, Graphics, Controls, ExtCtrls,
Dialogs, StdCtrls,
// GLScene
GLScene, GLMisc, GLObjects, VectorGeometry, GLVectorFileObjects, VectorLists,
PersistentClasses, OpenGL1x, GLTexture, GLMesh, MeshUtils, GLState, XCollection,
GLGeomObjects, GLVerletClothify, XOpenGL, GLTerrainRenderer, VectorTypes,
GLCrossPlatform, GLContext, GLSilhouette, TGA, GLFileSMD, JPEG,
// Newton
oxNewtonUtils, oxNewtonManager, oxNewtonImport;
{******************************************************************************}
// [15-9-2007]: TOXJointObject last change by Dave Gravel. //
{******************************************************************************}
type
{******************************************************************************}
// [15-9-2007]: TOXBallJoint last change by Dave Gravel. //
{******************************************************************************}
TOXBallJoint = class( TOXNewtonJoint )
private
FOrionX3D: byte;
FActived: boolean;
FJointConeMaxAngle, FJointConeTwistAngle: Float;
FCollisionState: integer;
FStiffness: Float;
FManager: TOXNewtonManager;
FOnBallCallBack: TOXJointBallCallBack;
function GetJAngle: TOXVector3;
function GetJOmega: TOXVector3;
function GetJForce: TOXVector3;
function GetStiffness: Float;
procedure SetStiffness( const val: Float );
function GetCollisionState: integer;
procedure SetCollisionState( const val: integer );
procedure SetTwistConeAngle( const val: Float );
procedure SetConeMaxAngle( const val: Float );
public
property Manager: TOXNewtonManager read FManager;
property Actived: boolean read FActived;
property JointGetAngle: TOXVector3 read GetJAngle;
property JointGetOmega: TOXVector3 read GetJOmega;
property JointGetForce: TOXVector3 read GetJForce;
property Joint;
procedure InitJoint( body1, body2: PNewtonBody );
constructor Create( aOwner: TComponent ); override;
Destructor Destroy; override;
procedure DoProgress( const progressTime: TProgressTimes ); override;
published
property JointCollisionState: integer read GetCollisionState write SetCollisionState;
property JointStiffness: Float read GetStiffness write SetStiffness;
property JointTwistConeAngle: Float read FJointConeTwistAngle write SetTwistConeAngle;
property JointMaxConeAngle: Float read FJointConeMaxAngle write SetConeMaxAngle;
property JointChildPin;
property JointParentPin;
property OnCallBack: TOXJointBallCallBack read FOnBallCallBack write FOnBallCallBack;
end;
{******************************************************************************}
// [15-9-2007]: TOXHingeJoint last change by Dave Gravel. //
{******************************************************************************}
TOXHingeJoint = class( TOXNewtonJoint )
private
FOrionX3D: byte;
FActived: boolean;
FCollisionState: integer;
FStiffness: Float;
FAngle: Float;
FManager: TOXNewtonManager;
FOnHingeCallBack: TOXJointHingeCallBack;
function GetStiffness: Float;
procedure SetStiffness( const val: Float );
function GetJAngle: TOXVector3;
function GetJOmega: TOXVector3;
function GetJForce: TOXVector3;
function GetCollisionState: integer;
procedure SetCollisionState( const val: integer );
public
property Manager: TOXNewtonManager read FManager;
property Actived: boolean read FActived;
property JointAngle: Float read FAngle write FAngle;
property JointGetAngle: TOXVector3 read GetJAngle;
property JointGetOmega: TOXVector3 read GetJOmega;
property JointGetForce: TOXVector3 read GetJForce;
property Joint;
procedure InitJoint( body1, body2: PNewtonBody );
constructor Create( aOwner: TComponent ); override;
Destructor Destroy; override;
procedure DoProgress( const progressTime: TProgressTimes ); override;
published
property JointCollisionState: integer read GetCollisionState write SetCollisionState;
property JointStiffness: Float read GetStiffness write SetStiffness;
property JointChildPin;
property JointParentPin;
property OnCallBack: TOXJointHingeCallBack read FOnHingeCallBack write FOnHingeCallBack;
end;
{******************************************************************************}
// [15-9-2007]: TOXSliderJoint last change by Dave Gravel. //
{******************************************************************************}
TOXSliderJoint = class( TOXNewtonJoint )
private
FOrionX3D: byte;
FActived: boolean;
FCollisionState: integer;
FStiffness: Float;
FManager: TOXNewtonManager;
FOnSliderCallBack: TOXJointSliderCallBack;
function GetStiffness: Float;
procedure SetStiffness( const val: Float );
function GetCollisionState: integer;
procedure SetCollisionState( const val: integer );
public
property Manager: TOXNewtonManager read FManager;
property Actived: boolean read FActived;
property Joint;
procedure InitJoint( body1, body2: PNewtonBody );
constructor Create( aOwner: TComponent ); override;
Destructor Destroy; override;
procedure DoProgress( const progressTime: TProgressTimes ); override;
published
property JointCollisionState: integer read GetCollisionState write SetCollisionState;
property JointStiffness: Float read GetStiffness write SetStiffness;
property JointChildPin;
property JointParentPin;
property OnCallBack: TOXJointSliderCallBack read FOnSliderCallBack write FOnSliderCallBack;
end;
{******************************************************************************}
// [15-9-2007]: TOXCorkscrewJoint last change by Dave Gravel. //
{******************************************************************************}
TOXCorkscrewJoint = class( TOXNewtonJoint )
private
FOrionX3D: byte;
FActived: boolean;
FCollisionState: integer;
FStiffness: Float;
FManager: TOXNewtonManager;
FOnCorkscrewCallBack: TOXJointCorkscrewCallBack;
function GetStiffness: Float;
procedure SetStiffness( const val: Float );
function GetJAngle: TOXVector3;
function GetJOmega: TOXVector3;
function GetJForce: TOXVector3;
function GetCollisionState: integer;
procedure SetCollisionState( const val: integer );
public
property Manager: TOXNewtonManager read FManager;
property Actived: boolean read FActived;
property JointGetAngle: TOXVector3 read GetJAngle;
property JointGetOmega: TOXVector3 read GetJOmega;
property JointGetForce: TOXVector3 read GetJForce;
property Joint;
procedure InitJoint( body1, body2: PNewtonBody );
constructor Create( aOwner: TComponent ); override;
Destructor Destroy; override;
procedure DoProgress( const progressTime: TProgressTimes ); override;
published
property JointCollisionState: integer read GetCollisionState write SetCollisionState;
property JointStiffness: Float read GetStiffness write SetStiffness;
property JointChildPin;
property JointParentPin;
property OnCallBack: TOXJointCorkscrewCallBack read FOnCorkscrewCallBack write FOnCorkscrewCallBack;
end;
{******************************************************************************}
// [15-9-2007]: TOXUniversalJoint last change by Dave Gravel. //
{******************************************************************************}
TOXUniversalJoint = class( TOXNewtonJoint )
private
FOrionX3D: byte;
FActived: boolean;
FCollisionState: integer;
FStiffness: Float;
FManager: TOXNewtonManager;
FOnUniversalCallBack: TOXJointUniversalCallBack;
function GetStiffness: Float;
procedure SetStiffness( const val: Float );
function GetCollisionState: integer;
procedure SetCollisionState( const val: integer );
public
property Manager: TOXNewtonManager read FManager;
property Actived: boolean read FActived;
property Joint;
procedure InitJoint( body1, body2: PNewtonBody );
constructor Create( aOwner: TComponent ); override;
Destructor Destroy; override;
procedure DoProgress( const progressTime: TProgressTimes ); override;
published
property JointCollisionState: integer read GetCollisionState write SetCollisionState;
property JointStiffness: Float read GetStiffness write SetStiffness;
property JointChildPin;
property JointParentPin;
property OnCallBack: TOXJointUniversalCallBack read FOnUniversalCallBack write FOnUniversalCallBack;
end;
{******************************************************************************}
// [15-9-2007]: TOXUpVectorJoint last change by Dave Gravel. //
{******************************************************************************}
TOXUpVectorJoint = class( TOXNewtonJoint )
private
FOrionX3D: byte;
FActived: boolean;
FCollisionState: integer;
FStiffness: Float;
FManager: TOXNewtonManager;
function GetStiffness: Float;
procedure SetStiffness( const val: Float );
function GetCollisionState: integer;
procedure SetCollisionState( const val: integer );
public
property Manager: TOXNewtonManager read FManager;
property Actived: boolean read FActived;
property Joint;
procedure InitJoint( body: PNewtonBody );
constructor Create( aOwner: TComponent ); override;
Destructor Destroy; override;
procedure DoProgress( const progressTime: TProgressTimes ); override;
published
property JointCollisionState: integer read GetCollisionState write SetCollisionState;
property JointStiffness: Float read GetStiffness write SetStiffness;
property JointChildPin;
property JointParentPin;
end;
{******************************************************************************}
// [15-9-2007]: TOXBilateralJoint last change by Dave Gravel. //
{******************************************************************************}
TOXUserBilateralJoint = class( TOXNewtonJoint )
private
FOrionX3D: byte;
FActived: boolean;
FCollisionState: integer;
FStiffness: Float;
FcPivot: TOXVector4;
FcPin: TOXVector4;
FpPivot: TOXVector4;
FpPin: TOXVector4;
FBody0, FBody1: PNewtonBody;
FLocalMatrix0: TOXMatrix;
FLocalMatrix1: TOXMatrix;
FDommyMatrix: TOXMatrix;
FLocalUse: boolean;
FMaxDOF: Integer;
FPinLength: Float;
FManager: TOXNewtonManager;
FOnCustomCreate: TOXJointCustomCreate;
FOnCustomBothCreate: TOXJointCustomBothCreate;
FOnUserBilateralCallBack: TOXJointUserBilateralCallBack;
function GetStiffness: Float;
procedure SetStiffness( const val: Float );
function GetCollisionState: integer;
procedure SetCollisionState( const val: integer );
public
property Manager: TOXNewtonManager read FManager;
property Actived: boolean read FActived;
property Joint;
property LocalMatrix0: TOXMatrix read FLocalMatrix0 write FLocalMatrix0;
property LocalMatrix1: TOXMatrix read FLocalMatrix1 write FLocalMatrix1;
procedure InitJoint( body1, body2: PNewtonBody ); virtual;
constructor Create( aOwner: TComponent ); override;
Destructor Destroy; override;
procedure DoProgress( const progressTime: TProgressTimes ); override;
procedure CalculateLocalMatrix( const aPivot, aDir: TOXVector3;
out aLocalMatrix0, aLocalMatrix1: TOXMatrix );
procedure CalculateGlobalMatrix( const aLocalMatrix0, aLocalMatrix1: TOXMatrix;
out aMatrix0, aMatrix1: TOXMatrix );
procedure AddLinearRow( pivot0: PFloat; pivot1: PFloat; Dir: PFloat );
procedure AddAngularRow( RelativeAngle: Float; Dir: PFloat );
procedure AddGeneralRow( Jacobian0: PFloat; Jacobian1: PFloat );
procedure SetRowMinimumFriction( Friction: Float );
procedure SetRowMaximumFriction( Friction: Float );
procedure SetRowAcceleration( Acceleration: Float );
procedure SetRowStiffness( Stiffness: Float );
procedure SetRowSpringDamperAcceleration( springK: Float; springD: Float );
function GetRowForce( Row: Int ): Float;
published
property MaxDOF: Integer read FMaxDOF write FMaxDOF;
property LocalUse: boolean read FLocalUse write FLocalUse;
property JointCollisionState: integer read GetCollisionState write SetCollisionState;
property JointStiffness: Float read GetStiffness write SetStiffness;
property JointChildPin;
property JointParentPin;
property JointMinPinLength: Float read FPinLength write FPinLength;
property OnCustomCreate: TOXJointCustomCreate read FOnCustomCreate write FOnCustomCreate;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -