Code: Select all
vector3df v = node->getRotation
the return value only gives me the X and Y rotation but Z always = 0??
If I use a matrix to get absolute transformation and getrotationDegrees I have the same problem.
THE END...
(Not answered)
Code: Select all
vector3df v = node->getRotation
Code: Select all
node->setRotation (core::vector3df (10, 10, 10));
Code: Select all
const core::vector3df r = node->getRotation();
Code: Select all
matrix4 trans = node->getAbsoluteTranslation();
vector3f v = trans.getRotationDegress();
bullet-setRotation(v);
If you post pseudo-code, then we have to guess what you really meant. I think it was this:timmymorris91 wrote:v should give me the rotation of the gun.Code: Select all
matrix4 trans = node->getAbsoluteTranslation(); vector3f v = trans.getRotationDegress(); bullet-setRotation(v);
I need the rotation so I can shoot a bullet and use the rotation
as the bullets.
All the rotation works but the Z axis is always the same. If I shoot up, then the bullet will still be flat, not tilted up or down.
Code: Select all
ISceneNode * actor = smgr->addEmptySceneNode();
actor->setRotation(vector3df(10, 20, 30));
actor->updateAbsolutePosition();
ISceneNode * gun = smgr->addEmptySceneNode(actor);
// Presumably the gun doesn't have any rotation of its own
gun->updateAbsolutePosition();
matrix4 trans = gun->getAbsoluteTransformation();
vector3df rotation = trans.getRotationDegrees();
(void)printf("%f %f %f\n", rotation.X, rotation.Y, rotation.Z);
No. What's returned isn't a direction vector, it's three Euler axis rotations. X axis is pitch.Eigen wrote:Actually, wouldn't it be Y? Because in XYZ coordinate system Y is "up/down"shogun wrote:This would be the X axis, not the Z axis.
Code: Select all
ISceneNode * actor = smgr->addEmptySceneNode();
actor->setRotation(vector3df(45, 90, 0)); // Face right, and 45 degrees up.
actor->updateAbsolutePosition();
ISceneNode * gun = smgr->addEmptySceneNode(actor);
// Presumably the gun doesn't have any rotation of its own
gun->updateAbsolutePosition();
matrix4 trans = gun->getAbsoluteTransformation();
vector3df direction(0, 0, 1);
trans.rotateVect(direction);
direction.normalize();
(void)printf("%f %f %f\n", direction.X, direction.Y, direction.Z);
I have used this method before.rogerborg wrote:Code: Select all
matrix4 trans = gun->getAbsoluteTransformation(); vector3df rotation = trans.getRotationDegrees(); (void)printf("%f %f %f\n", rotation.X, rotation.Y, rotation.Z);
It doesn't apply the transformation that you expect.timmymorris91 wrote:I have used this method before.rogerborg wrote:Code: Select all
matrix4 trans = gun->getAbsoluteTransformation(); vector3df rotation = trans.getRotationDegrees(); (void)printf("%f %f %f\n", rotation.X, rotation.Y, rotation.Z);
But when I use the rotation vector and set the bullet being shot to the same direction as the gun, it doesnt apply the right transformation to the bullet.
Code: Select all
vector3df rotation = trans->getRotationDegrees();
bullet->setRotation(v);
Code: Select all
// Your code so far
vector3df rotation = trans->getRotationDegrees();
bullet->setRotation(rotation);
// Build a rotation matrix for the direction
matrix4 rotationMatrix;
rotationMatrix.setRotationDegrees(rotation);
// Assume that +Z is forwards
vector3df bulletDirection(0, 0, 1);
// Rotate that vector to point in the direction that the bullet is facing
rotationMatrix.rotateVect(bulletDirection);
// bulletDirection is the direction in which bulletNode should move