void CPhysicsActor::SetFromBoneData( BONEINFO* boneInfo )
{
	NxMat34 transform;
	transform.setRowMajor44( boneInfo->m_Matrix->GetMatrix() );

	m_Actor->setGlobalPose( transform );
}
Example #2
0
NxMat34 StillDesign::PhysX::Math::MatrixToMat34( Matrix matrix )
{
	float values[ 16 ];
		values[ 0 ] = matrix.M11;
		values[ 1 ] = matrix.M21;
		values[ 2 ] = matrix.M31;
		values[ 3 ] = matrix.M41;
		
		values[ 4 ] = matrix.M12;
		values[ 5 ] = matrix.M22;
		values[ 6 ] = matrix.M32;
		values[ 7 ] = matrix.M42;
		
		values[ 8 ] = matrix.M13;
		values[ 9 ] = matrix.M23;
		values[ 10 ] = matrix.M33;
		values[ 11 ] = matrix.M43;
		
		values[ 12 ] = matrix.M14;
		values[ 13 ] = matrix.M24;
		values[ 14 ] = matrix.M34;
		values[ 15 ] = matrix.M44;
	
	NxMat34 mat = NxMat34( true );
		mat.setRowMajor44( &values[ 0 ] );
	
	return mat;
}
Example #3
0
void PxSingleActor::applyWarp( const MatrixF& mat, bool interpRender, bool sweep )
{
   MatrixF newMat( mat );

   if ( mActor )
   {
      mWorld->releaseWriteLock();

      mActor->wakeUp();    
      
      NxMat34 nxMat;
      nxMat.setRowMajor44( newMat );

      {
         mActor->setAngularVelocity( NxVec3( 0.0f ) );
         mActor->setLinearVelocity( NxVec3( 0.0f ) );
         mActor->setGlobalOrientation( nxMat.M );
      }

      /*
      if ( sweep )
      {
         mResetPos = mat;
         sweepTest( &newMat );
      }
      */

      nxMat.setRowMajor44( newMat );

      mActor->setGlobalPose( nxMat );
   }

   Parent::setTransform( newMat );

   mNextPos = newMat.getPosition();
   mNextRot = newMat;

   if ( !interpRender )
   {
      mLastPos = mNextPos;
      mLastRot = mNextRot;
   }
}
Example #4
0
void PxBody::applyCorrection( const MatrixF &transform )
{
   AssertFatal( mActor, "PxBody::applyCorrection - The actor is null!" );
   AssertFatal( isDynamic(), "PxBody::applyCorrection - This call is only for dynamics!" );

   // This sucks, but it has to happen if we want
   // to avoid write lock errors from PhysX right now.
   mWorld->releaseWriteLock();

   NxMat34 xfm;
   xfm.setRowMajor44( transform );
   mActor->setGlobalPose( xfm ); 
}
Example #5
0
void PxBody::moveKinematicTo( const MatrixF &transform )
{
   AssertFatal( mActor, "BtBody::moveKinematicTo - The actor is null!" );
   const bool isKinematic = mBodyFlags & BF_KINEMATIC;
   if (!isKinematic )
   {
      Con::errorf("PxBody::moveKinematicTo is only for kinematic bodies.");
      return;
   }

   NxMat34 xfm;
   xfm.setRowMajor44( transform );
   mActor->moveGlobalPose( xfm );
}
Example #6
0
void PxSingleActor::_createActor()
{
   // NXU::instantiateCollection sometimes calls methods that need
   // to have write access.
   mWorld->releaseWriteLock();

   if ( mActor )
   {
      mWorld->releaseActor( *mActor );      
      mActor = NULL;
   }
   
   NxScene *scene = mWorld->getScene();

   NxMat34 nxMat;
   nxMat.setRowMajor44( getTransform() );

   Point3F scale = getScale();

   // Look for a zero scale in any component.
   if ( mIsZero( scale.least() ) )
      return;

   bool createActors = false;
   if ( !mDataBlock->clientOnly || (mDataBlock->clientOnly && isClientObject()) )
      createActors = true;

   mActor = createActors ? mDataBlock->createActor( scene, &nxMat, scale ) : NULL;

   if ( !mActor )
   {
      mBuildScale = getScale();
      mBuildAngDrag = 0;
      mBuildLinDrag = 0;
      return;
   }

   U32 group = mDataBlock->clientOnly ? PxGroup_ClientOnly : PxGroup_Default;
   mActor->setGroup( group );

   mActor->userData = &mUserData;

   mActor->setContactReportFlags( NX_NOTIFY_ON_START_TOUCH_FORCE_THRESHOLD | NX_NOTIFY_FORCES );
   mActor->setContactReportThreshold( mDataBlock->forceThreshold );

   mBuildScale = getScale();
   mBuildAngDrag = mActor->getAngularDamping();
   mBuildLinDrag = mActor->getLinearDamping();
}
Example #7
0
void PxBody::setTransform( const MatrixF &transform )
{
   AssertFatal( mActor, "PxBody::setTransform - The actor is null!" );

   // This sucks, but it has to happen if we want
   // to avoid write lock errors from PhysX right now.
   mWorld->releaseWriteLock();

   NxMat34 xfm;
   xfm.setRowMajor44( transform );
   mActor->setGlobalPose( xfm ); 

   // If its dynamic we have more to do.
   if ( mActor->isDynamic() && !mActor->readBodyFlag( NX_BF_KINEMATIC ) )
   {
      mActor->setLinearVelocity( NxVec3( 0, 0, 0 ) );
      mActor->setAngularVelocity( NxVec3( 0, 0, 0 ) );
      mActor->wakeUp();
   }
}
void PhysXShape::setGlobalPos(const math::matrix4x4&m)
{
	NxMat34 nm;
	nm.setRowMajor44(m.getMatPointer());
	m_nxShape->setGlobalPose(nm);
}
void PhysXForceField::setPose(const math::matrix4x4 &m)
{
	NxMat34 pos;
	pos.setRowMajor44(m.mat);
	m_forceField->setPose(pos);
}