Assume you start with an input polygon (2D) that represents the plan of an art gallery, and a point inside this polygon that represents a guard. Implement an algorithm that computes and displays the part of the gallery visible to the guard.
The interface should be as follows: Initialize a polygon based on the user's mouse clicks. Initialize a guard inside the polygon based on the user's mouse click. Then run your algorithm that computes that polygon that's visible and render it with a different color.
To see some simple OpenGL examples on how to use the mouse, look in: Code.
Some things to think about:
glPolygonMode(GL_LINE); //glPolygonMode(GL_FILL);Something to be aware of is that openGL can only render filled polygons that are convex. Think about it: how would you imlement a function to render a filled polygon? Once you start thinking about it you realize it's not simple. Essentially you need to compute the triangulation of the polygon, and then render one triangle at a time. I do not expect you to implement the polygon triangulation algorithm that we talked in class. Just store the visible area as a polygon, and render its boundary with a different color. That will suffice.
How to turn in: Please use the svn folder provided for the class! If you would like to change partners, just come talk to me or send me an email, and we'll create new svn folders for you.
The usual comments:
Always code assuming you'll have to debug. Think and structure your code incrementally so that it is easy to debug it. Test one piece before you move on to the next one. Keep in mind that pointer errors do not always manifest, and soemtimes they manifest in different ways on different computers.
And finally, if your code has bugs, you need to make it to the study group and talk to Max (the TA). He may not be able to tell you exactly what is wrong, but going over your code with someone else may show you what's wrong. I've been in many situatiosn where someone would walk me through their code, only to find out the problem as they were explaining how it works.
Enjoy!