Grafica Computazionale

Documenti analoghi
DOUBLE BUFFERING. serve a nascondere la fase di drawing utilizzato soprattutto nelle animazioni INTRODUZIONE DRAWING EVENT MANAGEMENT VIEWING

OpenGL: visualizzazione 3D

RIEPILOGO DRAWING INTRODUZIONE DRAWING EVENT MANAGEMENT VIEWING DOUBLE BUFFERING Z-BUFFERING LIGHTING

Which three statements are true regarding single-row functions? (Choose three.)

Introduzione. Costruzione di Interfacce Primi passi in OpenGL. Sierpinski Gasket. Sierpinski gasket. Event driven programming. Stuttura del programma

Introduzione SOMMARIO

INFORMATICA GRAFICA. 20 Aprile Introduzione a OpenGL. Michele Antolini michele.antolini@mail.polimi.it

What You Need. Preparing Your Computer. Installing Hardware. Installing Software. Optional. Product Registration. Creative Knowledge Base

INFORMATICA GRAFICA. 27 Aprile Introduzione a OpenGL parte 2. Michele Antolini

3D PRINTING AND SMALL SERIES OF TRANSPARENT MODELS

Code: GW-IMP-WEB-1-S. Datalogger web pulses counter. Version 6 inputs without Ethernet. MarCom

Connecting Speakers. Using Your Creative Applications

Computer Graphics. Immagine sul Raster Display. Grafica 3D: analogia con fotocamera. La matrice di Pixel è memorizzata nel FRAME BUFFER

POLOPPOSTO ENGLISH MAGNETIC DEVICE TO COUNTERACT RISING DAMP IN WALLS

LoRaWAN TM TEMPERATURE-HUMIDITY SENSOR

Hello GL. subclassiamo. subclassiamo. Primo tentativo. Costruzione di Interfacce Lezione 20 Qt + Opengl

Proiezione Stereoscopica

Constant Propagation. A More Complex Semilattice A Nondistributive Framework

USER S MANUAL. Gateway DLMS-MODBUS for CEWE Prometer reading of INSTANT VALUES P/N: GW-DLMS-CEWE-INST. Edition 2.0

Grafica Computazionale

Informatica Grafica. (III anno Laurea Triennale - Corso di Laurea in Informatica) Donato D Ambrosio

INFORMATICA GRAFICA. 25 Marzo Introduzione a OpenGL. Michele Antolini

Informatica Grafica. (III anno Laurea Triennale e I anno Laurea Magistrale del Corso di Laurea in Informatica) Donato D Ambrosio

A new Trinity Corporate Services office opens in Lugano, a branch of the historical Dubai headquarters.

MIMO-0003-V2 Series LTE, WiFi & GPS Antennas for Transportation

Processo di rendering

INFORMATICA GRAFICA. 4 Maggio Trasformazioni - Illuminazione. Michele Antolini

L anno scorso c erano 643 postulanti e 384 novizii

How to use P-model scanners in Windows xp?

Pegaso. Meccanismo di apertura orizzontale per ante a pantografo Horizontal opening mechanism for pantograph doors

Introduzione a OpenGL e alle GLUT

College Algebra. Logarithms: Denitions and Domains. Dr. Nguyen November 9, Department of Mathematics UK

Guida alla configurazione Configuration Guide

CREAZIONE DI UNA LISTA PER SCANSIONE RPT ANALOGICI E TG DMR. HOW CREATE A SCAN LIST WITH BOTH DIGITAL & ANALOG RPT.

The new Trinity Corporate Services website is online: Your company abroad, with focus in Dubai and in the UAE

Smart gate controller. Cloud based solution.

LA SACRA BIBBIA: OSSIA L'ANTICO E IL NUOVO TESTAMENTO VERSIONE RIVEDUTA BY GIOVANNI LUZZI

ECCO LE ISTRUZIONI PER INSERIRE IL MATERIALE RICHIESTO DAL BANDO TEATRO SENZA FILO CONTEST:

Blender Tutorial Creazione gioco in FPS Questo video tutorial è stato preso da you tube e lo script richiama il sito

User Guide Guglielmo SmartClient

quick guide guida rapida J.touch hydromassage bath remote control telecomando per vasche idromassaggio

