Computer Graphics. Basic 3D Programming. Contents

Similar documents
CS354 Computer Graphics Viewing and Modeling

Computer Viewing. Prof. George Wolberg Dept. of Computer Science City College of New York

Computer Viewing Computer Graphics I, Fall 2008

Transformations (Rotations with Quaternions) October 24, 2005

2D and 3D Viewing Basics

CITSTUDENTS.IN VIEWING. Computer Graphics and Visualization. Classical and computer viewing. Viewing with a computer. Positioning of the camera

Describe the Orthographic and Perspective projections. How do we combine together transform matrices?

CSC Graphics Programming. Budditha Hettige Department of Statistics and Computer Science

OpenGL Transformations

Geometry: Outline. Projections. Orthographic Perspective

3D Graphics for Game Programming (J. Han) Chapter II Vertex Processing

Computer Graphics. Chapter 10 Three-Dimensional Viewing

Computer Viewing. CITS3003 Graphics & Animation. E. Angel and D. Shreiner: Interactive Computer Graphics 6E Addison-Wesley

Getting Started. Overview (1): Getting Started (1): Getting Started (2): Getting Started (3): COSC 4431/5331 Computer Graphics.

Fundamental Types of Viewing

1 Transformations. Chapter 1. Transformations. Department of Computer Science and Engineering 1-1

3D Viewing. With acknowledge to: Ed Angel. Professor of Computer Science, Electrical and Computer Engineering, and Media Arts University of New Mexico

The Viewing Pipeline adaptation of Paul Bunn & Kerryn Hugo s notes

Advanced Computer Graphics (CS & SE )

1 (Practice 1) Introduction to OpenGL

Overview. Viewing and perspectives. Planar Geometric Projections. Classical Viewing. Classical views Computer viewing Perspective normalization

Three-Dimensional Graphics III. Guoying Zhao 1 / 67

COMP3421. Introduction to 3D Graphics

Precept 2 Aleksey Boyko February 18, 2011

COMP3421. Introduction to 3D Graphics

MORE OPENGL. Pramook Khungurn CS 4621, Fall 2011

Viewing Transformation

COMP Computer Graphics and Image Processing. 5: Viewing 1: The camera. In part 1 of our study of Viewing, we ll look at ˆʹ U ˆ ʹ F ˆʹ S

Introduction to Computer Graphics 4. Viewing in 3D

// double buffering and RGB glutinitdisplaymode(glut_double GLUT_RGBA); // your own initializations

COMP3421. Introduction to 3D Graphics

Spring 2013, CS 112 Programming Assignment 2 Submission Due: April 26, 2013

Models and Architectures. Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts University of New Mexico

Viewing with Computers (OpenGL)

COMS 4160: Problems on Transformations and OpenGL

7. 3D Viewing. Projection: why is projection necessary? CS Dept, Univ of Kentucky

Models and Architectures

Graphics and Visualization

Wire-Frame 3D Graphics Accelerator IP Core. C Library Specification

Rasterization Overview

Getting Started. 1 st Week, Sun-Jeong Kim. Computer Graphics Applications

CS380: Computer Graphics Viewing Transformation. Sung-Eui Yoon ( 윤성의 ) Course URL:

CS559: Computer Graphics. Lecture 12: OpenGL Transformation Li Zhang Spring 2008

Computer Graphics (Basic OpenGL)

Lecture 3 Sections 2.2, 4.4. Mon, Aug 31, 2009

Lecture 9 Sections 2.6, 5.1, 5.2. Wed, Sep 16, 2009

CS 4204 Computer Graphics

Introduction to OpenGL Transformations, Viewing and Lighting. Ali Bigdelou

Introduction to Computer Graphics with WebGL

Three-Dimensional Viewing Hearn & Baker Chapter 7

Lecture 5: Viewing. CSE Computer Graphics (Fall 2010)

Viewing and Modeling

The View Frustum. Lecture 9 Sections 2.6, 5.1, 5.2. Robb T. Koether. Hampden-Sydney College. Wed, Sep 14, 2011

Introduction to OpenGL

OpenGL. 1 OpenGL OpenGL 1.2 3D. (euske) 1. Client-Server Model OpenGL

CS 381 Computer Graphics, Fall 2008 Midterm Exam Solutions. The Midterm Exam was given in class on Thursday, October 23, 2008.

Viewing. Reading: Angel Ch.5

Overview. By end of the week:

Notes on Assignment. Notes on Assignment. Notes on Assignment. Notes on Assignment

15. Clipping. Projection Transformation. Projection Matrix. Perspective Division

Computer graphics MN1

CIS 636 Interactive Computer Graphics CIS 736 Computer Graphics Spring 2011

Lecture 4. Viewing, Projection and Viewport Transformations

