Cameras

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
Camel
Posts: 5
Joined: Sun Jul 12, 2009 10:28 am

Cameras

Post by Camel »

Heyy

Is it possible to create a custom camera scene node without modifying the irrlicht engine? I'm guessing I would have to do something similar to tutorial 3.
I want to make a FPS camera, where you can crouch and so you can't change direction mid air.

If it is possible, where do I even start?
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Post by CuteAlien »

You can create a custom camera by deriving a class from ICameraSceneNode. Search a little around the forum, there are probably a few custom cameras.

Another solution is to write an own class which does control a ICameraSceneNode. So you pass a pointer to it and then just do whatever you want the the cameranode using it's interface functions.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Camel
Posts: 5
Joined: Sun Jul 12, 2009 10:28 am

Post by Camel »

Ok, so . . pretty much I could create an event receiver class like the one in tutorial 5, and put a pointer to a ICameraSceneNode in it. Then pretty much copy whats in CSceneNodeAnimatorCameraFPS.cpp, right? 8)
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Post by CuteAlien »

I think cameras already receive events. So you just have to derive from ICameraSceneNode and you can overload OnEvent.
Maybe you have to call setInputReceiverEnabled (true) but I think it is already enabled by default.

But I forgot that movement is now done mostly by animators (was different once) and no longer by cameras themself. So you can also use those and derive from ISceneNodeAnimatorCameraFPS or ISceneNodeAnimator and add your own animator to the camera. Then you can start by copying the stuff in CSceneNodeAnimatorCameraFPS.cpp. Haven't done that myself yet, I've always just used the camerapointer and worked with that, but I suppose it should work.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
DtD
Posts: 264
Joined: Mon Aug 11, 2008 7:05 am
Location: Kansas
Contact:

Post by DtD »

Did you even check the API? (It is very useful you know ;) )
http://irrlicht.sourceforge.net/docu/cl ... 346270bc79
You can create virtually everything through your scene manager. Of course, I am sure you could try the stuff CuteAlien suggested.

~DtD
Camel
Posts: 5
Joined: Sun Jul 12, 2009 10:28 am

Post by Camel »

DtD wrote:Did you even check the API? (It is very useful you know ;) )
http://irrlicht.sourceforge.net/docu/cl ... 346270bc79
You can create virtually everything through your scene manager. Of course, I am sure you could try the stuff CuteAlien suggested.

~DtD
Of course, I spent hours reading the documentation and looking at the source code before I posted. However I haven't been using Irrlicht for very long, and clearly I didn't read that.
Thanks though.
arras
Posts: 1622
Joined: Mon Apr 05, 2004 8:35 am
Location: Slovakia
Contact:

Post by arras »

Don't use inheritance. That is do not derive from ICameraSceneNode. It is just empty interface and you would need to revrite lot of code which was already done in CCameraSceneNode (and you can't inherit from it). I did use composition when creating custom camera but now I think the most clean way is to use ISceneNodeAnimator Class. Just create your animator then attach it to standard camera and use it to control it.
cr33
Posts: 22
Joined: Fri Mar 27, 2009 3:37 pm

Post by cr33 »

i think u must create a class anyway, for whatever camera does

because later how would you do e.g. acceleration, or some other stuff. i mean, i think of camera as of something that provides view, not as something that does anything... every object has its speed, acceleration, mass etc... if u want to add 1 person perspective and render some mesh like player legs, or cockpit then also i think camera should only be where u want to see, and movement should be calculated separately for every object
omar shaaban
Posts: 616
Joined: Wed Nov 01, 2006 6:26 pm
Location: Cairo,Egypt
Contact:

Post by omar shaaban »

exactly as said cr33 u should create a class as u who control the camera not making another custom camera scene node to apply for ur control
it will be complex(not that hard :wink: ) boring :P
and will decrease performance ( :? i dont think so )
instinct
Posts: 87
Joined: Sat May 10, 2008 3:42 pm

Post by instinct »

CuteAlien wrote:So you can also use those and derive from ISceneNodeAnimatorCameraFPS or ISceneNodeAnimator and add your own animator to the camera. Then you can start by copying the stuff in CSceneNodeAnimatorCameraFPS.cpp. Haven't done that myself yet, I've always just used the camerapointer and worked with that, but I suppose it should work.
works 8)

Im not sure if i tried deriving from ICameraSceneNodeFPS or CCameraSceneNodeFPS but one of them is using private which cant be accessed while deriving ;). Perhaps it's an idea to make those members protected? Im not suggesting it, since i dont know what the consequences are, but if those consequences are not fatal i guess making them protected is more programmer friendly :P.
kryton9
Posts: 20
Joined: Sun Feb 22, 2009 7:26 pm

Post by kryton9 »

I am having similar problems too. If I derive from the class, I can't seem to add it using scenemanager.

Can someone write a tutorial showing how to implement a custom camera with a custom animator. Or-- can we just use camera and make a custom animator... whatever is the best way to do it?

I downloaded many custom camera scene nodes from the forums that don't seem to work.

I don't want to alter the source code, but to derive my own classes and use the functionality that exists already and make changes where needed or add new additions.

There are so many posts about cameras on the forums and coming in new it is very confusing... a tutorial addition for something so important would be a great addition.

Three popular camera scene nodes seem to be created many times on the forums but none I have found really working well.
Space or Flight Camera
Full First Person Shooter Camera
Third Person Camera

So any of the above would be a great example for a tutorial, or perhaps a poll could be taken for the most requested type.
Post Reply