Camera looks at start Position

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
ruderalis
Posts: 3
Joined: Fri Dec 26, 2003 12:34 am
Location: switzerland

Camera looks at start Position

Post by ruderalis »

Hi everybody, sorry for my english!

i have taken the code structure from the techdemo.
now when i move the player thecamera follows him turn with him but look a the start position of the player.

here is the soure: http://www.homepage.hispeed.ch/rude/rfx/RFXBase001.cpp
:? :?:
thx
Keanu
Posts: 13
Joined: Sun Jan 04, 2004 11:10 am
Location: Italy
Contact:

Post by Keanu »

If I guessed your problem, the solution should be in one other thread but actually I can't find it so here it is what to do: add in the main loop (drawing loop) the following code pcamera->setTarget(Player1node->getPosition()); I think that is a bug of the camera but you can solve it in this way. I hope this could be of any help! :D
P4 2.53MHz 256MB GeForce4Mx VC++6.0
ruderalis
Posts: 3
Joined: Fri Dec 26, 2003 12:34 am
Location: switzerland

Post by ruderalis »

Thx for your help, but i had try out this way, (i had read the other threads disscusing this problem :) ) but when i do that in the draw loop like this:
while(device->run() && driver)
{
if (device->isWindowActive())
{
// load next scene if necessary
u32 now = device->getTimer()->getTime();


if (now - sceneStartTime > timeForThisScene && timeForThisScene!=-1)
switchToNextScene();

pcamera->setTarget(Player1node->getPosition());



// draw everything

driver->beginScene(true, true, backColor);

smgr->drawAll();
guienv->drawAll();
driver->endScene();




// statistics

swprintf(tmp, 255, L"%s fps:%d polys:%d", driver->getName(),
driver->getFPS(), driver->getPrimitiveCountDrawn());

statusText->setText(tmp);
}

}

it compiles but the app crash at start
Keanu
Posts: 13
Joined: Sun Jan 04, 2004 11:10 am
Location: Italy
Contact:

Post by Keanu »

The only difference in my code is that I inserted the line after the drawing commands. Maybe you can try it!
P4 2.53MHz 256MB GeForce4Mx VC++6.0
buhatkj
Posts: 444
Joined: Fri Dec 12, 2003 4:53 am
Contact:

not a bug persay...

Post by buhatkj »

well its not a bug persay, really what it is, is that the camera _is_ attached to the player, it has the player's translation and rotation, but its target does not. there are definitely instances where you would WANT this to be the case, but for most people, including me, the target is the thing you want to be attached, not necessarily the camera itself. I'm not certain, but i dont think the irrlicht camera really provides the functionality to attached the _TARGET_ of the camera to a given sceneNode, though that would certainly rock :-)

for now, as keanu says the only real way to do it is to do a camera->setTarget(playervector); every run through the render loop(or perhaps just when the player's position changes)
-Ted
My irrlicht-based projects have gone underground for now, but if you want, check out my webcomic instead! http://brokenboomerang.net
Post Reply