Geometric Objects and Transformations. Graphics Pipeline How can we render a triangle? High-level description: – Represent the 3D geometry – Transform.

Slides:



Advertisements
Similar presentations
CS 4731: Computer Graphics Lecture 20: Raster Graphics Part 1 Emmanuel Agu.
Advertisements

3D Game Programming Geometric Transformations
Graphics Pipeline.
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2007 Tamara Munzner Viewing/Projections I.
INTRODUCTION. Painting with numbers! Aspects Modeling Rendering Animation.
Part I: Basics of Computer Graphics Viewing Transformation and Coordinate Systems Chapter
CS 352: Computer Graphics Chapter 5: Viewing. Interactive Computer GraphicsChapter Overview Specifying the viewpoint Specifying the projection Types.
Essentials of Interactive Computer Graphics: Concepts and Implementation K. Sung, P. Shirley, S. Baer Chapter 14 Chapter 14: The Camera.
1 Lecture 8 Clipping Viewing transformations Projections.
IAT 3551 Computer Graphics Overview Color Displays Drawing Pipeline.
Graphics Systems I-Chen Lin’s CG slides, Doug James’s CG slides Angel, Interactive Computer Graphics, Chap 1 Introduction to Graphics Pipeline.
3D Rendering with JOGL Introduction to Java OpenGL Graphic Library By Ricardo Veguilla
Course Overview, Introduction to CG Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Friday, September 5, 2003.
Introduction to 3D Computer Graphics and Virtual Reality McConnell text.
COMP 261 Lecture 14 3D Graphics 2 of 2. Doing better than 3x3? Translation, scaling, rotation are different. Awkward to combine them. Use homogeneous.
Geometry Shaders. Visualizing Normal Vectors  textbook calls this a “hedgehog plot” but (I think) that this is a misuse of the term  a hedgehog plot.
COMP 175: Computer Graphics March 24, 2015
UniS CS297 Graphics with Java and OpenGL Viewing, the model view matrix.
Technology and Historical Overview. Introduction to 3d Computer Graphics  3D computer graphics is the science, study, and method of projecting a mathematical.
Transformations Dr. Amy Zhang.
3D Objects Subject:T0934 / Multimedia Programming Foundation Session:12 Tahun:2009 Versi:1/0.
Week 2 - Wednesday CS361.
Camera. Content Coordinate systems and transformations Viewing coordinates Coordinate transformation matrix Projections Window and viewport Acknowledgments:
UW EXTENSION CERTIFICATE PROGRAM IN GAME DEVELOPMENT 2 ND QUARTER: ADVANCED GRAPHICS The Geometry Pipeline.
OpenGL Conclusions OpenGL Programming and Reference Guides, other sources CSCI 6360/4360.
CSE Real Time Rendering Week 2. Graphics Processing 2.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
COMPUTER GRAPHICS CSCI 375. What do I need to know?  Familiarity with  Trigonometry  Analytic geometry  Linear algebra  Data structures  OOP.
Exam Review Questions. Problem: A cube has vertices with world coordinates: (1, 0, 0) (2, 0, 0) (1, 1, 0) (2, 1, 0) (1, 0, 1) (2, 0, 1) (1, 1, 1) (2,
Shadow Mapping Chun-Fa Chang National Taiwan Normal University.
Geometric Objects and Transformation
Representation. Objectives Introduce concepts such as dimension and basis Introduce coordinate systems for representing vectors spaces and frames for.
Computer Graphics Chapter 6 Andreas Savva. 2 Interactive Graphics Graphics provides one of the most natural means of communicating with a computer. Interactive.
Viewing CS418 Computer Graphics John C. Hart. Graphics Pipeline Homogeneous Divide Model Coords Model Xform World Coords Viewing Xform Still Clip Coords.
Image Synthesis Rabie A. Ramadan, PhD 4. 2 Review Questions Q1: What are the two principal tasks required to create an image of a three-dimensional scene?
Jens Krüger & Polina Kondratieva – Computer Graphics and Visualization Group computer graphics & visualization 3D Rendering Praktikum: Shader Gallery The.
Review on Graphics Basics. Outline Polygon rendering pipeline Affine transformations Projective transformations Lighting and shading From vertices to.
Chapters 5 2 March Classical & Computer Viewing Same elements –objects –viewer –projectors –projection plane.
1 Angel: Interactive Computer Graphics5E © Addison- Wesley 2009 Image Formation Fundamental imaging notions Fundamental imaging notions Physical basis.
Rendering Pipeline Fall, D Polygon Rendering Many applications use rendering of 3D polygons with direct illumination.
컴퓨터 그래픽스 Real-time Rendering 1. Introduction.
Viewing and Projection
 Learn some important functions and process in OpenGL ES  Draw some triangles on the screen  Do some transformation on each triangle in each frame.
Jens Krüger & Polina Kondratieva – Computer Graphics and Visualization Group computer graphics & visualization GameFX C# / DirectX 2005 The Rendering Pipeline.
What are shaders? In the field of computer graphics, a shader is a computer program that runs on the graphics processing unit(GPU) and is used to do shading.
GL transformations-models. x' = x+t x y' = y+t y z' = z+t z t x t y s x =s y =s z t z uniform nonuniform?!!?? x' = x·s x y' =
GLSL I.  Fixed vs. Programmable  HW fixed function pipeline ▪ Faster ▪ Limited  New programmable hardware ▪ Many effects become possible. ▪ Global.
1 E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012 Computer Viewing Isaac Gang University of Mary Hardin-Baylor.
1 E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012 Models and Architectures 靜宜大學 資訊工程系 蔡奇偉 副教授 2012.
CS 490: Computer Graphics Chapter 5: Viewing. Interactive Computer GraphicsChapter Overview Specifying the viewpoint Specifying the projection Types.
4. Geometric Objects and Transformations
Modeling Transformations Mario Costa Sousa University of Calgary CPSC 453, Fall 2001 Mario Costa Sousa University of Calgary CPSC 453, Fall 2001.
COMPUTER GRAPHICS AND LINEAR ALGEBRA AN INTRODUCTION.
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2008 Tamara Munzner Viewing/Projections I.
Forward Projection Pipeline and Transformations CENG 477 Introduction to Computer Graphics.
Computer Graphics Overview
Modeling Transformations
Rendering Pipeline Fall, 2015.
Computer Graphics CC416 Week 14 3D Graphics.
- Introduction - Graphics Pipeline
2D Viewing Pipeline.
Modeling 101 For the moment assume that all geometry consists of points, lines and faces Line: A segment between two endpoints Face: A planar area bounded.
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2016
3D Graphics Rendering PPT By Ricardo Veguilla.
Models and Architectures
Introduction to Computer Graphics with WebGL
Angel: Interactive Computer Graphics5E © Addison-Wesley 2009
Viewing/Projections I Week 3, Fri Jan 25
Geometric Objects and Transformations (I)
Game Programming Algorithms and Techniques
Presentation transcript:

Geometric Objects and Transformations

Graphics Pipeline How can we render a triangle? High-level description: – Represent the 3D geometry – Transform it to a 2D image Our 3D objects are given as polygon meshes

Geometric Objects Which mathematical entities do we need? – Scalars – Points – Vectors

Geometric Objects – Scalars

Geometric Objects – Points

Geometric Objects – Vectors

Transformations Which transformations do we need? – Transform (e.g., rotate) a particular object – Transform all of the objects together – Transform the camera (position or viewing)

Transformations In fact, all of the following frames are needed: 1. Object (model) frame 2. World frame 3. Camera (eye) frame 4. Clip frame 5. Normalized device frame 6. Screen (window) frame 3D 2D

Transformations In fact, all of the following frames are needed: 1. Object (model) frame 2. World frame 3. Camera (eye) frame 4. Clip frame 5. Normalized device frame 6. Screen (window) frame Next Tutorial

Coordinate Systems vs. Frames

Frames

Changing Frames

Question How can we implement a “look at” feature? The camera should snap to a certain object Basically, a change of frames for the camera…

Visual Studio Project A C++ project with the following classes: – Model class: geometry, frame,... – Camera class: frame, projection, … – Scene class: stores objects, cameras, lights, … – Renderer class: renders the scene to an output – Math related classes

Visual Studio Project – Model Class class Model { protected: virtual ~Model() {} void virtual draw()=0; Geometry T; mat4 mTransform; };

Visual Studio Project – Camera Class class Camera { // constructors mat4 cTransform; mat4 projection; public: void setTransformation(const mat4& T); void setProjection(const mat4& T); void LookAt(…); void Ortho(…); void Perspective(…); … };

Visual Studio Project – Scene Class class Scene { vector models; vector cameras; renderer *m_renderer; public: Scene(Renderer *renderer); void AddModel(Model* model); void AddCamera(Model* model); Model* GetModel(int model_id); … void draw(); };

Visual Studio Project – Renderer Class class Renderer{ float *m_outBuffer; // 3*width*height float *m_zbuffer; // width*height int m_width, m_height; void CreateBuffers(int width, int height); public: //construction void Init(); void DrawTriangles(vector * vertices) void SetCameraTransform(mat4& cTransform); void SetProjection(mat4& projection); void SetObjectMatrix(mat4& oTransform, mat3& nTransform); void SwapBuffers(); }

Visual Studio Project – Vector Class class vec3 { public: GLfloat x; GLfloat y; GLfloat z; vec3( GLfloat s = GLfloat(0.0) ): x(s), y(s), z(s) {} vec3( GLfloat x, GLfloat y, GLfloat z ): x(x), y(y), z(z) {} …

Visual Studio Project – Vector Class vec3 operator + ( const vec3& v ) const { return vec3( x + v.x, y + v.y, z + v.z ); } vec3 operator * ( const GLfloat s ) const { return vec3( s*x, s*y, s*z ); } vec3 operator * ( const vec3& v ) const { return vec3( x*v.x, y*v.y, z*v.z ); }

Visual Studio Project – Matrix Class class mat2 { vec2 _m[2]; public: mat2( const GLfloat d = GLfloat(1.0) ){ _m[0].x = d; _m[1].y = d; } mat2( const vec2& a, const vec2& b ){ _m[0] = a; _m[1] = b; } mat2( GLfloat m00, GLfloat m10, GLfloat m01, GLfloat m11 ) { _m[0] = vec2( m00, m01 ); _m[1] = vec2( m10, m11 ); }

Visual Studio Project – Matrix Class mat2 operator + ( const mat2& m ) const { return mat2( _m[0]+m[0], _m[1]+m[1] ); } mat2 operator * ( const GLfloat s ) const { return mat2( s*_m[0], s*_m[1] ); } mat2 operator * ( const mat2& m ) const { mat2 a( 0.0 ); for ( int i = 0; i < 2; ++i ) for ( int j = 0; j < 2; ++j ) for ( int k = 0; k < 2; ++k ) a[i][j] += _m[i][k] * m[k][j]; return a; }

Suggested Readings Interactive Computer Graphics, Chapter 3 and Appendices B and C.