Presentation is loading. Please wait.

Presentation is loading. Please wait.

Project 6 Tumbling Cube Fri, Nov 21, 2003 Due Mon, Dec 8, 2003.

Similar presentations


Presentation on theme: "Project 6 Tumbling Cube Fri, Nov 21, 2003 Due Mon, Dec 8, 2003."— Presentation transcript:

1 Project 6 Tumbling Cube Fri, Nov 21, 2003 Due Mon, Dec 8, 2003

2 Tumbling Cube Read the handout.handout Run Tumbling Cube.exe.Tumbling Cube.exe

3 The Motion of the Cube The cube should move in a specified direction at a specified speed. It should also spin on a specified axis at a specified rotation rate.

4 The Motion of the Cube You should create the following global variables. A point to store the cube’s position. A vector to store the direction of motion. A vector to store the axis of rotation. A float to store the spin angle of about the axis of rotation.

5 Animation The animation will be handled in the idle() function. This is a callback function that is called whenever nothing else is happening. The prototype is void idle();

6 Animation The function clock() returns the number of milliseconds since the computer was last turned on. Use clock() to compute the elapsed time since the last call to idle(). Then update the cube’s position and spin angle.

7 Animation New position = old position + direction * elapsed time. New angle = old angle + spin rate * elapsed time.

8 Animation Then determine whether the cube bounced off any of the six faces of the frustum. If it did, then update the position of the cube.

9 The View Frustum The cube will bounce around inside the view frustum.

10 The View Frustum Use gluPerspective() to create the projection matrix for this frustum. You may use any angle, but I think a 90  angle will be easy to work with. This is the angle between the top and bottom faces of the frustum. The angle between the sides is determined by this angle and the aspect ratio.

11 The Top and Bottom Walls of the Frustum Assume the angle is 90 . What are the equations of the top and bottom walls? What is the equation?Top wall z y 10 What is the intercept?

12 The Left and Right Walls of the Frustum To find the side walls, we must take the aspect ratio into account. x z 10 10*(aspect ratio) Right wall What is the equation?

13 Bouncing off the Walls The motion is in discrete jumps, so the cube will probably pass through the wall in one of its “jumps.”

14 Bouncing off the Walls When the center of the cube “passes through” a wall, we will relocate the center to the point where the cube would be if it bounced off the wall.

15 Bouncing off the Walls How do we calculate the new location of the cube? x = a (x 0, y 0 ) (x 1, y 1 )(x 2, y 2 )

16 Bouncing off the Walls We will assume that the walls are parallel to the coordinate planes for the purpose of computing the reflected location, even though the wall is at an angle. Real wall Pretend wall

17 Bouncing off the Walls If we didn’t do that, then the cube might get stuck in a corner.


Download ppt "Project 6 Tumbling Cube Fri, Nov 21, 2003 Due Mon, Dec 8, 2003."

Similar presentations


Ads by Google