FPS Camera Position Offset

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
gabs
Posts: 2
Joined: Wed Aug 17, 2011 11:53 am

FPS Camera Position Offset

Post by gabs »

So well, my first post :D

my problem is that when creating an fps-cam, i need to modify the Y-position value that the cam doesnt "surf" on the surface you're normally walking on (the gravity pulls it down till the cams position is nearly the Y-Position of the ground -> you think your ingame character is not that tall at all :D). How can I add an Y-Offset so that there's a small space between the ground and the cam? (maybe without writing a new camera class :))

greets
gabs
Ravi08
Posts: 249
Joined: Thu Jul 17, 2008 12:25 pm

Re: FPS Camera Position Offset

Post by Ravi08 »

Hi, you could disable the gravity for the camera but honestly need more info, ie how have you setup the camera currently and if you using Irrlicht collsion animators or a physics engine.
"Hey Baby Wobbling Wobbling"
-Russell Peters
RdR
Competition winner
Posts: 273
Joined: Tue Mar 29, 2011 2:58 pm
Contact:

Re: FPS Camera Position Offset

Post by RdR »

If you use Irrlicht for the collision of the camera (which you can) ( mgr->createCollisionResponseAnimator() )
You can set ellipsoidRadius.

http://irrlicht.sourceforge.net/docu/cl ... 6a78f002be

Simple example:

Code: Select all

 
// Create a FPS camera
irr::scene::ICameraSceneNode* camera = smgr->addCameraSceneNodeFPS();
 
// Set some values
irr::core::vector3df ellipsoidRadius = irr::core::vector3df(1, 1, 1);
irr::core::vector3df gravityPerSecond = irr::core::vector3df(0, -10, 0);
irr::core::vector3df ellipsoidTranslation = irr::core::vector3df(0, 0, 0);
 
// Your world node or your terrain mesh
irr::scene::IMeshSceneNode* terrainNode;
 
//Make Triangle Selector from Mesh
irr::scene::ITriangleSelector* sele = smgr->createTriangleSelector(terrainNode->getMesh(), terrainNode);
irr::scene::ISceneNodeAnimator* anim = smgr->createCollisionResponseAnimator(sele, camera, ellipsoidRadius, gravityPerSecond, ellipsoidTranslation);
 
//Add Animator to Camera
camera->addAnimator(anim);
 
//Clean
anim->drop();
sele->drop();
 
 
Experiment a bit with the ellipsoidRadius values whats best for you.
gabs
Posts: 2
Joined: Wed Aug 17, 2011 11:53 am

Re: FPS Camera Position Offset

Post by gabs »

Thanks, that's exactly what I needed :D
Post Reply