Rotating Camera
Rotating Camera
I have created a camera scene node with ISceneManager::addCameraSceneNode(). This camera is irresponsive to ICameraSceneNode::setRotation(), because of the ICameraSceneNode::setTarget() method. I mean, the target of the camera is set to 0,0,0, so when I move the camera around, it will be rotated so it looks at the position 0,0,0. If I use setRotate() to rotate it, it has no effect, as the camera is rotated automatically again to face the target position.
I think that the setTarget() method should update the camera's rotation when it is called, but not updated automatically each frame. I mean, if I want a camera that is constantly looking at a certain position, I'll use setTarget() each frame for that camera. But if I want a camera which I want to turn around, I want to be able to rotate it with setRotation().
I think that the setTarget() method should update the camera's rotation when it is called, but not updated automatically each frame. I mean, if I want a camera that is constantly looking at a certain position, I'll use setTarget() each frame for that camera. But if I want a camera which I want to turn around, I want to be able to rotate it with setRotation().
I'm having a similar problem...
I'm doing a flight sim...Cameras don't look at any thing, they point where you tell them the plane is aiming in full 3d. I can't get any rotation to bank the camera...and really want it to stay where I put it relitive to world coordinates...the flight dynamics will decide where that is...
What do I do? I've started this questing in the beginners forum too.
Thanks for any work around!
What do I do? I've started this questing in the beginners forum too.
Thanks for any work around!
Me too
Hi
I am not well experinced in engine But i also found this . If i am right
in CameraSceneNode::OnPrender() function that is calcutating every frame
for camera .
I want ask to experinced programmers to look at code of CameraSceneNode::OnPrender function has sum calcaulation of Upvector and so that calculating 2 time .Normalize() and crossprouduct in one frame
for camera evenif camera not updated (not changed) . So i thing in 3d math .Normalize using sqrt math function that'll be big bottlenek for engine because render call lot times at that time sqrt will calcuated .
So guys just check code in my opnion for optimization
If am i wrong please tell me
devil20
I am not well experinced in engine But i also found this . If i am right
in CameraSceneNode::OnPrender() function that is calcutating every frame
for camera .
I want ask to experinced programmers to look at code of CameraSceneNode::OnPrender function has sum calcaulation of Upvector and so that calculating 2 time .Normalize() and crossprouduct in one frame
for camera evenif camera not updated (not changed) . So i thing in 3d math .Normalize using sqrt math function that'll be big bottlenek for engine because render call lot times at that time sqrt will calcuated .
So guys just check code in my opnion for optimization
If am i wrong please tell me
devil20
Well, I have found a quick&dirty way which works really fine to rotate the camera using euler angles instead of defining a target position.
When you create a camera, also create an EmptySceneNode which is a child of the camera, and position it at vector3df(0,0,1) (so it is always in front of the camera).
When you want to rotate the camera, use camera->setRotation(). I said that this has no effect, because an ICameraSceneNode has a target position where the camera is always aiming at. But if each frame you do:
Then you will update the target value to be at the front of the camera (as "child" is the empty scene node you created which is attached to the camera and in the front of it).
Probably there are other ways but this one works perfectly.
When you create a camera, also create an EmptySceneNode which is a child of the camera, and position it at vector3df(0,0,1) (so it is always in front of the camera).
When you want to rotate the camera, use camera->setRotation(). I said that this has no effect, because an ICameraSceneNode has a target position where the camera is always aiming at. But if each frame you do:
Code: Select all
camera->setTarget(child->getAbsolutePosition());
Probably there are other ways but this one works perfectly.
Nothing dirty about that - it's quite elegant because you let Irr handle the calculations and Irr has to know how to do it in the first place.
However, you don't incorporate roll - for that you'd need to supply an up-vector.
You can probably extend it by attaching another node at 0,1,0 and then subtracting the camera position from that node's absolute position to get the correct upvector.
However, you don't incorporate roll - for that you'd need to supply an up-vector.
You can probably extend it by attaching another node at 0,1,0 and then subtracting the camera position from that node's absolute position to get the correct upvector.