Download presentation
Presentation is loading. Please wait.
Published byRoss Sutton Modified over 9 years ago
1
Visualization Recreate the ping pong scene in 3D using ball and racket coordinates
2
Choosing an adequate platform C++ Scientific data visualization Limited animation capabilities Few online examples available C++ Game development Variety of online examples
3
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
4
OpenGL Rendering Pipeline Listing 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.
5
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 Right glVertex3f( 1, -1, -1);// Bottom Right glVertex3f( 1, 1, -1);// Top Right glVertex3f( 1, 1, 1);// Top left glVertex3f( 1, -1, 1);// Bottom left
6
Animating the ball movement Only possible to draw spheres with void 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
7
Displaying the rackets Same strategy as with the ball movement Drawing a cylinder at a specified position Coordinates are in a separate CSV file
8
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)
9
Animation (2) Regulating speed: skipping coordinates List of coordinates fuels: –Rewind/forward –Pause/play –Tracers –Special camera positions
10
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. posUp vectorCenter (ref. point)
11
Camera placement (2) First-person ball tracking using recently displayed coordinates
12
Functionality Continuous rotation Tracers –Use already displayed coordinates and draw a stippled line between each pair
13
Demo Using mouse & keyboard controls to interpret commands
14
Improvements Anti-aliasing Enhancing the coordinates by using a physics engine –Calculating accurate speed –Simulating gravity –Simulating air resistance
15
Conclusion Visualization runs smoothly Success or failure depends on accurate 3D coordinates
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.