📄 oxnewtondynamicobjects.pas
字号:
unit oxNewtonDynamicObjects;
{******************************************************************************}
// [15-9-2007]: oxNewtonDynamicObjects 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]: oxNewtonDynamicObjects last change by Dave Gravel. //
{******************************************************************************}
uses
// Windows
Classes, SysUtils,
// GLScene
GLScene, GLMisc, GLObjects, VectorGeometry, VectorTypes, GLTexture,
GLGeomObjects, VectorLists,
// Newton
oxNewtonImport, oxNewtonUtils, oxNewtonManager;
{******************************************************************************}
// [15-9-2007]: TOXNewtonDynCube last change by Dave Gravel. //
{******************************************************************************}
type
TOXNewtonDynCube = class( TGLCube )
private
FOrionX3D: byte;
FOXVisual: boolean;
FCollision: PNewtonCollision;
FBody: PNewtonBody;
FMass: Float;
FActived: boolean;
FManager: TOXNewtonManager;
FContactID: integer;
FAutoFreeze: boolean;
FMaterialSurfaceMode: TOXMaterialSurfaceMode;
FMaterialCustom: boolean;
FMaterialSoftness: Float;
FMaterialElasticity: Float;
FMaterialStaticFriction: Float;
FMaterialKineticFriction: Float;
FFreezeSpeedMag2: Float;
FFreezeOmegaMag2: Float;
FFreezeFramesCount: integer;
FInertiaX: Float;
FInertiaY: Float;
FInertiaZ: Float;
FOriginX: Float;
FOriginY: Float;
FOriginZ: Float;
FConcretX: Float;
FConcretY: Float;
FConcretZ: Float;
FRollingFriction: Float;
FCustomMassInertiaOrigin: boolean;
FLinearDamping: Float;
FAngularDampingX: Float;
FAngularDampingY: Float;
FAngularDampingZ: Float;
FContinuousCollisionMode: boolean;
FisSetMatrix: boolean;
FisAddImpulse: boolean;
FisAddTorque: boolean;
FisAddForce: boolean;
FisSetOmega: boolean;
FisSetVelocity: boolean;
FisSetForce: boolean;
FisSetTorque: boolean;
FAddImpulse: TOXVector3;
FAddImpulseVel: TOXVector3;
FAddForce: TOXVector3;
FAddTorque: TOXVector3;
FSetOmega: TOXVector3;
FSetVelocity: TOXVector3;
FSetForce: TOXVector3;
FSetTorque: TOXVector3;
FGetOmega: TOXVector3;
FGetVelocity: TOXVector3;
FGetForce: TOXVector3;
FGetTorque: TOXVector3;
FGetMatrix: TOXMatrix;
FSetMatrix: TOXMatrix;
FOnAir: boolean;
FInternalForceAndTorque: boolean;
FFrictionMotion1: boolean;
FFrictionMotion2: boolean;
FOnContactBegin: TOXOnContactBegin;
FOnContactProcess: TOXOnContactProcess;
FOnContactEnd: TOXOnContactEnd;
FForceAndTorque: TOXPhysicsApplyForceAndTorque;
FOnStepRender: TOXOnStepRender;
FOnCustomMass: TOXOnCustomMass;
procedure SetMaterialSurfaceMode( const Mode: TOXMaterialSurfaceMode );
procedure SetMass( const val: Float );
procedure SetConcretX( const val: Float );
procedure SetConcretY( const val: Float );
procedure SetConcretZ( const val: Float );
procedure SetInertiaX( const val: Float );
procedure SetInertiaY( const val: Float );
procedure SetInertiaZ( const val: Float );
procedure SetOriginX( const val: Float );
procedure SetOriginY( const val: Float );
procedure SetOriginZ( const val: Float );
procedure SetAngularDampingX( const val: Float );
procedure SetAngularDampingY( const val: Float );
procedure SetAngularDampingZ( const val: Float );
procedure SetAutoFreeze( const val: boolean );
procedure SetContinuousCollision( const val: boolean );
procedure SetMassValues;
function GetGeom: PNewtonCollision;
function GetBody: PNewtonBody;
procedure SetLinearDamping( const val: Float );
procedure SetFreezeSpeedMag2( const val: Float );
procedure SetFreezeOmegaMag2( const val: Float );
procedure SetFreezeFramesCount( const val: Integer );
protected
//
public
property Manager: TOXNewtonManager read FManager;
property Actived: boolean read FActived;
property BodyGetOmega: TOXVector3 read FGetOmega write FGetOmega;
property BodyGetForce: TOXVector3 read FGetForce write FGetForce;
property BodyGetTorque: TOXVector3 read FGetTorque write FGetTorque;
property BodyGetVelocity: TOXVector3 read FGetVelocity write FGetVelocity;
property BodyGetMatrix: TOXMatrix read FGetMatrix write FGetMatrix;
property BodySetMatrix: TOXMatrix read FSetMatrix write FSetMatrix;
property BodyAddImpulse: TOXVector3 read FAddImpulse write FAddImpulse;
property BodyAddImpulseVelocity: TOXVector3 read FAddImpulseVel write FAddImpulseVel;
property BodyAddForce: TOXVector3 read FAddForce write FAddForce;
property BodyAddTorque: TOXVector3 read FAddTorque write FAddTorque;
property BodySetOmega: TOXVector3 read FSetOmega write FSetOmega;
property BodySetVelocity: TOXVector3 read FSetVelocity write FSetVelocity;
property BodySetForce: TOXVector3 read FSetForce write FSetForce;
property BodySetTorque: TOXVector3 read FSetTorque write FSetTorque;
property isSetMatrix: boolean read FisSetMatrix write FisSetMatrix;
property isAddImpulse: boolean read FisAddImpulse write FisAddImpulse;
property isAddTorque: boolean read FisAddTorque write FisAddTorque;
property isAddForce: boolean read FisAddForce write FisAddForce;
property isSetOmega: boolean read FisSetOmega write FisSetOmega;
property isSetVelocity: boolean read FisSetVelocity write FisSetVelocity;
property isSetForce: boolean read FisSetForce write FisSetForce;
property isSetTorque: boolean read FisSetTorque write FisSetTorque;
property Collide: boolean read FOnAir write FOnAir;
procedure SetMaterialSurface( Custom: boolean; Softness, Elasticity, StaticFriction, KineticFriction: Float );
procedure UpdateTransformation( poweroff: boolean );
procedure InitNewton; virtual;
procedure BuildList( var rci: TRenderContextInfo ); override;
procedure Notification(AComponent: TComponent; Operation: TOperation); override;
procedure DoProgress( const progressTime: TProgressTimes ); override;
property Geom: PNewtonCollision read GetGeom;
property Body: PNewtonBody read GetBody;
property ContactID: integer read FContactID write FContactID;
constructor Create( AOwner: TComponent ); override;
destructor Destroy; override;
published
property OXVisual: boolean read FOXVisual write FOXVisual;
property ContinuousCollisionMode: boolean read FContinuousCollisionMode write SetContinuousCollision;
property AutoFreeze: boolean read FAutoFreeze write SetAutoFreeze;
property LinearDamping: Float read FLinearDamping write SetLinearDamping;
property AngularDampingX: Float read FAngularDampingX write SetAngularDampingX;
property AngularDampingY: Float read FAngularDampingY write SetAngularDampingY;
property AngularDampingZ: Float read FAngularDampingZ write SetAngularDampingZ;
property Mass: Float read FMass write SetMass;
property MassCenterX: Float read FConcretX write SetConcretX;
property MassCenterY: Float read FConcretY write SetConcretY;
property MassCenterZ: Float read FConcretZ write SetConcretZ;
property MassInertiaX: Float read FInertiaX write SetInertiaX;
property MassInertiaY: Float read FInertiaY write SetInertiaY;
property MassInertiaZ: Float read FInertiaZ write SetInertiaZ;
property MassOriginX: Float read FOriginX write SetOriginX;
property MassOriginY: Float read FOriginY write SetOriginY;
property MassOriginZ: Float read FOriginZ write SetOriginZ;
property RollingFriction: Float read FRollingFriction write FRollingFriction;
property MaterialSurfaceMode: TOXMaterialSurfaceMode read FMaterialSurfaceMode write SetMaterialSurfaceMode;
property MaterialCustom: boolean read FMaterialCustom write FMaterialCustom;
property MaterialSoftness: Float read FMaterialSoftness write FMaterialSoftness;
property MaterialElasticity: Float read FMaterialElasticity write FMaterialElasticity;
property MaterialStaticFriction: Float read FMaterialStaticFriction write FMaterialStaticFriction;
property MaterialKineticFriction: Float read FMaterialKineticFriction write FMaterialKineticFriction;
property InternalForceAndTorque: boolean read FInternalForceAndTorque write FInternalForceAndTorque;
property FrictionMotion1: boolean read FFrictionMotion1 write FFrictionMotion1;
property FrictionMotion2: boolean read FFrictionMotion2 write FFrictionMotion2;
property CustomMassInertiaOrigin: boolean read FCustomMassInertiaOrigin write FCustomMassInertiaOrigin;
property ApplyForceAndTorque: TOXPhysicsApplyForceAndTorque read FForceAndTorque write FForceAndTorque;
property FreezeSpeedMag2: Float read FFreezeSpeedMag2 write SetFreezeSpeedMag2;
property FreezeOmegaMag2: Float read FFreezeOmegaMag2 write SetFreezeOmegaMag2;
property FreezeFramesCount: integer read FFreezeFramesCount write SetFreezeFramesCount;
property OnStepRender: TOXOnStepRender read FOnStepRender write FOnStepRender;
property OnCustomMass: TOXOnCustomMass read FOnCustomMass write FOnCustomMass;
property OnContactBegin: TOXOnContactBegin read FOnContactBegin write FOnContactBegin;
property OnContactProcess: TOXOnContactProcess read FOnContactProcess write FOnContactProcess;
property OnContactEnd: TOXOnContactEnd read FOnContactEnd write FOnContactEnd;
end;
{******************************************************************************}
// [15-9-2007]: TOXNewtonDynSphere last change by Dave Gravel. //
{******************************************************************************}
type
TOXNewtonDynSphere = class( TGLSphere )
private
FOrionX3D: byte;
FOXVisual: boolean;
FCollision: PNewtonCollision;
FBody: PNewtonBody;
FMass: Float;
FActived: boolean;
FManager: TOXNewtonManager;
FContactID: integer;
FAutoFreeze: boolean;
FMaterialSurfaceMode: TOXMaterialSurfaceMode;
FMaterialCustom: boolean;
FMaterialSoftness: Float;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -