• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
hossainiir

[Solved]Smooth Camera

15 posts in this topic

Hi and happy new year,

 

I want to create a smooth camera for my application like Kodu's camera, any one has any information or idea how can I do that???

 

indeed my camera works fine but isn't smooth.

Thanks.

0

Share this post


Link to post
Share on other sites

I don't know how Kodu's camera works, but my best bet would be to use a lerp with some damping/springiness applied to it.

 

You are likely to find plenty of examples if you search for "Smooth camera movement using X" where X stands for the language/engine/framework/something you are using.

0

Share this post


Link to post
Share on other sites
Smooth hm, sounds like you may want to use slerping for rotation, and lerping for movement. I've never looked at Kudo's camera, but thats what I would do if I wanted to smooth anything.
0

Share this post


Link to post
Share on other sites


but my best bet would be to use a lerp with some damping/springiness applied to it.

Thanks Rld_ I tried to use Lerp but I couldn't get acceptable smoothness.

0

Share this post


Link to post
Share on other sites

I don't know about Kodu's camera system. However, linear interpolation gives smoothness between key values, but it does not do so when key values are crossed. You need to use another interpolation scheme. Which exactly depends on which kind and degree of smoothness you want. There are 2 (not mutual exclusive) types: Geometric continuity Gn and parametric continuity Cn

 

G0 means that the the segments on both sides of a key just join; G1 means that they join and their tangents are equal in direction; if both tangents are also equal in magnitude then they are C1 continuous; if the direction and magnitude are equal in the n-th derivative then they are Cn continuous.

 

So why all this? Lerp gives you G0 / C0 continuity. But you don't want the direction change, so you want at least G1 continuity. Is this sufficient? Probably not, because if you don't have C1 continuity, the position of the camera is smooth but its speed is not. Further, if you don't have C2 continuity the acceleration of the camera will not be smooth when crossing key values.

 

That said, there are some parametric cubic curves / splines that may do what you want. Hermite and Bezier splines both have C0 / G0 continuity, so they are smooth inside their span but jump as Lerp does when going to the next span. Catmull-Rom and Kochanek-Bartels splines both have  C1 / G1 continuity. And both uniform and non-uniform B-splines have C2 / G2 continuity.

2

Share this post


Link to post
Share on other sites


Thanks haegarr ,very nice but it is very theortical .

Well, I don't know how you are currently doing things, so a concrete answer requires more details...

 

What I meant so far is that if you do interpolation on the fly, i.e. you have not continuous animation paths at hand but just supporting points, then the smoothness depends on the interpolation function you use. There are many interpolation functions out there. So far you seem to use a linear polynomial. That has problems at the supporting points because although the position is continuous when crossing the point, the orientation (and other parameters) has not. Using another interpolation function like the said splines (which are essentially cubic polynomials) does suiting the problem better, depending on the type of spline.

 

The above suggestion is based on the fact in a previous post linear interpolation was mentioned and you have tried it with no satisfactorily success. If your problem is related to something else, then please tell us.

0

Share this post


Link to post
Share on other sites

Let me give you more detail, I have a strategic camera that look from a distance above of a terrain, by holding mouse button and moving the mouse camera can move toward x and z, because of discontinuity in reading mouse position the camera movement will be discontinuity.

0

Share this post


Link to post
Share on other sites

Has the camera approximately pass through all the intermediate support points drawn by the mouse sampling? E.g. if you "draw" a right angles gesture with the mouse, should the camera move more-or-less right angled, too, or should it move in a wide arc, or should it move from its own current position immediately to the position marked by the mouse (i.e. ignoring intermediate support points because they are obsoleted), ever with a smooth motion in mind, of course?

0

Share this post


Link to post
Share on other sites


E.g. if you "draw" a right angles gesture with the mouse, should the camera move more-or-less right angled, too, or should it move in a wide arc, or should it move from its own current position immediately to the position marked by the mouse (i.e. ignoring intermediate support points because they are obsoleted), ever with a smooth motion in mind, of course?

 

It should move from current position to next mouse position with more right angle.

 


I use Catmull-Rom interpolation for my smooth camera class:
http://mtnphil.wordpress.com/2012/09/13/smooth-camera-movement-for-replay/

 

Thanks phil_t I will check it.

0

Share this post


Link to post
Share on other sites
There's this article on interpolation methods:
http://sol.gfxile.net/interpolation/
 

Let me give you more detail, I have a strategic camera that look from a distance above of a terrain, by holding mouse button and moving the mouse camera can move toward x and z, because of discontinuity in reading mouse position the camera movement will be discontinuity.

A simple way to handle this is to have the camera be translated with the following:  
 
float p = 0.1
float threshold = 0.001

vector3 smoothOffset = ( target.position - camera.position ) * p
smoothOffset = ( ( smoothOffset.length() > threshold ) ? smoothOffset : target.position )

camera.move( smoothOffset )

The bigger the difference between 'targetPosition' and 'currentPosition,' the faster the camera will move. The smaller the difference, the slower it will move. This produces a fast-in, ease-out behaviour, which is quite common.
The 'p' value controls how fast it arrives at the 'targetPosition.' Note that with any value below '1.0' the camera will never exactly reach the "limit" target position, so you can implement a snapping to the target position so that it does. Edited by Kryzon
1

Share this post


Link to post
Share on other sites

Well, three kinds of sources that may cause discontinuities come to my mind. Let's assume a mouse movement in a slight arc.

 

1.) Crossing a support point requires the movement immediately before and after the point to be identical. That means continuity and is already mentioned in the posts above.

 

2.) Due to "jitter" in using the mouse, the sampled points may lie slightly left or right of the wanted arc. I don't assume real outliers there, so outlier rejection is probably not necessary. *If* such aberrations are noticeable, some kind of curve fitting has to be done: I.e. you don't require the support points to be touched but approximated only.

 

3.) Due to temporarily irregular sampling w.r.t. the mouse movement speed, the path segments from one support point to the next are irregular. Moving on an interpolated path with a fixed time per segment means a different speed per segment. This can be overcome with a re-parametrization for the movement, i.e. the length of the segments is measured and the position is then calculated considering a given speed.

Edited by haegarr
1

Share this post


Link to post
Share on other sites

Thanks haegarr for reply,

 


I wrote the camera code in Kodu so I can tell you exactly what it's doing.

Really !?

I love this camera,it's very smooth and nice, now i'm a little busy i'll check your method and tell you the response .

Also i have some more question about this camera that i'll ask them.

 

Thanks.

0

Share this post


Link to post
Share on other sites

Thanks a lot Scoy.

It worked very fine now I have a smooth camera!!!

And also I have no question to ask every thing was clear.

Thank you again.

biggrin.png

Edited by hossainiir
0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0