Problem Set 1 for CMSC 427 - Computer Graphics, Assignments of Computer Graphics

A problem set for a computer graphics course, cmsc 427. The assignment includes programming exercises to create a 3d scene with a moving car, add buildings, and implement steering and speed control. The document also includes pencil and paper exercises on 2d and 3d viewing positions and rotations about an axis.

Typology: Assignments

Pre 2010

Uploaded on 07/30/2009

koofers-user-ldm
koofers-user-ldm 🇺🇸

4

(1)

10 documents

1 / 3

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Problem Set 1
CMSC 427 – Computer Graphics
Assigned September 11, 2007
Due September 25, 2007
Programming Exercise: Car 101
You will program a simple vehicle that can move around a 3D scene. Think of it as a car
that is driving on a plane that also contains some buildings. You will add buildings, and
the ability to steer the car and change its speed. You’ll also add a special somersault
feature. We are including an executable showing my version of the finished project.
Your version need not be identical in every detail. For example, you can vary the speed
at which the car moves, how rapidly it steers, or the size and position of the buildings.
However, keep the interface the same, using the keyboard functions we specify, so that
we will be able to easily test the result.
We are giving you skeleton code that will display a rectanguloid on the screen. You will
enhance this code to add more rectanguloids, to change the type of projection, and to
allow yourself to navigate about the scene. Note that included in the code that we give
you is a file vector3.cpp that contains many useful functions for vectors. There are
skeleton functions for 3D rotation, which you might find it useful to write and use. We
are also including code for the class “cube”, which you may use in drawing cubes
(actually, rectanguloids).
1. 10 points Add more buildings. For this part, enrich the scene that you are looking
at by adding at least four more buildings on the ground plane.
2. 20 points Move forward at fixed speed. Now enhance the car so that it can move.
The car should always move forward, in the direction in which it is looking. You
should use glutTimerFunc so that you can control the speed in a machine
independent way.
3. 20 points Use mouse to change direction. Now add a feature allowing you to
steer the car. Pressing on the left mouse button should turn you to the left. The
right mouse button should steer you to the right.
4. 10 points Change speed. Now allow keyboard input that will change the speed of
the car. Pressing “s” should slow the car down, while pressing “f” should make it
go faster.
5. 10 points Somersault. The car also has a special trick. Pressing “m” causes it to
do a somersault. While the car is somersaulting, it continues to move forward,
and cannot be steered to the left or right. During a somersault, the car rotates
about a direction perpendicular to the direction it is going in that is also
perpendicular to the “up” direction.
pf3

Partial preview of the text

Download Problem Set 1 for CMSC 427 - Computer Graphics and more Assignments Computer Graphics in PDF only on Docsity!

Problem Set 1

CMSC 427 – Computer Graphics

Assigned September 11, 2007

Due September 25, 2007

Programming Exercise: Car 101

You will program a simple vehicle that can move around a 3D scene. Think of it as a car that is driving on a plane that also contains some buildings. You will add buildings, and the ability to steer the car and change its speed. You’ll also add a special somersault feature. We are including an executable showing my version of the finished project. Your version need not be identical in every detail. For example, you can vary the speed at which the car moves, how rapidly it steers, or the size and position of the buildings. However, keep the interface the same, using the keyboard functions we specify, so that we will be able to easily test the result.

We are giving you skeleton code that will display a rectanguloid on the screen. You will enhance this code to add more rectanguloids, to change the type of projection, and to allow yourself to navigate about the scene. Note that included in the code that we give you is a file vector3.cpp that contains many useful functions for vectors. There are skeleton functions for 3D rotation, which you might find it useful to write and use. We are also including code for the class “cube”, which you may use in drawing cubes (actually, rectanguloids).

  1. 10 points Add more buildings. For this part, enrich the scene that you are looking at by adding at least four more buildings on the ground plane.
  2. 20 points Move forward at fixed speed. Now enhance the car so that it can move. The car should always move forward, in the direction in which it is looking. You should use glutTimerFunc so that you can control the speed in a machine independent way.
  3. 20 points Use mouse to change direction. Now add a feature allowing you to steer the car. Pressing on the left mouse button should turn you to the left. The right mouse button should steer you to the right.
  4. 10 points Change speed. Now allow keyboard input that will change the speed of the car. Pressing “s” should slow the car down, while pressing “f” should make it go faster.
  5. 10 points Somersault. The car also has a special trick. Pressing “m” causes it to do a somersault. While the car is somersaulting, it continues to move forward, and cannot be steered to the left or right. During a somersault, the car rotates about a direction perpendicular to the direction it is going in that is also perpendicular to the “up” direction.
  1. Challenge Problem (up to 20 points): For extra credit, you can add additional features. You should avoid the topics of future problem sets (mapping textures onto the cubes, calculating collisions so that you don’t run into the cubes, and getting objects other than the car to move). Some possible ideas: On the side or in another window, show the scene from overhead; add a curved bridge and have the car’s position follow the bridge, so that as you go over it you are pointing up and then down (ie, you are not always pointing parallel to the ground plane as you drive); or add a roller coaster that the car can drive onto.

Pencil and Paper exercises: For all these problems, you might compute a matrix by taking the product of several matrices. If you do that, it is not necessary to multiply these out. It is fine to express your answer as the product of matrices.

  1. 2D Viewing Position - 10 points. As we move and change our viewing direction, we want to consider the world using a coordinate system that moves with us. In this problem, we consider a 2D world. We will describe locations using the original, world coordinate system, but we will also define a local coordinate system, in which the viewer’s position is the origin, and the direction the viewer is looking in is the x axis. a. Suppose we are positioned at (6,3), in world coordinates. We have not rotated at all, so our viewing direction is (1,0), the original x axis. Consider a point, p , with world coordinates (15,12). What are p ’s coordinates in our local coordinate system? b. Give a matrix that will transform any point from its world coordinates to the local coordinate system in (a). c. Now suppose we move to (8,2), and are looking in the direction (0,1). What are the coordinates of p in the new local coordinate system? d. Give a matrix that will transform any point from its world coordinates to the local coordinate system in (c). e. Suppose we are located at (4,2), and a point with world coordinates (8,5) has coordinates (0,5) in the local coordinate system. What are the world coordinates of the point that has local coordinates (5,5)?
  2. 3D Viewing Position – 10 points. Now we consider a 3D world. Assume that we again use our location as the origin of a local coordinate system, and that now our viewing direction is used as the z axis, and the “up” direction defines the y axis. a. Suppose we are positioned at (2, 4, 3). We have not rotated at all, so our viewing direction is the original z axis, and our up direction is the original y axis. Consider a point, p , with world coordinates (16, 6, 9). What are p ’s coordinates in our local coordinate system? b. Give a matrix that will transform any point from its world coordinates to the local coordinate system in (a).