⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 oxnewtondynamicmesh.pas

📁 Newton Game Dynamic 1.52 Delphi下基于GLScene的OpenGL游戏开发控件。功能非常强大和易于使用。 Advanced physics engine for re
💻 PAS
📖 第 1 页 / 共 3 页
字号:
    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;
implementation
uses oxNewtondll, oxNewtonDynamicObjects;
// Create                                                                     //
{******************************************************************************}
// [15-9-2007]: TOXNewtonDynMesh last change by Dave Gravel.                 //
{******************************************************************************}
constructor TOXNewtonDynMesh.Create( aOwner: TComponent );
begin
  inherited create( aOwner );
  FOrionX3D:= 100;  
  FActived:= False;
  FFreezeSpeedMag2:= 0.01;
  FFreezeOmegaMag2:= 0.01;
  FFreezeFramesCount:= 10;
  FOriginX:= 0.0; FOriginY:= 0.0; FOriginZ:= 0.0;
  FInertiaX:= 0.0; FInertiaY:= 0.0; FInertiaZ:= 0.0;
  FConcretX:= 0.0; FConcretY:= 0.0; FConcretZ:= 0.0;
  FAngularDampingX:= 0.0; FAngularDampingY:= 0.0; FAngularDampingZ:= 0.0;
  FGetMatrix:= oxEmptyHmgM;
  FSetMatrix:= oxEmptyHmgM;
  FContinuousCollisionMode:= False;
  FisSetMatrix:= False;
  FisAddImpulse:= False;
  FisAddTorque:= False;
  FisAddForce:= False;
  FisSetOmega:= False;
  FisSetVelocity:= False;
  FisSetForce:= False;
  FisSetTorque:= False;
  FAddImpulse:= oxV3Make( 0, 0, 0 );
  FAddImpulseVel:= oxV3Make( 0, 0, 0 );
  FAddForce:= oxV3Make( 0, 0, 0 );
  FAddTorque:= oxV3Make( 0, 0, 0 );
  FSetOmega:= oxV3Make( 0, 0, 0 );
  FSetVelocity:= oxV3Make( 0, 0, 0 );
  FSetForce:= oxV3Make( 0, 0, 0 );
  FSetTorque:= oxV3Make( 0, 0, 0 );
  FContactID:= -1;
  FAutoFreeze:= True;
  FLinearDamping:= 0.0;
  FRollingFriction:= 0;
  FMaterialCustom:= False;
  FOXVisual:= True;
  FCustomMassInertiaOrigin:= False;
  FPathFile:='';
  FOnAir:= True;
  FInternalForceAndTorque:= false;
  FFrictionMotion1:= true;
  FFrictionMotion2:= false;
end;
// Notification                                                               //
{******************************************************************************}
// [15-9-2007]: TOXNewtonDynMesh last change by Dave Gravel.                 //
{******************************************************************************}
procedure TOXNewtonDynMesh.Notification( AComponent: TComponent; Operation: TOperation );
begin

  inherited;
end;
{******************************************************************************}
// [15-9-2007]: TOXNewtonDynMesh last change by Dave Gravel.                 //
{******************************************************************************}
procedure TOXNewtonDynMesh.SetAutoFreeze( const val: boolean );
begin
  FAutoFreeze:= val;
  if FActived then begin
    if FAutoFreeze then begin
      NewtonBodySetAutoFreeze( FBody, 1 );
    end else begin
      NewtonBodySetAutoFreeze( FBody, 0 );
      NewtonWorldUnfreezeBody( FManager.World, FBody );
    end;
  end;
end;
// UpdateTransformation                                                       //
{******************************************************************************}
// [15-9-2007]: TOXNewtonDynMesh last change by Dave Gravel.                 //
{******************************************************************************}
procedure TOXNewtonDynMesh.UpdateTransformation( poweroff: boolean );
var
  halt: TOXVector3;
begin
  if FActived then begin
    NewtonBodySetAutoFreeze( FBody, 0 );
    NewtonWorldUnfreezeBody( FManager.World, FBody );
    if poweroff then begin
      halt:= oxV3Make( 0, 0, 0 );
      NewtonBodySetForce( FBody, @halt[0] );
      NewtonBodySetVelocity( FBody, @halt[0] );
      NewtonBodySetOmega( FBody, @halt[0] );
      NewtonBodySetTorque( FBody, @halt[0] );
    end;
    oxPSetInitTransform( FBody, Self );
    if FAutoFreeze then
      NewtonBodySetAutoFreeze( FBody, 1 );
  end;    
end;
// SetLinearDamping                                                           //
{******************************************************************************}
// [15-9-2007]: TOXNewtonDynMesh last change by Dave Gravel.                 //
{******************************************************************************}
procedure TOXNewtonDynMesh.SetLinearDamping( const val: Float );
begin
  FLinearDamping:= val;
  if FActived then
    NewtonBodySetLinearDamping( FBody, FLinearDamping );
end;
// SetContinuousCollision                                                     //
{******************************************************************************}
// [15-9-2007]: TOXNewtonDynMesh last change by Dave Gravel.                 //
{******************************************************************************}
procedure TOXNewtonDynMesh.SetContinuousCollision( const val: boolean );
begin
  if FContinuousCollisionMode <> val then begin
    FContinuousCollisionMode:= val;
    if FActived then begin
      if FContinuousCollisionMode then
        NewtonBodySetContinuousCollisionMode( FBody, 1 ) else
        NewtonBodySetContinuousCollisionMode( FBody, 0 );
    end;
  end;
end;
// BuildList                                                                  //
{******************************************************************************}
// [15-9-2007]: TOXNewtonDynMesh last change by Dave Gravel.                 //
{******************************************************************************}
procedure TOXNewtonDynMesh.BuildList( var rci: TRenderContextInfo );
begin
  if FOXVisual then
    inherited else
  exit;
end;
// SetMaterialSurfaceMode                                                     //
{******************************************************************************}
// [15-9-2007]: TOXNewtonDynMesh last change by Dave Gravel.                 //
{******************************************************************************}
procedure TOXNewtonDynMesh.SetMaterialSurfaceMode( const Mode: TOXMaterialSurfaceMode );
begin
  case Mode of
    mdNone: SetMaterialSurface( True, 0.0, 0.0, 0.0, 0.0 );
    mdDefault: SetMaterialSurface( True, 0.05, 0.4, 1.0, 0.5 );
    mdHard: SetMaterialSurface( True, 1.0, 0.5, 1.0, 0.5 );
    mdSoft: SetMaterialSurface( True, 0.01, 0.2, 1.0, 0.5 );
    mdSlide: SetMaterialSurface( True, 0.05, 0.4, 0.25, 0.25 );
    mdStatic: SetMaterialSurface( True, 0.05, 0.4, 1.0, 1.0 );
  end;
end;
// SetMaterialSurface                                                         //
{******************************************************************************}
// [15-9-2007]: TOXNewtonDynMesh last change by Dave Gravel.                 //
{******************************************************************************}
procedure TOXNewtonDynMesh.SetMaterialSurface( Custom: boolean; Softness,
Elasticity, StaticFriction, KineticFriction: Float );
begin
  FMaterialCustom:= Custom;
  FMaterialSoftness:= Softness;
  FMaterialElasticity:= Elasticity;
  FMaterialStaticFriction:= StaticFriction;
  FMaterialKineticFriction:= KineticFriction;
end;
// GetGeom                                                                    //
{******************************************************************************}
// [15-9-2007]: TOXNewtonDynMesh last change by Dave Gravel.                 //
{******************************************************************************}
function TOXNewtonDynMesh.GetGeom: PNewtonCollision;
begin
  result:= FCollision;
end;
{******************************************************************************}
// [15-9-2007]: TOXNewtonDynMesh last change by Dave Gravel.                 //
{******************************************************************************}
procedure TOXNewtonDynMesh.SetFreezeSpeedMag2( const val: Float );
begin
  FFreezeSpeedMag2:= val;
  if FActived then
    NewtonBodySetFreezeTreshold( FBody, FFreezeSpeedMag2, FFreezeOmegaMag2, FFreezeFramesCount );
end;
{******************************************************************************}
// [15-9-2007]: TOXNewtonDynMesh last change by Dave Gravel.                 //
{******************************************************************************}
procedure TOXNewtonDynMesh.SetFreezeOmegaMag2( const val: Float );
begin
  FFreezeOmegaMag2:= val;
  if FActived then
    NewtonBodySetFreezeTreshold( FBody, FFreezeSpeedMag2, FFreezeOmegaMag2, FFreezeFramesCount );
end;
{******************************************************************************}
// [15-9-2007]: TOXNewtonDynMesh last change by Dave Gravel.                 //
{******************************************************************************}
procedure TOXNewtonDynMesh.SetFreezeFramesCount( const val: Integer );
begin
  FFreezeFramesCount:= val;
  if FActived then
    NewtonBodySetFreezeTreshold( FBody, FFreezeSpeedMag2, FFreezeOmegaMag2, FFreezeFramesCount );
end;
// GetBody                                                                    //
{******************************************************************************}
// [15-9-2007]: TOXNewtonDynMesh last change by Dave Gravel.                 //
{******************************************************************************}
function TOXNewtonDynMesh.GetBody: PNewtonBody;
begin
  result:= FBody;
end;
// SetMassValues                                                              //
{******************************************************************************}
// [15-9-2007]: TOXNewtonDynMesh last change by Dave Gravel.                 //
{******************************************************************************}
procedure TOXNewtonDynMesh.SetMassValues;
begin
  if FActived then if Assigned( FOnCustomMass ) then
      FOnCustomMass( FMass, FOriginX, FOriginY, FOriginZ,
                            FInertiaX, FInertiaY, FInertiaZ )
    else
      oxMeshSetMass( FBody, FMass, FInertiaX, FInertiaY, FInertiaZ,
                                   FOriginX, FOriginY, FOriginZ,
                                   FConcretX, FConcretY, FConcretZ );
end;
// SetConcretX                                                                //
{******************************************************************************}
// [15-9-2007]: TOXNewtonDynMesh last change by Dave Gravel.                 //
{******************************************************************************}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -