Page 1 of 1

Camera looks at start Position

Posted: Sun Jan 11, 2004 11:12 am
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

Posted: Sun Jan 11, 2004 12:31 pm
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

Posted: Sun Jan 11, 2004 2:00 pm
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

Posted: Fri Jan 16, 2004 6:26 pm
by Keanu
The only difference in my code is that I inserted the line after the drawing commands. Maybe you can try it!

not a bug persay...

Posted: Wed Jan 21, 2004 6:46 pm
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