📄 oxnewtonjoint.pas
字号:
result:= NewtonJointGetStiffness( Joint )
else
result:= FStiffness;
end;
{******************************************************************************}
// [15-9-2007]: TOXUpVectorJoint last change by Dave Gravel. //
{******************************************************************************}
procedure TOXUpVectorJoint.DoProgress( const progressTime: TProgressTimes );
begin
inherited;
if FActived then
begin
end;
end;
{******************************************************************************}
// [15-9-2007]: TOXUpVectorJoint last change by Dave Gravel. //
{******************************************************************************}
procedure TOXUpVectorJoint.InitJoint( body: PNewtonBody );
begin
FManager:= TOXNewtonManager(Scene);
if FActived or ( FManager = nil ) then Exit;
FManager.AddLog( Name + ' create.', 1, ':Info Object' );
oxSetJointUpVector( self, body );
FManager.AddLog( 'Joint UpVector Name: '+Name, 1, ':Info Object' );
FManager.AddLog( Name + ' InitJoint.', 1, ':Info Object' );
FActived:= True;
end;
{******************************************************************************}
// [15-9-2007]: TOXUpVectorJoint last change by Dave Gravel. //
{******************************************************************************}
procedure TOXUpVectorJoint.SetStiffness( const val: Float );
begin
if FStiffness <> val then
begin
FStiffness:= val;
if FActived then
NewtonJointSetStiffness( Joint, FStiffness );
end;
end;
{******************************************************************************}
// [15-9-2007]: TOXUpVectorJoint last change by Dave Gravel. //
{******************************************************************************}
destructor TOXUpVectorJoint.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]: TOXUserBilateralJoint last change by Dave Gravel. //
{******************************************************************************}
constructor TOXUserBilateralJoint.Create( aOwner: TComponent );
begin
inherited Create( aOwner );
FOrionX3D:= 100;
FActived:= False;
FPinLength:= 50.0;
FCollisionState:= 0;
FStiffness:= 1;
FMaxDOF:= 1;
FcPivot:= oxV4Make( 0, 0, 0, 0 );
FcPin:= oxV4Make( 0, 0, 0, 0 );
FpPivot:= oxV4Make( 0, 0, 0, 0 );
FpPin:= oxV4Make( 0, 0, 0, 0 );
FLocalUse:= True;
EdgeColor.AsWinColor:= clRed;
end;
{******************************************************************************}
// [15-9-2007]: TOXUserBilateralJoint last change by Dave Gravel. //
{******************************************************************************}
procedure TOXUserBilateralJoint.CalculateLocalMatrix( const aPivot, aDir: TOXVector3;
out aLocalMatrix0, aLocalMatrix1: TOXMatrix );
var
Matrix0: TOXMatrix;
Matrix1: TOXMatrix;
PinAndPivot: TOXMatrix;
InverseMatrix: TOXMatrix;
begin
if FBody0 <> nil then
NewtonBodyGetMatrix( FBody0, @Matrix0[0, 0] );
Matrix1:= oxIdentityM;
if FBody1 <> nil then
NewtonBodyGetMatrix( FBody1, @Matrix1[0, 0] );
PinAndPivot:= oxMGrammSchmidt( aDir );
oxMSetTransform( PinAndPivot, aPivot );
InverseMatrix:= Matrix0;
oxInvertM( InverseMatrix );
aLocalMatrix0:= oxMMultiply( PinAndPivot, InverseMatrix );
InverseMatrix:= Matrix1;
oxInvertM( InverseMatrix );
aLocalMatrix1:= oxMMultiply( PinAndPivot, InverseMatrix );
end;
{******************************************************************************}
// [15-9-2007]: TOXUserBilateralJoint last change by Dave Gravel. //
{******************************************************************************}
procedure TOXUserBilateralJoint.CalculateGlobalMatrix( const aLocalMatrix0, aLocalMatrix1: TOXMatrix;
out aMatrix0, aMatrix1: TOXMatrix );
var
Matrix0: TOXMatrix;
Matrix1: TOXMatrix;
begin
if FBody0 <> nil then
NewtonBodyGetMatrix( FBody0, @Matrix0[0, 0] );
Matrix1:= oxIdentityM;
if FBody1 <> nil then
NewtonBodyGetMatrix( FBody1, @Matrix1[0, 0] );
aMatrix0:= oxMMultiply( aLocalMatrix0, Matrix0 );
aMatrix1:= oxMMultiply( aLocalMatrix1, Matrix1 );
end;
{******************************************************************************}
// [15-9-2007]: TOXUserBilateralJoint last change by Dave Gravel. //
{******************************************************************************}
procedure TOXUserBilateralJoint.InitJoint( body1, body2: PNewtonBody );
begin
FManager:= TOXNewtonManager(Scene);
if FActived or ( FManager = nil ) then Exit;
FManager.AddLog( Name + ' create.', 1, ':Info Object' );
FBody0:= body1; FBody1:= body2;
FcPivot[0]:= Position.X;
FcPivot[1]:= Position.Y;
FcPivot[2]:= Position.Z;
FcPivot[3]:= Position.W;
FcPin[0]:= JointChildPin.X;
FcPin[1]:= JointChildPin.Y;
FcPin[2]:= JointChildPin.Z;
FpPivot[0]:= Position.X;
FpPivot[1]:= Position.Y;
FpPivot[2]:= Position.Z;
FpPin[0]:= JointParentPin.X;
FpPin[1]:= JointParentPin.Y;
FpPin[2]:= JointParentPin.Z;
if assigned( FOnCustomCreate ) and not assigned( FOnCustomBothCreate ) then begin
FOnCustomCreate( FBody0, FBody1, FcPivot, FcPin );
if FLocalUse then
CalculateLocalMatrix( oxV3Make(FcPivot), oxV3Make(FcPin), FLocalMatrix0, FLocalMatrix1 );
end else
if assigned( FOnCustomBothCreate ) and not assigned( FOnCustomCreate ) then begin
FOnCustomBothCreate( FBody0, FBody1, FcPivot, FcPin, FpPivot, FpPin );
if FLocalUse then begin
CalculateLocalMatrix( oxV3Make(FcPivot), oxV3Make(FcPin), FLocalMatrix0, FLocalMatrix1 );
CalculateLocalMatrix( oxV3Make(FpPivot), oxV3Make(FpPin), FDommyMatrix, FLocalMatrix1 );
end;
end else
if not assigned( FOnCustomCreate ) and not assigned( FOnCustomBothCreate ) then
CalculateLocalMatrix( oxV3Make(FcPivot), oxV3Make(FcPin), FLocalMatrix0, FLocalMatrix1 );
oxSetJointUserBilateral( self, body1, body2 );
FManager.AddLog( 'Joint UserBilateral Name: ' + Name, 1, ':Info Object' );
FManager.AddLog( Name + ' InitJoint.', 1, ':Info Object' );
FActived:= True;
end;
{******************************************************************************}
// [15-9-2007]: TOXUserBilateralJoint last change by Dave Gravel. //
{******************************************************************************}
function TOXUserBilateralJoint.GetCollisionState: integer;
begin
if FActived then
result:= NewtonJointGetCollisionState( Joint )
else
result:= FCollisionState;
end;
{******************************************************************************}
// [15-9-2007]: TOXUserBilateralJoint last change by Dave Gravel. //
{******************************************************************************}
procedure TOXUserBilateralJoint.SetCollisionState( const val: integer );
begin
if FCollisionState <> val then
begin
FCollisionState:= val;
if FActived then
NewtonJointSetCollisionState( Joint, FCollisionState );
end;
end;
{******************************************************************************}
// [15-9-2007]: TOXUserBilateralJoint last change by Dave Gravel. //
{******************************************************************************}
function TOXUserBilateralJoint.GetStiffness: Float;
begin
if FActived then
result:= NewtonJointGetStiffness( Joint )
else
result:= FStiffness;
end;
{******************************************************************************}
// [15-9-2007]: TOXUserBilateralJoint last change by Dave Gravel. //
{******************************************************************************}
procedure TOXUserBilateralJoint.DoProgress( const progressTime: TProgressTimes );
begin
inherited;
if FActived then
begin
end;
end;
{******************************************************************************}
// [15-9-2007]: TOXUserBilateralJoint last change by Dave Gravel. //
{******************************************************************************}
procedure TOXUserBilateralJoint.SetStiffness( const val: Float );
begin
if FStiffness <> val then
begin
FStiffness:= val;
if FActived then
NewtonJointSetStiffness( Joint, FStiffness );
end;
end;
{******************************************************************************}
// [15-9-2007]: TOXUserBilateralJoint last change by Dave Gravel. //
{******************************************************************************}
procedure TOXUserBilateralJoint.AddLinearRow( pivot0: PFloat; pivot1: PFloat; Dir: PFloat );
begin
if FActived then
begin
NewtonUserJointAddLinearRow( Joint, pivot0, pivot1, Dir );
end;
end;
{******************************************************************************}
// [15-9-2007]: TOXUserBilateralJoint last change by Dave Gravel. //
{******************************************************************************}
procedure TOXUserBilateralJoint.AddAngularRow( RelativeAngle: Float; Dir: PFloat );
begin
if FActived then
begin
NewtonUserJointAddAngularRow( Joint, RelativeAngle, Dir );
end;
end;
{******************************************************************************}
// [15-9-2007]: TOXUserBilateralJoint last change by Dave Gravel. //
{******************************************************************************}
procedure TOXUserBilateralJoint.AddGeneralRow( Jacobian0: PFloat; Jacobian1: PFloat );
begin
if FActived then
begin
NewtonUserJointAddGeneralRow( Joint, Jacobian0, Jacobian1 );
end;
end;
{******************************************************************************}
// [15-9-2007]: TOXUserBilateralJoint last change by Dave Gravel. //
{******************************************************************************}
procedure TOXUserBilateralJoint.SetRowMinimumFriction( Friction: Float );
begin
if FActived then
begin
NewtonUserJointSetRowMinimumFriction( Joint, Friction );
end;
end;
{******************************************************************************}
// [15-9-2007]: TOXUserBilateralJoint last change by Dave Gravel. //
{******************************************************************************}
procedure TOXUserBilateralJoint.SetRowMaximumFriction( Friction: Float );
begin
if FActived then
begin
NewtonUserJointSetRowMaximumFriction( Joint, Friction );
end;
end;
{******************************************************************************}
// [15-9-2007]: TOXUserBilateralJoint last change by Dave Gravel. //
{******************************************************************************}
procedure TOXUserBilateralJoint.SetRowAcceleration( Acceleration: Float );
begin
if FActived then
begin
NewtonUserJointSetRowAcceleration( Joint, Acceleration );
end;
end;
{******************************************************************************}
// [15-9-2007]: TOXUserBilateralJoint last change by Dave Gravel. //
{******************************************************************************}
procedure TOXUserBilateralJoint.SetRowStiffness( Stiffness: Float );
begin
if FActived then
begin
NewtonUserJointSetRowStiffness( Joint, Stiffness );
end;
end;
{******************************************************************************}
// [15-9-2007]: TOXUserBilateralJoint last change by Dave Gravel. //
{******************************************************************************}
procedure TOXUserBilateralJoint.SetRowSpringDamperAcceleration( springK: Float; springD: Float );
begin
if FActived then
begin
NewtonUserJointSetRowSpringDamperAcceleration( Joint, springK, springD );
end;
end;
{******************************************************************************}
// [15-9-2007]: TOXUserBilateralJoint last change by Dave Gravel. //
{******************************************************************************}
function TOXUserBilateralJoint.GetRowForce( Row: Int ): Float;
begin
if FActived then
result:= NewtonUserJointGetRowForce( Joint, Row )
else
result:= 0.0;
end;
{******************************************************************************}
// [15-9-2007]: TOXUserBilateralJoint last change by Dave Gravel. //
{******************************************************************************}
destructor TOXUserBilateralJoint.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;
{******************************************************************************}
{$D '[15-9-2007]: TOXNewtonManager v1.55 by Dave Gravel under MPL-1.1 license.'}
{******************************************************************************}
initialization
RegisterClasses( [ TOXBallJoint, TOXBallJoint, TOXHingeJoint, TOXSliderJoint,
TOXCorkscrewJoint, TOXUniversalJoint, TOXUpVectorJoint,
TOXUserBilateralJoint ] );
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -