Skip to main content
GameDev.net gamedev.net
🔒 Locked

Bézier curve in old school racing game

Started by Udovis Devoh Mar 12, 2012 at 3:32 PM 2 replies 2.4k views
Original Post
Udovis Devoh
Udovis Devoh
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!
[quote]Firemen get paid even if there's no fire, and that's a good thing -me[/quote]
ink
ink
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
Krohm
Krohm
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.
Previously "Krohm"
Udovis Devoh
Udovis Devoh
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]

[quote]Firemen get paid even if there's no fire, and that's a good thing -me[/quote]

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.