Page 2 of 2

Posted: Thu Nov 29, 2007 10:51 am
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.

Posted: Thu Nov 29, 2007 1:17 pm
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 ??? ;)

Posted: Thu Nov 29, 2007 5:30 pm
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

Posted: Thu Nov 29, 2007 6:42 pm
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... ;)

Posted: Thu Nov 29, 2007 8:45 pm
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);


Posted: Thu Nov 29, 2007 8:55 pm
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.

Posted: Thu Nov 29, 2007 8:57 pm
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.

Posted: Thu Nov 29, 2007 9:02 pm
by dlangdev
ICameraSceneNode is only one of the many interfaces of CCameraFPSSceneNode.

You can get another interface from the same object.

Posted: Thu Nov 29, 2007 9:54 pm
by dlangdev
thanks for the comment, hybrid.

sounds like a refactoring is in the works.

Posted: Thu Nov 29, 2007 10:02 pm
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... ;)

Posted: Thu Nov 29, 2007 10:25 pm
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.

Posted: Thu Nov 29, 2007 11:07 pm
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:

Posted: Fri Nov 30, 2007 1:35 am
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

Posted: Fri Nov 30, 2007 2:12 am
by Acki
dlangdev wrote:by the way, it turns out acki was right.
lol @ dudMaN !!! :lol: