Build a Room

Write a OpenGL program to produce a room. One wall is to have an object that is textured mapped with a picture of you or some other externally entered picture. One wall is to be color mapped with the function f(x) = x sin(x). You may want to both color map and 3 dimensionally map the function. One wall is to have a greeting (in text). The forth wall is to have a pull down list with at least two choices. This could be objects, color, actions or anything else that can be seen by the viewer.

Some Programming Notes

Much of what you need to do for this assignment can be done by finding programs that do part of what you need, copy and change the program. There are numerous examples that came with the book, on our site and out on the web. You might want to find and browse a tutorial for OpenGL. You do NOT need to LEARN EVERYTHING about an example before you can use parts of the code. This works fairily well for these types of problems because the code parts do not interact very much. That is, you can build individual objects, each with their own properties. The code for that object, largely does not effect other objects in your world.

One part of the problem is to build a function mapped wall. One way to do this is to build a grid function. First write a program to build a grid for a wall. Debug with a 3 by 3 node wall. Then change to a 20x20 or 100x100 wall. Then add the colors to the nodes as shown in cubeview. If you want an elevation map also, rather than the flat grid, add f(x,y) to the z value for each grid location. You start out with the simple figure

|--|
|--|
Where you specify four vertices and four lines for the face. Then build the one face out of more parts.
|--|--|
|--|--|
|--|--|
Now, your one face is composed of 4 sub-faces. Write the code to make this work, and then set the number to somewhere between 20 and 100 steps.

To get text output into the image see the use of sprintf and ourPrintString in the cube.c example (not the book's cube). The ourPrintString calls the glut routine glutBitmapCharacter. [this is the O'Reilly demo by C.Halsall]

Find the examples for keyboard control in the same cube.c program.

There a number of the example programs that have mouse button pull down menus. One example is the demo program.

The file format ppm is a way of encoding an image. See the ppm man page for the format. We need to use the ASCII format. You can convert to the format with a number of programs. The best is xv, another is giftopnm. The ppm ASCII file is easy to read as is shown in the example ppmdisplay. The problem is we want to use the image as a texture. OpenGL textures are to have the number of row and the number of columns each a power of 2. To solve this problem, I wrote a little chunk of code in teatex2 that reads in a ppm file (code from ppmdisplay) and remaps this into a texture.

END OF THE REQUIRED WORK



I would like to do something like the following. I tried it once, and it was too complex, too ill defined and too much work. I would like suggestions, if you can see a way to meet many of the overall goals of the work. I would like to

The idea of a room and the larger environment

adventure rooms demos
Goal:  I hoped to allow you to walk through an interactive versions of everyone in the class demos. I would like this to be accessible through the web, and each person simply publish their work, and we all can interactively access it from wherever we are. It would also be nice if everyone in the space showed as a figure in the space. We will have to start with a scalled down version of this idea.  There are few versions of how this could be done.  One is that each person captures a still frame of each project and we then create a group of web pages that will allow walking from display to display.  This loses the interactive nature of the programs.  Another version is to set up so each person has an open area in their SOD space and everyone includes files from each of these spaces into their program.  This loses the web and anywhere access properties, but does allow the interactive version of the program.  This is the version we will try.  You are to setup and debug your program in a stand-alone mode.  This limits problems to you and others.  When you have a stable project you will then  publish a version of the object file ( the .o file) and each of the required files.  In order to keep the naming clear your are to preface each file with the class assigned student number or your unix id.  So an program 2 image might be called s02p2.jpg or unixidp2.jpg.

Programming style:
Your program is to fit into a "room".  You call a room with the following format call:
s02room(orientation,movedirection,domoorinteractive,northwallstate,westwallstate,southwallstate,easetwallstate);
Orientation is in {n,w,s,e}, movedirection is in {n,w,s,e}, each state is a four tuple of statevalue, x, y, z. statevalue of -1  is the
starting value.  If the statevalue=-1, the x, y, and z values are ignored. If a wall does something, it will normally set the statevalue to a value of zero or larger and the x, y, and z values. What these values mean is up to the programmer. This statevector  will be used  to allow it to pick up     where the viewer left it.  The x,y,z values often will give mouse or object positions, but this left up to the programmer.  The programmer should be carful that the program does not remember something in code or variables, but only in the state vector.  If the programmer does not do this, you can not leave and re-enter the wall or room and return to the current state. In the room, the commands L (for left) and R (for right will change the wall you are looking at to the the next wall in requested order (clockwise or clockwise).  The room will call the correct one of the four walls, passing the statevector.  The wall when done will set the movedirection to a value in {n,w,s,e,l,r}.

The values of n, w, s, and e will take you to the "next" room in that row.  The room interconnection topology is left up the programmer.  However,  a five by five square is reasonable.  You might want the left and top sides to wraparound and go one less for row and column number.
Then have the bottom and right sides to increase the row or column number.  This way a user can go through all of the rooms by pressing just one direction, such as n.

Demo mode does not ask the user for input and tries to do something interesting with little or no user interaction.  If you need to read a  data file, demo mode will load a know file (using a full path for the file name).  The interactive mode can ask the user for file names and/or expect other interactions.  If you expect interactions, it would be nice to leave visible notes about what is expected.

Since this is something new I am trying, I expect it will have to evolve before everything works the way we want it. To start with, I will assign each of you a class student number snn (please keep the xeros in the number). Once you have the standallone version of your program working, you will include a file /home/juell/library/cs728list.h into your program. This then will be all of the other's work.