Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Programming Assignment Hints: Creating 3D Polygons with OpenGL - Prof. Paul Merrell, Study Guides, Projects, Research of Computer Graphics

Recommendations for implementing a programming assignment that involves creating 3d polygons using opengl. It covers setting up an opengl window, reading polygon data, manipulating polygon data, creating classes for points and shapes, and implementing a scan conversion routine. Students are encouraged to read the opengl course notes for assistance and to optimize their code for speed.

Typology: Study Guides, Projects, Research

Pre 2010

Uploaded on 03/11/2009

koofers-user-0ly-1
koofers-user-0ly-1 🇺🇸

5

(1)

10 documents

1 / 5

Toggle sidebar

Partial preview of the text

Download Programming Assignment Hints: Creating 3D Polygons with OpenGL - Prof. Paul Merrell and more Study Guides, Projects, Research Computer Graphics in PDF only on Docsity! Hints for Program 1 Justin Talbot These are just recommendations for how to implement the assignment. 1. Get an OpenGL window up and running. See the OpenGL course notes for more help on doing this. Make sure that your window is 800 by 800 pixels. It is common for students to accidentally make 799 by 799 or 801 by 801 pixel windows. To test this, try drawing pixels to the corners of the screen. Do they show up exactly in the corners? 2. Here is the general outline of what your code should do. The processes for Programs 1-3 are basically the same. Try to represent the following steps in your code: 1 1. Read polygon data into memory – be sure to allow for different file formats (Program 1 uses a very simple format, Program 2 requires you to read in a more complex format) 2 2. Do mathematical manipulation on polygon data to put the polygon in the right place on the screen. This could include rotations, translations, projections, etc. (This step is ignored in Program 1, but will be needed in Program 2 and 3; make sure you remember that when you are coding) 3 3. Draw the manipulated polygon to the screen (the basics of this are handled in Program 1. Program 2 and 3 extend this to draw prettier pictures.) 3. Create a Point class. Right now this only has to store the X and Y coordinates of the polygon vertices. In the future you will extend it to 3D points. Also, points and vectors are mathematically similar, so this could become your Vector class later on. Class Point { Float x, y; //even though the points are currently integers, in the future we’ll need floating point numbers //possible functions you may need for Program 1 operator + () //p1 + p2 = (x1+x2, y1+y2) operator – () //p1 – p2 = (x1-x2, y1-y2) bool operator < (Point p1, Point p2) //p1 < p2 if (y1 < y2) //in our scan conversion routine we often need to know if one point is vertically below another }; 4. Create a Shape class. This is the abstract ancestor class of the polygons. We’ll use this later in our ray tracing program to handle Spheres as well. Class Shape { virtual Draw() = 0; //pure virtual function } 5. Create a Polygon class. Each polygon is made up of a list of Points (Vertices). We can represent this in a class. Note that we inherit from Shape and that we override the Draw function–where the actual scan conversion will take place. Class Polygon : public Shape { Linked list of Points or a STL vector of Points //functions you may need for Program 1 virtual void Draw(); //use scan conversion to draw this polygon void addPointToPolygon( Point ) } This class will be extended in Programs 2 and 3. Hint: Read in the whole polygon file and store the data in memory before you draw. In the past some students have drawn each polygon as it is read in from the file. Although this is OK for this program, by the time you get to Program 3 you will want to kill yourself because it runs so slow. 6. Create an Edge class. The Global Edge Table and the Active Edge Table presented in class use “Edges” to define the polygon when it is drawn. Using the list of points given in the Polygon class, we can generate all the edges needed for the GET and AET. Class Edge { //perhaps the constructor could calculate these values automatically if you simply pass it the two end Points of the edge
Docsity logo



Copyright © 2024 Ladybird Srl - Via Leonardo da Vinci 16, 10126, Torino, Italy - VAT 10816460017 - All rights reserved