Assignment 4 - Lighting in MeshShop

This assignment will require you to learn about the OpenGL lighting model. You'll need to render meshes using lights and material properties. You'll have sliders to change the material properties. You need to provide control over the ambient color, the diffuse color, the specular color, as well as the coefficients for each of these. Finally there should be rudimentary control over the lighting direction. You should play around with your tool so that if we ask you to show us a bright green shiny mesh with blue light coming from the left you know how to create it.

You're going to be doing this inside the MeshShop framework. This will be implemented as a display() plugin. You won't need to worry about rotating the mesh etc.. only about drawing it properly. You'll bare difficult (?) to use since they aren't centered, etc.. Although you'll have a chance to fix this later, you'll need some other meshes to use for now. Here is a link to your classmates meshes as well as a few standard meshes. You can also download meshes from the web if they are in the PLY format.

(links to meshes here soon) -- use the submit command to submit your meshes and eventually they will show up here

(the bunny and dinosaur toy meshes are included with the base code)

Resources

Base Code

You can use the same process that you used in Assignment1 to check out the code for MeshShop using subversion (svn). That process is here. Over the next few weeks the base code may change often (though not in a way that will affect the code you are writing). To get an incremental update using subversion use the same process linked above by substitute the work update for co in the command.

The code should build (when you try to do this from a Mac) using "make -f Makefile.Aqua"

You can view your meshes in the new meshshop just like you did in the old. You can translate and rotate your mesh by dragging the mouse (right or ctrl+click to get a popup menu to select a different interactor plugin).

Creating a new Plugin

To create your own plugin, first look at the demo_display plugin code. It is in plugins/display/demo_display. This code has just about the minimum to render all of the meshes using some special lighting. Your program will use variable coefficients in the lighting model instead of hard-coded values. After you have a feel for what is happening in the demo, create your own directory in the plugins/display directory called yourname_display. Copy demo_display.cpp and .h to your new directory and rename them to match the directory name. Inside of these files there is a lot more renaming that needs to be done. If you are good with your text editor this shouldn't be hard at all. Replace all occurennces of "Demo" by "Yourname", all "DD" to "YD" (if yourname starts with Y), and all "demo" with "yourname". The compiler will whine about any you missed later on. Now, edit Makefile.Aqua in the base of the meshshop tree to include yourname_display.o on the OBJECTS list and copy the vpath % plugins/display/demo_display line and change demo for your name. If this all went well then using "make -f Makefile.Aqua" should build a new meshshop with a second display plugin. Run meshshop on some mesh and select yourname_display from the display plugins menu. If the mesh is still there after then you did this part perfectly.

Modifying the Plugin for Your Puposes

Demo display has no options in the popup menu, your plugin needs to be controllable! Look at the code for the filter plugin called example. In its startup method it requests that some GUI elements (a checkbox, a button, a slider, an enumeration). Your plugin should use these same methods to create options that allow the user to control the light parameters in your display. This example plugin will be expanded soon to give you a better idea of the information flow.

Things you need to add to your plugin

Note

The MeshShop base code is still under development and may change often, we will tell you if you should update your copy of the code. In general the changes we make should not affect the way your code works. In the near future a real menu and side-panel should be replacing the popup menu to give you easier access to the options your plugins requrest, but the method to request an option will be the same.

Example Options