Yet Another Camera Question...

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
Aerinai
Posts: 5
Joined: Wed Nov 22, 2006 8:50 pm

Yet Another Camera Question...

Post by Aerinai »

Alright, you have all heard this a million and a half times, but I'm trying to do camera movement that will be locked onto the character moving horizontally only. So basically I need the camara to do this:
Camera.Pos(heroPosX,heroPosY,-100);
camera.LookAt(heroPosX, HeroPosY, heroPosZ);
--------------------------------------------------------
This SHOULD create a side scrolling 3d game if it works correctly. i've tried to add the animatedSceneNode of the character i've been moving to the camera's parent property, but the camera does NOT like to be updated beyond that point. it will move the position of the camera, but not the lookAt position. I cannot add it to the main game loop because it freaks out. Is there a way to update the camera's Position and its Look At position in the game loop? Or does anyone know where I can start looking for this?
zeno60
Posts: 342
Joined: Sun May 21, 2006 2:48 am
Location: NC, USA
Contact:

Post by zeno60 »

Are you looking for camera->setPosition(vector3df(0,0,0)); and camera->setTarget(vector3df(0,0,0)); functions?
Aerinai
Posts: 5
Joined: Wed Nov 22, 2006 8:50 pm

Post by Aerinai »

my problem with the camera->setTarget() is that I cannot find WHERE my camera is. Its set up in the ISceneManager->AddCameraSceneNode(). I can't get to the setTarget() function :(. Am I missing Something?
bitplane
Admin
Posts: 3204
Joined: Mon Mar 28, 2005 3:45 am
Location: England
Contact:

Post by bitplane »

yes, you're missing the pointer that addCameraSceneNode returns-

Code: Select all

ICameraSceneNode* myCamera = smgr->addCameraSceneNode();
myCamera->setPosition(newpos);
Submit bugs/patches to the tracker!
Need help right now? Visit the chat room
zeno60
Posts: 342
Joined: Sun May 21, 2006 2:48 am
Location: NC, USA
Contact:

Post by zeno60 »

Are you creating a ICameraSceneNode variable pointer to hold your camera?

ICameraSceneNode * camera = scene_manager->addCameraSceneNodeFPS(0,100.0f,300.0f);

Obviously changing for the values you want.

Then you would use camera->setPosition() and setTarget().
Aerinai
Posts: 5
Joined: Wed Nov 22, 2006 8:50 pm

Post by Aerinai »

Thanks SO much :) it worked!
execute
Posts: 14
Joined: Wed Nov 22, 2006 7:48 pm

Post by execute »

I understand SetPosition. But how exactly does SetTarget work, and what does it do?
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

setTarget tells the camera at which point in the 3D space to look at.
Image Image Image
Post Reply