📄 oxnewtonmanager.pas
字号:
unit oxNewtonManager;
{******************************************************************************}
// [15-9-2007]: oxNewtonManager 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]: oxNewtonManager last change by Dave Gravel. //
{******************************************************************************}
uses
// Windows not compatible linux and i have not times about it...
Forms, Classes, SysUtils, dialogs,
// GLScene
GLScene, GLMisc,VectorGeometry,
OpenGL1x, GLTexture, VectorTypes, GLCadencer,
// oxNewton
oxNewtonUtils, oxNewtonImport;
{******************************************************************************}
// [15-9-2007]: TOXNewtonManager last change by Dave Gravel. //
{******************************************************************************}
type
TOXNewtonManager = class( TGLScene )
private
FOrionX3D: byte;
FPath: string;
FEnabledManagerOptions: boolean;
FArchitecture: Integer;
FDebugLog: boolean;
FActived: boolean;
FCadencer: TGLCadencer;
FRenderer: TGLDirectOpenGL;
FColor: TGLColor;
FDebugView: boolean;
FWorldMultiplyLimit: Float;
FWorldMultiplySize: Float;
FNewtonTime: Float;
FNewtonStepTime: Float;
FNewtonMultiplyTime: Float;
FWorld: PNewtonWorld;
FWorldStep: TOXWorldStep;
FWorldSolver: TOXWorldSolver;
FWorldFriction: TOXWorldFriction;
FGravity: TGLCoordinates;
FWorldSize: TGLCoordinates;
FNewtonVersion: integer;
FMinimumFrameRate: boolean;
FMinimumFrameRateValue: Float;
FLogEnable: boolean;
FWorldWallLimitation: boolean;
FWorldDefaultMaterial: boolean;
FWorldDafaultMaterialID: integer;
FMaterialSurfaceMode: TOXMaterialSurfaceMode;
FMatrialCustom: boolean;
FMaterialSoftness: Float;
FMaterialElasticity: Float;
FMaterialCollidable: integer;
FMaterialStaticFriction: Float;
FMaterialKineticFriction: Float;
FVehicleList: TList;
FFrictionMotion1: boolean;
FFrictionMotion2: boolean;
FCollidableLineSize: Float;
FContactBody0: PNewtonBody;
FContactBody1: PNewtonBody;
FOnStepRender: TOXOnStepRender;
FOnMultiplyStepRender: TOXOnMultiStepRender;
FOnContactBegin: TOXOnContactBegin;
FOnContactProcess: TOXOnContactProcess;
FOnContactEnd: TOXOnContactEnd;
FOnCustomContactBegin: TOXOnContactBegin;
FOnCustomContactProcess: TOXOnContactProcess;
FOnCustomContactEnd: TOXOnContactEnd;
FOnApplyForceAndTorque: TOXPhysicsApplyForceAndTorque;
FOnCustomApplyForceAndTorque: TOXPhysicsApplyForceAndTorque;
FOnCustomPhysicsStep: TOXOnCustomPhysicsStep;
procedure SetMaterialSurfaceMode( const Mode: TOXMaterialSurfaceMode );
procedure SetMaterialSoftness( const val: Float );
procedure SetMaterialElasticity( const val: Float );
procedure SetMaterialCollidable( const val: integer );
procedure SetMaterialStaticFriction( const val: Float );
procedure SetMaterialKineticFriction( const val: Float );
function GetMaterialSoftness: Float;
function GetMaterialElasticity: Float;
function GetMaterialCollidable: integer;
function GetMaterialStaticFriction: Float;
function GetMaterialKineticFriction: Float;
procedure SetLogEnable( const val: boolean );
procedure SetGravity( const val: TGLCoordinates );
procedure SetWorldSize( const val: TGLCoordinates );
procedure SetNewtonStepTime( const val: Float );
procedure SetNewtonMultiplyTime( const val: Float );
procedure SetWorldStepMode( const val: TOXWorldStep );
procedure SetWorldSolver( const val: TOXWorldSolver );
procedure SetWorldFriction( const val: TOXWorldFriction );
procedure SetWorldLimitation( const val: boolean );
procedure SetMinimumFrameRate( const val: boolean );
procedure SetMinimumFrameRateValue( const val: Float );
procedure SetArchitecture( const val: Integer );
function GetArchitecture: Integer;
function GetLogEnable: boolean;
function GetNewtonStepTime: Float;
function GetNewtonMultiplyTime: Float;
function GetMinimumFrameRate: boolean;
function GetMinimumFrameRateValue: Float;
function GetWorldStepMode: TOXWorldStep;
function GetWorldSolver: TOXWorldSolver;
function GetWorldFriction: TOXWorldFriction;
function GetWorld: PNewtonWorld;
function GetWorldLimitation: boolean;
procedure SetMaterialSurface( Custom: boolean; Softness, Elasticity, StaticFriction, KineticFriction: Float; Collidable: integer );
procedure BuildList(Sender: TObject; var rci: TRenderContextInfo);
procedure SetCadencer( val: TGLCadencer );
procedure SetColor( val: TGLColor );
procedure SetWorldMultiplyLimit( const val: Float );
function GetWorldMultiplyLimit: Float;
procedure SetWorldMultiplySize( const val: Float );
function GetWorldMultiplySize: Float;
public
procedure InitNewton; virtual;
procedure AddLog( str: string; level: integer; desc: string );
procedure Notification( AComponent: TComponent; Operation: TOperation ); override;
procedure DoProgress( const progressTime : TProgressTimes ); override;
property NewtonVersion: integer read FNewtonVersion;
property World: PNewtonWorld read GetWorld;
property ContactBody0: PNewtonBody read FContactBody0 write FContactBody0;
property ContactBody1: PNewtonBody read FContactBody1 write FContactBody1;
property VehicleList: TList read FVehicleList write FVehicleList;
property WorldDefaultMaterialID: integer read FWorldDafaultMaterialID write FWorldDafaultMaterialID;
constructor Create( AOwner: TComponent ); override;
destructor Destroy; override;
protected
//
published
property SplashOptions: boolean read FEnabledManagerOptions write FEnabledManagerOptions;
property DebugColor: TGLColor read FColor write SetColor;
property DebugLog: boolean read FDebugLog write FDebugLog;
property Cadencer: TGLCadencer read FCadencer write SetCadencer;
property Gravity: TGLCoordinates read FGravity write SetGravity;
property Architecture: Integer read GetArchitecture write SetArchitecture;
property LogEnabled: boolean read GetLogEnable write SetLogEnable;
property WorldStepTime: Float read GetNewtonStepTime write SetNewtonStepTime;
property WorldMultiplyLimit: Float read GetWorldMultiplyLimit write SetWorldMultiplyLimit;
property WorldMultiplySize: Float read GetWorldMultiplySize write SetWorldMultiplySize;
property WorldMultiplyTime: Float read GetNewtonMultiplyTime write SetNewtonMultiplyTime;
property WorldSolverMode: TOXWorldSolver read GetWorldSolver write SetWorldSolver;
property WorldFrictionMode: TOXWorldFriction read GetWorldFriction write SetWorldFriction;
property WorldStepMode: TOXWorldStep read GetWorldStepMode write SetWorldStepMode;
property WorldSize: TGLCoordinates read FWorldSize write SetWorldSize;
property WorldWallLimitation: boolean read GetWorldLimitation write SetWorldLimitation;
property WorldMaterialSurfaceMode: TOXMaterialSurfaceMode read FMaterialSurfaceMode write SetMaterialSurfaceMode;
property WorldMatrialCustom: boolean read FMatrialCustom write FMatrialCustom;
property WorldMaterialSoftness: Float read GetMaterialSoftness write SetMaterialSoftness;
property WorldMaterialElasticity: Float read GetMaterialElasticity write SetMaterialElasticity;
property WorldMaterialCollidable: integer read GetMaterialCollidable write SetMaterialCollidable;
property WorldMaterialStaticFriction: Float read GetMaterialStaticFriction write SetMaterialStaticFriction;
property WorldMaterialKineticFriction: Float read GetMaterialKineticFriction write SetMaterialKineticFriction;
property DebugView: boolean read FDebugView write FDebugView;
property MinimumFrameRate: boolean read GetMinimumFrameRate write SetMinimumFrameRate;
property MinimumFrameRateValue: Float read GetMinimumFrameRateValue write SetMinimumFrameRateValue;
property FrictionMotion1: boolean read FFrictionMotion1 write FFrictionMotion1;
property FrictionMotion2: boolean read FFrictionMotion2 write FFrictionMotion2;
property CollidableLineSize: Float read FCollidableLineSize write FCollidableLineSize;
property OnStepRender: TOXOnStepRender read FOnStepRender write FOnStepRender;
property OnMultiplyStepRender : TOXOnMultiStepRender read FOnMultiplyStepRender write FOnMultiplyStepRender;
property OnContactBegin: TOXOnContactBegin read FOnContactBegin write FOnContactBegin;
property OnContactProcess: TOXOnContactProcess read FOnContactProcess write FOnContactProcess;
property OnContactEnd: TOXOnContactEnd read FOnContactEnd write FOnContactEnd;
property OnCustomContactBegin: TOXOnContactBegin read FOnCustomContactBegin write FOnCustomContactBegin;
property OnCustomContactProcess: TOXOnContactProcess read FOnCustomContactProcess write FOnCustomContactProcess;
property OnCustomContactEnd: TOXOnContactEnd read FOnCustomContactEnd write FOnCustomContactEnd;
property OnApplyForceAndTorque: TOXPhysicsApplyForceAndTorque read FOnApplyForceAndTorque write FOnApplyForceAndTorque;
property OnCustomApplyForceAndTorque: TOXPhysicsApplyForceAndTorque read FOnCustomApplyForceAndTorque write FOnCustomApplyForceAndTorque;
property OnCustomPhysicsStep: TOXOnCustomPhysicsStep read FOnCustomPhysicsStep write FOnCustomPhysicsStep;
end;
implementation
uses oxNewtonDynamicObjects, oxNewtonStaticObjects,
oxNewtondll, oxNewtonDynamicMesh, oxNewtonJoint,
oxNewtonStaticMesh, oxNewtonVehicle4Wheels;
{******************************************************************************}
// [15-9-2007]: TOXNewtonManager last change by Dave Gravel. //
{******************************************************************************}
constructor TOXNewtonManager.Create( aOwner: TComponent );
begin
inherited create( aOwner );
FActived:= False;
FEnabledManagerOptions:= True;
FDebugLog:= True;
FDebugView:= False;
FVehicleList:= TList.Create;
FColor:= TGLColor.Create( self );
FPath:= ExtractFilePath( Application.ExeName );
DeleteFile( FPath + 'oxNewton.log' );
FMaterialSoftness:= 0.0;
FMaterialElasticity:= 0.0;
FMaterialStaticFriction:= 0.0;
FMaterialKineticFriction:= 0.0;
FMatrialCustom:= True;
FLogEnable:= True;
FCollidableLineSize:= 0.25;
AddLog( 'System Log :' + DateToStr( Date ), 1, ':Info System' );
AddLog( 'Newton Game Dynamics SDK License Version 1.55', 1, ':Info License' );
AddLog( 'Copyright 2003-2006 Newton Game Dynamics. All rights reserved.', 1, ':Info License' );
AddLog( 'Julio Jerez and Alain Suero', 1, ':Info License' );
AddLog( 'http://www.newtondynamics.com', 1, ':Info License' );
AddLog( '', 0, ':Info License' );
AddLog( '', 0, ':Info License' );
AddLog( 'oxNewton v1.55 Component by Dave Gravel [dave.gravel@cgocable.ca]', 1, ':Info License' );
AddLog( 'Build on the newton 1.55', 1, ':Info License' );
AddLog( 'http://www.dave.serveusers.com', 1, ':Info License' );
AddLog( 'http://www.dave.serveusers.com/oxNewton.html', 1, ':Info License' );
FOrionX3D:= 100;
FMinimumFrameRateValue:= 60;
FMaterialCollidable:= 1;
FArchitecture:= 2;
FNewtonTime:= 0.0;
FWorldMultiplyLimit:= 0.1;
FWorldMultiplySize:= 0.1;
FNewtonStepTime:= 0.1;
FNewtonMultiplyTime:= 6.0;
FWorldStep:= mdNormalStep;
FWorldSolver:= mdSolverLinear;
FWorldFriction:= mdFrictionExact;
FWorldWallLimitation:= True;
FWorldDafaultMaterialID:= -1;
FWorldDefaultMaterial:= False;
FMinimumFrameRate:= False;
FFrictionMotion1:= True;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -