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

📄 oxnewtonjoint.pas

📁 Newton Game Dynamic 1.52 Delphi下基于GLScene的OpenGL游戏开发控件。功能非常强大和易于使用。 Advanced physics engine for re
💻 PAS
📖 第 1 页 / 共 4 页
字号:
    property OnCustomBothCreate: TOXJointCustomBothCreate read FOnCustomBothCreate write FOnCustomBothCreate;
    property OnCallBack: TOXJointUserBilateralCallBack read FOnUserBilateralCallBack write FOnUserBilateralCallBack;
  end;
implementation
uses oxNewtonDynamicMesh, oxNewtonDynamicObjects, oxNewtonStaticObjects,
     oxNewtonStaticMesh, oxNewtondll;
{******************************************************************************}
// [15-9-2007]: TOXBallJoint last change by Dave Gravel.                     //
{******************************************************************************}
constructor TOXBallJoint.Create( aOwner: TComponent );
begin
  inherited Create( aOwner );
  FOrionX3D:= 100;
  FActived:= False;
  FCollisionState:= 0;
  FStiffness:= 1;
  EdgeColor.AsWinColor:= clRed;
  FJointConeMaxAngle:= 0;
  FJointConeTwistAngle:= 0;
end;
{******************************************************************************}
// [15-9-2007]: TOXBallJoint last change by Dave Gravel.                     //
{******************************************************************************}
function TOXBallJoint.GetCollisionState: integer;
begin
  if FActived then begin
    result:= NewtonJointGetCollisionState( Joint );
    FCollisionState:= result;
  end else
    result:= FCollisionState;
end;
{******************************************************************************}
// [15-9-2007]: TOXBallJoint last change by Dave Gravel.                     //
{******************************************************************************}
procedure TOXBallJoint.SetCollisionState( const val: integer );
begin
  if FCollisionState <> val then
  begin
    FCollisionState:= val;
    if FActived then
      NewtonJointSetCollisionState( Joint, FCollisionState );
  end;
end;
{******************************************************************************}
// [15-9-2007]: TOXBallJoint last change by Dave Gravel.                     //
{******************************************************************************}
function TOXBallJoint.GetStiffness: Float;
begin
  if FActived then
    result:= NewtonJointGetStiffness( Joint )
  else
    result:= FStiffness;
end;
{******************************************************************************}
// [15-9-2007]: TOXBallJoint last change by Dave Gravel.                     //
{******************************************************************************}
function TOXBallJoint.GetJAngle: TOXVector3;
begin
  if FActived then
  begin
    NewtonBallGetJointAngle( Joint, @result[0] );
  end else
  result:= oxV3Make( 0, 0, 0 );
end;
{******************************************************************************}
// [15-9-2007]: TOXBallJoint last change by Dave Gravel.                     //
{******************************************************************************}
function TOXBallJoint.GetJOmega: TOXVector3;
begin
  if FActived then
  begin
    NewtonBallGetJointOmega( Joint, @result[0] );
  end else
  result:= oxV3Make( 0, 0, 0 );
end;
{******************************************************************************}
// [15-9-2007]: TOXBallJoint last change by Dave Gravel.                     //
{******************************************************************************}
function TOXBallJoint.GetJForce: TOXVector3;
begin
  if FActived then
  begin
    NewtonBallGetJointForce( Joint, @result[0] );
  end else
  result:= oxV3Make( 0, 0, 0 );
end;
{******************************************************************************}
// [15-9-2007]: TOXBallJoint last change by Dave Gravel.                     //
{******************************************************************************}
procedure TOXBallJoint.DoProgress( const progressTime: TProgressTimes );
begin
  inherited;
  if FActived then
  begin

  end;
end;
{******************************************************************************}
// [15-9-2007]: TOXBallJoint last change by Dave Gravel.                     //
{******************************************************************************}
procedure TOXBallJoint.InitJoint( body1, body2: PNewtonBody );
begin
  FManager:= TOXNewtonManager(Scene);
  if FActived or ( FManager = nil ) then Exit;
  oxSetJointBall( self, body1, body2 );
  FManager.AddLog( Name + ' create.', 1, ':Info Object' );
  FManager.AddLog( 'Joint Ball Name: ' + Name, 1, ':Info Object' );
  FManager.AddLog(  Name + ' InitJoint.', 1, ':Info Object' );
  FActived:= True;
  SetConeMaxAngle( FJointConeMaxAngle );
  SetTwistConeAngle( FJointConeTwistAngle );  