INFORMATICA GRAFICA. 28 Aprile Trasformazioni - Illuminazione. Michele Antolini

NSE8 Dumps- Fortinet Network Security Expert Exam Questions

INFORMATICA GRAFICA. 5 Maggio Interattività. Michele Antolini

Le piccole cose che fanno dimagrire: Tutte le mosse vincenti per perdere peso senza dieta (Italian Edition)

GUIDE TO VACUUM CASTING (OR SILICONE MOLDS)

light light pensiline canopies

A.A. 2006/2007 Laurea di Ingegneria Informatica. Fondamenti di C++ Horstmann Capitolo 3: Oggetti Revisione Prof. M. Angelaccio

Master thesis Guidelines and Procedure

INFORMATICA GRAFICA. 19 Maggio Texture. Michele Antolini

How to apply for the first issue of the residence permit for study. Come fare domanda di primo rilascio di permesso di soggiorno per studio

USER S MANUAL. Gateway DLMS-MODBUS for LANDIS & GYR E650 with RS232 P/N: GW-DLMS-232-LG. Edition 2.0

Display OLED 128 x 64

INFORMATICA GRAFICA!

USER S MANUAL. Gateway DLMS-MODBUS for LANDIS & GYR E650 with RS485 P/N: GW-DLMS-485-LG. Edition 2.0

Downloading and Installing Software Socio TIS

Grafica Computazionale

drag & drop visual programming appinventor storia appinventor un esempio di drag & drop programming: Scratch

Paloalto Networks PCNSE7 Exam Dumps (PDF)

GETTING SIX PACK ABS FAST. By Brian Cannone.

599CD/A I EN ISTRUZIONI PER L USO INSTRUCTIONS FOR USE

L IOB I/ O Controllers

Gateway DLMS-MODBUS for ISKRA with RS485 P/N: GW-DLMS-485-ISK

Modellare un bottiglia

Electrical. Environmental. Mechanical

USER S MANUAL. Gateway DLMS-MODBUS for LANDIS & GYR E650 with RS232 OPTICAL PROBES P/N: GW-DLMS-OPT-LG. Edition 2.0

Corso di Grafica Computazionale

Quadrature. Emma Perracchione. Corso di Calcolo Numerico per Ingegneria Meccanica - Matr. PARI (Univ. PD)

SEI PRONTO AD ENTRARE IN UNA NUOVA DIMENSIONE? ARE YOU READY TO ENJOY A NEW DIMENSION?

Il Piccolo Principe siamo noi: Adattamento teatrale per la scuola primaria (ABW. Antoine de Saint- Exupery) (Volume 1) (Italian Edition)

layout senza tabelle Posizionamento con i CSS Ad ogni elemento HTML corrisponde un area rettangolare, detta box Contenuto

LA SACRA BIBBIA: OSSIA L'ANTICO E IL NUOVO TESTAMENTO VERSIONE RIVEDUTA BY GIOVANNI LUZZI

Primo dicembre Roberto Gretter, primo dicembre 2000

Esempio con Google Play tore Example with Google Play tore

Canti Popolari delle Isole Eolie e di Altri Luoghi di Sicilia (Italian Edition)

Gateway DLMS-MODBUS for ISKRA with RS232 OPTICAL PROBES P/N: GW-DLMS-OPT-ISK

INFORMATICA GRAFICA!

Finite Model Theory / Descriptive Complexity: bin

Gateway DLMS-MODBUS for ISKRA with RS232 P/N: GW-DLMS-232-LG

Tabella 2.2 Indice delle proprietà Nome Valori Pr El Er Cp

WELCOME UNIPA REGISTRATION:

RelAirConf. Configuration Software for the Wireless-To-Wired M-Bus Gateways RelAir R2M Home / Pro. User Manual

Istruzioni di montaggio ferramenta per scorrevoli

Computer Graphics. Realtà Virtuale: il presente, il passato, 3D il Graphics futuro

IINFORMATION REQUIRED TERMS OF DELIVERY

istruzioni montaggio assembly instructions

Affare Bitcoin. Pagare Col P2p E Senza Banche Centrali (Italian Edition) [Kindle Edition] By Gabriele De Palma

Amazon Kindle Publishing Guidelines for Kindle Plugin for Adobe InDesign 0.973

Corso di Grafica Computazionale

