FUNDAMENTALS OF PROGRAMMING SM1204 Semester A 2011.

Slides:



Advertisements
Similar presentations
Computer Graphics - Viewing -
Advertisements

02/17/05CISC640/440 OpenGL Tutorial1 OpenGL Tutorial CISC 640/440 Computer Graphics TA: Qi Li/Mani Thomas
Introduction to Programming
A Quick Introduction to Processing
Grundaufbau import processing.core.PApplet; public class Proc_Minimal extends PApplet { public void setup(){ size(1024, 768); frameRate(60.0f);
Translation and Rotation in 2D and 3D David Meredith Aalborg University.
CS 4363/6353 INTRODUCTION TO COMPUTER GRAPHICS. WHAT YOU’LL SEE Interactive 3D computer graphics Real-time 2D, but mostly 3D OpenGL C/C++ (if you don’t.
Viewing and Transformation
Viewing and Projections
CS 352: Computer Graphics Chapter 5: Viewing. Interactive Computer GraphicsChapter Overview Specifying the viewpoint Specifying the projection Types.
, Fall 2006IAT 800 Lab 2: Polygons, Transformations, and Arrays.
Lecture 5 Monday, 29 June ENGINEERING GRAPHICS 1E7 Lecture 5: Isometric Projections.
OpenGL (II). How to Draw a 3-D object on Screen?
Development of Interactive 3D Virtual World Applications
CS 470 Introduction to Computer Graphics Basic 3D in OpenGL.
3D coordinate systems X Y Z Right-Hand Coordinate System X Y Z Left-Hand Coordinate System OpenGL uses this! Direct3D uses this!
CSE 381 – Advanced Game Programming Basic 3D Graphics
Advanced Computer Graphics Three Dimensional Viewing
Rujchai Ung-arunyawee Department of Computer Engineering Khon Kaen University.
Week 2 - Wednesday CS361.
Geometric transformations The Pipeline
CS559: Computer Graphics Lecture 9: Projection Li Zhang Spring 2008.
Viewing Angel Angel: Interactive Computer Graphics5E © Addison-Wesley
March 5, Quiz Monday on the following:
Rendering Overview CSE 3541 Matt Boggus. Rendering Algorithmically generating a 2D image from 3D models Raster graphics.
CAP 4703 Computer Graphic Methods Prof. Roy Levow Chapter 5.
Foundations of Computer Graphics (Fall 2012) CS 184, Lecture 4: Transformations 2
Computer Graphics Bing-Yu Chen National Taiwan University.
Review Inheritance Overloading and overriding. example1.pde.
OpenGL The Viewing Pipeline: Definition: a series of operations that are applied to the OpenGL matrices, in order to create a 2D representation from 3D.
OpenGL Viewing and Modeling Transformation Geb Thomas Adapted from the OpenGL Programming Guidethe OpenGL Programming Guide.
Viewing and Transformation. Pixel pipeline Vertex pipeline Course Map Transformation & Lighting Primitive assembly Viewport culling & clipping Texture.
Review on Graphics Basics. Outline Polygon rendering pipeline Affine transformations Projective transformations Lighting and shading From vertices to.
The Camera Analogy ► Set up your tripod and point the camera at the scene (viewing transformation) ► Arrange the scene to be photographed into the desired.
CGGM Lab. Tan-Chi Ho 2001 Viewing and Transformation.
Projections. Viewports Windows can have separate viewports void glViewport(GLint x, GLint y, GLsizei width, GLsizei height ) x, y - Specify the lower.
______________________________________________________________________________________ SCHOOL OF INTERACTIVE ARTS + TECHNOLOGY [SIAT] |
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Classical Viewing Ed Angel Professor of Computer Science, Electrical and Computer Engineering,
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.
Classical Viewing Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts University of New Mexico.
Taxonomy of Projections FVFHP Figure Taxonomy of Projections.
Computer Science I 3D Classwork / Homework: plan and implement your own 3D example.
 Learn some important functions and process in OpenGL ES  Draw some triangles on the screen  Do some transformation on each triangle in each frame.
Chap 3 Viewing and Transformation
A Photograph of two papers

FUNDAMENTALS OF PROGRAMMING SM1204 SEMESTER A 2012.
CS559: Computer Graphics Lecture 9: 3D Transformation and Projection Li Zhang Spring 2010 Most slides borrowed from Yungyu ChuangYungyu Chuang.
Viewing and Projection. The topics Interior parameters Projection type Field of view Clipping Frustum… Exterior parameters Camera position Camera orientation.
Viewing Angel Angel: Interactive Computer Graphics5E © Addison-Wesley
Coordinate Systems Lecture 20 Wed, Oct 15, Object Coordinates Each object has its own “local” coordinate system, called object coordinates. Normally.
GLSL Review Monday, Nov OpenGL pipeline Command Stream Vertex Processing Geometry processing Rasterization Fragment processing Fragment Ops/Blending.
OpenGL LAB III.
CS 490: Computer Graphics Chapter 5: Viewing. Interactive Computer GraphicsChapter Overview Specifying the viewpoint Specifying the projection Types.
A Photograph of two papers The Model: 2 papers – 8cm x 8cm and 5cm x 5cm The Camera – Simple pinhole – No focusing capability The Scene – Arrangements.
Introduction to Computer Graphics
What you will learn about today
- Introduction - Graphics Pipeline
Projection Our 3-D scenes are all specified in 3-D world coordinates
Chapter 14, Translate & Rotate
Polygons, Transformations, and Arrays
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.
CS451Real-time Rendering Pipeline
A Photograph of two papers
Class 12 Complex object with moving parts
What you will learn about today
Type of View Perspective View COP(Center of Plane) Diminution of size
Computer Graphics 3Practical Lesson
Chapter 3 Viewing.
Presentation transcript:

FUNDAMENTALS OF PROGRAMMING SM1204 Semester A 2011

3D Programming in Processing

3D Programming  First Step: Select rendering engine  size(w, h, P3D); OR size (w, h, OPENGL);  P3D (Processing 3D) - Fast 3D renderer for the web. Sacrifices rendering quality for quick 3D drawing.  OPENGL - High speed 3D graphics renderer that makes use of OpenGL-compatible graphics hardware is available.

Primitives 3D  light() - Sets the default ambient light, directional light, falloff, and specular values.  box() - A box with equal dimension on all sides is a cube.  sphere() - A sphere is a hollow ball made from tessellated triangles.  sphereDetial() - Controls the detail used to render a sphere by adjusting the number of vertices of the sphere.

Primitive 3D size(640, 360, P3D); background(0); lights(); noStroke(); pushMatrix(); translate(130, height/2, 0); rotateY(1.25); rotateX(-0.4); box(100); popMatrix(); noFill(); stroke(255); pushMatrix(); translate(500, height*0.35, -200); sphere(280); popMatrix();

Default Light float spin = 0.0; void setup() { size(640, 360, P3D); noStroke(); } void draw() { background(51); lights(); spin += 0.01; pushMatrix(); translate(width/2, height/2, 0); rotateX(PI/9); rotateY(PI/5 + spin); box(150); popMatrix(); }

Lights  pointLight() - Adds a point light.  spotLight() - Adds a spot light.  directionalLight() - Adds a directional light.  ambientLight() - Adds an ambient light.  Lights need to be included in the draw() to remain persistent in a looping program.

Default Light void setup() { size(640, 360, P3D); noStroke(); } void draw() { background(0); translate(width / 2, height / 2); // Orange point light on the right pointLight(150, 100, 0, // Color 200, -150, 0); // Position // Blue directional light from the left directionalLight(0, 102, 255, // Color 1, 0, 0); // The x-, y-, z-axis direction // Yellow spotlight from the front spotLight(255, 255, 109, // Color 0, 40, 200, // Position 0, -0.5, -0.5, // Direction PI / 2, 2); // Angle, concentration rotateY(map(mouseX, 0, width, 0, PI)); rotateX(map(mouseY, 0, height, 0, PI)); box(150); }

Vertices  beginShape(MODE )  endShape()  Using the beginShape() and endShape() functions allow creating more complex forms.  The MODEs available are POINTS, LINES, TRIANGLES, TRIANGLE_FAN, TRIANGLE_STRIP, QUADS, and QUAD_STRIP  vertex() - used to specify the vertex coordinates for points.

Vertices

Cubic Grid

Texture  texture() - Sets a texture to be applied to vertex points.  textureMode() - Sets the coordinate space for texture mapping (either IMAGE or NORMALIZED).

Camera  ortho() - Sets an orthographic projection and defines a parallel clipping volume.  perspective() - Sets a perspective projection applying foreshortening, making distant objects appear smaller than closer ones.  camera() - Sets the position of the camera through setting the eye position, the center of the scene, and which axis is facing upward.

Camera void setup() { size(640, 360, P3D); fill(204); } void draw() { lights(); background(0); // Change height of the camera with mouseY camera(30.0, mouseY, 220.0, // eyeX, eyeY, eyeZ 0.0, 0.0, 0.0, // centerX, centerY, centerZ 0.0, 1.0, 0.0); // upX, upY, upZ noStroke(); box(90); stroke(255); line(-100, 0, 0, 100, 0, 0); line(0, -100, 0, 0, 100, 0); line(0, 0, -100, 0, 0, 100); }

Ortho vs Perspective void setup() { size(640, 360, P3D); noStroke(); fill(204); } void draw() { background(0); lights(); if(mousePressed) { float fov = PI/3.0; float cameraZ = (height/2.0) / tan(PI * fov / 360.0); perspective(fov, float(width)/float(height), cameraZ/2.0, cameraZ*2.0); } else { ortho(-width/2, width/2, -height/2, height/2, -10, 10); } translate(width/2, height/2, 0); rotateX(-PI/6); rotateY(PI/3); box(160); }