addCameraSceneNode without target??

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
enforceman
Posts: 26
Joined: Sat Jan 03, 2004 3:43 pm

addCameraSceneNode without target??

Post by enforceman »

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
Boogle
Posts: 162
Joined: Fri Nov 21, 2003 3:16 pm
Location: Toronto, Canada

Post by Boogle »

Nope.. you will have to update the target every game loop. Or create a small SceneNodeAnimator to do this for you and attach it to your camera.
keless
Posts: 805
Joined: Mon Dec 15, 2003 10:37 pm
Location: Los Angeles, California, USA

Post by keless »

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
a screen cap is worth 0x100000 DWORDS
enforceman
Posts: 26
Joined: Sat Jan 03, 2004 3:43 pm

Post by enforceman »

thank you,

in my case i have to use the mousepointer to click on GUI stuff (left button) and to rotate / translate the cam (right button). Thats imposible with the Maya Camera (what a pity).

regards, tom
Boogle
Posts: 162
Joined: Fri Nov 21, 2003 3:16 pm
Location: Toronto, Canada

Post by Boogle »

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.
enforceman
Posts: 26
Joined: Sat Jan 03, 2004 3:43 pm

Post by enforceman »

How can I do this? Can you post some code, please?

Thank you, Boogle
keless
Posts: 805
Joined: Mon Dec 15, 2003 10:37 pm
Location: Los Angeles, California, USA

Post by keless »

here is some pseudo code:

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

}
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.
a screen cap is worth 0x100000 DWORDS
enforceman
Posts: 26
Joined: Sat Jan 03, 2004 3:43 pm

Post by enforceman »

When I don't do 'p_MayaCam->OnEvent(event) ' the maya cam is still usable ans I can't click on buttons. Is there an other possiblility to use the buttons while displaying the scene?
Boogle
Posts: 162
Joined: Fri Nov 21, 2003 3:16 pm
Location: Toronto, Canada

Post by Boogle »

Try this code:

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 

} 
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.
Andechs

Post by 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.
Post Reply