Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void IrrSetCamera (irr::scene::ICameraSceneNode* camera,
- float rotx, float roty, float rotz,
- float x, float y , float z) {
- quaternion tempQuaternion;
- // Work out the 3 axes for the camera:
- // Forward = target (0,0,0) - position -- the position at (x=0, y=0) is (0,0,1).
- // Right = -1 * cross-product of up.
- // Pos = -forward + x * right + y * up.
- vector3df up(0,1,0);
- vector3df forward(0,0,-1);
- vector3df pos(x,y,1);
- tempQuaternion.fromAngleAxis(rotz, forward);
- tempQuaternion.getMatrix().rotateVect(up);
- tempQuaternion.fromAngleAxis(rotx, up);
- tempQuaternion.getMatrix().rotateVect(forward);
- vector3df right = forward.crossProduct (up);
- tempQuaternion.fromAngleAxis(roty, right);
- tempQuaternion.getMatrix().rotateVect(forward);
- tempQuaternion.getMatrix().rotateVect(up);
- pos = pos + z * forward;
- camera->setUpVector (up);
- camera->setTarget (pos + forward);
- camera->setPosition (pos);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement