NewtonSetTransform

From Newton Wiki
Jump to: navigation, search

NewtonSetTransform

typedef void (*NewtonSetTransform) (const NewtonBody* const body, const dFloat* const matrix, int threadIndex)

Usage

This callback is called by NewtonUpdate for every rigid body that has had its position or orientation changed. If you wish to receive this callback, assign it using NewtonBodySetTransformCallback function.

Parameters

  • const NewtonBody* body - The body for which the matrix has changed.
  • const dFloat* matrix - New rotation & position expressed as a 4x4 matrix for the newton body, copy this data to your own engine structure where it is needed.
  • int threadIndex

Remarks

  • This is not a library function, but a callback event.

Examples

C++

void _cdecl callbackTransform( const NewtonBody* body, const float* matrix)
{
  CSceneMoveableObject *obj = ((CSceneMoveableObject*)NewtonBodyGetUserData(body));   
  CopyMatrix( obj->m_matrix,  matrix );
} 

Delphi

procedure PhysicsSetTransform(const Body : PNewtonBody; const Matrix : PFloat); cdecl;
var
 Primitive : TNewtonPrimitive;
begin
 if not Assigned(NewtonBodyGetUserData(Body)) then
  exit;
 Primitive := TNewtonPrimitive(NewtonBodyGetUserData(Body));
 Move(Matrix^, Primitive.Matrix, SizeOf(TMatrix4f));
end;

See also

NewtonBodySetTransformCallback NewtonSetTransform NewtonBodySetMatrix NewtonBodyGetMatrix