예제 #1
0
CVector PhysicObject::getPhysPosition() {
	if (!rigidBody)
    	return initialPosition;
	btTransform trans;
    if (getIsKinematic()) {
        rigidBody->getMotionState()->getWorldTransform(trans);
    } else {
        trans = rigidBody->getWorldTransform();
    }

	CVector res = CVector(trans.getOrigin().getX() * 100.0f, trans.getOrigin().getY() * 100.0f, trans.getOrigin().getZ() * 100.0f);
    return res;
}
예제 #2
0
void PhysXRigidbody::rotate(const Quaternion& rotation)
{
    if (getIsKinematic())
    {
        PxTransform target;
        if (!mInternal->getKinematicTarget(target))
            target = PxTransform(PxIdentity);

        target.q = toPxQuaternion(rotation);

        mInternal->setKinematicTarget(target);
    }
    else
    {
        setTransform(getPosition(), rotation);
    }
}
예제 #3
0
void PhysXRigidbody::move(const Vector3& position)
{
    if (getIsKinematic())
    {
        PxTransform target;
        if (!mInternal->getKinematicTarget(target))
            target = PxTransform(PxIdentity);

        target.p = toPxVector(position);

        mInternal->setKinematicTarget(target);
    }
    else
    {
        setTransform(position, getRotation());
    }
}
예제 #4
0
void PhysicObject::setPhysPosition(CVector pos) {
	if (rigidBody) {
		btTransform trans;
        if (getIsKinematic()) {
            rigidBody->getMotionState()->getWorldTransform(trans);
            trans.setOrigin(btVector3(pos.x / 100.0f, pos.y / 100.0f, pos.z / 100.0f));
            rigidBody->getMotionState()->setWorldTransform(trans);
        } else {
            trans = rigidBody->getWorldTransform();
            trans.setOrigin(btVector3(pos.x / 100.0f, pos.y / 100.0f, pos.z / 100.0f));
            rigidBody->setWorldTransform(trans);
        }
        
		return;
	}
	initialPosition = pos / 100.0f;
}