Project 6 - PowerPoint PPT Presentation

About This Presentation
Title:

Project 6

Description:

Use gluPerspective() to create the projection matrix for this frustum. ... This is the angle between the top and bottom faces of the frustum. ... – PowerPoint PPT presentation

Number of Views:19
Avg rating:3.0/5.0
Slides: 18
Provided by: peopl93
Learn more at: https://people.hsc.edu
Category:
Tags: frustum | project

less

Transcript and Presenter's Notes

Title: Project 6


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

2
Tumbling Cube
  • Read the handout.
  • Run 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 cubes 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 cubes 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?

12
The Left and Right Walls of the Frustum
  • To find the side walls, we must take the aspect
    ratio into account.

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?

(x1, y1)
(x2, y2)
(x0, y0)
x a
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.

17
Bouncing off the Walls
  • If we didnt do that, then the cube might get
    stuck in a corner.
Write a Comment
User Comments (0)
About PowerShow.com