Video Master Class 3dsmax 2016 Interfaccia Versione Cd Front

U Corso di italiano, Lezione Diciassette

BACnet IoT Gateway. Access BACnet Data From the Cloud! Copyright 2014 Sierra Monitor Corporation. Copyright 2018 Sierra Monitor Corporation 1

WELCOME. Go to the link of the official University of Palermo web site Click on the box on the right side Login unico

Sun paths in the sky. Solar diagrams and obstructions: shading systems design. Sun paths in the sky. Sun paths in the sky

LIGHTING INTRODUZIONE DRAWING EVENT MANAGEMENT VIEWING DOUBLE BUFFERING Z-BUFFERING LIGHTING

Opera Aperta: Forma E Indeterminazione Nelle Poetiche Contemporanee (Tascabili Saggi) (Italian Edition) By Umberto Eco

Installation and Debugging Guidance

LA SACRA BIBBIA: OSSIA L'ANTICO E IL NUOVO TESTAMENTO VERSIONE RIVEDUTA BY GIOVANNI LUZZI

Principali tipi di layout. Approfondimento sul box model

Transcript:

Grafica Computazionale lezione34 Informatica e Automazione, "Roma Tre" May 27, 2010

Grafica Computazionale: Lezione 33 OpenGL examples Perspective projection Parallel projection Isomorphic viewport transformation Multiple viewports Color primitives Hidden surface removal Modeling transformation

Contents OpenGL examples Perspective projection Parallel projection Isomorphic viewport transformation Multiple viewports Color primitives Hidden surface removal Modeling transformation

OpenGL examples source Main reference:

OpenGL examples source Main reference: http://www.opengl.org

OpenGL examples source Main reference: http://www.opengl.org http://www.opengl.org/resources/code/samples/redbook

OpenGL examples source Main reference: http://www.opengl.org http://www.opengl.org/resources/code/samples/redbook Geometric Programming for Computer Aided Design

OpenGL examples source Main reference: http://www.opengl.org http://www.opengl.org/resources/code/samples/redbook Geometric Programming for Computer Aided Design Nate Robins OpenGL Tutors

Nate Robins OpenGL Tutors Interactive (simple) programs to make experiments with the main topics of OpenGL programming

Nate Robins OpenGL Tutors Interactive (simple) programs to make experiments with the main topics of OpenGL programming Go to the Tutors site and explore it

Nate Robins OpenGL Tutors Interactive (simple) programs to make experiments with the main topics of OpenGL programming Go to the Tutors site and explore it download the [zipped archive]

Nate Robins OpenGL Tutors Interactive (simple) programs to make experiments with the main topics of OpenGL programming Go to the Tutors site and explore it download the [zipped archive] compile the whole

Nate Robins OpenGL Tutors Interactive (simple) programs to make experiments with the main topics of OpenGL programming Go to the Tutors site and explore it download the [zipped archive] compile the whole

Nate Robins OpenGL Tutors Interactive (simple) programs to make experiments with the main topics of OpenGL programming Go to the Tutors site and explore it download the [zipped archive] compile the whole 1. unzip the archive

Nate Robins OpenGL Tutors Interactive (simple) programs to make experiments with the main topics of OpenGL programming Go to the Tutors site and explore it download the [zipped archive] compile the whole 1. unzip the archive 2. $ cd (to it from terminal)

Nate Robins OpenGL Tutors Interactive (simple) programs to make experiments with the main topics of OpenGL programming Go to the Tutors site and explore it download the [zipped archive] compile the whole 1. unzip the archive 2. $ cd (to it from terminal) 3. $ make (compile and build)

Nate Robins OpenGL Tutors Interactive (simple) programs to make experiments with the main topics of OpenGL programming Go to the Tutors site and explore it download the [zipped archive] compile the whole 1. unzip the archive 2. $ cd (to it from terminal) 3. $ make (compile and build) 4. $./name (play with the executables :o)

Contents OpenGL examples Perspective projection Parallel projection Isomorphic viewport transformation Multiple viewports Color primitives Hidden surface removal Modeling transformation

