A C C O U N T

B A N   T H E   R E W I N D

My name is Stephen Schieberl. I am a Creative Technology Lead at Wieden+Kennedy in Portland, Oregon. I build everything from large format installations to experimental interactive art to database-driven web sites and more.

Friend on Facebook
Ban the Rewind?

Pictured: The VTF sample demonstrates how to shape a sphere using a texture If you've worked with Cinder, you know that you can draw 3D shapes like spheres, cubes, cylinders and more through some convenient functions. What you might not know is that you could do it a lot faster. When you tell Cinder to draw a sphere, it has to do all the math to create it before uploading it to your video card to be drawn. If you want to draw hundreds of spheres, this can start to get pretty slow. However, this is not a problem if you are able to create the model one time as a VboMesh or a TriMesh and re-use it. Building a mesh to create a common shape such as a sphere or cube can quickly turn into a daunting task. Plotting the geometry efficiently where each position also has proper surface normals and texture map coordinates can prove to be quite challenging. Enter Cinder-MeshHelper. CINDER-MESHHELPER ON GITHUB Cinder-MeshHelper takes away the math and mystery of creating basic 2D and 3D shapes as a TriMesh. It also provides shortcuts for creating custom meshes. The class contains static methods for generating shapes made of GL_TRIANGLES which include vertex indices, positions, normals, and texture coordinates. The dimension of all shapes is 1.0. That is, a radius is always 1.0, a height is always 1.0, an edge length is always 1.0, etc. Just create your mesh, scale it, and draw it, like so: ci::Vec2i resolution( 32, 16 ); ci::gl::VboMesh sphere( MeshHelper::createSphere( resolution ) ); gl::pushMatrices(); gl::scale( Vec3f::one() * 10.0f ); gl::draw( sphere ); gl::popMatrices(); Pictured: 262,144 textured cubes with lighting at 60+ fps The block contains four applications. Two are identical, one with TriMesh shapes and one with VboMesh shapes. These demonstrate all supported primitives and one custom mesh. Another demonstrates VBO instancing, a technique which allows you to make a single call to OpenGL with one VBO and draw many instances in GLSL. The last shows off vertex texture fetching (VTF), a technique which uses texture data to modify geometry.