visualization recreate the ping pong scene in 3d using ball and racket coordinates
DESCRIPTION
OpenGL + GLUT GLUT = OpenGL Utility Toolkit –I/O operations –Opening a window and handling resizes –Executing the actual OpenGL code –Mouse controls and keyboard interaction –Façade functions that combine several basic OpenGL routinesTRANSCRIPT
Visualization
Recreate the ping pong scene in 3D using ball and racket
coordinates
Choosing an adequate platform
• C++• Scientific data
visualization• Limited animation
capabilities• Few online examples
available
• C++• Game development• Variety of online
examples
OpenGL + GLUT
• GLUT = OpenGL Utility Toolkit– I/O operations– Opening a window and handling resizes– Executing the actual OpenGL code– Mouse controls and keyboard interaction– Façade functions that combine several basic
OpenGL routines
OpenGL Rendering PipelineListing of points, lines and basic primitives
Transformations, lighting and clipping non-visible parts from the scene
Conversion into fragments, each fragment square corresponds to a pixel in the frame buffer.
Drawing the table
• Within glBegin(GL_QUADS) block– Specifies that quadrangle points follow below
• Using glVertex3f-function– Calling this function for every angular point
• In combination with glNormal3f– Specifies the direction of the normal
glNormal3f( 1.0f, 0.0f, 0.0f); // Normal Facing RightglVertex3f( 1, -1, -1); // Bottom RightglVertex3f( 1, 1, -1); // Top RightglVertex3f( 1, 1, 1); // Top leftglVertex3f( 1, -1, 1); // Bottom left
Animating the ball movement
• Only possible to draw spheres withvoid glutSolidSphere(GLdouble radius, GLint slices, GLint stacks);
• Specifing the location: multiplying the table matrix with a matrix that moves the object glTranslatef(x, y, z);
• Then draw the ball• Do this for every 3D ballcoordinate
Displaying the rackets
• Same strategy as with the ball movement• Drawing a cylinder at a specified position• Coordinates are in a separate CSV file
Animation (1)
• Key frame animation• Movie is 25 frames per second (40 ms)• Animation has a 10 ms refresh rate• At least 4 times the coordinates as in the
movie• Redrawing the ball using an (interpolated)
xyz-coordinate (generated in WP4)
Animation (2)
• Regulating speed: skipping coordinates• List of coordinates fuels:
– Rewind/forward– Pause/play– Tracers– Special camera positions
Camera placement (1)• Use the Utility Library (GLUT) routine gluLookAt() to
define a line of sight– Encapsulates a series of rotation and translation commands
gluLookAt(4.0, 2.0, 1.0, 2.0, 4.0, -3.0, 2.0, 2.0, -1.0);
• Fully adjustable camera angles:– Rotating the view (around all axis)– Dragging table (up, down, left, right)– Zooming
Cam. pos Up vectorCenter (ref. point)
Camera placement (2)
• First-person ball tracking using recently displayed coordinates
Functionality
• Continuous rotation• Tracers
– Use already displayed coordinates and draw a stippled line between each pair
Demo
• Using mouse & keyboard controls to interpret commands
Improvements
• Anti-aliasing• Enhancing the coordinates by using a
physics engine– Calculating accurate speed– Simulating gravity– Simulating air resistance
Conclusion
• Visualization runs smoothly• Success or failure depends on accurate
3D coordinates