Your first perspective (cube.py) from OpenGL.GL import * from OpenGL.GLU import * from OpenGL.GLUT import * def init(): glclearcolor(o.o, 0.0, 0.0, 0.0) glshademodel(gl FLAT) def display ( ) : glclear(gl COLOR BUFFER BIT) gicolor3f(i.0, 1 0, 1.0) giloadldentity() #/* clear the matrix */ #/* viewing transformation */ glulookat(o.o, 0.0, 5.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0) giscalef(l.o, 2.0, 1.0) #/* modeling transformation */ glutwirecube(l.o) glflush( ) def reshape(w, h): giviewport(o, 0, w, h) glmatrixmode(gl PROJECTION) glloadidentity() glfrustum(-l.o, 1.0, -1.0, 1.0, 1.5, 20.0) glmatrixmode(gl MODELVIEW) # Main program entry point if name ",,,, " main " : -- -- glutlnit() glutlnitdisplaymode(glut_single I GLUT RGB) glutlnitwindowsize(soo, 500) glutlnitwindowposition(loo, 100) glutcreatewindow( "cube") init() glutdisplayfunc(display) glutreshapefunc(reshape) glutmainloop( )

Play with the resulting window

Play with the resulting window One-point perspective projection

Play with the resulting window One-point perspective projection

Play with the resulting window One-point perspective projection notice that the Viewport transformation, from Normalized device coordinates to Window coordinates:

Play with the resulting window One-point perspective projection notice that the Viewport transformation, from Normalized device coordinates to Window coordinates: is Non-isomorphic

glulookat glulookat(eyex, eyey, eyez, centerx, centery, centerz, upx, upy, upz ) None Parameters eyex, eyey, eyez Specifies the position of the eye point. centerx, centery, centerz Specifies the position of the reference point. upx, upy, upz Specifies the direction of the up vector.

glulookat Description glulookat creates a viewing matrix derived from an eye point, a reference point indicating the center of the scene, and an UP vector. The matrix maps the reference point to the negative z axis and the eye point to the origin

glulookat Description glulookat creates a viewing matrix derived from an eye point, a reference point indicating the center of the scene, and an UP vector. The matrix maps the reference point to the negative z axis and the eye point to the origin When a typical projection matrix is used, the center of the scene therefore maps to the center of the viewport

glulookat Description glulookat creates a viewing matrix derived from an eye point, a reference point indicating the center of the scene, and an UP vector. The matrix maps the reference point to the negative z axis and the eye point to the origin When a typical projection matrix is used, the center of the scene therefore maps to the center of the viewport Similarly, the direction described by the UP vector projected onto the viewing plane is mapped to the positive y axis so that it points upward in the viewport

glulookat Description glulookat creates a viewing matrix derived from an eye point, a reference point indicating the center of the scene, and an UP vector. The matrix maps the reference point to the negative z axis and the eye point to the origin When a typical projection matrix is used, the center of the scene therefore maps to the center of the viewport Similarly, the direction described by the UP vector projected onto the viewing plane is mapped to the positive y axis so that it points upward in the viewport The UP vector must not be parallel to the line of sight from the eye point to the reference point.

Perspective projections What viewing model (COP, VRP, VUV) when setting (function glulookat) for:

Perspective projections What viewing model (COP, VRP, VUV) when setting (function glulookat) for: a one-point projection?

Perspective projections What viewing model (COP, VRP, VUV) when setting (function glulookat) for: a one-point projection? a two-point projection?

Perspective projections What viewing model (COP, VRP, VUV) when setting (function glulookat) for: a one-point projection? a two-point projection? a three-point projection?

Perspective projections What viewing model (COP, VRP, VUV) when setting (function glulookat) for: a one-point projection? a two-point projection? a three-point projection?

Perspective projections What viewing model (COP, VRP, VUV) when setting (function glulookat) for: a one-point projection? a two-point projection? a three-point projection? PLEASE experiment with...!!

glfrustum glfrustum(left, right, bottom, top, znear, zfar) None Parameters left, right Specify the coordinates for the left and right vertical clipping planes. bottom, top Specify the coordinates for the bottom and top horizontal clipping planes. nearval, farval Specify the distances to the near and far depth clipping planes. Both distances must be positive.

glfrustum Description (deprecated since 3.0) glfrustum describes a perspective matrix that produces a perspective projection. The current matrix (see glmatrixmode) is multiplied by this matrix and the result replaces the current matrix

