cameraFPS 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
thatax
Posts: 25
Joined: Thu Jul 31, 2008 7:33 am

cameraFPS question

Post by thatax »

the camera is in FPS mode,how to get the camera's postion in real time,
I used camera->getPostion() int function device->run(),but it crashes when the game begin.
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

So you have a corrupt pointer somewhere, the method won't crash otherwise.
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

You may well have made the error of having both a global and local pointer called camera and you're then referencing the wrong one...

If you post your code then we can spot that easily.
Image Image Image
thatax
Posts: 25
Joined: Thu Jul 31, 2008 7:33 am

Post by thatax »

yes, I got it, thx.
thatax
Posts: 25
Joined: Thu Jul 31, 2008 7:33 am

Post by thatax »

another question:
I want to move the camera from a place to another one if push a button.
camera->setPosion(...).this function can not take the camera to the correct place due to the cllision between the camera and the wall.how to solve this.
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

Do you mean effectively teleporting the camera from one position to another which is quite far away?

If so then yes the collision response animator will prevent this from being completed.

So what you have to do is remove the animator, move the camera and then readd the animator.
Image Image Image
thatax
Posts: 25
Joined: Thu Jul 31, 2008 7:33 am

Post by thatax »

JP wrote:Do you mean effectively teleporting the camera from one position to another which is quite far away?
If so then yes the collision response animator will prevent this from being completed.
So what you have to do is remove the animator, move the camera and then readd the animator.
if I code: cameraFPS->removeAnimator(collider);
cameraFPS->setPosition(core::vector3df(630,370,1053));
it works well, but collision occurs when I wrote this:
cameraFPS->removeAnimator(collider);
cameraFPS->setPosition(core::vector3df(630,370,1053));
cameraFPS->addAnimator(collider);
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

After set position you might have to do camera->updateAbsolutePosition()
Image Image Image
rogerborg
Admin
Posts: 3590
Joined: Mon Oct 09, 2006 9:36 am
Location: Scotland - gonnae no slag aff mah Engleesh
Contact:

Post by rogerborg »

Ze updates, ze do nuzzink!

You'll need to trick the animator into updating its LastPosition without actually doing an animation. There's no direct access to it, but by fortunate happenstance, calling animateNode() with a changed node does the trick. So we call it twice, once with a 0 node, then again with the original node. There's no need to remove and re add the animator. Job's a good 'un.

Code: Select all

cameraFPS->setPosition(core::vector3df(630,370,1053)); 
collider->animateNode(0, device->getTimer()->getTime());
collider->animateNode(cameraFPS, device->getTimer()->getTime());
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
thatax
Posts: 25
Joined: Thu Jul 31, 2008 7:33 am

Post by thatax »

it still does not work well, I really don't know why.
rogerborg
Admin
Posts: 3590
Joined: Mon Oct 09, 2006 9:36 am
Location: Scotland - gonnae no slag aff mah Engleesh
Contact:

Post by rogerborg »

It Works For Me, at least with the SVN trunk (I rarely post untested code), so perhaps if you post more of your source, or define in what way it's not working for you, we can puzzle out what's going on.
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
thatax
Posts: 25
Joined: Thu Jul 31, 2008 7:33 am

Post by thatax »

Code: Select all

	if (event.EventType == EET_KEY_INPUT_EVENT &&
		event.KeyInput.Key == KEY_KEY_T &&
		event.KeyInput.PressedDown == true)
	{
      cameraFPS->setPosition(core::vector3df(630,370,1053)); 
      collider->animateNode(0, device->getTimer()->getTime()); 
      collider->animateNode(cameraFPS, device->getTimer()->getTime()); 
   }
it is an FPS game, I want to transform the camera's position when press Key T.but the camera is prevent by the wall every time.
rogerborg
Admin
Posts: 3590
Joined: Mon Oct 09, 2006 9:36 am
Location: Scotland - gonnae no slag aff mah Engleesh
Contact:

Post by rogerborg »

Oops, I'm very sorry.

CSceneNodeAnimatorCollisionResponse::animateNode() has been changed since 1.4. That method will only work with the SVN trunk version.

Hmm, let's see...

Nope, sorry, the only way that I can see it working with 1.4 is to remove the old collision animator and create and attach a brand new one each time you do the teleport.

Alternatively, you could update to using the SVN trunk and use the workaround above. I'd recommend it; you get all the best toys.
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
jontan6
Posts: 278
Joined: Fri Jun 13, 2008 5:29 pm

Post by jontan6 »

is there tutorial somewhere on how to compile from svn trunk? is it easy?

what if i dont move the camera, but i move all objects instead? do you think that will work?
Ion Dune
Posts: 453
Joined: Mon Nov 12, 2007 8:29 pm
Location: California, USA
Contact:

Post by Ion Dune »

You could probably (definitely) find tutorials in either the FAQ section of this forum or in the wiki, but another alternative is to use the Irrlicht Nightly Builds website. Once you download that, you just have to open the project that matches your IDE (under irrlicht\source\irrlicht\), configure the Irr Compile Config file, and hit compile.
Post Reply