Kim2
24-11-2008 00:46:10
Hi, a couple of basic questions.
I want to set an acceleration value (say, 5m/s/s) and then have an object accelerate in a direction at that value.
The accelVector is direction with magnitude = acceleration amount (which I set to 5).
However, watching the linear velocity returned from the actor, this doesn't seem to provide the right amount of acceleration at all. Acceleration seems more like 20ms/s.
What am I missing here?
Second problem, I'm trying to orient the ship to face a point using torque.
When I was using Newton SDK I could get the ship to turn and face a point (only considering single axis of rotation) like this:
With a bit more code to smooth out the turning so it doesn't wobble back and forth.
Using NxOgre the rotation is only going in one direction and it seems to go off axis until the ship is facing downwards and rotating around its local z axis.
What is the best way to get my ship facing a point using physics?
Thanks a lot.
I want to set an acceleration value (say, 5m/s/s) and then have an object accelerate in a direction at that value.
ships[i]->forceToApply = ships[i]->mass * accelVector;
The accelVector is direction with magnitude = acceleration amount (which I set to 5).
However, watching the linear velocity returned from the actor, this doesn't seem to provide the right amount of acceleration at all. Acceleration seems more like 20ms/s.
What am I missing here?
Second problem, I'm trying to orient the ship to face a point using torque.
When I was using Newton SDK I could get the ship to turn and face a point (only considering single axis of rotation) like this:
Quaternion r; Vector3 p;
p = ships[i]->mPosition;
r = ships[i]->mOrientation;
Vector3 directionToTarget = ships[i]->navPoints[0] - ships[i]->mPosition;
directionToTarget.normalise();
Vector3 negZ = r.zAxis() * -1.0;
Quaternion rotationNeeded = negZ.getRotationTo(directionToTarget);
float rotYaw = rotationNeeded.getYaw().valueDegrees() * -1.0;
float rotPitch = rotationNeeded.getPitch().valueDegrees() * -1.0;
//OverlayElement* guiCurr = OverlayManager::getSingleton().getOverlayElement("Core/CurrFps");
//guiCurr->setCaption(StringConverter::toString(rotationNeeded.getYaw() * -1.0));
ships[i]->torque = Vector3(0,0,0);
if(rotYaw < 0) {
// left
ships[i]->torque = Vector3(0, 20, 0);
}
else if(rotYaw > 0) {
// right
ships[i]->torque = Vector3(0, -20, 0);
}
With a bit more code to smooth out the turning so it doesn't wobble back and forth.
Using NxOgre the rotation is only going in one direction and it seems to go off axis until the ship is facing downwards and rotating around its local z axis.
What is the best way to get my ship facing a point using physics?
Thanks a lot.