glfrustum Description (deprecated since 3.0) glfrustum describes a perspective matrix that produces a perspective projection. The current matrix (see glmatrixmode) is multiplied by this matrix and the result replaces the current matrix Typically, the matrix mode is GL_PROJECTION

glfrustum Description (deprecated since 3.0) glfrustum describes a perspective matrix that produces a perspective projection. The current matrix (see glmatrixmode) is multiplied by this matrix and the result replaces the current matrix Typically, the matrix mode is GL_PROJECTION (left bottom, nearval) and (right top, nearval) specify the points on the near clipping plane that are mapped to the lower left and upper right corners of the window, assuming that the eye is located at (0, 0, 0).

glfrustum Description (deprecated since 3.0) glfrustum describes a perspective matrix that produces a perspective projection. The current matrix (see glmatrixmode) is multiplied by this matrix and the result replaces the current matrix Typically, the matrix mode is GL_PROJECTION (left bottom, nearval) and (right top, nearval) specify the points on the near clipping plane that are mapped to the lower left and upper right corners of the window, assuming that the eye is located at (0, 0, 0). farval specifies the location of the far clipping plane. Both nearval and farval must be positive.

Contents OpenGL examples Perspective projection Parallel projection Isomorphic viewport transformation Multiple viewports Color primitives Hidden surface removal Modeling transformation

Your first axonometric projection (cube1.py) from OpenGL.GL import * from OpenGL.GLU import * from OpenGL.GLUT import * def init(): glclearcolor(o.o, 0.0, 0.0, 0.0) glshademodel(gl FLAT) def display(): glclear(gl_color_buffer_bit) glcolor3f (1.0, 1.0, 1.0) glloadidentity() #/* clear the matrix */ #/* viewing transformation */ glulookat(5.0, 5.0, 5.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0) glscalef(l.0, 2.0, 1.0) #/* modeling transformation */ glutwirecube(l.0) glflush( ) def reshape(w, h): glviewport(o, 0, w, h) glmatrixmode(gl PROJECTION) glloadidentity() glortho(-4.0, 4.0, -4.0, 4.0, 1.5, 20.0) glmatrixmode(gl MODELVIEW) # Main program entry point if name " main ": glutinit( ) glutinitdisplaymode(glut SINGLE glutinitwindowsize(400, 400) glutinitwindowposition(940, 0) glutcreatewindow( "cube") ini t () glutdisplayfunc(display) glutreshapefunc(reshape) glutmainloop( ) I GLUT_RGB)

Play with the window...

Play with the window... isometric parallel projection

Play with the window... isometric parallel projection

Play with the window... isometric parallel projection notice AGAIN that the Viewport transformation, from Normalized device coordinates to Window coordinates:

Play with the window... isometric parallel projection notice AGAIN that the Viewport transformation, from Normalized device coordinates to Window coordinates: is Non-isomorphic

Contents OpenGL examples Perspective projection Parallel projection Isomorphic viewport transformation Multiple viewports Color primitives Hidden surface removal Modeling transformation

"Isomorphic" viewport transformation def display(): glclear(gl_color_buffer_bit) glcolor3f(1.0, 1.0, 1.0) glloadidentity() #/* clear the matrix */ #/* viewing transformation */ glulookat(1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0) glutwirecube(1.0) glflush() def reshape(w, h): glviewport(o, 0, w, h) aspectratio = float(w) / float(h) if (w <= h): u,v = 1,1/aspectRatio else: u,v = aspectratio, 1 glmatrixmode(gl PROJECTION) glloadidentity() glortho(-1.0*u, 1.0*u, -1.0*v, 1.0*v, 0.01, 20.0) glmatrixmode(gl MODELVIEW) Unit cube in isometric parallel projection

The Viewport transformation is now isomorphic...

The Viewport transformation is now isomorphic... play with the window aspect ratio...

The Viewport transformation is now isomorphic... play with the window aspect ratio...

The Viewport transformation is now isomorphic... play with the window aspect ratio... isometric parallel projection

Parallel projections What viewing model (DOP, VRP, VUV) when setting (function glulookat) for:

Parallel projections What viewing model (DOP, VRP, VUV) when setting (function glulookat) for: isometric orthogonal projection?

Parallel projections What viewing model (DOP, VRP, VUV) when setting (function glulookat) for: isometric orthogonal projection? (standard) dimetric orthogonal projection?

