You are on page 1of 29

Providing all possible views and Interaction for the viewer to change the bouncing speed of the (sphere)ball.

OpenGL was developed by Silicon Graphics Inc (SGI) on 1992 and is popular in the gaming industry where it competes with the Direct3D in the Microsoft Windows platform. OpenGL is broadly used in CAD (Computer Aided Design), virtual reality, scientific visualization, information visualization, flight simulation and video games development. OpenGL is a standard specification that defines an API that is multi-language and multi-platform and that enables the codification of applications that output computerized graphics in 2D and 3D. The interface consists in more than 250 different functions, which can be used to draw complex tridimensional scenes with simple primitives. It consist of many functions that help to create an real world object and an particular existence for an object can be given.

In this project we are showing the necessary steps and routines to the proper codification and simulation of a bouncing sphere in 3D, which is the most used in the animation field. With a simulation (virtual) model, we can have a closer vision of the object of study in contrast with reality, what make us capable of foreseeing how a determined object will look like and how it will behave after its proper construction in the physical world This program contains different types of viewing effects which the user can specify easily specify by using keyboard and mouse interfaces There is an immense amount of user interface provided both through the mouse and keyboard interface which helps the user to select the speed of the bouncing sphere , view angle along with the idle position of the object and other activities.

In this project we are showing the necessary steps and routines to the proper codification and simulation of a 3D Bouncing Sphere. A 3-Dimensional ball(sphere) bounces on a rectangular plane with an adjacent semi circle plane. There is user interface provided both through the keyboard and mouse

The ball keeps bouncing and the camera spins around it continuosly. Human intervention. A pop up menu is provided by a right click of mouse that consists of sub menus for performing various actions.

Then the selected option will generate an event.


This will place the device measure with its identifier is placed in an event queue.

After that,a particular service routine gives service to that particular event. Uses glut to manage windows, callbacks, and online menu. Uses glPolygonfill( ) to maintain colors in wireframe and solid mode. Various key strokes available to control independently the mech's many joints.and to view mech and environment from different angles, to alter positioning of the single light source.

Our objective is to create a Bouncing 3D sphere the ball will be bouncing and the camera(Users view) should slowly rotate about the center of the scene .The program should respond to keyboard events including arrow keys along with the mouse interface in a textured background. So that it can adjust to the environment very easily.The model will be created through OpenGL programming.

Initially the user is given the privilege of giving interaction with the input devices. The user can select any option that listed in menu list. Then the selected option will generate an event. This project is implemented using C++ and OpenGL built in functions. Initially the bouncing ball appears on the screen.

A menu is created when the user right clicks on the mouse. The menu object shape mode contains nine submenus toggle camera spin ,toggle ball bounce ,screen mode ,ball size ,bouncing speed, view mode ,camera spin speed ,reset ,quit. When we click on toggle camera spin or toggle ball bounce the camera stops spinning or the ball stops bouncing.

The size of the ball can be set as small.big or medium by clicking the ball size on pop up menu.

The screen mode can be either set to full or window size ,through screen mode option.
The bouncing speed of the bal or the camera spin speed can be varied by selecting the respective options in the menu. The objects can be either viewed in polygonal form or mesh form according to the choice of the user by specifying it through the respective menu option.

The role of the user in our project can be specified as follows

The bouncing of the ball and the spin of the camea can be stopped.
The size of the ball can be varied.

The ball can be viewed in polygonal or mesh form.


The ball can be viewed in a full screen ode or window mode.

By using the keys specified in the keyboard the movement of the ball can be controlled. A description of various keys used in our project is as follows: ADWSM,NK,IO,TL,Pmoves the ball to left of the screen. moves the ball to right of the screen. moves the ball backwards ,away from screen. moves the ball forward , towards the screen. increases and decreases the length of ball bounce. increases and decreases the ball size. enables and disables the culling effect . shows the ball in line or poygonal form.

Both keyboard and mouse interface is provided. Allows the user to move the camera suitably to experiment with the perspective viewing. Movement of the ball in all possible directions. Variation can be done in shape and size of the ball. The size of the ball shrinks when it comes in contact with other object. This can be used in designing various games.

