Skip to content

Instantly share code, notes, and snippets.

@Kerollmops
Last active March 29, 2016 22:41
Show Gist options
  • Save Kerollmops/1f8f6c9c74427abe5130b87673666aac to your computer and use it in GitHub Desktop.
Save Kerollmops/1f8f6c9c74427abe5130b87673666aac to your computer and use it in GitHub Desktop.
let road_width = 10.0f32;
let main_road = Road::new();
let bezier1 = Bezier::new(control_points1);
let bezier2 = Bezier::new(control_points2);
// compute connection curve from other road stretch
let hermite = HermiteSpline::from_curves(&bezier1, &bezier2);
let stretch1 = StretchRoad::from_curve(bezier1, road_width);
let stretch2 = StretchRoad::from_curve(bezier2, road_width);
let connection = StretchRoad::from_curve(hermite, road_width);
// push stretch of road in the right order
main_road.push_front(stretch1);
main_road.push_front(connection);
main_road.push_front(stretch2);
// when cars doesn't need road stretch anymore
main_road.pop_back(); // it's a VecDeqeu
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment