new camera

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
emadof85
Posts: 31
Joined: Sun May 25, 2014 6:10 pm

new camera

Post by emadof85 »

I don't want to use fps camera or maya camera in the scene.
I want to define my own camera and add control to it like moving and rotating and zooming .
helpmeplease :roll: :roll: :roll:
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: new camera

Post by CuteAlien »

There are different ways to do that. For example you can write your own animator and add that to a camera.
Or you can do it similar like I did here: https://code.google.com/p/irr-playgroun ... sonCam.cpp
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
Destructavator
Posts: 40
Joined: Sat Feb 06, 2010 9:00 pm
Location: Ohio, USA

Re: new camera

Post by Destructavator »

One way you could do it is create your own camera scene node class, containing appropriate transformation matrices as needed, with get***() and set***() functions that you would want, and then when you want to actually render / draw something "seen" by that camera, send each matrix to the driver: IVideoDriver->setTransform(); right when each visible mesh is actually rendered: IVideoDriver->drawMeshBuffer(); or any of the similar methods, whichever fits the situation best.

If you use a shader-based approach, you could choose not to bother sending any matrix to the driver class and instead send it straight to the shader as a constant whenever you render a scene node using the shader material you create and assign to it.

There's a number of different approaches and methods to it, exactly as CuteAlien said.

Or, you could choose a simple approach of taking a standard, regular ICameraSceneNode camera and use the function to bind the target / rotation. I forget the exact function name, but it allows you to use simple setRotation() commands on the camera just like an animated mesh scene node. The setPosition() function would still work, so there you'd have your "moving and rotating" stuff you're looking for.

As for zooming, there's more than one way of doing that too, everything from a simple change of the camera's FOV ( ICameraSceneNode->setFOV() ) to shader-based stuff.

Hint: Don't forget that you can also attach a camera scene node to a parent node, which can be an invisible, empty scene node. You can also have the camera look *at* a specific node, including the position of another empty scene node. This means you can have a game character (a person, player controlled), represented by an animated mesh scene node, with a child node being an empty node floating in the air behind it (where you can attach a camera), and another node somewhere in front of your player-controlled hero / person / whatever that you focus the camera on. In other words, this allows for an easy 3rd-person camera, one that follows a game character and looks at the area in front of the character.

Again, there's different ways, depending on what you want.
- - - -
"Destructavator" Dave: Developer of OS GPL VST "ScorchCrafter" Audio Plug-ins, contributer to UFO AI, Day Job: Guitar Luthier (Customize musical instruments, repainting w/ custom artwork, graphics, logos, decals, etc.)
Post Reply