end;
{******************************************************************************}
// [15-9-2007]: TOXBallJoint last change by Dave Gravel.                     //
{******************************************************************************}
procedure TOXBallJoint.SetTwistConeAngle( const val: Float );
var JointPinVector: TOXVector3;
begin
  FJointConeTwistAngle:= val;
  JointPinVector[0]:= JointChildPin.X;
  JointPinVector[1]:= JointChildPin.Y;
  JointPinVector[2]:= JointChildPin.Z;
  if FActived then
    NewtonBallSetConeLimits( Joint, @JointPinVector[0],
    FJointConeMaxAngle * PI / 180, FJointConeTwistAngle * PI / 180 );
end;
{******************************************************************************}
// [15-9-2007]: TOXBallJoint last change by Dave Gravel.                     //
{******************************************************************************}
procedure TOXBallJoint.SetConeMaxAngle( const val: Float );
var JointPinVector: TOXVector3;
begin
  FJointConeMaxAngle:= val;
  JointPinVector[0]:= JointChildPin.X;
  JointPinVector[1]:= JointChildPin.Y;
  JointPinVector[2]:= JointChildPin.Z;
  if FActived then
    NewtonBallSetConeLimits( Joint, @JointPinVector[0],
    FJointConeMaxAngle * PI / 180, FJointConeTwistAngle* PI / 180 );
end;
{******************************************************************************}
// [15-9-2007]: TOXBallJoint last change by Dave Gravel.                     //
{******************************************************************************}
procedure TOXBallJoint.SetStiffness( const val: Float );
begin
  if FStiffness <> val then
  begin
    FStiffness:= val;
    if FActived then
      NewtonJointSetStiffness( Joint, FStiffness );
  end;
end;
{******************************************************************************}
// [15-9-2007]: TOXBallJoint last change by Dave Gravel.                     //
{******************************************************************************}
destructor TOXBallJoint.destroy;
begin
  if FActived and assigned(Joint) then begin
    if ( not ( csDesigning in ComponentState ) ) then
      if Name = '' then FManager.AddLog( ClassName + ' destroyed.', 1, ':Info Object' )
      else FManager.AddLog( Name + ' destroyed.', 1, ':Info Object' );
    if Joint<>nil then
      NewtonDestroyJoint( FManager.World, Joint );
    FActived:= False;
  end;
  inherited destroy;
end;
{******************************************************************************}
// [15-9-2007]: TOXHingeJoint last change by Dave Gravel.                    //
{******************************************************************************}
constructor TOXHingeJoint.Create( aOwner: TComponent );
begin
  inherited Create( aOwner );
  FOrionX3D:= 100;
  FActived:= False;
  FCollisionState:= 0;
  FStiffness:= 1;
  FAngle:= 0;
  EdgeColor.AsWinColor:= clRed;
end;
{******************************************************************************}
// [15-9-2007]: TOXHingeJoint last change by Dave Gravel.                    //
{******************************************************************************}
function TOXHingeJoint.GetCollisionState: integer;
begin
  if FActived then
    result:= NewtonJointGetCollisionState( Joint )
  else
    result:= FCollisionState;
end;
{******************************************************************************}
// [15-9-2007]: TOXHingeJoint last change by Dave Gravel.                    //
{******************************************************************************}
procedure TOXHingeJoint.SetCollisionState( const val: integer );
begin
  if FCollisionState <> val then
  begin
    FCollisionState:= val;
    if FActived then
      NewtonJointSetCollisionState( Joint, FCollisionState );
  end;
end;
{******************************************************************************}
// [15-9-2007]: TOXHingeJoint last change by Dave Gravel.                    //
{******************************************************************************}
function TOXHingeJoint.GetJAngle: TOXVector3;
begin
  if FActived then
  begin
    NewtonBallGetJointAngle( Joint, @result[0] );
  end else
  result:= oxV3Make( 0, 0, 0 );
