Help with batching, gl::translate/rotate, tutorial questions

Sorry, newbie here and excited about cinder!

I’m confused from the 3d tutorial, there are two examples
example 1: 9 static shapes
example 2: stack of rotating panels

In example 1, gl::translate is used before every ->draw() call
In example 2, gl::translate is called only once on setup()


  1. Why isn’t gl::translate used only once at setup, in example 1, since all 9 shapes are in fixed position?
  2. getElapsedFrames() is the frames since app started – just wondering if there is a built in function that returns the elapsed seconds between frames? (Also wouldn’t getElapsedSeconds() make more sense than getElapsedFrames(), since it would animate at the same rate regardless of dipping framerate?)

Thanks all!

  1. gl::translate ( lowercase “t” ) is a function that alters the current model matrix, whereas geom::Translate is a modifier that acts on vertex data.

One thing to notice in this example is how we’re constructing our gl::Batches. Specifically, we’re passing slice >> trans >> color as the geometry portion of the constructor. Another way to read this is that we’re piping the result of a geom::Cube construction into a geom::Translate modifier, and then piping that into a geom::Constant modifier. The geom::Translate instance trans is used to offset each slice vertically.

  1. getElapsedSeconds() returns the seconds since the app started, and there is no built-in way to get a delta time, but you can do something like this.
void App::update ( )
    static double kPrev = app::getElapsedSeconds();
    double now = app::getElapsedSeconds();
    double deltaTimeBetweenFrames = now - kPrev;
    kPrev = now;
1 Like