Difference between revisions of "Project3F20"

From Immersive Visualization Lab Wiki
Jump to: navigation, search
(Environment Mapping (Points))
(Project 3: Amusement Park Ride)
Line 6: Line 6:
 
In this project you will need to implement a scene graph to render an amusement park ride which consists of a number of objects that are part of a hierarchy.
 
In this project you will need to implement a scene graph to render an amusement park ride which consists of a number of objects that are part of a hierarchy.
  
The user of your program should be able to control a variety of options within your simulation using the keyboard. You may choose which keys control which functions, but make sure they are clearly documented in a text file named <tt>README.txt</tt> which you add to the main directory of your code.
+
This project implements the following skills from the lectures:
  
Allow the user the following controls:
+
* texturing
 +
* sky box
 +
* environment mapping
 +
* scene graph
 +
 
 +
The user of your program should be able to control a variety of options within your simulation using the keyboard. You may choose which keys control which functions, but make sure they are clearly documented in a text file named <tt>README.txt</tt> which you add to the main directory of your code. The following interactive controls should be available to the user:
  
 
* start/stop the animation
 
* start/stop the animation
Line 15: Line 20:
 
The total score for this project is 100 points. Additionally, you can obtain up to 10 points of extra credit.
 
The total score for this project is 100 points. Additionally, you can obtain up to 10 points of extra credit.
  
Start with your code from project 2 and remove the rendering of the 3D models. In this project you are going to render all new objects, using your own implementation of a scene graph.
+
We recommend starting with your code from project 2 and removing the rendering of the 3D models. In this project you are going to render all new objects, using your own implementation of a scene graph.
  
 
==Sky Box (Points)==
 
==Sky Box (Points)==

Revision as of 16:45, 7 November 2020

Contents

UNDER CONSTRUCTION - DO NOT START YET

Project 3: Amusement Park Ride

In this project you will need to implement a scene graph to render an amusement park ride which consists of a number of objects that are part of a hierarchy.

This project implements the following skills from the lectures:

  • texturing
  • sky box
  • environment mapping
  • scene graph

The user of your program should be able to control a variety of options within your simulation using the keyboard. You may choose which keys control which functions, but make sure they are clearly documented in a text file named README.txt which you add to the main directory of your code. The following interactive controls should be available to the user:

  • start/stop the animation
  • move around within the simulation (by moving the camera), i.e., move left/right/up/down, turn left/right

The total score for this project is 100 points. Additionally, you can obtain up to 10 points of extra credit.

We recommend starting with your code from project 2 and removing the rendering of the 3D models. In this project you are going to render all new objects, using your own implementation of a scene graph.

Sky Box (Points)

Create a sky box for your scene. A sky box is a large, square box which is shown around your entire scene, to give it a nice background. The camera is located inside of this box. The inside walls of the box usually consist of pictures of a sky and a horizon, as well as the terrain below. Sky boxes are normally cubic, which means that they consist of six square textures for the six sides of a cube. Here is a great tutorial for sky boxes and how to implement them in modern OpenGL.

Here is is a nice collection of textures for sky boxes, and here is an even bigger one. Make sure the width and height of your sky box textures are powers of two, such as 512x512 or 1024x1024. You are allowed to create your own sky box if you want.

Choose a sky box texture. Then create a cubic sky box and make it very large by giving it coordinates from -500 to +500. Check to see if the textures align correctly at the edges - if not you may need to rotate some of the textures. There should not be any visible seams.

Make sure single-sided rendering (backface culling) is enabled. If your sky box is defined with the triangles' normals facing outward (like the example in the discussion slides), use the following code lines to ensure that the user will never see the outside of the box:

glEnable(GL_CULL_FACE); 
glCullFace(GL_FRONT); 

If your normals point inward, you need to use GL_BACK instead of GL_FRONT in the above code.

Use the following settings for your texture after your first glBindTexture(GL_TEXTURE_CUBE_MAP, id) for correct lighting and filtering settings:


  // Make sure no bytes are padded:
  glPixelStorei(GL_UNPACK_ALIGNMENT, 1);

  // Use bilinear interpolation:
  glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
  glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_LINEAR);

  // Use clamp to edge to hide skybox edges:
  glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
  glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);

