addCameraSceneNode without target??
-
enforceman
- Posts: 26
- Joined: Sat Jan 03, 2004 3:43 pm
addCameraSceneNode without target??
Hello!
How is it possible to set a normal camera (cam->addCameraSceneNode();, which I can move without looking to a fixed point ((0,0,100) in the case)? I want to create my own FPS camera.
regards, Tom
How is it possible to set a normal camera (cam->addCameraSceneNode();, which I can move without looking to a fixed point ((0,0,100) in the case)? I want to create my own FPS camera.
regards, Tom
i'd simply suggest looking at the FPS camera class code, and the addFPScamera () function before starting your own class.
if you just want to have an FPS camera which uses different keys for movement: you can define a custom keymap (look at the documentation for addFPScamera
if you just want to have an FPS camera which uses different keys for movement: you can define a custom keymap (look at the documentation for addFPScamera
a screen cap is worth 0x100000 DWORDS
-
enforceman
- Posts: 26
- Joined: Sat Jan 03, 2004 3:43 pm
I believe you can do this just by not sending mouse events to the maya cam, if you want the user to use gui elements. Eg. if the user presses the Alt button, switch between GUI mouse mode and movement mouse mode, and send events accordingly.
With the FPS, do something similar, except you have to tell the camera to be inactive, so that it doesn't recenter the mouse on you constantly.
With the FPS, do something similar, except you have to tell the camera to be inactive, so that it doesn't recenter the mouse on you constantly.
-
enforceman
- Posts: 26
- Joined: Sat Jan 03, 2004 3:43 pm
here is some pseudo code:
perhaps you should have a GUI button to switch into MAYA mode too? though, you obviously wouldnt be able to click this button to go out of maya mode.
Code: Select all
OnEvent(event) {
static bool useMAYA = false;
//let the user switch modes (make sure u do this before sending events to the camera!)
if(key == KEY_ALT)
useMAYA = !useMAYA; return true;
if(useMAYA && p_mayaCam != NULL)
p_mayaCam->onEvent(event);
else
//handle regular GUI stuff here
// like when a button is pressed
}a screen cap is worth 0x100000 DWORDS
-
enforceman
- Posts: 26
- Joined: Sat Jan 03, 2004 3:43 pm
Try this code:
I just added the && !key.PressedDown to keless's code. I just noticed the way he had it, the useMAYA switch would always happen at least twice each time the alt button was pressed; once pressing the button, once releasing the button. So your Maya cam was in fact still having its OnEvent code called, which is why it was still usable.
Code: Select all
OnEvent(event) {
static bool useMAYA = false;
//let the user switch modes (make sure u do this before sending events to the camera!)
if(key == KEY_ALT && !key.PressedDown)
useMAYA = !useMAYA; return true;
if(useMAYA && p_mayaCam != NULL)
p_mayaCam->onEvent(event);
else
//handle regular GUI stuff here
// like when a button is pressed
} -
Andechs
How does it function with cameraFPS?
First I tried following..
if (device->getSceneManager()->getActiveCamera() && cam_active)
{
device->getSceneManager()->getActiveCamera()->OnEvent(event);
return true;
}
.. an nothing ( accept the cursor keys switched off ) happens
Second i tried that...
two cams, one FPS, one static and i wanna copy the view.
if (sm->getActiveCamera() == camera)
{
cameraFPS->setPosition(camera->getPosition());
cameraFPS->setTarget(camera->getTarget());
sm->setActiveCamera(cameraFPS);
device->getCursorControl()->setVisible(false);
}
else
{
camera->setPosition(cameraFPS->getPosition());
camera->setTarget(cameraFPS->getTarget());
sm->setActiveCamera(camera);
device->getCursorControl()->setVisible(true);
}
but this seems to be a buggy. Until i don't move it works but if i go far away, the positions are different.
First I tried following..
if (device->getSceneManager()->getActiveCamera() && cam_active)
{
device->getSceneManager()->getActiveCamera()->OnEvent(event);
return true;
}
.. an nothing ( accept the cursor keys switched off ) happens
Second i tried that...
two cams, one FPS, one static and i wanna copy the view.
if (sm->getActiveCamera() == camera)
{
cameraFPS->setPosition(camera->getPosition());
cameraFPS->setTarget(camera->getTarget());
sm->setActiveCamera(cameraFPS);
device->getCursorControl()->setVisible(false);
}
else
{
camera->setPosition(cameraFPS->getPosition());
camera->setTarget(cameraFPS->getTarget());
sm->setActiveCamera(camera);
device->getCursorControl()->setVisible(true);
}
but this seems to be a buggy. Until i don't move it works but if i go far away, the positions are different.