OpenGL: Modeling void DrawPyramid(){ glBegin(GL_TRIANGLES); glVertex3f(0.0, 0.0, 0.0); glVertex3f(0.0, 1.0, 0.0); glVertex3f(0.1, 0.0, 0.0); glVertex3f(0.0,

Slides:



Advertisements
Similar presentations
OpenGL Computer Graphics
Advertisements

Using GLU/GLUT Objects GLU/GLUT provides very simple object primitives glutWireCube glutWireCone gluCylinder glutWireTeapot.
CLASS 4 CS770/870. Translation Scale Multiplying Matrices. The R C rule What happens when we do two translates? What happens when we do two scales?
Chapter 3. Drawing primitives in Space Presented by Garrett Yeh.
Hidden Surfaces and Shading CS BSP Tree T1T1 T2T2 E if (f 1 (E) < 0) then draw T 1 draw T 2 else draw T 2 draw T 1 f 1 (p) = 0 is the.
1 Understanding of OpenGL TA: Dong Hyun Jeong Instructor : Dr. Kalpathi Subramanian Transformations and Projections.
2IV60 Computer Graphics 2D transformations
COMP 175: Computer Graphics March 10, 2015
3D coordinate systems X Y Z Right-Hand Coordinate System X Y Z Left-Hand Coordinate System OpenGL uses this! Direct3D uses this!
COS 397 Computer Graphics Assoc. Prof. Svetla Boytcheva AUBG 2013 COS 397 Computer Graphics Practical Session №1 Introduction to OpenGL, GLFW and CG.
Introduction to Computer Graphics CS 445 / 645 Lecture 4 OpenGL OpenGL OpenGL Programming Guide.
Computer Graphics 3 Lecture 3: OpenGL Benjamin Mora 1 University of Wales Swansea Pr. Min Chen Dr. Benjamin Mora.
Computer Graphics, KKU. Lecture 131 Transformation and Viewing in OpenGL.
TWO DIMENSIONAL GEOMETRIC TRANSFORMATIONS CA 302 Computer Graphics and Visual Programming Aydın Öztürk
The Viewing Pipeline (Chapter 4) 5/26/ Overview OpenGL viewing pipeline: OpenGL viewing pipeline: – Modelview matrix – Projection matrix Parallel.
OpenGL A Brief Overview. What is OpenGL? It is NOT a programming language. It is a Graphics Rendering API consisting of a set of functions with a well.
Interactive Computer Graphics CS 418 – Spring 2015 Mesh Rendering, Transformation, Camera Viewing and Projection in OpenGL TA: Zhicheng Yan Sushma S Kini.
Introduction to GL Geb Thomas. Example Code int main(int argc, char **argv) { glutInit(&argc, argv); glutInitDisplayMode ( GLUT_SINGLE | GLUT_RGB | GLUT_DEPTH);
Stages of Vertex Transformation To specify viewing, modeling, and projection transformations, you construct a 4 × 4 matrix M, which is then multiplied.
Computer Graphics Bing-Yu Chen National Taiwan University.
Modeling with OpenGL Practice with OpenGL transformations.
Jul 25, 2014IAT 3551 Scene Graphs.  A data structure that stores information about a graphics scene –Each node has information that structures the interpretation.
Computer Science Term 1, 2006 Tutorial 2 Assignment 3 – The Virtual World.
Computer Graphics I, Fall 2010 Programming with OpenGL Part 3: Three Dimensions.
Graphics Graphics Korea University kucg.korea.ac.kr Viewing 고려대학교 컴퓨터 그래픽스 연구실.
Projections. Viewports Windows can have separate viewports void glViewport(GLint x, GLint y, GLsizei width, GLsizei height ) x, y - Specify the lower.
Introduction to OpenGL & HW1 Announcement 劉軒銘, 網媒所 碩二 ICG 2012 Fall.
Doç. Dr. Cemil Öz SAÜ Bilgisayar Mühendisliği Dr. Cemil Öz.
CS552: Computer Graphics Lecture 4: 2D Graphics. Recap 2D Graphics Coordinate systems 2D Transformations o Translation o Scaling o Rotation Combining.
OpenGL Basic Drawing 2003 Spring Keng Shih-Ling
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Programming with OpenGL Part 3: Three Dimensions Ed Angel Professor of Computer Science,
Learning Objectives Affine transformations Affine transformations Translation Translation Rotation Rotation Scaling Scaling Reflection Reflection Shear.
CS559: Computer Graphics Lecture 12: OpenGL - Transformation Li Zhang Spring 2008.
CS559: Computer Graphics Lecture 12: OpenGL: ModelView Li Zhang Spring 2010.
OpenGL: Introduction #include main() { OpenWindow() ; glClearColor(0.0, 0.0, 0.0, 0.0); glClear(GL_COLOR_BUFFER_BIT); glOrtho(-1.0, 1.0, -1.0, 1.0, -1.0,
1 Geometric Transformations-II Modelling Transforms By Dr.Ureerat Suksawatchon.
OpenGL Basic Drawing Jian-Liang Lin A Smidgen of OpenGL Code #include main() { InitializeAWindowPlease(); glClearColor (0.0, 0.0, 0.0, 0.0); glClear.
1 Perception, Illusion and VR HNRS 299, Spring 2008 Lecture 17 Animations, Loops.
Implement of transformation,projection, viewing Hanyang University Jungsik Park.
CSC Graphics Programming Budditha Hettige Department of Statistics and Computer Science.
CSCE 441: Computer Graphics: Hierarchical Models Jinxiang Chai.
Transformation Example. Order of Transformation Matters Scale, translate Scale, translate Translate scale Translate scale Rotate, Translate Rotate, Translate.
CS380 LAB II OpenGL Donghyuk Kim Reference1. [OpenGL course slides by Rasmus Stenholt] Reference2. [
Viewing 고려대학교 컴퓨터 그래픽스 연구실 kucg.korea.ac.kr.
IAT 355 Scene Graphs Feb 23, 2017 IAT 355.
Reference1. [OpenGL course slides by Rasmus Stenholt]
Transformation and Viewing
Programming with OpenGL Part 3: Three Dimensions
OpenGL (Open Graphics Library) Mr. B.A.Swamy Assistant Professor Dept of CSE.
Understanding of OpenGL
גרפיקה ממוחשבת: מבוא ל-OpenGL
Geometric Transformations
CSCE 441: Computer Graphics: Hierarchical Models
Lighting and Shading Lab 8:.
Computer Graphics, KKU. Lecture 13
Chapter 4/5 glMatrixMode Modeling Transformations glTranslate glScale
Programming with OpenGL Part 3: Three Dimensions
Introduction to OpenGL
Geometric Transformations
Lecture 12: OpenGL Li Zhang Spring 2008
Computer Graphics Prof. Muhammad Saeed Dept. of Computer Science & IT
OpenGL program.
Lighting and Shading Lab 8:.
Programming with OpenGL Part 3: Three Dimensions
THREE-DIMENSIONAL VIEWING I
Geometric Transformations
Angel: Interactive Computer Graphics5E © Addison-Wesley 2009
Programming with OpenGL Part 3: Three Dimensions
Angel: Interactive Computer Graphics5E © Addison-Wesley 2009
CSCE 441: Computer Graphics: Hierarchical Models
Presentation transcript:

OpenGL: Modeling void DrawPyramid(){ glBegin(GL_TRIANGLES); glVertex3f(0.0, 0.0, 0.0); glVertex3f(0.0, 1.0, 0.0); glVertex3f(0.1, 0.0, 0.0); glVertex3f(0.0, 0.0, 0.0); glVertex3f(0.0, 0.0, 1.0); glVertex3f(0.0, 1.0, 0.0); glVertex3f(0.1, 0.0, 0.0); glVertex3f(0.0, 0.1, 0.0); glVertex3f(0.0, 0.0, 0.1); glEnd() ; }

Modeling: Cone void DrawCone(int res){ GLfloat d = 2*PI/res ; GLfloat a = 0; glBegin(GL_TRIANGLE_FAN); glVertex3f(0.0, 0.0, 0.0); for (int i = 0 ; i < res ; i++ ){ glVertex3f(cos(a), sin(a), 0.0); a += d ; } glEnd() ; a = 0.0 ; glBegin(GL_TRIANGLE_FAN); glVertex3f(0.0, 0.0, 1.0); for (int i = 0 ; i < res ; i++ ){ glVertex3f(cos(a), sin(a), 0.0); a += d ; } glEnd() ; }

Modeling: cylinder void DrawCylinder (int res){ GLfloat a, d = 2*PI/res ; glBegin(GL_TRIANGLE_FAN); glVertex3f(0.0, 0.0, 0.0); for (int i = 0, a = 0 ; i < res ; i++,a += d ) glVertex3f(cos(a), sin(a), 0.0); glEnd() ; glBegin(GL_TRIANGLE_FAN); glVertex3f(0.0, 0.0, 1.0); for ( i = 0, a = 0 ; i < res ; i++, a += d ) glVertex3f(cos(a), sin(a), 1.0); glEnd() ; glBegin(GL_TRIANGLE_STRIP); for ( i = 0, a = 0 ; i < res; i++, a += d) { glVertex3f(cos(a), sin(a), 0.0); glVertex3f(cos(a), sin(a), 1.0); } glEnd() ; }

Scene // Set Up glViewport(0,0,w,h); glMatrixMode(GL_PROJECTION); glLoadIdentity() ; glOrtho(-100,100,-100,100,-100,100); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); // Draw Scene glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); // Draw Cylinder glPushMatrix() ; glRotate(90, 1,0,0); glTranslate(0,0,10); glScale(10,10,10) DrawCylinder(50); glPopMatrix() ;

Scene // Draw Cube glPushMatrix() ; glTranslate(10,0,2); glScale(5,10,5) DrawCube(10); glPopMatrix() ; // Draw Cones glPushMatrix() ; glRotate(90, 0,1,0); glRotate(45, 0,0,1); glPushMatrix(); glTranslate(5,0,5); glScale(5,5,5) DrawCone(10); glPopMatrix() ; glTranslate(5,10,5); glScale(10,10,10); DrawCone(10); glPopMatrix() ;