Graphische Primitive Punkte Geradenstücke (Liniensegmente) Polygone

Ähnliche Dokumente
Grundlegende Darstellungsfunktionen

Aufgabe. - Beispiel "Fahrt durch Blutgefäße":

OpenGL. Rendering: (Wiedergabe, Darstellung): Erzeugg. digitaler (Pixel-)Bilder aus log.-mathem. Modell-Beschreibungen.

Computergrafik 1 Übung

Kapitel 21: OpenGl 1

Computergrafik SS 2008 Oliver Vornberger. Kapitel 21: OpenGl

Übung: Computergrafik 1

Wo stehen wir? Geometrie Transformationen Viewing Beleuchtungsmodelle

Licht. Elektromagnetische Strahlung Emitter > Reflektor -> Auge. Sichtbares Spektrum: 400nm 700nm. Universität Frankfurt

Geometrische Primitive und Hidden Surface Removal

Programmierpraktikum 3D Computer Grafik

(6) Polygon Clipping. Vorlesung Computergraphik I S. Müller U N I V E R S I T Ä T KOBLENZ LANDAU

Technische Universität Dresden Fakultät Informatik Prof. Dr.-Ing.habil. Orlamünder. OpenGL. OpenGL. OpenGL000

OpenGL 2.0 Vertex Arrays

7.1 Polygon Offset. Anwendung - Darstellung von Polygonen als Teil von Oberflächen - Beispiel: Gradlinien auf der Erde - Schwierigkeit:

Tim Pommerening v0.0.1 (ohne Gewähr) Seite 1 von 6

Eine Einführung in OpenGL

Grafikprogrammierung (Echtzeitrendering)

Aufgaben und Lösungen

2.10 Lichtquellen und Beleuchtung

2.10 Lichtquellen und Beleuchtung

2.10 Lichtquellen und Beleuchtung

Einführung in die API OpenGL

Lichtquellen und Beleuchtung

(4) Polygon Clipping. Vorlesung Computergrafik T. Grosch

7.4 Tesselierung von Polygonen

Geometry Shader. Ausarbeitung im Rahmen des Seminars Echtzeit Rendering" Von Sebastian Jackel Franz Peschel. Geometry Shader 1

Einführung Grundlagen OpenGL Primitive Farbe Licht und Material Viewing Pipeline Demos

Klausur Computergrafik WS 2008 / 09

Advanced Computer Graphics 1. Übung

Grafikprogrammierung mit OpenGL


OpenGL. Kapitel Grundlagen

Klausur Computergrafik für Bachelor-Studierende SS 2013

(12) OpenGL-Pipeline. Vorlesung Computergraphik I S. Müller U N I V E R S I T Ä T KOBLENZ LANDAU

Klausur Computergrafik für Bachelor-Studierende SS Lösungshilfe

Klausur Computergrafik für Bachelor-Studierende SS 2018

Grafikprogrammierung mit OpenGL I

Polygon Offset. Anwendung - Darstellung von Polygonen als Teil von Oberflächen - Beispiel: Gradlinien auf der Erde - Schwierigkeit:

Klausur Computergrafik für Bachelor-Studierende SS Lösungshilfe

Computergrafik 1 Übung

OpenGL for Java OpenGL for Java Prof. Dr. V. Stahl

Klausur Computergrafik für Bachelor-Studierende WS 2009 / 10

Klausur Computergrafik für Bachelor-Studierende SS Lösungshilfe

2. Übung zu Computergraphik 2

Grafikprogrammierung mit OpenGL

(3) Buffer. Vorlesung Computergraphik II S. Müller U N I V E R S I T Ä T KOBLENZ LANDAU

Erste Schritte in OpenGL

Übungsstunde 7 zu Computergrafik 1

Computergraphik I Die Graphik-Pipeline &

Augmented Reality Einführung in GLUT

Einführung in OpenGL. Einführung in OpenGL

OpenGL Modelierung und Beleuchtung

Java 3D. Linien, Flächen und Objekte Axel Bartsch, Okt. 2002

Graphische Datenverarbeitung und Bildverarbeitung

CGVert. Projekt. 3D-Scannen. Multimarker Tracking. Triangulierung. Low-Cost Scanner P 4. Ball-Erkennung. 3D Positionsbestimmung. Kalmanfilter. CGVert.

