Advanced C++ Programming Tutorial 2

From Chilipedia
Jump to: navigation, search

In this tutorial we learn how to transform our shit. Move it around, make it bigger (no pills or pumps required), flip it and reverse it. And later on we make a camera system to scroll our shit in the world. You're gonna like it.

Topics

Part 1

  • Polyline drawing
  • Vertices
  • Trivial line clipping
  • Translation
  • Flipping across an axis
  • Screen coordinate transformation
  • Scaling

Part 2

  • Camera scrolling
  • Concatenating (combining) transforms
  • Drawable packet design

Video Timestamp Index

Tutorial 2.1

[Expand]
  • What are transformations? 0:26
  • Storing vertices and drawing polygons/polylines 1:00
  • Clipping (trivial implementation) 4:22
  • Translation: moving your model on the screen 6:13
  • Coordinate systems: screen vs. world (/math model) coordinates 7:09
  • Implementing a persistant Entity class to hold models 13:37
  • Integrating Entity control in Game::UpdateModel() (the game loop) 16:06

Tutorial 2.2

[Expand]
  • Scrolling with a Camera system 0:54
  • Camera zooming (scaling transformation) 6:50
  • Concatenating multiple transformations 9:46
  • Implementation of concatenation using a Drawable class 13:41
  • Recap: how to chain filter operations (Pipeline concept) 22:25
  • Homework assignments 23:53

Links

Homework

  1. Create random starfield in large rectangular region with randomized positions, sizes, and shapes. Stars should not overlap.
  2. Implement scrolling via mouse dragging.
  3. Process vertices in-place (don't use a buffered polyline copy).
  4. Only draw models that appear in the viewport.
  5. Animate the scale (size) and color of stars so that they pulsate.

The Homework solution is here.

See also