Hi,
Is there a way to get which direction the camera is facing?
camera direction
I think this should work
Code: Select all
ICameraSceneNode *pCamera = pSceneManager->getActiveCamera();
vector3df pos = pCamera->getAbsolutePosition();
vector3df target = pCamera->getTarget();
vector3df dir = target - pos;
Hi,
i'm trying to create a cube that's always in the middle of the screen and away from the camera.
I tried your method:
i think i'm doing it wrong because it's not working as expected.. sorry i'm still learning :S/
i'm trying to create a cube that's always in the middle of the screen and away from the camera.
I tried your method:
Code: Select all
pCamera = smgr->getActiveCamera();
pos = pCamera->getAbsolutePosition();
target = pCamera->getTarget();
dir = target - pos;
node->setPosition(dir);
maybe
Just a guess tough, you could also make camera orbit around It.(code snippets section to the rescue).
Code: Select all
node->setPosition(dir*100);
Working on game: Marrbles (Currently stopped).
If you want the node to follow the camera around on a fixed distance, do
dir by itself is just a vector representing the direction from the camera towards where it looks. We normalize it (make its length = 1) then makes it distance long, and we add the position where the camera is.
If you just want the camera to focus on the node, do
Code: Select all
node->setPosition(pos + dir.normalize() * distance);
If you just want the camera to focus on the node, do
Code: Select all
pCamera->setTarget(node->getAbsolutePosition())