Transformation, Input and Interaction. Hanyang University

CSE4030 Introduction to Computer Graphics

One or more objects A viewer with a projection surface Projectors that go from the object(s) to the projection surface

Computer Graphics. Lecture 04 3D Projection and Visualization. Edirlei Soares de Lima.

Viewing transformations. 2004, Denis Zorin

Classical and Computer Viewing. Adapted From: Ed Angel Professor of Emeritus of Computer Science University of New Mexico

Transforms 3: Projection Christian Miller CS Fall 2011

5.8.3 Oblique Projections

Lecture 4 of 41. Lab 1a: OpenGL Basics

On the Midterm Exam. Monday, 10/17 in class. Closed book and closed notes. One-side and one page cheat sheet is allowed. A calculator is allowed

CS 381 Computer Graphics, Fall 2012 Midterm Exam Solutions. The Midterm Exam was given in class on Tuesday, October 16, 2012.

Chapter 3 - Basic Mathematics for 3D Computer Graphics

Blue colour text questions Black colour text sample answers Red colour text further explanation or references for the sample answers

Introduction to OpenGL Week 1

Objectives. Image Formation Revisited. Physical Approaches. The Programmer s Interface. Practical Approach. Introduction to OpenGL Week 1

Android and OpenGL. Android Smartphone Programming. Matthias Keil. University of Freiburg

Perspective transformations

Lecture 4 Advanced Computer Graphics (CS & SE )

Computer Graphics 7: Viewing in 3-D

Clipping and Scan Conversion

Models and The Viewing Pipeline. Jian Huang CS456

CIS 441/541: Introduction to Computer Graphics Lecture 14: OpenGL Basics

CSE452 Computer Graphics

Image Rendering. Rendering can be divided into three sub-problems. Image Formation The hidden surface problem visibility determination steps

Computer Graphics. Bing-Yu Chen National Taiwan University

Rendering. Part 1 An introduction to OpenGL

COMP Computer Graphics and Image Processing. a6: Projections. In part 2 of our study of Viewing, we ll look at. COMP27112 Toby Howard

CSC 470 Computer Graphics. Three Dimensional Viewing

CSC 470 Computer Graphics

Cameras (and eye) Ideal Pinhole. Real Pinhole. Real + lens. Depth of field

Chapter 8 Three-Dimensional Viewing Operations

CS 4204 Computer Graphics

Early History of APIs. PHIGS and X. SGI and GL. Programming with OpenGL Part 1: Background. Objectives

Visualizing Molecular Dynamics

3D Tree Generator. 3D Fractal Tree Generator. Konstantinos Seventekidis DEPARTMENT OF COMPUTER SCIENCE UNIVERSITY OF IOANNINA

CSC Graphics Programming. Budditha Hettige Department of Statistics and Computer Science

3D Viewing. CMPT 361 Introduction to Computer Graphics Torsten Möller. Machiraju/Zhang/Möller

Transcription:

Computer Graphics Basic 3D Programming September 21, 2005 Sun-Jeong Kim 1 http://www.hallym.ac.kr/~sunkim/teach/2005/cga Contents Cameras and objects Perspective projections Orthographic projections Viewing a cube Locating the camera Building objects Hidden surface removal Rotating a color cube Exercise Sun-Jeong Kim 2 http://www.hallym.ac.kr/~sunkim/teach/2005/cga

Cameras and Objects (1/3) Projection synthetic camera model projectors, center of projection, projection plane Sun-Jeong Kim 3 http://www.hallym.ac.kr/~sunkim/teach/2005/cga Cameras and Objects (2/3) Projection plane moved in front of the camera Sun-Jeong Kim 4 http://www.hallym.ac.kr/~sunkim/teach/2005/cga

Cameras and Objects (3/3) View frustum degree of freedom six parameters truncated pyramid clipping volume Sun-Jeong Kim 5 http://www.hallym.ac.kr/~sunkim/teach/2005/cga Perspective Projections General viewing projection plane anywhere in front of the camera void glfrustum(gldouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble near, GLdouble far) Sun-Jeong Kim 6 http://www.hallym.ac.kr/~sunkim/teach/2005/cga

Orthographic Projections (1/2) Direction of projection simple camera view frustum a right parallelepiped y x void glortho(gldouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble near, GLdouble far) z Sun-Jeong Kim 7 http://www.hallym.ac.kr/~sunkim/teach/2005/cga Orthographic Projections (2/2) Sun-Jeong Kim 8 http://www.hallym.ac.kr/~sunkim/teach/2005/cga

