How do you manually control a camera?

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
muller
Posts: 1
Joined: Thu Jun 29, 2006 5:10 am

How do you manually control a camera?

Post by muller »

Im previously a java programer and am new to c++.

So far I've been able to make a regulkar camera like this:

Code: Select all

scene::ICameraSceneNode* camera = scenemgr->addCameraSceneNode(node, core::vector3df(0, 200, 100), core::vector3df(0, 200, 100), 1);
The second vector3df is for a target to look at. But i don't want that. I want to manually set the rotation and position of a camera. I've tried to use setUpVector(core::vector3df) to override the the look at but it doesn't work.

I see that ICameraSceneNode's constructor takes position and a rotation, but i always get errors when constructing it:

Code: Select all

scene::ICameraSceneNode* camera = new scene::ICameraSceneNode(node, smgr, 1, core::vector3df(-200,200,-200), core::vector3df(0, 100, 0), core::vector3df(1.0f, 1.0f, 1.0f) );
And yes i am trying to make 'node' a parent of the camera.

Could someone please give an example of how to make a camera that is manually controlled.

Thank you for your time.
~muller
Baal Cadar
Posts: 377
Joined: Fri Oct 28, 2005 10:28 am
Contact:

Post by Baal Cadar »

ICameraSceneNode is just an interface. You can't new interfaces (true in Java too. ;) )

ICameraSceneNode is subclass of ISceneNode and ISceneNode has functions to change position and rotation. See API docs.
No offense :)
kornerr
Posts: 245
Joined: Thu Jul 06, 2006 9:57 am
Location: Russia, Siberia, Kemerovo
Contact:

Post by kornerr »

So how to move camera manually?
I redefine EventReceiver to be able to use GUI and game, I haven't seen any tut on this (WHY? Don't games have GUI?). So I need to move camera from there manually. Can you tell me how to do it?
More certainly, how to:
1) move forward;
2) move backward;
3) strafe left;
4) strafe right.
I guess, I should change ViewMatrix, but how? What formulas should I apply?

Thanks.
Open Source all the way, baby ;)
OSRPG
irrlicher
Posts: 9
Joined: Sat Jul 01, 2006 9:27 am

Post by irrlicher »

I think there might be a code like this in the demo in SDK.In demo you can move camera with W,S,A,D try to look at demo's code.
Do you think 13 year aged children can't make 3d games? :)
TheWorstCoderEver
Posts: 47
Joined: Wed Feb 01, 2006 8:09 pm
Location: Wroclaw
Contact:

Post by TheWorstCoderEver »

scenemgr->addCameraSceneNodeFPS();

W - forwards, S - backwards, A-D - left - right.

Regards.
DeusXL
Posts: 114
Joined: Sun Mar 14, 2004 9:37 am
Contact:

Post by DeusXL »

TheWorstCoderEver wrote:scenemgr->addCameraSceneNodeFPS();

W - forwards, S - backwards, A-D - left - right.

Regards.
Isn't default keymapping with arrows keys for movement and mouse for target ?

There is an example on documentation about how to make a special key mapping :
http://irrlicht.sourceforge.net/docu/cl ... er.html#a3
Irrlicht .NET complete and Cross Platform Wrapper
The kid on my avatar wrote:A painless lesson is one without any meaning
kornerr
Posts: 245
Joined: Thu Jul 06, 2006 9:57 am
Location: Russia, Siberia, Kemerovo
Contact:

Post by kornerr »

ok, i've looked into Demo, and this is what i wanted:

Code: Select all

 if (ev.EventType == EET_KEY_INPUT_EVENT) {
                switch (ev.KeyInput.Key) {
                        case KEY_KEY_W:
                        case KEY_KEY_S:
                        case KEY_KEY_D:
                        case KEY_KEY_A:
                                dev->getSceneManager ()->getActiveCamera ()->OnEvent (ev);
                                break;
                } // switch
        }
Open Source all the way, baby ;)
OSRPG
strale
Posts: 119
Joined: Wed Nov 23, 2005 1:58 pm
Location: Lambrugo Italy
Contact:

Post by strale »

scene::ICameraSceneNode* camera = scenemgr->addCameraSceneNode(node, core::vector3df(0, 200, 100), core::vector3df(0, 200, 100), 1);
Hi
if i m not wrong ...

using "node" as firs parametwer you set the camera as parent of the "node"

so moving the node (rotating ecc.. ) the camera will rotate ecc.. with it

bye
Post Reply