Hold shift to make the FPS camera go faster

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.
dlangdev
Posts: 1324
Joined: Tue Aug 07, 2007 7:28 pm
Location: Beaverton OR
Contact:

Post by dlangdev »

cast the camera object to CCameraFPSSceneNode and call its member function setMoveSpeed().

i have not tried it, but it looks like it's how the code was made out.

see CCameraSceneNode.h for details.
Acki
Posts: 3496
Joined: Tue Jun 29, 2004 12:04 am
Location: Nobody's Place (Venlo NL)
Contact:

Post by Acki »

dlangdev wrote:cast the camera object to CCameraFPSSceneNode and call its member function setMoveSpeed().
well, there is no setMoveSpeed() function for the camera, yet...
maybe you're using my IrrExtension where I added this function to ??? ;)
while(!asleep) sheep++;
IrrExtensions:Image
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
dudMaN
Posts: 111
Joined: Fri Mar 02, 2007 6:37 pm

Post by dudMaN »

Yes, there IS a setmovespeed.

Code: Select all

  282 //! Sets the movement speed
  283 void CCameraFPSSceneNode::setMoveSpeed(const f32 speed)
  284 {
  285 	MoveSpeed = speed;
  286 

Code: Select all

http://irrlicht.svn.sourceforge.net/viewvc/irrlicht/trunk/source/Irrlicht/CCameraFPSSceneNode.cpp?revision=964&view=markup
Please look around before posting untrue information :)

-dudMan
Complete Irrlicht Beginners Tutorial
http://irrlicht.sourceforge.net/phpBB2/ ... hp?t=24898
Acki
Posts: 3496
Joined: Tue Jun 29, 2004 12:04 am
Location: Nobody's Place (Venlo NL)
Contact:

Post by Acki »

yeah, but you can't access it (without modifying the engine)...
or am I wrong again ??? :lol:
if so, then please show me how to access it !!! ;)
and please not with the svn version, but with the official release... ;)
while(!asleep) sheep++;
IrrExtensions:Image
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
dlangdev
Posts: 1324
Joined: Tue Aug 07, 2007 7:28 pm
Location: Beaverton OR
Contact:

Post by dlangdev »

from CSceneManager.cpp

notice the return type is ICameraSceneNode, it doesn't return the handle to the CCameraFPSSceneNode interface, but you can get the interface by simply casting the camera object to CCameraFPSSceneNode and you'll be able to call its members.

Code: Select all

//! Adds a camera scene node which is able to be controled with the mouse and keys
//! like in most first person shooters (FPS):
ICameraSceneNode* CSceneManager::addCameraSceneNodeFPS(ISceneNode* parent,
	f32 rotateSpeed, f32 moveSpeed, s32 id,
	SKeyMap* keyMapArray, s32 keyMapSize, bool noVerticalMovement,f32 jumpSpeed)
{
	if (!parent)
		parent = this;

	ICameraSceneNode* node = new CCameraFPSSceneNode(parent, this, CursorControl,
		id, rotateSpeed, moveSpeed, jumpSpeed, keyMapArray, keyMapSize, noVerticalMovement);
	node->drop();

	setActiveCamera(node);

	return node;
}
Sample code

Code: Select all


// create camera...

scene::ICameraSceneNode* camera = smgr->addCameraSceneNodeFPS();

//cast it.
//you get the idea...

(CCameraFPSSceneNode*)camera->setMoveSpeed(aNumber);

Last edited by dlangdev on Thu Nov 29, 2007 8:57 pm, edited 2 times in total.
ultran00b
Posts: 35
Joined: Tue Oct 30, 2007 3:30 pm

Post by ultran00b »

The third argument of addCameraSceneNodeFPS lets you define the move speed of the camera. But there is NO member, "setMoveSpeed()", at least no public member.
Use the debugger, young Skywalker...
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

There had been such a method, but it was removed again in favor of a better camera control interface. The latter is not yet implemented, though.
dlangdev
Posts: 1324
Joined: Tue Aug 07, 2007 7:28 pm
Location: Beaverton OR
Contact:

Post by dlangdev »

ICameraSceneNode is only one of the many interfaces of CCameraFPSSceneNode.

You can get another interface from the same object.
dlangdev
Posts: 1324
Joined: Tue Aug 07, 2007 7:28 pm
Location: Beaverton OR
Contact:

Post by dlangdev »

thanks for the comment, hybrid.

sounds like a refactoring is in the works.
Acki
Posts: 3496
Joined: Tue Jun 29, 2004 12:04 am
Location: Nobody's Place (Venlo NL)
Contact:

Post by Acki »

dlangdev wrote:Sample code

Code: Select all


// create camera...

scene::ICameraSceneNode* camera = smgr->addCameraSceneNodeFPS();

//cast it.
//you get the idea...

(CCameraFPSSceneNode*)camera->setMoveSpeed(aNumber);

I know exactly what you mean, but this doesn't work, as far as CCameraFPSSceneNode is encapsulated in the engine and you can't cast a ICameraSceneNode to it, just try it and you'll see !!! ;)
and btw assuming this would work, then it has to be like this:

Code: Select all

((CCameraFPSSceneNode*)camera)->setMoveSpeed(aNumber);
otherwise you don't cast the camera, but the return value of setMoveSpeed if it had one... ;)
while(!asleep) sheep++;
IrrExtensions:Image
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
dlangdev
Posts: 1324
Joined: Tue Aug 07, 2007 7:28 pm
Location: Beaverton OR
Contact:

Post by dlangdev »

Thanks acki for responding.

I'm a bit worked-up with this thread because i'll be adding the same feature to the sample program #16 i'm currently adding code.

so, i really appreciate all your inputs as well.

i'll be able to see if casting will work or not later.

thanks again for your patience, it's becoming like a debate in C++. pardon my stubbornness.
Acki
Posts: 3496
Joined: Tue Jun 29, 2004 12:04 am
Location: Nobody's Place (Venlo NL)
Contact:

Post by Acki »

no need for pardons ;)
I'm not all-knowing and we all never finish learning, so from time to time I also could be wrong :lol:
especially because the engine is growing realy fast and sometimes I don't realise that something was changed that didn't work in previous versions... ;)
and always remember I'm just talking about the official versions, so it could also be that some things are already implemented in the svn I don't know about... :oops:
dudMaN wrote: Please look around before posting untrue information :)
returned to sender !!! :twisted:
while(!asleep) sheep++;
IrrExtensions:Image
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
dlangdev
Posts: 1324
Joined: Tue Aug 07, 2007 7:28 pm
Location: Beaverton OR
Contact:

Post by dlangdev »

by the way, it turns out acki was right.

so i had to use the animator object to tweak the translation of the xz plane.

though i still not sure if tweaking the translation is the right way to do it.

Code: Select all

	scene::ISceneNodeAnimatorCollisionResponse* animator = findSceneNodeAnimator_CollisionResponse(camera); 
	if (animator) 
	  //animator->setGravity(core::vector3df(0, -1, 0)); // disable gravity 
		animator->setEllipsoidTranslation(core::vector3df(0, -1, 0)) ;

the rest of the code is found here ...

http://irrlicht.sourceforge.net/phpBB2/ ... tanimators
Acki
Posts: 3496
Joined: Tue Jun 29, 2004 12:04 am
Location: Nobody's Place (Venlo NL)
Contact:

Post by Acki »

dlangdev wrote:by the way, it turns out acki was right.
lol @ dudMaN !!! :lol:
while(!asleep) sheep++;
IrrExtensions:Image
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
Post Reply