Parallel projections What viewing model (DOP, VRP, VUV) when setting (function glulookat) for: isometric orthogonal projection? (standard) dimetric orthogonal projection? (standard) three-metric orthogonal projection?

Parallel projections What viewing model (DOP, VRP, VUV) when setting (function glulookat) for: isometric orthogonal projection? (standard) dimetric orthogonal projection? (standard) three-metric orthogonal projection?

Parallel projections What viewing model (DOP, VRP, VUV) when setting (function glulookat) for: isometric orthogonal projection? (standard) dimetric orthogonal projection? (standard) three-metric orthogonal projection? PLEASE experiment with...!!

Parallel projections PROBLEM What about the OBLIQUE projections?

Parallel projections PROBLEM What about the OBLIQUE projections? isometric cavalier projections?

Parallel projections PROBLEM What about the OBLIQUE projections? isometric cavalier projections? dimetric cabinet projections?

Parallel projections PROBLEM What about the OBLIQUE projections? isometric cavalier projections? dimetric cabinet projections?

Parallel projections PROBLEM What about the OBLIQUE projections? isometric cavalier projections? dimetric cabinet projections? PLEASE look the web (better: just THINK) and try with...!!

Contents OpenGL examples Perspective projection Parallel projection Isomorphic viewport transformation Multiple viewports Color primitives Hidden surface removal Modeling transformation

Multiple viewport rendering (cube2.py) (1/3) from OpenGL.GL import * from OpenGL.GLU import * from OpenGL.GLUT import * def init(): glclearcolor(o.o, 0.0, 0.0, 0.0) glshademodel(gl FLAT) glenable(gl_scissor_test) def scenemodel(): glscalef(3.0, 3.0, 3.0) #/* modeling transformation */ glutwirecube(l.o) def display(): global viewl,view2,view3,view4 global winwidth,winheigth glcolor3f(1.0, 1.0, 1.0) glloadidentity() #/* clear the matrix */ #/* viewing transformation */ w,h = winwidth,winheigth glscissor(o, 0, w/2, h/2) glclear(gl COLOR BUFFER BIT) glviewport(o, 0,-w/2, h72) glloadidentity() glulookat(*viewl) scenemodel()

Multiple viewport rendering (2/3) glscissor(w/2, 0, w/2, h/2) glclear(gl COLOR BUFFER BIT) glviewport(w/2, 0, w/2,-h/2) glmatrixmode(gl PROJECTION) glpushmatrix() glloadidentity() glortho(-4.0, 4.0, -4.0, 4.0, 1.5, 100.0) glmatrixmode(gl MODELVIEW) glloadidentity() glulookat(*view2) scenemodel() glmatrixmode(gl PROJECTION) glpopmatrix() glmatrixmode(gl MODELVIEW) glloadidentity() glscissor(o, h/2, w/2, h/2) glclear(gl COLOR BUFFER BIT) glviewport(o, h/2, w/2,-h/2) glloadidentity() glulookat(*view3) scenemodel() glscissor(w/2, h/2, w/2, h/2) glclear(gl COLOR BUFFER BIT) glviewport(w/2, h/2, w/2, h/2) glloadidentity() glulookat(*view4) scenemodel() glfiush()

Multiple viewport rendering (3/3) glscissor(w/2, h/2, w/2, h/2) glclear(gl COLOR BUFFER BIT) glviewport(w/2, h/2, w/2, h/2) glloadidentity() glulookat(*view4) scenemodel ( ) glflush( ) def reshape(w, h): global viewl,view2,view3,view4 global winwidth,winheigth winwidth,winheigth = w,h glmatrixmode(gl PROJECTION) glloadidentity() glfrustum( -1. 0, 1. 0, -1. 0, 1. 0, 1. 5, 100.0) glmatrixmode(gl MODELVIEW) view3 - (0.0, 0.0, 6.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0) view4 = (3.0, 0.0, 5.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0) viewl = (3.0, 2.0, 5.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0) view2 = (5.0, 5.0, 5.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0) winwidth, winheigth = 0, 0 # Main program entry point if name " main " : glutinit( ) glutinitdisplaymode(glut SINGLE I GLUT_RGB) glutinitwindowsize(soo, 500) glutinitwindowposition(940, 0) glutcreatewindow( "cube") ini t ( ) glutdisplayfunc(display) glutreshapefunc(reshape) glutmainloop( )

