Hi Guys,
Is there anyway I can rotate my ICameraSceneNode (not fps) using setRotation() ??
Currently it doesn't work because it always points to the "target" which doesn't seem to move with setRotation(). I have looked through the APIs but cant find anything to help.
I think I need to tell the camera to always face 'straight ahead' (on the rotation angle) or ignore the 'target' position.
Thanks,
Rotate ICameraSceneNode with setRotation()?
-
- Posts: 10
- Joined: Fri May 05, 2006 10:38 am
- Location: Australia
-
- Posts: 10
- Joined: Fri May 05, 2006 10:38 am
- Location: Australia
Ok,
I dont know much trig w/ cos and sin but this is what I came up with...
Is this correct?
Atm - my camera jolts around when I try and move the mouse (vibrates in a 'nonsense-able' way). I am not sure if it is this snippet that is causing that or if its somewhere else in my code?
Either way - I would like comments please!
Thanks,
I dont know much trig w/ cos and sin but this is what I came up with...
Code: Select all
ICameraSceneNode* node = (ICameraSceneNode*)
NewtonBodyGetUserData(body);
if(node)
{
node->setPosition(mat.getTranslation()); // set position
node->setRotation(mat.getRotationDegrees()); // and rotation
vector3df target;
target.X = cos(node->getRotation().X) * 10;
node->setTarget(target);
}
Atm - my camera jolts around when I try and move the mouse (vibrates in a 'nonsense-able' way). I am not sure if it is this snippet that is causing that or if its somewhere else in my code?
Either way - I would like comments please!
Thanks,
You need first of all to convert your "node->getRotation().X" angle from degrees to radians in this way: node->getRotation().X/(180/3.1416);
It seems to me to be workable . But I'm not sure.
Code: Select all
target.X=cos(node->getRotation().Y/(180/3.1416))*10;
target.Z=sin(node->getRotation().Y/(180/3.1416))*10;
target.Y=0;
node->setTarget(target+node->getPosition());
-
- Posts: 10
- Joined: Fri May 05, 2006 10:38 am
- Location: Australia
Thanks LM,
I have re-learnt some trigonometry, tried a few things, I think this works for left-right rotation, still not very smooth but I think that is due to another area of my code.
I would like to add up and down rotation now...
I am thinking this should work...
Except, I dont know how to modify the Z (depth) so as the target rises and falls, it also comes towards me and away from me... without screwing up what I have already done (left -right rotation).
Thanks for any advice!
I have re-learnt some trigonometry, tried a few things, I think this works for left-right rotation, still not very smooth but I think that is due to another area of my code.
Code: Select all
vector3df target;
target.Z=cos(node->getRotation().X/(180/3.1416))*10;
target.X=sin(node->getRotation().X/(180/3.1416))*10;
I am thinking this should work...
Code: Select all
target.Y=sin(node->getRotation().Y/(180/3.1416))*10;
Thanks for any advice!
Everytime someone asks of rotating the camera, there is a new complicated way.
Instead is so easy:
I already posted it (http://irrlicht.sourceforge.net/phpBB2/ ... hp?t=12961)
Bye
Instead is so easy:
Code: Select all
ICameraSceneNode *camera;
camera = smgr->addCameraSceneNodeFPS (0, 100, 500);
camera->setInputReceiverEnabled (false);
then:
camera->setPosition (irr::core::vector3df (posx, posy, posz));
camera->setRotation (irr::core::vector3df (rotx, roty,rotz));
Bye
-
- Posts: 10
- Joined: Fri May 05, 2006 10:38 am
- Location: Australia
Thanks stef_,
Although, I haven't got your code working yet...
As far as I 'knew' smgr->addCameraSceneNodeFPS() will still create a camera that 'looks at' the target. So an FPS camera with input disabled would be the same as a non-FPS camera? ... and setRotation won't work... am I mistaken?, you claim 'it works really well' in your other post... Please explain!
Thanks,
Although, I haven't got your code working yet...
As far as I 'knew' smgr->addCameraSceneNodeFPS() will still create a camera that 'looks at' the target. So an FPS camera with input disabled would be the same as a non-FPS camera? ... and setRotation won't work... am I mistaken?, you claim 'it works really well' in your other post... Please explain!
Thanks,