UCSD Graphics group

Project 5: Scene Graphs

In this project you will need to implement a scene graph data structure and a view frustum culling algorithm.

This project is due on Friday, November 5th and will be introduced in the lab by Han on Monday, November 1st.

1. Scene Graph (60 points)

In this part of the project you will need to modify your renderer to use a scene graph data structure instead of a linear list of objects.

1a. Class Hierarchy (15 points)

Implement an abstract base class Node for nodes in the scene graph, and abstract subclasses Group and Leaf as shown in the figure below. The Group class should store a list of pointers to child nodes and provide functionality to add and remove child nodes. Implement a subclass TransformGroup of Group, and a subclass Shape3D of Leaf. TransformGroup should store a transformation matrix that is applied to the subtree below the node, and Shape3D should store a pointer to a 3D object. Your main application should store a pointer to the root node of the scene graph.

scenegraph.jpg

1b. Rendering (15 points)

Modify the GLUT draw callback in your application to recursively traverse the scene graph for rendering. Each subclass of Node, e.g., Group, TransformGroup and Shape3D, will need to have its own implementation of a draw method that is called recursively during scene graph traversal. See the lecture slides for more details on the recursive function for rendering the scene graph.

1c. Testing (30 points)

Demonstrate your scene graph functionality by constructing a walking robot. The robot should have a torso, a head, and arms and legs that consist of at least two parts each, for instance upper and lower arms or arm and hand. This means that the robot has to consist of at least 10 instances of Shape3D. You can use simple shapes for the body parts, like boxes, spheres or cylinders. It may be helpful to sketch the scene graph on a piece of paper before you implement it. The root node should be a transform group that represents the torso. It will have several children: a Shape3D node to represent the torso geometry, and several TransformGroup nodes to represent the arms, legs, and the head. The arm and leg nodes should have at least two children of their own, representing for instance the upper and lower arm. (20 points)

Animate the robot to make it look like it is walking: move the arms and legs back and forth by rotating around hip, shoulder, elbow and knee joints. You can choose to move the torso to make the robot walk in a circle, or you can choose for it to walk in place. You can accomplish motion by changing the transformation matrices of the TransformGroup nodes in your scene graph. (10 points)

Note: Starting with this homework project, you are allowed to use GLUT's geometry creation routines like glutSolidSphere, glutSolidCube, glutSolidCone, etc.

2. Object-Level Culling using Bounding Spheres (40 points)

Add a method to your Shape3D class to compute a bounding sphere, i.e., its center and radius. Store the bounding sphere center and radius in the Shape3D class. (5 points)

Extend the Shape3D class to perform view frustum culling using the bounding spheres of the objects. If the bounding sphere of an object lies completely outside the view frustum, the object should be culled. Your culling algorithm should make use of a utility function to test whether a bounding sphere intersects with a given plane, or whether the sphere is completely on one side of the plane. (10 points)

Test your implementation by constructing a scene that contains at least one hundred instances of the teapot, bunny, buddha, or dragon from homework project 2. Distribute the objects on a 2D grid (i.e., place the objects on a plane with uniform spacing) (5 points). Make sure that you choose the camera parameters such that many of the instances lie outside of the view frustum, so that object-level culling matters (5 points). Use your virtual trackball to allow the user to rotate the grid of 3D objects (5 points). Compare the frame rates with and without object-level culling by supporting the keys 'n' for no culling and 'c' for culling to switch between the two modes, and displaying the frame rate (frames per second) in the console window (5 points). You should use a scene graph to create instances of the object, which you load from disk only once at the start of your program. To get full credit, your frame rate must be higher when culling is enabled. (5 points) If it seems like you cannot achieve this, you might need to use a different 3D model, different camera parameters, or check your culling algorithm for correctness.

Note: Windows users can use clock() and Linux users can use gettimeofday() to compute the time between frames.

3. Optional project (10 points)

Lights and Cameras in the Scene Graph

Implement scene graph node classes for light sources (Light) and the camera (Camera), so that lights and the camera can be positioned relative to other nodes in the scene. Demonstrate this functionality by creating a spot light that is fixed with respect to your robot's hand from part one, acting as a flashlight. Add a floor to the scene which the robot walks on. Set the spot light parameters so that it shines on the floor in front of the robot. The camera should circle slowly around the robot, always looking at the robot.

r2 - 29 Oct 2010 - 22:37:30 - JuergenSchulze
This site is powered by the TWiki collaboration platformCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding UCSD Graphics TWiki? Send feedback
Syndicate this site RSSATOM