Multiple viewport rendering (non-isomorphic)

glscissor glscissor(x, y, width, height) None Definethe scissorbox Parameters x, y Specify the lower left corner of the scissor box. Initially (0, 0). width, height Specify the width and height of the scissor box. When a GL context is first attached to a window, width and height are set to the dimensions of that window.

glscissor Description glscissor defines a rectangle, called the scissor box, in window coordinates. The first two arguments, x and y, specify the lower left corner of the box. width and height specify the width and height of the box. To enable and disable the scissor test, call glenable and gldisable with argument GL_SCISSOR_TEST.

glscissor Description glscissor defines a rectangle, called the scissor box, in window coordinates. The first two arguments, x and y, specify the lower left corner of the box. width and height specify the width and height of the box. To enable and disable the scissor test, call glenable and gldisable with argument GL_SCISSOR_TEST.

glscissor Description glscissor defines a rectangle, called the scissor box, in window coordinates. The first two arguments, x and y, specify the lower left corner of the box. width and height specify the width and height of the box. To enable and disable the scissor test, call glenable and gldisable with argument GL_SCISSOR_TEST. The test is initially disabled. While the test is enabled, only pixels that lie within the scissor box can be modified by drawing commands.

glscissor Description glscissor defines a rectangle, called the scissor box, in window coordinates. The first two arguments, x and y, specify the lower left corner of the box. width and height specify the width and height of the box. To enable and disable the scissor test, call glenable and gldisable with argument GL_SCISSOR_TEST. The test is initially disabled. While the test is enabled, only pixels that lie within the scissor box can be modified by drawing commands. glscissor(0,0,1,1) allows modification of only the lower left pixel in the window, and glscissor(0,0,0,0) doesn t allow modification of any pixels in the window.

glscissor Description glscissor defines a rectangle, called the scissor box, in window coordinates. The first two arguments, x and y, specify the lower left corner of the box. width and height specify the width and height of the box. To enable and disable the scissor test, call glenable and gldisable with argument GL_SCISSOR_TEST. The test is initially disabled. While the test is enabled, only pixels that lie within the scissor box can be modified by drawing commands. glscissor(0,0,1,1) allows modification of only the lower left pixel in the window, and glscissor(0,0,0,0) doesn t allow modification of any pixels in the window. When the scissor test is disabled, it is as though the scissor box includes the entire window.

isomorphic multi-viewport (1/2) cube3.py... def init(): glclearcolor(1.0, 1.0, 1.0, 1.0) glcolor3f(0.0, 0.0, 0.0) glshademodel(gl_flat) glenable(gl_scissor_test) def scenemodel() : glscalef(3.0, 3.0, 3.0) #/* modeling transformation */ glutwirecube(1.0) def display(): global view1,view2,view3,view4 global winwidth,winheigth w,h = winwidth,winheigth aspectratio = float(w) / float(h) if (w <= h): u,v = 1,1/aspectRatio else: u,v = aspectratio, 1 glmatrixmode(gl_projection) glloadldentity() glfrustum(-1.0*u, 1.0*u, -1.0*v, 1.0*v, 1.5, 100.0) glmatrixmode(gl_modelview) glloadldentity()...

isomorphic multi-viewport (2/2)... glmatrixmode(gl PROJECTION) glpushmatrix( ) glloadidentity() glortho(-4.0*u, 4.0*u, -4.0*v, 4.0*v, 1.5, 100.0) glmatrixmode(gl MODELVIEW) glloadidentity() glulookat(*view2) scenemodel ( ) glmatrixmode(gl PROJECTION) glpopmatrix( ) glmatrixmode(gl MODELVIEW) glloadidentity() glflush( ) def reshape(w, h): global viewl,view2,view3,view4 global winwidth,winheigth winwidth,winheigth = w,h...

isomorphic multi-viewport...

Contents OpenGL examples Perspective projection Parallel projection Isomorphic viewport transformation Multiple viewports Color primitives Hidden surface removal Modeling transformation