The above project can be analyzed as follows:

This project is implemented using C and OpenGL built in functions. In the beginning the sphere will be bouncing and the camera will be spinning. When the user right clicks on the mouse menus will appear. The main pop-up contains nine menus toggle camera spin, toggle ball bounce, screen mode, ball size, bouncing speed, view mode, camera speed, reset, Quit. The menu screen mode contains two submenus - Full Screen mode and window Screen mode. The menu ball size contains three sub menus - small, medium, big. The menu bouncing speed contains three sub menus - slow, medium, fast. The menu view mode contains two sub menus - polygon mode, wired mode. The menu camera speed contains three sub menus slow, medium, fast. The menu contains reset option and quit. The quit menu, quits the window and come back to the main program.

3D Bouncing Sphere

Varying the speed of the ball bouncing.

Bouncing ball viewed in wired form.

Figure showing various size of the ball.

Figure to show the top-view .

Some of the important function definitions used in our code are: void Display(void) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glPushMatrix(); MakeCamera(FALSE,0,0); MakeGeometry(); glPopMatrix(); glutSwapBuffers(); }

void MakeCamera(int pickmode,int x,int y) { static double theta = 0; glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(70.0,1.0, 0.10,1000.0); /* near and far */ glMatrixMode(GL_MODELVIEW); glLoadIdentity(); gluLookAt(5*cos(theta*PI/180)*sin(updownrotate*PI/180), 5*cos(updownrotate*PI/180), 5*sin(theta*PI/180)*sin(updownrotate*PI/180),0.0,0.0,0.0, 0.0,1.0,0.0); if (spincamera) theta += (cameradirection * 0.3); }

void HandleMainMenu(int whichone) { switch (whichone) { case 1: spincamera = !spincamera; break; case 2: ballbounce = !ballbounce; break; case 3:glutFullScreen();break; case 4:glutReshapeWindow(400,400);break; case 100: exit(0); break; } }

void HandleSpeedMenu(int whichone) { switch (whichone) { case 1: ballspeed = 0.5; break; case 2: ballspeed = 2; break; case 3: ballspeed = 10; break; } }

void HandleCamaraMenu(int whichone) { switch (whichone) { case 1:cameradirection = 1; break; case 2: cameradirection = 2; break; case 3: cameradirection = 6; break; } }

void HandleClarityMenu(int ccc) { switch (ccc) { case 1: drawquality = DRAFT; break; case 2: drawquality = MEDIUM; break; case 3: drawquality = BEST; break; } }

void HandleVisibility(int visible) { if (visible == GLUT_VISIBLE) glutIdleFunc(HandleIdle); else glutIdleFunc(NULL); }

void DrawTextXY(double x,double y,double z,double scale,char *s) { int i; glPushMatrix(); glColor3f(1.0,0.0,1.0); glTranslatef(x,y,z); glScalef(scale,scale,scale); for (i=0;i< strlen(s);i++) glutStrokeCharacter(GLUT_STROKE_ROMAN,s[i]); glPopMatrix(); }

An attempt has been made to develop an OpenGL graphics package which meets all the necessary requirements that were set out. It is user friendly and provides an easy interaction for the user. The user can very easily use this tool to draw or manipulate a drawing. The interfaces are mouse driven and the user can select a function by clicking on an option representing that function The sphere can be moved in all directions and shrinks whenever it touches other objects. There is an immense amount of user interface provided both through the keyboard and mouse

FUTURE ENHANCEMENT
This project has been designed using OpenGL. The project can be designed using better languages and better graphical interfaces making use of inputs from light pens. New options like shear effect, shadows, lightning etc can be implemented. Higher languages like JAVA can be used to provide a new look to the project. In future we can enhance this project by including the various other interactive options to the mouse and the keyboard (can also use joysticks) like increasing the number of balls (bouncing balls).We can develop this project as a game also by providing control over the movement of the ball and making the ball to reach the specified target in the environment.

You might also like