end;
{******************************************************************************}
// [15-9-2007]: TOXHingeJoint last change by Dave Gravel.                    //
{******************************************************************************}
function TOXHingeJoint.GetJOmega: TOXVector3;
begin
  if FActived then
  begin
    NewtonBallGetJointOmega( Joint, @result[0] );
  end else
  result:= oxV3Make( 0, 0, 0 );
end;
{******************************************************************************}
// [15-9-2007]: TOXHingeJoint last change by Dave Gravel.                    //
{******************************************************************************}
function TOXHingeJoint.GetJForce: TOXVector3;
begin
  if FActived then
  begin
    NewtonBallGetJointForce( Joint, @result[0] );
  end else
  result:= oxV3Make( 0, 0, 0 );
end;
{******************************************************************************}
// [15-9-2007]: TOXHingeJoint last change by Dave Gravel.                    //
{******************************************************************************}
function TOXHingeJoint.GetStiffness: Float;
begin
  if FActived then
    result:= NewtonJointGetStiffness( Joint )
  else
    result:= FStiffness;
end;
{******************************************************************************}
// [15-9-2007]: TOXHingeJoint last change by Dave Gravel.                    //
{******************************************************************************}
procedure TOXHingeJoint.DoProgress( const progressTime: TProgressTimes );
begin
  inherited;
  if FActived then
  begin

  end;
end;
{******************************************************************************}
// [15-9-2007]: TOXHingeJoint last change by Dave Gravel.                    //
{******************************************************************************}
procedure TOXHingeJoint.InitJoint( body1, body2: PNewtonBody );
begin
  FManager:= TOXNewtonManager(Scene);
  if FActived or ( FManager = nil ) then Exit;
  oxSetJointHinge( self, body1, body2 );
  FManager.AddLog(  Name + ' create.', 1, ':Info Object' );
  FManager.AddLog( 'Joint Hinge Name: '+Name, 1, ':Info Object' );
  FManager.AddLog(  Name + ' InitJoint.', 1, ':Info Object' );
  FActived:= True;
end;
{******************************************************************************}
// [15-9-2007]: TOXHingeJoint last change by Dave Gravel.                    //
{******************************************************************************}
procedure TOXHingeJoint.SetStiffness( const val: Float );
begin
  if FStiffness <> val then
  begin
    FStiffness:= val;
    if FActived then
      NewtonJointSetStiffness( Joint, FStiffness );
  end;
end;
{******************************************************************************}
// [15-9-2007]: TOXHingeJoint last change by Dave Gravel.                    //
{******************************************************************************}
destructor TOXHingeJoint.destroy;
begin
  if FActived and assigned(Joint) then begin
    if ( not ( csDesigning in ComponentState ) ) then
      if Name = '' then FManager.AddLog( ClassName + ' destroyed.', 1, ':Info Object' )
      else FManager.AddLog( Name + ' destroyed.', 1, ':Info Object' );
    if Joint<>nil then
      NewtonDestroyJoint( FManager.World, Joint );
    FActived:= False;
  end;
  inherited destroy;
end;
{******************************************************************************}
// [15-9-2007]: TOXSliderJoint last change by Dave Gravel.                   //
{******************************************************************************}
constructor TOXSliderJoint.Create( aOwner: TComponent );
begin
  inherited Create( aOwner );
  FOrionX3D:= 100;
  FActived:= False;
  FCollisionState:= 0;
  FStiffness:= 1;
  EdgeColor.AsWinColor:= clRed;
end;
{******************************************************************************}
// [15-9-2007]: TOXSliderJoint last change by Dave Gravel.                   //
{******************************************************************************}
function TOXSliderJoint.GetCollisionState: integer;
begin
  if FActived then
    result:= NewtonJointGetCollisionState( Joint )
  else
    result:= FCollisionState;
end;
{******************************************************************************}
// [15-9-2007]: TOXSliderJoint last change by Dave Gravel.                   //
{******************************************************************************}
procedure TOXSliderJoint.SetCollisionState( const val: integer );
begin
  if FCollisionState <> val then
  begin
    FCollisionState:= val;
    if FActived then

⌨️ 快捷键说明

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