Physics don't move
by Cedrik zamo · in Torque 3D Professional · 01/13/2012 (1:06 am) · 5 replies
Hi,
I created a new class to use Nvidia PhysX for my vehicle instead of the rigid one used by torque vehicle. But my object don't move.
Some code :
I created a new class to use Nvidia PhysX for my vehicle instead of the rigid one used by torque vehicle. But my object don't move.
Some code :
bool AMHPlayer::onAdd()
{
if(!Parent::onAdd())
return false;
if(!PHYSICSMGR)
return false;
PhysicsCollision *colShape = PHYSICSMGR->createCollision();
colShape->addBox( mObjBox.getExtents() * 0.5f, MatrixF::Identity );
PhysicsWorld *world = PHYSICSMGR->getWorld( isServerObject() ? "server" : "client" );
mPhysicsRep = PHYSICSMGR->createBody();
if(!mPhysicsRep->init( colShape, 0, PhysicsBody::BF_KINEMATIC, this, world ))
return false;
mPhysicsRep->setTransform( getTransform() );
mDelta.rot[1].identity();
mDelta.rot[0].identity();
MatrixF * t = new MatrixF();
mPhysicsRep->getTransform(t);
mDelta.pos = t->getPosition();
mDelta.posVec = Point3F(0,0,0);
mDirection.setSize(NumThrustBits);
mDirection.clear();
addToScene();
if (isServerObject())
scriptOnAdd();
return true;
}void AMHPlayer::updateMove(const Move* move)
{
PROFILE_SCOPE( AMHPlayer_UpdateMove );
if (move && move != &NullMove)
{
if(move->x > 0)
mDirection.set(ThrustForward, true);
else if(move->x < 0)
mDirection.set(ThrustBackward, true);
else
{
mDirection.set(ThrustForward, false);
mDirection.set(ThrustBackward, false);
}
if(move->y > 0)
mDirection.set(ThrustLeft, true);
else if(move->y < 0)
mDirection.set(ThrustRight, true);
else
{
mDirection.set(ThrustLeft, false);
mDirection.set(ThrustRight, false);
}
if(move->z > 0)
mDirection.set(ThrustUp, true);
else if(move->z < 0)
mDirection.set(ThrustDown, true);
else
{
mDirection.set(ThrustUp, false);
mDirection.set(ThrustDown, false);
}
}
}void AMHPlayer::updateForces(F32 /*dt*/)
{
PROFILE_SCOPE( AMHPlayer_UpdateForces );
MatrixF currPosMat;
mPhysicsRep->getTransform(&currPosMat);
Point3F xv,yv,zv;
currPosMat.getColumn(0,&xv);
currPosMat.getColumn(1,&yv);
currPosMat.getColumn(2,&zv);
Point3F direction =
xv * ( mDirection.getBits()[ThrustForward] - mDirection.getBits()[ThrustBackward] )
+ yv * ( mDirection.getBits()[ThrustLeft] - mDirection.getBits()[ThrustRight] )
+ zv * ( mDirection.getBits()[ThrustUp] - mDirection.getBits()[ThrustDown] );
direction *= 1000.0;
mPhysicsRep->applyImpulse(currPosMat.getPosition(), direction);
MatrixF * t = new MatrixF();
mPhysicsRep->getTransform(t);
mObjToWorld.setPosition(t->getPosition());
//mWorldToObj;
}void AMHPlayer::processTick(const Move* move)
{
Parent::processTick(move);
updateMove(move);
updateForces(0);
}
#2
As you learn more about the class keep posting so other people who come along can understand what progress you made.
01/14/2012 (9:08 am)
There is not a whole lot of docs on this area of the engine. I would conclude it is incomplete not fake. Or it was intended to be derived from and certain parts completed in the derived class. We would probably have to ask the person who wrote it.As you learn more about the class keep posting so other people who come along can understand what progress you made.
#3
has been for ages.
its past the stage of being "new", and is now considered "part of the engine".
so is bullet physics, for that matter.
you need to be looking at creating your objects in the "physicsShape", "PhysicsObject", and "physicsDebris" classes....
01/14/2012 (11:08 am)
physx is fully integrated.has been for ages.
its past the stage of being "new", and is now considered "part of the engine".
so is bullet physics, for that matter.
you need to be looking at creating your objects in the "physicsShape", "PhysicsObject", and "physicsDebris" classes....
#4
Most PhysX methods are not implemented.
I don't call this "fully integrated".
Edit :
There is 102 methods in NxActor class and only 22 in pxBody.
80 methods are missing. Is it what you call full ?
01/14/2012 (11:55 am)
PhysX is not used for vehicle at all.Most PhysX methods are not implemented.
I don't call this "fully integrated".
Edit :
There is 102 methods in NxActor class and only 22 in pxBody.
80 methods are missing. Is it what you call full ?
#5
then thought its just not worth it.
RTFM.
good luck now.....
01/14/2012 (10:43 pm)
I was going to be quipy,then thought its just not worth it.
RTFM.
good luck now.....
Torque 3D Owner Cedrik zamo
In
mPhysicsRep->applyImpulse(currPosMat.getPosition(), direction);
if ( mIsEnabled && isDynamic() )
isDynamic() always return false.
the code is :
return mActor->isDynamic() && ( mBodyFlags & BF_KINEMATIC ) == 0;
My body is BF_KINEMATIC so PhysX isDynamic return false, but there is no BF_DYNAMIC and all functions in NxActor are designed for dynamic objects.
Should I conclude that Torque implementation of NxActor is a fake ?