roma star

roma star

  • NA
  • 2
  • 6.1k

virtual train set , 2D in openGL

Dec 23 2010 6:03 PM

create a virtual train set, complete with a model train, tracks, hill and tunnel. The train will be animated such that it traverses the tracks,
 

Part 1: Creating and animating the train set.

The best method for building the objects is by placing all the drawing code for each object in a separate function. Each object is defined using a coordinate system that makes the model simple. When placing the objects in the world, you can translate them to the appropriate location. Add a menu item called "Toggle Animation". If the train is not moving, and this menu item is selected, the train should start going around the track. If the train is moving and this item is selected, the train should stop. We will provide the code to animate your model on the web site. The camera should be placed such that the entire scene is visible and you can see the train going around the track (except when it's through the tunnel.

 

1. Drawing the track.

The track is defined by a closed bezier curve composed of multiple joined segments

(atleast 4). You are free to make the track any shape you want given one constraint:

At the location where you place the hill, it has to hug the hill and elevate off the ground plane. Hint: The bezier curve defines the track shape, but the actual two tracks are offset on each side of this curve.

 

2. Building the hill and tunnel

The tunnel is a simple bezier surface that is placed such that the track goes under it.

Make sure the tunnel bottom is on the ground plane. The hill needs to coincide with the elevated part of the track. It should also be flat along the path of the track. Use multiple bezier surfaces to build the hill model. You may have multiple Bezier surfaces which define the each side of the hill with another surface joining them that is flat along the track.

 

3. Making and moving the train model

The third step is building the model of the train. The train is composed of a 3-d box next to a cylinder on one side. The smoke stack is another cylinder protruding from the body cylinder. There are 4 circular wheels on the sides of the train. The train should be constrained to be high enough off the tracks such that the bottom of the wheels touch the track. As the train is moved along the track, it is translated and rotated. On level ground the train will need to be rotated around the y-axis. To climb the hill, it will also need to be rotated around either the x-axis or the z-axis.

Hint: Draw the box, cylinder, smoke stack and wheels with respect to one object coordinate system. When the train needs to be moved, the coordinate system is simply translated, and/or rotated as described in class. Make sure to place the origin of this object coordinates in a location that is convenient to rotate around.

 

4. Lights and Materials

Initially, you should build the object models using simple color attributes (glColor3f).

Once all the above functionality is in place, introduce lights and material properties. The different surfaces in the train set (hill, tunnel, and train) have different material properties. The hill is a diffuse green surface, the train should look metallic with a non-zero shininess component, and the tunnel should look like something man-made (concrete or wood, etc.). Introduce a light that illuminates the entire scene, the coloring is of your choosing.

Hint: You'll have to define you material properties and lights such that they work well together. For example, if you define a surface to have a particular specular color (say blue), make sure the light illuminating the scene actually has a non-zero blue component otherwise you won't see the specular highlight.
 


Answers (1)