Übung Augmented Reality Einführung in GLUT. Agenda (I)

Einführung in OpenGL. Thomas Kalbe Technische Universität Darmstadt.

DirectX und OpenGL. Proseminar Multimedia-Hardwareerweiterungen Michel Weimerskirch, 15. Februar 2006

Klausur Computergrafik für Bachelor-Studierende WS 2010 / 11

Texture Mapping Beispiel. Universität Frankfurt

Computergrafik SS 2012 Probeklausur Universität Osnabrück Henning Wenke, M. Sc. Sascha Kolodzey, B. Sc., Nico Marniok, B. Sc.

Das ausführbare Programm Bsp1.cfg, Bsp1.dof, Bsp1.dpr, Bsp1.res Projektdateien für Delphi 7 Prak.pas

Das OpenGL Utility Toolkit GLUT. Verwendung von GLUT

Zusammenfassung Graphische Daten Verarbeitung By Fabian Flohrmann

Der Unterschied zwischen beiden Modellen liegt lediglich in der Berechnung des spekularen Anteils, der sich bei Phong aus

(6) Fortgeschrittene GPU- Programmierung

8. Modelle für feste Körper

Computergrafik 1. Blatt 5

1.1 Verwendung von GLUT

Klausur Computergrafik WS 2007 / 08

Klausur Computergrafik WS 2007 / 08. Lösungshilfe

Aufgabe 2: Zweifacher de Casteljau

M. Pester 29. Ein konvexes d-polytop ist eine begrenzte d-dimensionale polyedrale Menge. (d = 3 Polyeder, d = 2 Polygon)

Klausur Computergrafik für Bachelor-Studierende SS 2017

Computergraphik Grundlagen

Klausur Computergrafik SS 2007

Wer bin ich. 1. Übung zu Computergraphik 2. Allgemeines zur Übung. OpenGL allgemeines. Aufbau OpenGL Programm. Hauptprogramm

Teil VIII. Grundlagen der Computergrafik

Geometrie I. Sebastian Redinger Informatik 2 Programmiersysteme Martensstraße Erlangen

Voronoi-Diagramme. Dr. Martin Nöllenburg Vorlesung Algorithmische Geometrie INSTITUT FÜR THEORETISCHE INFORMATIK FAKULTÄT FÜR INFORMATIK

Klausur Computergrafik für Bachelor-Studierende SS 2015

Intensivübung zu Algorithmen und Datenstrukturen

Gouraud-Schattierung Phong-Schattierung

Einführung OpenGL und GLUT WPF Spiele, Simulation und dynamische Systeme

Klausur Computergrafik für Bachelor-Studierende WS 2010 / 11. Lösungshilfe

Praktikum 4: Delegation

< hergeleitet. < war nach 1.9 mit Hilfe von Rechenregeln für

Vorlesung Algorithmen für hochkomplexe Virtuelle Szenen

Voronoi-Diagramme INSTITUT FÜR THEORETISCHE INFORMATIK FAKULTÄT FÜR INFORMATIK. Dr. Martin Nöllenburg Vorlesung Algorithmische Geometrie

Computergraphik Grundlagen

Darstellung runder Objekte in OpenGL ES. 1 Darstellung eines Zylinders oder Kegels. Inhaltsverzeichnis. Berechnen der Punkte.

Schattierung und Beleuchtung

Grundlagen der 3D-Computergrafik Programmieren mit OpenGL

Computergraphik 1 LU ( ) Ausarbeitung Abgabe 2

Geometrie I. Laura Lawniczak Hallo Welt -Seminar - LS 2

Transkript:

Graphische Primitive Punkte Geradenstücke (Liniensegmente) Polygone

Punkte glvertex3f (50.0, 50.0, 0.0) glvertex2f (50.0, 50.0) glvertex4f (50.0, 50.0, 0.0,1.0) GLfloat vect[3] = {50.0, 50.0, 0.0} glvertex3fv (vect)

Darstellung von Punkten I glbegin(gl_points); /* Liste von Punkten */ glvertex2f (50.0, 50.0) ; /* Punkt-Definition */ glvertex4f (-25.0, -25.0, 0.0, 1.0); /* */ glvertex4f (0.0, 0.0, 0.0,1.0); /* */ glvertex3f (319.0, -14.0, 0.0); /* */ glvertex3f (7.0, 3.0, 0.0); /* */ glvertex2f (-30.0, 12.0); /* */ glend(); /* Ende der Liste */

