Project 2: Modeler
Assigned: 10/14/2003
Due: 10/28/2003
Artifact: 10/31/2003Project TA : Gary
Quick Links
- W2K Skeleton Code and examples (fixed) (zip)
- Linux Skeleton Code and examples (zipped tar)
- Linux Users README
- FLTK headers and library (zip)
- How to use and extend the modeler
- Answers to occasionally asked questions (OAQ)
- Height Fields - an idea for triangles
Project Description
In this project you define a 3D model and its controls, and then display and operate the model. The project skeleton includes the full source for a simple arm model. You will replace the appropriate parts of the sample.cpp file with your own model. You should not need to modify any other files, though you may create additional files to define more primitives. You may choose to modify some files in order to implement advanced effects. Do not modify files marked as read-only. This is because the animator project will work with your modeler files, and may not work correctly if your model relies on changes in the read only files.Project Objectives
In this project you will use OpenGL to create and animate a character of your own design. You will become familiar with 3D hierarchical modeling and transformations In the process. Because you will have the option of animating this model later, it is strongly recommended that you model something that you would like to animate. Animals, robots, "living toys", people or anything else that you can easily add personality to are things of this sort. Helicopters, cars, and engines make amazing hierarchical models, but, in general will not be fun to animate. Some nice character studies can be found at here if your looking for ideas.What is a Hierarchical Model?
A hierarchical model is a way of grouping together shapes and attributes to form a complex object. Parts of the object are defined in relationship to each other as opposed to their position in some absolute coordinate system. Think of each object as a tree, with nodes decreasing in complexity as you move from root to leaf. Each node can be treated as a single object, so that when you modify a node you end up modifying all its children together. Hierarchical modeling is a very common way to structure 3D scenes and objects, and is found in many other contexts.Project Requirements
First of all, you must come up with a character. This character can be composed solely of primitive shapes (box, generalized cylinder, sphere, and triangle). It should use at least ten primitives and at least four levels of hierarchy. You must also use at least one each of the glTranslate(), glRotate() and glScale() calls to position these primitives in space (and you will probably use many of all of them!) You must also use glPushMatrix() and glPopMatrix() to nest your matrix transformations. The modeler has facilities for creating user interface widgets and hooking them to different features of your model. You must use at least one of these to add a simple animation to your model - have your character do some simple action as you scrub a slider back and forth, however it is easy and fun to add these whenever you would like to animate a part of your character (the more you make, the better the animations you will be able to create when you get to Animator).You are required to complete two bells (or equivalent) from the list below. Feel free to come up with your own ideas and pass them by us. If they're cool, we'll count them as bells and whistles.
You must not break the built-in viewpoint controls unless you implement your own. This means you should not call glLoadIdentity in your code, and you should not remove the ModelerView::draw(); call at the beginning of your draw function.
Other than these requirements, you have complete artistic freedom on this, so be creative!
WARNING: We strongly discourage editing the modelerapp and modelerdraw classes. For the Animator project, you will be re-using your new model source file and plugging it into a different application. Thus, if your model library depends on changes or additions you make to the modelerapp or modelerdraw classes, it may not be compatible with the Animator skeleton application. You should be able to implement almost all of the bells and whistles inside your new model source file. Some changes can safely be made to the modelerview class for adding extra camera control functionality; the appropriate source files are documented to indicate where your code should be added.
Bells and Whistles
One bell is worth two whistles.
Change the default light source to illuminate your scene more dramatically.
Come up with another whistle and implement it. A whistle is something that extends the use of one of the things you are already doing. It is part of the basic model construction, but extended or cloned and modified in an interesting way.
Use a texture map on all or part of your character. (This requires altering the implementation of the primitives shapes to include texture coordinates, or implementing your own primitives that do texture mapping).
Build a complex shape as a set of polygonal faces, using the "triangle" primitive to render them.
Make your character perform an animation. Although you can try to use a timed callback (see here for more information), an easier solution is just to increment values each time your model's draw() function is called. If you use the menu option to turn on animation, your draw() function will be executed at around 30 times per second.
Add controls that let you change the "style" of your model. Changing these controls will make your model morph into a dramatically different looking model (but with the same controls). Dramatic and very creative style changes can earn more credit, whereas simple morphs will earn less. The transformation could either be an instantaneous style change, or a gradual animated transition.
Implement the "Hitchcock Effect" described in class, where the camera zooms in on an object, whilst at the same time pulling away from it (the effect can also be reversed--zoom out and pull in) . The transformation should fix one plane in the scene--show this plane. Make sure that the effect is dramatic--adding an interesting background will help.
Make your character express at least three moods (for example: happy, sad, and puzzled), and have it change its mood over time or in response to a control. The reason there is a little more credit for this is that you are also expected to put some thought into the personality of the character. Implement features or gestures that express a mood in a convincing and recognizable way. Note that just changing color is not a mood change.
Add a function in your model file for drawing a new type of primitive. The following examples will definitely garner two bells; if you come up with your own primitive, you will be awarded one or two bells based on its coolness.
- Swept surfaces -- given two curves, sweep one profile curve along the path defined by the other. These are also known as "generalized cylinders" when the profile curve is closed. This isn't quite as simple as it may first sound, as it requires the profile curve to change its orientation as it sweeps over the path curve. See this page for some uses of generalized cylinders. This document may be helpful as well.
- Surfaces of rotation - given a curve and an axis, draw the surface that results from sweeping the curve around the axis. This is really nice for making pottery :).
- Rail surfaces - see Watt, p. 41.
If you have a sufficiently complex model, you'll soon realize what a pain it is to have to play with all the sliders to pose your character correctly. Implement a method of adjusting the joint angles, etc., directly though the viewport. For instance, clicking on the shoulder of a human model might select it and activate a sphere around the joint. Click-dragging the sphere then should rotate the shoulder joint intuitively. For the elbow joint, however, a sphere would be quite unintuitive, as the elbow can only rotate about one axis. For ideas, you may want to play with the Maya 3D modeling/animation package, which is installed on the workstations in 228. Credit depends on quality of implementation.
Use some sort of procedural modeling (such as an L-system) to generate all or part of your character. Have parameters of the procedural modeler controllable by the user via control widgets.
In addition to mood cycling, have your character react differently to UI controls depending on what mood they are in. Think about the mood that the character is in, and the things that you might want the character to do, and then provide a means for expressing and controlling those actions.
Another method to build organic shapes is subdivision surfaces. Implement these for use in your model. You may want to visit this to get some starter code.
One difficulty with hierarchical modeling using primitives is the difficulty of building "organic" shapes. It's difficult, for instance, to make a convincing looking human arm because you can't really show the bending of the skin and bulging of the muscle using cylinders and spheres. There has, however, been success in building organic shapes using metaballs. Implement your hierarchical model and "skin" it with metaballs. Hint: look up "marching cubes" and "marching tetrahedra" --these are two commonly used algorithms for volume rendering. Here is a demo application by Chris Danford and Mathew Chasan that shows metaballs in action.
You might notice after building your model that it's difficult to have very "goal-oriented" motion. Given a model of a human, for instance, if the goal is to move the hand to a certain coordinate, we might have to change the shoulder angle, elbow angle -- maybe even the angle of the knees if the feet are constrained to one position. Implement a method, given a set of position constraints like
left foot is at (1,0,2)
right foot is at (3,0,4)
left hand is at (7,8,2)that computes the intermediate angles necessary such that all constrains are satisfied (or, if the constraints can not be satisfied, the square of the distance violations is minimized). For an additional 4 bells, make sure that all angle constraints are satisfied as well. In your model, for instance, you might have a slider that constrains the elbow angle between 30 and 180 degrees. Look here for some related material. You should probably contact us if you would like to attempt IK, as it's hard.
Come up with another heavy duty extension and implement it. "Heavy duty" is something that explores an area of technical or artistic development that is interesting, challenging, and well beyond the requirements of the assignment.