Viewing a Cube (1/3) GLUT Library glut.h (include), glut32.lib (lib), glut32.dll (system32) void glutwirecube(gldouble size) void glutsoildcube(gldouble size) Sun-Jeong Kim 9 http://www.hallym.ac.kr/~sunkim/teach/2005/cga Viewing a Cube (2/3) Sun-Jeong Kim 10 http://www.hallym.ac.kr/~sunkim/teach/2005/cga

Viewing a Cube (3/3) Sun-Jeong Kim 11 http://www.hallym.ac.kr/~sunkim/teach/2005/cga Result Viewing a Cube Sun-Jeong Kim 12 http://www.hallym.ac.kr/~sunkim/teach/2005/cga

Locating Camera (1/2) Setting position and orient of the camera within the world coordinate system eye point, at point, up vector void glulookat(gldouble eyex, GLdouble eyey, GLdouble eyez, GLdouble atx, GLdouble aty, GLdouble atz, GLdouble upx, GLdouble upy, GLdouble upz) Sun-Jeong Kim 13 http://www.hallym.ac.kr/~sunkim/teach/2005/cga Locating Camera (2/2) Sun-Jeong Kim 14 http://www.hallym.ac.kr/~sunkim/teach/2005/cga

Result Locating Camera Sun-Jeong Kim 15 http://www.hallym.ac.kr/~sunkim/teach/2005/cga Building Objects (1/5) Using arrays typedef Glfloat point3[3]; point3 vertices[8][3] = { { -1, -1, 1 }, { -1, 1, 1 }, { 1, 1, 1 }, { 1, -1, 1 }, { -1, -1, -1 }, { -1, 1, -1 }, { 1, 1, -1 }, { 1, -1, -1 } }; GLfloat colors[8][3] = { { 0, 0, 1 }, { 0, 1, 1 }, { 1, 1, 1 }, { 1, 0, 1 }, { 0, 0, 0 }, { 0, 1, 0 }, { 1, 1, 0 }, { 1, 0, 0 } }; 5 6 1 2 Quad(0, 3, 2, 1); Quad(1, 2, 6, 5); Quad(2, 3, 7, 6); Quad(3, 0, 4, 7); Quad(4, 5, 6, 7); Quad(5, 4, 0, 1); 4 7 0 3 Sun-Jeong Kim 16 http://www.hallym.ac.kr/~sunkim/teach/2005/cga

Building Objects (2/5) Sun-Jeong Kim 17 http://www.hallym.ac.kr/~sunkim/teach/2005/cga Building Objects (3/5) Sun-Jeong Kim 18 http://www.hallym.ac.kr/~sunkim/teach/2005/cga

Building Objects (4/5) Sun-Jeong Kim 19 http://www.hallym.ac.kr/~sunkim/teach/2005/cga Result Building Objects (1) Sun-Jeong Kim 20 http://www.hallym.ac.kr/~sunkim/teach/2005/cga

Building Objects (5/5) Sun-Jeong Kim 21 http://www.hallym.ac.kr/~sunkim/teach/2005/cga Result Building Objects (2) Sun-Jeong Kim 22 http://www.hallym.ac.kr/~sunkim/teach/2005/cga

Note Display List (1/2) Immediate mode: standard in OpenGL primitives are no longer in the system after passing through the OpenGL pipeline when redrawing the screen, we have to regenerate the primitives time consuming Retained mode display lists in OpenGL collections of primitives and other information can be stored avoiding costly regeneration problem Sun-Jeong Kim 23 http://www.hallym.ac.kr/~sunkim/teach/2005/cga Note Display List (2/2) Steps creating a new display list void glnewlist(gluint name, GLenum mode); void glendlist(); mode: GL_COMPILE, GL_COMPILE_AND_EXECUTE executing a display list void glcalllist(gluint name); deleting a display list display list cannot be changed!! void gldeletelists(gluint first, GLsizei number); Sun-Jeong Kim 24 http://www.hallym.ac.kr/~sunkim/teach/2005/cga

Hidden Surface Removal (1/2) Z-Buffer Algorithm depth buffer extra storage to store depth information Sun-Jeong Kim 25 http://www.hallym.ac.kr/~sunkim/teach/2005/cga Hidden Surface Removal (2/2) Sun-Jeong Kim 26 http://www.hallym.ac.kr/~sunkim/teach/2005/cga

Rotating a Cube Sun-Jeong Kim 27 http://www.hallym.ac.kr/~sunkim/teach/2005/cga Result Rotating a Cube Sun-Jeong Kim 28 http://www.hallym.ac.kr/~sunkim/teach/2005/cga

Exercise Rotate a cube in the reverse direction when the left button of a mouse is clicked Change the axis of the rotation when the following keys are pressed: x or X : the x-axis rotation y or Y : the y-axis rotation z or Z : the z-axis rotation Sun-Jeong Kim 29 http://www.hallym.ac.kr/~sunkim/teach/2005/cga