Jump to content
  • Advertisement
Sign in to follow this  
Udovis Devoh

Bézier curve in old school racing game

This topic is 2443 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi!
I'm currently working on an oldschool racing game (top gear, lotus, rad racer etc).
In order to improve its look, I would like to draw bézier curves for the road's side and the white line in the middle.
(see screenshot in attached file).
I would like to know where must I add control points.
The best would be if someone could post a modified version of my screenshot with location of control points.
Thank you!

Share this post


Link to post
Share on other sites
Advertisement
You might want to consider using a Catmull-Rom spline instead - I find them easier to fine-tune because every control point lies on the curve.

Edit:

But if you want to stick with Bezier curves, you'll want to create a piecewise quadratic or cubic Bezier curve with C1 continuity (i.e. the end points of connected curves meet at a common point and share a common tangent). See below for an approximation of the left edge of the road using two cubic Bezier curves.

bezier.jpg

Share this post


Link to post
Share on other sites
There's a cheap yet effective way to draw beziers... if you have access to triangle rasterization and shading (it's unclear to me if you do).
Use bezier triangles (optionally inverted) and put their three vertices on the red spots you marked. The technique is used in Resolution Independent Curve Rendering using Programmable Graphics Hardware.

Another way - which also requires some kind of HW acceleration is Green's method based on distance maps. Improved Alpha-Tested Magni?cation for Vector Textures and Special Effects.

The latter is more flexible IMHO and comes at an extremely reduced effort although it delivers slightly less quality (it's still very good). I only suggest the first for "true" vector renderers.
If there's no access to 3D acceleration, I'm afraid you will have to write everything yourself. Hopefully this is still not so difficult given those two limited tests.

Share this post


Link to post
Share on other sites
Thank you guys. I think (not sure) everything is software rendered because I use a canvas.getContext('2d'). [color=#282828][font=helvetica, arial, verdana, tahoma, sans-serif]

The Catmull-Rom spline seems to be a good solution.

[/font]

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!