Color primitives (1/2) cube4.py def scenemodel(): glscalef(1.5, 1.5, 1.5) #/* modeling transformation */ glbegin(gl QUADS); glcolor3f(0.0,1.0,0.0) glvertex3f( 1.0, 1.0,-1.0) glvertex3f(-1.0, 1.0,-1.0) glvertex3f(-1.0, 1.0, 1.0) glvertex3f( 1.0, 1.0, 1.0) glcolor3f(1.0,0.5,0.0) glvertex3f( 1.0,-1.0, 1.0) glvertex3f(-1.0,-1.0, 1.0) glvertex3f(-1.0,-1.0,-1.0) glvertex3f( 1.0,-1.0,-1.0) glcolor3f(1.0,0.0,0.0) glvertex3f( 1.0, 1.0, 1.0) glvertex3f(-1.0, 1.0, 1.0) glvertex3f(-1.0,-1.0, 1.0) glvertex3f( 1.0,-1.0, 1.0) glcolor3f(1.0,1.0,0.0) glvertex3f( 1.0,-1.0,-1.0) glvertex3f(-1.0,-1.0,-1.0) glvertex3f(-1.0, 1.0,-1.0) glvertex3f( 1.0, 1.0,-1.0) glcolor3f(0.0,0.0,1.0) glvertex3f(-1.0, 1.0, 1.0) glvertex3f(-1.0, 1.0,-1.0) glvertex3f(-1.0,-1.0,-1.0) glvertex3f(-1.0,-1.0, 1.0) glcolor3f(1.0,0.0,1.0) glvertex3f( 1.0, 1.0,-1.0) glvertex3f( 1.0, 1.0, 1.0) glvertex3f( 1.0,-1.0, 1.0) glvertex3f( 1.0,-1.0,-1.0) glend()

Color primitives (2/2) glpushmatrix() glscalef(2, 2, 2) glcolor3f(1.0, 1.0, 1.0) glutwirecube(1.0) glpopmatrix() glutswapbuffers() def display(): global view1,view2,view3,view4 global winwidth,winheigth w,h = winwidth,winheigth aspectratio = float(w) / float(h) if (w <= h): u,v = 1,1/aspectRatio else: u,v = aspectratio, 1 glmatrixmode(gl PROJECTION) glloadidentity() glfrustum(-1.0*u, 1.0*u, -1.0*v, 1.0*v, 1.5, 10.0) glmatrixmode(gl MODELVIEW) glloadidentity() glscissor(o, 0, w/2, h/2) glclear(gl COLOR BUFFER BIT) glviewport(o, 0,-w/2, h72) glloadidentity() glulookat(*view1) scenemodel()

Color primitives (no depth-ordering of quads) Notice that at least one of the faces is covered by the others

Contents OpenGL examples Perspective projection Parallel projection Isomorphic viewport transformation Multiple viewports Color primitives Hidden surface removal Modeling transformation

Hidden surface removal (cube5.py) def init(): glclearcolor(1.0, loo, loo, 1.0) glcolor3f(0.o, 0.0, 1.0) glshademodel(gl_flat) glenable(gl_scissor_test) glenable(gl_depth_test) glscissor(o, 0, w/2, h/2) glclear(gl COLOR BUFFER BIT I glviewport(o, 0,-w/2, h72) glloadidentity() glulookat(*viewl) scenemodel() GL_DEPTH_BUFFER_BIT) # Main program entry point if name ",,,, " main " : - - glutlnit( ) glutlnitdisplaymode(glut DOUBLE I GLUT RGB I GLUT_DEPTH) glutlnitwindowsize(500, 500) glutlnitwindowposition(940, 0) glutcreatewindow( "cube")

Hidden surface removal The only visible faces are drawn (z-buffer algorithm)

Contents OpenGL examples Perspective projection Parallel projection Isomorphic viewport transformation Multiple viewports Color primitives Hidden surface removal Modeling transformation

Interactive model rotation via arrow keys (1/2) cube5.py

Interactive model rotation via arrow keys (2/2)

Modeling transformations Let us play with arrow key rotations... :o)

Exercises PROBLEM 1 add interactive model scaling to the above PROBLEM 2 build a more complex structured world (a room with table and chairs?) PROBLEM 3 create an articulated lamp model PROBLEM 4 Define a viewport transformation that maps isomorphically the biggest possible image (of any world and with any projection) within the window