95.402 Fall 2001 Assignment #3


Due: Tuesday, October 2, 2001 (1 week) in the assignment box, before midnight


Add vehicles to your game. It's the same as teapots except that they don't rotate. Find some other geometric object to draw in place of a "real" vehicle model; e.g., two spheres - a large one for the body of the vehicle and a small one ahead of the large one to indicate the front of the vehicle. However, a few additional requirements will make the assignment different from the previous one.

1. Allow the player to "take control of a vehicle" as follows. If the enter key is pressed and the player (actually, the camera) is within a specified "radiusOfInfluence" from a vehicle in the current world, then the "vehicle" as currently oriented becomes the camera (this "radiusOfInfluence" in meters could be a parameter you specify in Worldcraft).

Moving around actually moves the vehicle around. Eventually, if the enter key is pressed while driving a vehicle, that causes the camera to "let go of the vehicle" . So if you go just a little further and turn around, you should see the vehicle at the spot you let it go. It will be oriented just like the camera was oriented where you "released control".

2. Do not draw a vehicle that is being driven the same way that you draw other vehicles (it is too close to the camera and besides, you can't see the inside of an object if all the faces are facing out - as they would be for a really close sphere, for example).

In real games, you would draw a different model for the inside of a vehicle when you are driving it to differentiate it from other vehicles you see in front of you.

Find a different way of drawing a vehicle that is being driven so that you can tell the difference between a vehicle that is being driven and one that isn't (draw it far enough ahead of the camera so you can see it).

Hint 1: Have you vehicle object keep a dual transformation; that way it will be easy to get the inverse for use as a camera.

Hint 2: Vehicles have their own draw method. To draw differently depending on the circumstances, they need to know whether or not they are being driven.

Hint 3: You can draw "player controllable objects" in the normal way providing you ensure that the stack contains WC-1 where W is the transformation for the object you wish to draw and C-1 is the inverse of the transformation for the object that is behaving as the camera.