Page 1 of 1

Camera Behind Vehicle

Posted: Tue Jan 03, 2012 5:05 pm
by mubashar
How to set camera exactly behind vehicle

In My case Its carNode and its IAnimatedMeshSceneNode ??? and i am using IrrBullet Raycast Vehicle

http://irrlicht.sourceforge.net/forum/v ... =1&t=45529

Re: Camera Behind Vehicle

Posted: Tue Jan 03, 2012 5:07 pm
by randomMesh
The recommended way to do this stuff is to write a custom camera animator. Have a look at the FPS animator and see how it's done.

Re: Camera Behind Vehicle

Posted: Tue Jan 03, 2012 5:36 pm
by mubashar
don't know how to do it can you please elaborate it little more

Re: Camera Behind Vehicle

Posted: Tue Jan 03, 2012 5:49 pm
by Granyte
i don't know about the specific animator but my solution is to

set the came as a child of the node
then set a camera up vector and a camera target vector

and pass them through the node to be folowed matrix

Re: Camera Behind Vehicle

Posted: Tue Jan 03, 2012 6:15 pm
by mubashar
@grantye plz give me example code

Re: Camera Behind Vehicle

Posted: Tue Jan 03, 2012 6:17 pm
by serengeor
mubashar wrote:don't know how to do it can you please elaborate it little more
erm, look at how other camera animators are implemented (in irrlicht source folder), write one yourself that would do the math to maintain it's possition behind the car scene node? AND read the API doc to figure out what does what..
If you have little knowledge of c++ and OOP, that's another question.

Re: Camera Behind Vehicle

Posted: Tue Jan 03, 2012 6:25 pm
by mubashar
@serengeor yeah actually i am thinking there might be some easy way or code available so my time saved .... :( well i can give it try if no alternative solution is there

Re: Camera Behind Vehicle

Posted: Tue Jan 03, 2012 6:34 pm
by Granyte
what i gave you is the easy way the code just need to be called befor a render call

Re: Camera Behind Vehicle

Posted: Tue Jan 03, 2012 8:46 pm
by serengeor
mubashar wrote:@serengeor yeah actually i am thinking there might be some easy way or code available so my time saved .... :( well i can give it try if no alternative solution is there
Erm, I can't really see how hard and time time consuming can this be.. If you know the basics, it's pretty much +- 1hr of coding depending on how complex you want the movement of the camera to be.

Or you can just update the camera in the main loop.

Re: Camera Behind Vehicle

Posted: Thu Jan 05, 2012 9:11 am
by mubashar
@Granyte applied your solution but camera looks very unnatural ...

Re: Camera Behind Vehicle

Posted: Thu Jan 05, 2012 10:03 am
by serengeor
mubashar wrote:@Granyte applied your solution but camera looks very unnatural ...
Then do a controller (animator) that would translate to the final position over some time instead of doing it instantly, if that is what you want ofc.

Re: Camera Behind Vehicle

Posted: Fri Jan 06, 2012 6:27 am
by Granyte
i don't know how you implemented it but on my end it feel like if the camera is ducktaped on the controled object

it's not the most natural camera but it's quick easy and dirty

but if you wan more advanced stuf you will have to learn how to dow it

Re: Camera Behind Vehicle

Posted: Tue Jan 17, 2012 8:25 pm
by mubashar
Successfully implemented much better camera got idea from bullet Vehicle demo its quite nice :)

Re: Camera Behind Vehicle

Posted: Wed Jan 18, 2012 11:02 am
by Mel
When i have to make a camera move smoothly, i interpolate the original position of the camera target and the intended position of the camera just in the middle, and then, i use that point as the new camera target. The advantage is that the camera moves much more smoothly, the drawback is that if the vehicle moves too fast, it may disappear from the screen, but that only happens with very fast motions, and in most cases, it behaves very well.

Re: Camera Behind Vehicle

Posted: Wed Jan 18, 2012 1:02 pm
by hendu
I find using smooth(er)step makes for very nice camera transitions.