1Computer Graphics Programming with OpenGL Three Dimensions Lecture 06 John Shearer Culture Lab – space 2

Slides:



Advertisements
Similar presentations
1Computer Graphics Building Models John Shearer Culture Lab – space 2
Advertisements

OpenGL: Simple Use Open a window and attach OpenGL to it Set projection parameters (e.g., field of view) Setup lighting, if any Main rendering loop –Set.
COMP 175 | COMPUTER GRAPHICS Remco Chang1/6103b – Shapes Lecture 03b: Shapes COMP 175: Computer Graphics February 3, 2015.
CHAPTER 3 2D GRAPHICS ALGORITHMS
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Building Models modified by Ray Wisman Ed Angel Professor of Computer Science,
1 Building Models. 2 Objectives Introduce simple data structures for building polygonal models ­Vertex lists ­Edge lists OpenGL vertex arrays.
2IV60 Computer graphics Graphics primitives and attributes Jack van Wijk TU/e.
1 Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009 Programming with OpenGL Part 3: Three Dimensions.
CSC 461: Lecture 51 CSC461 Lecture 5: Simple OpenGL Program Objectives: Discuss a simple program Discuss a simple program Introduce the OpenGL program.
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Programming with OpenGL Part 2: Complete Programs Ed Angel Professor of Computer Science,
1 Lecture 4 Graphical primitives Rasterization: algorithmic approach Rasterization: geometric approach 2D discrete lines, triangles Discrete planes 3D.
1 CSC461 Lecture 7: 3D Programming in OpenGL Objectives: Develop 2D and 3D examples -- Sierpinski gasket: a fractal Develop 2D and 3D examples -- Sierpinski.
COEN Computer Graphics I
Sierpinski Gasket Program
OpenGL and WebGL Drawing Functions CSCI 440 Day Five.
COS 397 Computer Graphics Assoc. Prof. Svetla Boytcheva AUBG 2013 COS 397 Computer Graphics Practical Session №1 Introduction to OpenGL, GLFW and CG.
Drawing Basic Graphics Primitives Lecture 4 Wed, Sep 3, 2003.
Geometric Primitives Used in Open GL Polygons Polygon is : Flat shape with three or more straight sides. It could be either : convex or concave.
Demetriou/Loizidou – ACSC330 – Chapter 2 Graphics Programming Dr. Giorgos A. Demetriou Dr. Stephania Loizidou Himona Computer Science Frederick Institute.
Computer Graphics CS 385 January 31, Fractals Some definitions Object which is self-similar at all scales. Regardless of scale the same level of.
Graphics Programming Chapter 2. CS 480/680 2Chapter 2 -- Graphics Programming Introduction: Introduction: Our approach is programming oriented. Our approach.
Ch 2 Graphics Programming page 1 CSC 367 Coordinate Systems (2.1.2) Device coordinates, or screen coordinates (pixels) put limitations on programmers and.
1. OpenGL/GLU/GLUT  OpenGL v4.0 (latest) is the “core” library that is platform independent  GLUT v3.7 is an auxiliary library that handles window creation,
CD2012 Principles of Interactive Graphics Lecture 01 Introduction Abir Hussain (Rome: 6.33,Tel , Web:
Representation. Objectives Introduce concepts such as dimension and basis Introduce coordinate systems for representing vectors spaces and frames for.
1Computer Graphics Programming with OpenGL Three Dimensions – 2 Lecture 7 John Shearer Culture Lab – space 2
1Computer Graphics Implementation II Lecture 16 John Shearer Culture Lab – space 2
1 Programming with OpenGL Part 3: Three Dimensions Yuanfeng Zhou Shandong University.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
Computer Graphics I, Fall 2010 Programming with OpenGL Part 3: Three Dimensions.
1 Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009 Programming with OpenGL Review.
1 Chapter 2: Graphics Programming Bryson Payne CSCI 3600 NGCSU.
CS 480/680 Computer Graphics Programming with Open GL Part 6: Three Dimensions Dr. Frederick C Harris, Jr. Fall 2011.
1 Chapter 2 Graphics Programming. 2 Using OpenGL in Visual C++ – 1/3 Opengl32.dll and glu32.dll should be in the system folder Opengl32.lib and glu32.lib.
Geometric Primitives Used in Open GL Drawing Triangles glBegin(GL_TRIANGELS); glVertex2i(p0); glVertex2i(p1); glVertex2i(p2); glVertex2i(p3); glVertex2i(p4);
Lecture 2 Review OpenGL Libraries Graphics Overview Rendering Pipeline OpenGL command structure.
CS552: Computer Graphics Lecture 6: Viewing in 2D.
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Programming with OpenGL Part 3: Three Dimensions Ed Angel Professor of Computer Science,
1 Programming with OpenGL Part 2: Complete Programs.
OpenGL API 2D Graphic Primitives Angel Angel: Interactive Computer Graphics5E © Addison-Wesley
Learning Objectives Affine transformations Affine transformations Translation Translation Rotation Rotation Scaling Scaling Reflection Reflection Shear.
1 E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012 Programming with OpenGL Part 6: Three Dimensions Ed Angel Professor.
Computer Graphics I, Fall 2010 Building Models.
31/1/2006Based on: Angel (4th Edition) & Akeine-Möller & Haines (2nd Edition)1 CSC345: Advanced Graphics & Virtual Environments Lecture 2: Introduction.
1 Geometric Transformations-II Modelling Transforms By Dr.Ureerat Suksawatchon.
Graphics Graphics Korea University kucg.korea.ac.kr Graphics Programming 고려대학교 컴퓨터 그래픽스 연구실.
CSC Graphics Programming Budditha Hettige Department of Statistics and Computer Science.
Computer Graphics I, Fall Programming with OpenGL Part 2: Complete Programs.
CS5500 Computer Graphics March 2, 2006.
Course code:10CS65 | Computer Graphics and Visualization
Programming with OpenGL Part 2: Complete Programs
Programming with OpenGL Part 1: Background
Programming with OpenGL Part 3: Three Dimensions
OpenGL API 2D Graphic Primitives
Programming with OpenGL Part 2: Complete Programs
Graphics Programming (I)
Programming with OpenGL Part 3: Three Dimensions
Introduction to OpenGL
Primitive Objects Lecture 6 Wed, Sep 5, 2007.
Angel: Interactive Computer Graphics5E © Addison-Wesley 2009
Introduction to Computer Graphics with WebGL
OpenGL program.
Programming with OpenGL Part 2: Complete Programs
Programming with OpenGL Part 2: Complete Programs
Programming with OpenGL Part 6: Three Dimensions
Programming with OpenGL Part 3: Three Dimensions
Programming with OpenGL Part 2: Complete Programs
Angel: Interactive Computer Graphics5E © Addison-Wesley 2009
Programming with OpenGL Part 3: Three Dimensions
Angel: Interactive Computer Graphics5E © Addison-Wesley 2009
Presentation transcript:

1Computer Graphics Programming with OpenGL Three Dimensions Lecture 06 John Shearer Culture Lab – space 2

2Computer Graphics Objectives Develop a more sophisticated example – Sierpinski gasket: a fractal Think about extending that to 3D

3Computer Graphics Three-dimensional Applications In OpenGL, two-dimensional applications are a special case of three-dimensional graphics Going to 3D – Not much changes – Use glVertex3*( ) – Have to worry about the order in which polygons are drawn or use hidden-surface removal – Polygons should be simple, convex, flat

4Computer Graphics Sierpinski Gasket (2D) Start with a triangle Connect bisectors of sides and remove central triangle Repeat

5Computer Graphics Example Five subdivisions

6Computer Graphics The gasket as a fractal Consider the filled area (black) and the perimeter (the length of all the lines around the filled triangles) As we continue subdividing –the area goes to zero –but the perimeter goes to infinity This is not an ordinary geometric object –It is neither two- nor three-dimensional It is a fractal (fractional dimension) object

7Computer Graphics Gasket Program Can we write a program to draw Sierpinski Gasket (to a certain number of subdivisions)? Write a function to draw a triangle – What parameters should it take?

8Computer Graphics Gasket Program First draw a triangle private static void drawTriangle( float ax, float ay, float bx, float by, float cx, float cy) /* display one triangle */ { glBegin(GL_TRIANGLES); glVertex2f(ax, ay); glVertex2f(bx, by); glVertex2f(cx, cy); glEnd(); // Done Drawing }

9Computer Graphics Gasket Program First draw a triangle private static void drawTriangle( float ax, float ay, float bx, float by, float cx, float cy) /* display one triangle */ { GL11.glBegin(GL11.GL_TRIANGLES); GL11.glVertex2f(ax, ay); GL11.glVertex2f(bx, by); GL11.glVertex2f(cx, cy); GL11.glEnd(); // Done Drawing } We could pass in vectors for each to opengl rather than separate floats – How do you do this with LWJGL?

10Computer Graphics Triangle Subdivision 1 pseudocode …

11Computer Graphics Triangle Subdivision 2 pseudocode divideTriangle(vector2f a, vector2f b, vector2f c, int m) { // triangle subdivision using vertex numbers vector2f v0, v1, v2; if(m>0) { v0.x = (a.x +_b.x) / 2; v0.y = (a.y +_b.y) / 2; v1.x = (b.x +_c.x) / 2; v1.y = (b.y +_c.y) / 2; v2.x = (c.x +_a.x) / 2; v2.y = (c.y +_a.y) / 2; divide_triangle(a, v0, v1, m-1); divide_triangle(c, v1, v2, m-1); divide_triangle(b, v2, v0, m-1); } else(triangle(a,b,c)); // draw triangle at end of recursion }

12Computer Graphics Triangle Subdivision 3 pseudocode main() { create window etc. n=4; // setup projection matrix glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluOrtho2D(-2.0, 2.0, -2.0, 2.0); // prepare for drawing glMatrixMode(GL_MODELVIEW); glClearColor (1.0, 1.0, 1.0,1.0) glColor3f(0.0,0.0,0.0); glClear(GL_COLOR_BUFFER_BIT) ; divideTriangle( a, b, c); }

13Computer Graphics Efficiency Note 1 Having the glBegin and glEnd in the display callback rather than in the function triangle means we could call glBegin and glEnd only once for the entire gasket rather than once for each triangle

14Computer Graphics Moving to 3D Think about it for next lecture How to we store the points? What will we see using the above ? gluOrtho2D(-2.0, 2.0, -2.0, 2.0) Should we change this?