Darstellung von Punkten II

Darstellung von Punkten III glpointsize(7.0); /* Punktgröße definieren */ glbegin(gl_points); /* Liste von Punkten */ glvertex2f (50.0, 50.0) ; /* Punkt-Definition */ glvertex4f (-25.0, -25.0, 0.0, 1.0); /* */ glvertex4f (0.0, 0.0, 0.0,1.0); /* */ glvertex3f (319.0, -14.0, 0.0); /* */ glvertex3f (7.0, 3.0, 0.0); /* */ glvertex2f (-30.0, 12.0); /* */ glend(); /* Ende der Liste */

Darstellung von Punkten IV Inquiry-Funktion: GLfloat size[2]; /* min/max Größe */ GLfloat step; /* Schrittweite */ glgetfloatv (GL_POINT_RANGE, size); glgetfloatv (GL_POINT_SIZE_GRANULARITY, &step);

Darstellung von Punkten IV

Darstellung von Punkten V void display(void) { float angle, x, y; GLclampf b = 0.0; GLclampf g = 0.0; GLfloat size = 10.0; glclear(gl_color_buffer_bit); for (angle=0.0; angle <= PI; angle+= PI/20.0) //#define P I 3.1415 { x = 30*cos(angle); y = 30.0*sin(angle); glpointsize(size); //!!! glbegin(gl_points); glcolor3f (1.0, b, g); glvertex2f (x, y); glend(); size += 0.5; b += 0.05; g += 0.05; } /* end_for */ } glflush();

Geradenstücke I GLfloat vect[2] = {-30.0, 12.0} glbegin(gl_lines); /* Liste von Punkten */ glvertex2f (50.0, 50.0) ; /* Punkt-Definition */ glvertex4f (-25.0, -25.0, 0.0, 1.0); /* */ glvertex4f (0.0, 0.0, 0.0,1.0); /* */ glvertex3f (319.0, -14.0, 0.0); /* */ glvertex3f (7.0, 3.0, 0.0); /* */ glvertex2fv (vect); /* */ glend(); /* Ende der Liste */

Geradenstücke II

Geradenstücke III gllinewidth(5.0); glbegin(gl_lines); /* Liste von Punkten */ glvertex2f (50.0, 50.0) ; /* Punkt-Definition */ glvertex4f (-25.0, -25.0, 0.0, 1.0); /* */ glvertex4f (0.0, 0.0, 0.0,1.0); /* */ glvertex3f (19.0, -14.0, 0.0); /* */ glvertex3f (7.0, 3.0, 0.0); /* */ glvertex2f (-30.0, 12.0); /* */ glend(); /* Ende der Liste */

Geradenstücke IV Inquiries: GLfloat width_range[2]; GLfloat step; glgetfloatv (GL_LINE_WIDTH_RANGE, width_range); glgetfloatv (GL_LINE_WIDTH_GRANULARITY, &step);

Geradenstücke V

Geradenstücke VI void display(void) { float angle, x, y; GLclampf b = 0.0; GLclampf g = 0.0; glclear(gl_color_buffer_bit); gllinewidth(3.0); glbegin(gl_line_strip); for (angle=0.0; angle <= PI; angle+= PI/11.0) { x = 30*cos(angle); y = 30.0*sin(angle); glcolor3f (1.0, b, g); glvertex2f (x, y); b += 0.1; g += 0.1; } /* end_for */ glend(); /* Ende LINE_STRIP */ glflush(); }

Geradenstücke VII GL_LINES GL_LINE_STRIP GL_LINE_LOOP

Geradenstücke VIII Line Stippling

Geradenstücke IX Line Stippling void gllinestipple(glint factor, GLushort pattern); // 1 <=factor <= 255 Beispiel: gllinestipple (1, 0xAAAA); glenable(gl_line_stipple);... gldisable(gl_line_stipple);

void display(void) { GLfloat y; GLint factor = 1; GLushort pattern = 0x5555; Geradenstücke X Line Stippling // Varying Y coordinate // Stippling factor // Simple stipple pattern glclear(gl_color_buffer_bit); // Clear the window with current clearing color glenable(gl_line_stipple); // Enable stippling for(y = -40.0f; y <= 40.0f; y += 10.0f) { gllinestipple(factor,pattern); // Step up Y axis 10 units at a time // Reset the repetition factor and pattern glbegin(gl_lines); glvertex2f(-40.0f, y); glvertex2f(40.0f, y); glend(); factor++; } glflush(); // Flush drawing commands }

Geradenstücke XI Line Stippling

Polygone I Voraussetzungen eben Polygon ist Teilmenge einer Ebene einfach keine Schnittpunkte der Kanten konvex jede Strecke zwischen zwei Punkten des Polygon liegt vollständig innerhalb des Polygons. zweiseitig (front face, back face)

Polygone II Darstellung nur Eckpunkte (vertices) Umriß (outline) gefüllt mit oder ohne Muster (solid, stipple pattern) Voreinstellung: gleiche Darstellung für Vorder- und Rückseite

Polygone III Darstellung Einstellungen: void glpolygonmode(glenum face, Glenum mode) face: GL_FRONT_AND_BACK, GL_FRONT, GL_BACK) mode: GL_POINT, GL_LINE, GL_FILL Beispiele: glpolygonmode(gl_front, GL_FILL); glpolygonmode(gl_back, GL_LINE);

Polygone IV Definition von Vorder- und Rückseite Definition der Vorderseite durch geordnete Aufzählung der Eckpunkte: mathematisch positiv / in Gegenuhrzeigerrichtung (counterclockwise): mathematisch negativ / in Uhrzeigerrichtung (clockwise)

Polygone V Bestimmung von Vorder-/Rückseite in OpenGL Berechnung der Polygonfläche in geeigneten Koordinaten:

Polygone VI Definition der Vorderseite Definition durch Festlegung der Drehrichtung: void glfrontface( GLenum mode) mode: GL_CCW, GL_CW default: GL_CCW Beispiel: glfrontface (GL_CCW);

Polygone VIIa Darstellung glbegin(gl_triangle_fan); //Defined in counterclockwise order glvertex3f(0.0, 0.0, 0.0); for (i=0; i<=8; i++) { } if (i%2 == 0) glcolor3f (1.0, 0.0, 0.0); else glcolor3f (0.0, 1.0, 0.0); glvertex3f (cos(i*2*pi/8), sin(i*2*pi/8), 0.0); glend(); glbegin(gl_triangle_fan); //Defined in clockwise order glcolor3f (1.0, 0, 1.0); for (i=0; i>= -7; i--) glvertex3f (cos(i*2*pi/8)+1, sin(i*2*pi/8)+1, -1); glend();

Polygone VIIb Darstellung

Polygone VIII Polygon Stippling void glpolygonstipple(glubyte *mask) mask: pointer to 32x32 stipple pattern Beispiel: GLubyte pattern[128]; glpolygonstipple (pattern); glenable(gl_polygon_stipple). gldisable(gl_polygon_stipple)

Polygone VIIIa Polygon Stippling

Polygone IX GL_TRIANGLES GL_TRIANGLE_FAN GL_TRIANGLE_STRIP GL_QUADS GL_QUAD_STRIP GL_POLYGON void glrectw(glww x1, GLww y1, GLww x2, GLww y2) mit (w,ww){(d, double),( f, float), (i, int), (s,short)}

void draw_triangles (void) { int i; Polygone IXa glbegin(gl_triangles); //Defined in counterclockwise order for (i=0; i<8; i++) { if (i%2 == 0) glcolor3f (1.0, 1.0, 0.0); else glcolor3f (0.0, 1.0, 1.0); glvertex3f(0.0, 0.0, 0.0); glvertex3f (cos(i*2*pi/8), sin(i*2*pi/8), 0.0); glvertex3f (cos((i+1)*2*pi/8), sin((i+1)*2*pi/8), 0.0); } glend(); }

Polygone IXai

Polygone IXb void draw_triangle_fan (void) { int i; glbegin(gl_triangle_fan); //Defined in counterclockwise order glvertex3f(0.0, 0.0, 0.0); for (i=0; i<=8; i++) { if (i%2 == 0) glcolor3f (1.0, 0.0, 0.0); else glcolor3f (0.0, 1.0, 0.0); glvertex3f (cos(i*2*pi/8), sin(i*2*pi/8), 0.0); } glend(); }

Polygone IXbi

Polygone IXc void draw_triangle_strip (void) { int i; float phi = -1.0*PI; float r = 1.5; glbegin(gl_triangle_strip); //First triangle defined in counterclockwise order glvertex3f (r*sin(pi/4.0)*cos(phi), r*cos(pi/4.0), r*sin(pi/8.0)*sin(phi)); glvertex3f (r*sin(pi/2.0)*cos(phi), r*cos(pi/2.0), r*sin(pi/2.0)*sin(phi)); for (i=0; i<8; i++) { if (i%2 == 0) { glcolor3f (1.0, 1.0, 0.0); glvertex3f (r*sin(pi/4.0)*cos(phi-(i+1)*pi/8.0), r*cos(pi/4.0), r*sin(pi/4.0)*sin(phi-(i+1)*pi/8.0)); }

Polygone IXci else { glcolor3f (0, 1.0, 1.0); glvertex3f (r*sin(pi/2.0)*cos(phi-(i+1)*pi/8.0), r*cos(pi/2.0), r*sin(pi/2.0)*sin(phi-(i+1)*pi/8.0)); } } glcolor3f (1.0, 1.0, 0.0); glvertex3f (r*sin(pi/4.0)*cos(0.0), r*cos(pi/4.0), r*sin(pi/2.0)*sin(0.0)); glend(); }

Polygone IXcii

Polygone IXd void draw_quads (void) { int i; glbegin (GL_QUADS); for (i=0; i>=-8; i--) { if (i%2 == 0) glcolor3f (0.0, 0.0, 1.0); else glcolor3f (0.0, 1.0, 0.0); glvertex3f (cos(i*pi/4.0), sin(i*pi/4.0), 0); glvertex3f (0.5*cos(i*PI/4.0), 0.5*sin(i*PI/4.0), 1.5); glvertex3f (0.5*cos((i-1)*PI/4.0), 0.5*sin((i-1)*PI/4.0), 1.5); glvertex3f (cos((i-1)*pi/4.0), sin((i-1)*pi/4.0), 0); } glend(); }

Polygone IXdi

Polygone IXe void draw_quad_strip(void) { int i; glbegin (GL_QUAD_STRIP); for (i=0; i>=-8; i--) { if (i%2 == 0) glcolor3f (1.0, 1.0, 0.0); else glcolor3f (1.0, 1.0, 1.0); glvertex3f (cos(i*pi/4.0), sin(i*pi/4.0), 0); glvertex3f (0.5*cos(i*PI/4.0), 0.5*sin(i*PI/4.0), 1.5); } glend(); }

Polygone IXei

Rendering von Kanten: Polygone X Boundary Edges void gledgeflag (GLboolean flag) flag: GL_TRUE, GL_FALSE default: GL_TRUE Beispiel: gledgeflag (GL_TRUE); glvertex3f (.); gledgeflag (GL_FALSE) glvertex3f (.);

Rendering von Rückseiten: Polygone XI Back Face Culling glcullface(glenum mode) mode: GL_FRONT, GL_BACK, GL_FRONT_AND_BACK default: GL_BACK Beispiel: glcullface (GL_BACK) glenable (GL_CULL_FACE); gldisable(gl_cull_face);

Polygone XII Verdeckungsrechnung glutinitdisplaymode (GLUT_DEPTH ); glclear (GL_DEPTH_BUFFER_BIT ); glenable(gl_depth_test); gldisable(gl_depth_test);

Übungsaufgaben Aufgabe 2: Orientierung von Polygonen Geben Sie eine Herleitung für die Gleichung zur Bestimmung der Fläche eines Polygons aus der Vorlesung. Wie/warum hängt die so berechnete Fläche mit der Orientierung des Polygons im Raum zusammen? Aufgabe 3: Modellierung Entwickeln Sie Algorithmen, um die gebräuchlichen, drei-dimensionalen Grundkörper, wie Würfel, Kugel, Zylinder, Tetraeder, Torus mit den zwei-dimensionalen Primitiven von OpenGL zu approximieren. Schreiben Sie zu jedem Körper eine Routine draw_xxx() mit xxx {cube,.., torus).