Grading:

  • -5 if sky box works but is not seamless
  • -3 if backface culling is not enabled, or it is enabled but the wrong faces are culled

Environment Mapping (Points)

Create code to tessellate a disco ball style sphere (ie, create vertices and normals for a sphere with a relatively low number of rectangular faces, ie, quads). Its surface should look like polished metal, so you need to use environment mapping on it. The tessellation level (which determines the number of quads used in the model) needs to be easily adjustable in software with a single const variable.

Feel free to use code from the internet to generate the sphere, such as this example.

The Cube map tutorial explains how environment mapping is done with a sky box as the environment. Feel free to follow it and use the code from the site to make it work in your code. The goal is to have the sky box reflect on the sphere, to give the impression of the sphere's surface being polished metal (i.e., act like a perfect mirror).

The image below shows an example of a sphere with environment mapping in a sky box:

DiscoballF20.jpg

Grading:

  • -10 if reflection looks somewhat like the skybox but is off by a lot
  • -5 if reflection is upside down but code looks good

Scene Graph Engine (Points)

To create a ride with multiple moving body parts, we need to first implement a simple scene graph structure for our rendering engine. This scene graph should consist of at least three nodes: Node (5 points), Transform (10 points) and Geometry (10 points). You are free to add more scene graph node types as you see fit.

  • Class Node should be abstract and serve as the common base class. It should implement the following class methods:
    • an abstract draw method: virtual void draw(Matrix4 C)=0
    • an abstract virtual void update()=0 method to separate bounding sphere updates from rendering
  • Transform should be derived from Node and have the following features:
    • store a 4x4 transformation matrix M
    • store a list of pointers to child nodes (std::list<Node*>)
    • provide a class methods to add a child node (addChild()) to the list
    • its draw method needs to traverse the list of children and call each child node's draw function
    • when draw(C) is called, multiply matrix M with matrix C.
  • Geometry should be derived from Node and have the following features:
    • set the modelview matrix to the current C matrix
    • an initialization method to load a 3D model (OBJ file) whose filename is passed to it (init(string filename). Your OBJ loader from project 2 should work.
    • have a class method which draws the 3D model associated with this node.

Ride Design (Points)

Now that we have the scene graph classes, it is time to put them to work. Build your own amusement park ride using the addChild methods.

Your design needs to include the following features:

  • You need to have a ground plane for the ride.
  • The ride must be anchored to the ground (can't be floating in space).
  • Your discoball sphere must be part of the design. It can occur once or multiple times.
  • Your hierarchy needs to be at least three levels deep. For instance a ferris wheel which spins around its center with cars that rotate so they are always aligned with gravity, with the cars rotating about their vertical axis (see first picture below).
  • Drawing the same object multiple times in different positions, orientations, and/or with different scaling factors.
  • Moving objects over time, including rotations not centered at the origin, linear motion (changing direction at the end points) and compound motions.
  • Use normal based lighting for the surfaces of all your ride geometries. This means that you need to have normals for all your 3D objects.

High resolution objects are not required for this simulation. Adequate results can be achieved with a simple cube, cone, cylinder, and possibly sphere if they are scaled appropriately.

Start with code that uses your trackball code, and modify it so that trackball rotations control the camera's direction vector instead. (If you don't have trackball rotation code, keyboard controls will suffice, but the camera still needs to be movable and pivot about its location when rotated.) (5 points)

Here a few examples of valid rides:

Ride3F20.jpg FerrisWheel.png RideF20.jpg Ride2F20.jpg Carousel.png

Once you've created your scene graph, you need to get your rendering engine ready to recursively traverse the scene graph for rendering by creating a root node of type Transform and calling its draw() function with the identity matrix as its parameter.

Animated Ride (15 Points)

Animate your amusement park ride to make it look like it would when it is running, by changing the matrices in the Transform nodes.


Extra Credit (Up to 10 Points)

  1. Create a custom object with a 3D modeling tool (e.g., Blender), or find a free model on the internet which you add to your amusement park scene. It needs to be textured.
  2. Dynanmic environment mapping: have sphere reflect not just the sky box, but also your ride.
  3. Create a camera node and attach it to one of the leaf nodes of your scene graph, for instance showing a rider's view. Allow switching between this view and the default observer view.