A village
In this assignment you should use OpenGL to practice using simple
transformations. Your code
should behave like my example: /chalmers/groups/thomas_math/VIS/OpenGL/village
.
Note the following:
- There are nine houses (a village) on some grass. Your program
should draw the houses by calling a routine, DrawHouse(), nine times. The
routine must not have any arguments and may not have access to any
global variables. So in order to get the houses in the correct
positions, your program have to perform suitable transformations,
before calling DrawHouse().
Note the windows on the back and the two different red colours on the
gables of the house.
DrawHouse() should
draw a house with the same modeling coordinates each time.
- Your program should draw a coordinate system (attached to the
village) and the grass as well.
- Typing x should rotate the village around an x-axis (clockwise
when looking along the negative x-direction). Pressing X should rotate
ccw. Similarly for pressing y, Y and z, Z. There should be two choices
of coordinate systems (that is the reason why it says "an x-axis",
rather than "the x-axis"). The user can choose coordinate system by
using the menu, described below.
- There is a menu with three alternatives, Village, Window and Quit.
- Picking Village or Window should reset the scene so that we see
it from the positive z-direction towards the origin.
- The first alternative, Village, should be the default. The
rotations, as described above, are relative the village (relative to
the coordinate system attached to the village).
- The
second alternative, Window, should cause the rotations to be
relative the window coordinate system (window refers to the figure
window, and not any window in any of the houses). Think of a plus-sign
in a square
window, where the centre of the plus is in the middle of the window.
The x-axis is the horizontal line of the plus. The y-axis, is the
vertical line. The z-axis goes out orthogonally from the centre of the
screen (plus-sign) towards the viewer. Note that this coordinate system
is not affected by any of the rotations performed by the user.
- Quit should terminate the execution of the program.
- Pressing q should also end the run.
- The scene should not be deformed (i.e. the x-, y- and z-proportions should be unaltered) if the
window is resized.
Your program does not have to be more fancy than my example code. So,
you can use simple color (glColor)
and not light. My coordinate system is not drawn perfectly (pieces are
sometimes hidden by the grass).
Hint:
in one of the menu-choices you may find it useful to handle the matrix
operations yourself. Start by reading the following manual page glLoadMatrix.
