Comp 360 Lab 1 : Affine Graphics
Due Wednesday, 5 October 2011, 11:59 PM
Overview
In this project you will render simple and complex two dimensional shapes. You will also create transformations for these shapes and generate fractals using iterated function systems.
This project is due on Wednesday, 5 October, 2011, 11:59 PM. It is worth 100 points.
For this lab you will work with two or three other people. As soon as possible, send an email with your partners' names and usernames to linda.hill@rice.edu. If you have trouble finding a group, let us know and we will try to find one for you.
Specification
Using OpenGL, Glut, and Fltk, you will design the user interface for this program which will consist of a Geometry Editor and a Transformation editor.
The global coordinate system is set up so that the origin lies in the upper left-hand corner of the program window, the x-axis increases horizontally to the right, and the y-axis increases downward.
The first portion of the lab involves implementing basic shapes in the Geometry Editor. Clicking on the shape's button will draw the basic shape using OpenGL. Your shapes must be able to move around when selected with the mouse. In addition vertices should be highlighted when the mouse hovers over them and the vertices must have the ability to be dragged by the mouse to change the objects' shape.
The second portion of the lab involves creating tranformations by mapping three points at the vertices of a base triangle to three (possibly different) points on the base triangle.
The third portion of the lab is to integrate the shape editor and the transformation editor to create fractals.
In parts four and five you will be asked to create a few specific fractals as well as several fractals of your own design.
Part 1a: Simple Shapes
Create a base triangle in the center of the Geometry Editor.
Create buttons to add the following shapes to the screen:
-
Add Line
-
Add Circle
-
Add Triangle
-
Add Square
-
Add Hexagon
-
Add Octagon
Part 1b: Basic GUI Functions in the Geometry Editor
Once your Geometry Editor can handle the these shapes, add the below functionality to the editor:
-
Clear All
Clear all the shapes on the screen.
-
Delete Selected
The ability to delete a specific shape from the screen
-
Hide Base
The base triangle in the Geometry Editor should no longer appear on the screen.
It is not necessary to allow the base triangle in the Geometry Editor to be manipulated the way it is in the demo.
Part 2a: Basic GUI functions in the Transformation Editor
In the Transformation Editor you will create the transformations that will manipulate the shapes you are using in the Geometry Editor.
-
Create the base triangle
Your transformations will be created using this triangle as the base shape.
Create the following buttons for the base triangle:
-
Zoom In
The triangle should appear larger every time this button is clicked.
-
Zoom Out
The opposite of Zoom In. The triangle should appear smaller when this button is clicked.
The Grid on the base triangle should create equidistant points on the edges and in the interior of the triangle. These points will be used to place transformation triangles at precise locations on top of the base triangle. Dragging a transformation triangle's vertex with the mouse near a point on the grid should cause the vertex of the transformation triangle to snap to this point on the grid.
- Increase Grid
Create more points on the base triangle every time this button is clicked. The points should remain equidistant.
-
Decrease Grid
Remove points on the base triangle. This button should have the effect of undoing an Increase Grid action. If Increase grid has not been clicked, the editor should be able to remove points on the grid every time Decrease Grid is clicked until only the vertices of the base triangle remain as grid points. Every time Decrease Grid is clicked and grid points are removed, the remaining points should be equidistant.
2b. Create Transformations
Transformations are created by mapping the three vertices of the base triangle to three (possibly different) points on the base triangle. The actual base triangle should not have the ability to move. The mapping is done by adding an additional triangle on top of the base triangle and moving the vertices of the new triangle to points on the grid of the base triangle. Multiple triangles should be added to created compound transformations. The transformations should allow for rotation, scaling, and translation.
Create the following buttons to handle the transformation triangles:
- Add Triangle
A new transformation triangle should appear on top of the base triangle.
- Del Triangle
The selected triangle is deleted from the screen, and its transformation can no longer be used.
- Clear
This should clear all triangles from the screen, and all their associated transformations should be eliminated.
- Next Triangle
Each time this button is clicked, a different transformation triangle on the screen is selected.
- Prev Triangle
Clicking this button has the effect of undoing Next Triangle. The previous transformation triangle in the editor is selected. If Next Triangle has not been clicked, the button simply highlights a different transformation triangle.
3. Integrate the Geometry and Transformation Editors
The Geometry Editor should have the ability to apply the transformations created in the Transformation Editor to the shapes selected in the Geometry Editor. A shape should be selected in the Geometry Editor by right-clicking on the shape.
Add the following button to the Transformation Editor:
- Geometry Editor
The Transformation Editor should be replaced by the Geometry Editor on the screen.
Add the following buttons to the Geometry Editor:
- Apply Transformation(s)
This button should apply the transformations created using the Transformation Editor to the shapes selected in the Geometry Editor. This button should implement transformations iteratively by clicking on the button repeatedly.
- Transformation EditorThe Geometry Editor should be replaced by the Transformation Editor on the screen.
4. Create fractals using the Geometry Editor and the Transformation Editor
Fractals should be independent of their base cases. So when creating your fractal, you can build your fractal using any of the selected shapes from the Geometry Editor. Please take screen shots of your fractals in the Geometry Editor as well as screen shots of the transformations used in the Transformation Editor to create your fractals.
Create the following fractals:
- Sierpinski Gasket
- Koch Curve
- Koch Curve combined with Sierpinski Gasket
5. Create at least five fun fractals of your own design
As with the above fractals please take screen shots of the fractals you create in the Geometry Editor as well as screen shots of the transformations used in the Transformation Editor to create your fractals.
Part of your grade will depend on the originality and elegance of the fractals you create.
Code For Your Use
You can use the following files:
- MainWindow.h/.cpp
This file is where the GUI windows are handled. Actual drawing should occur in this class.
- NGeometry.h/.cpp
This file contains a basic Point2D class which includes some operations on points/vectors. The file also includes a Box and Triangle class. Your other shapes should be implemented in NGeometry as well.
The provided implementations are there to give you hints as to how to proceed with your implementation of other shapes and operations on points and vectors that you might need.
- Please implement any linear algebra (matrices and their operations) you might use ON YOUR OWN. Linear algebra is one of the main things you should learn from this lab. Of course, we cannot stop you from looking at existing code out on the web, but please do not directly copy other people's code, and please document your sources if you do use concepts from other people's code.
What To Turn In
Create the directory lab2. This directory should contain your source code and all files needed to build your program in Visual Studio (or a CMakeList.txt file). Also include the screen shots of your fractals and transformations and a README file containing:
- The names of you and your partners.
- A brief overview of how your code is organized.
- Any known bugs or incomplete features.
- Any other implementation details you think your grader should know.
Part of your grade will depend on the originality and elegance of the fractals you create.
Only one partner per group should turn in code.
If your project will be completed late, email the TA (lkh3@rice.edu).
Please follow the instruction on the COMP 360 home page to submit your lab.
File translated from
TEX
by
TTH,
version 3.85.
On 15 Sep 2009, 10:10.