Computer Graphics Hands-on

Similar documents
Computer Graphics Hands-on

Transforms 1 Christian Miller CS Fall 2011

CS4202: Test. 1. Write the letter corresponding to the library name next to the statement or statements that describe library.

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

Outline. Introduction Surface of Revolution Hierarchical Modeling Blinn-Phong Shader Custom Shader(s)

Introduction to OpenGL

TIEA311 Tietokonegrafiikan perusteet kevät 2018

Two possible ways to specify transformations. Each part of the object is transformed independently relative to the origin

Due: Thursday, February 6 th, 11:59 pm TA: Mason Remy

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

Modeling with Transformations

Using GLU/GLUT Objects

HIERARCHICAL TRANSFORMATIONS A Practical Introduction

9. [20 points] A degree three Bezier curve q(u) has the four control points p 0 = 0,0, p 1 = 2,0, p 2 = 0,2, and p 3 = 4,4.

Computer Graphics Geometric Transformations

CSC 470 Computer Graphics

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

Due: Thursday, April 28 th by the stroke of midnight! TA: Jeff Booth

Hierarchical Modeling II. Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts University of New Mexico

GL_MODELVIEW transformation

Fall CSCI 420: Computer Graphics. 2.2 Transformations. Hao Li.

Computer Graphics. Chapter 7 2D Geometric Transformations

CIS 636 Interactive Computer Graphics CIS 736 Computer Graphics Spring 2011

OpenGL: Open Graphics Library. Introduction to OpenGL Part II. How do I render a geometric primitive? What is OpenGL

EECE 478. Learning Objectives. Learning Objectives. Linear Algebra and 3D Geometry. Linear algebra in 3D. Coordinate systems

COMP3421. Week 2 - Transformations in 2D and Vector Geometry Revision

Modeling Objects. Modeling. Symbol-Instance Table. Instance Transformation. Each appearance of the object in the model is an instance

Fachhochschule Regensburg, Germany, February 15, 2017

Transformations. CSCI 420 Computer Graphics Lecture 4

OpenGL: Setup 3D World

Rendering Pipeline and Coordinates Transforms

Lecture 5b. Transformation

HIERARCHICAL TRANSFORMATIONS A Practical Introduction

蔡侑庭 (Yu-Ting Tsai) National Chiao Tung University, Taiwan. Prof. Wen-Chieh Lin s CG Slides OpenGL 2.1 Specification

The Model Stack. Lecture 8. Robb T. Koether. Hampden-Sydney College. Wed, Sep 6, 2017

6.837 Computer Graphics Hierarchical Modeling Wojciech Matusik, MIT EECS Some slides from BarbCutler & Jaakko Lehtinen

COMP 175 COMPUTER GRAPHICS. Lecture 07: Scene Graph. COMP 175: Computer Graphics March 10, Remco Chang 07 Scene Graph

CS 4204 Computer Graphics

3D Viewing Episode 2

Hierarchical Modeling. University of Texas at Austin CS384G - Computer Graphics Fall 2010 Don Fussell

API for creating a display window and using keyboard/mouse interations. See RayWindow.cpp to see how these are used for Assignment3

Scene Graphs. CS4620/5620: Lecture 7. Announcements. HW 1 out. PA 1 will be out on Wed

Surface Graphics. 200 polys 1,000 polys 15,000 polys. an empty foot. - a mesh of spline patches:

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

HIERARCHICAL TRANSFORMATIONS A Practical Introduction

Review of Thursday. xa + yb xc + yd

Computer Graphics (CS 4731) Lecture 11: Implementing Transformations. Prof Emmanuel Agu. Computer Science Dept. Worcester Polytechnic Institute (WPI)

COMP3421. Week 2 - Transformations in 2D and Vector Geometry Revision

Computer Graphics (CS 543) Lecture 6a: Hierarchical 3D Models. Prof Emmanuel Agu. Computer Science Dept. Worcester Polytechnic Institute (WPI)

1/29/13. Computer Graphics. Transformations. Simple Transformations

Questions HW1 Transform Q/A. Transform. Shaoting Zhang. May 11, 2008

Computer Graphics (CS 4731) Lecture 11: Implementing Transformations. Prof Emmanuel Agu. Computer Science Dept. Worcester Polytechnic Institute (WPI)

Computer Graphics Hands-on

Graphics pipeline and transformations. Composition of transformations

12. Selection. - The objects selected are specified by hit records in the selection buffer. E.R. Bachmann & P.L. McDowell MV 4202 Page 1 of 13

CSE 690: GPGPU. Lecture 2: Understanding the Fabric - Intro to Graphics. Klaus Mueller Stony Brook University Computer Science Department

Transformations IV. Week 3, Wed Jan 20

E.Order of Operations

Chapter 3: Modeling Transformation

Exercise Max. Points Total 90

CS380: Computer Graphics 2D Imaging and Transformation. Sung-Eui Yoon ( 윤성의 ) Course URL:

6. Modelview Transformations

Reading. Hierarchical Modeling. Symbols and instances. Required: Angel, sections , 9.8. Optional:

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

Rendering a 3-Dimensional Cube Applet Using Light Weight Java Graphing Library (LWJGL) with Java Swing with NetBeans IDE 6.1

Cheating: In case of cheating, all parts involved (source(s) and receiver(s)) get zero.

Affine Transformations in 3D

DH2323 DGI16 Lab2 Transformations

Translation. 3D Transformations. Rotation about z axis. Scaling. CS 4620 Lecture 8. 3 Cornell CS4620 Fall 2009!Lecture 8

Transformations IV. Week 3, Mon Jan 22

GRAFIKA KOMPUTER. ~ M. Ali Fauzi

GRAPHICS & INTERACTIVE PROGRAMMING. Lecture 1 Introduction to Processing

CS 428: Fall Introduction to. Transformations in OpenGL + hierarchical modeling. Andrew Nealen, Rutgers, /21/2009 1

Hierarchical Modelling

Computer Graphics. Transformations. CSC 470 Computer Graphics 1

Hierarchy I. Guoying Zhao 1 / 40

2D ANIMATION & INTERACTION COURSE WEEK 5 QUICK REFERENCE

Computer graphics 2: Graduate seminar in computational aesthetics

Chapter 3 - Basic Mathematics for 3D Computer Graphics

3D Viewing Episode 2

OpenGL Transformations

Lecture 4 Advanced Computer Graphics (CS & SE )

OpenGL: A Practical Introduction. (thanks, Mark Livingston!)

CS 559 Computer Graphics Midterm Exam March 22, :30-3:45 pm

Hierarchical Modeling

CS559 Computer Graphics Fall 2015

Hierarchical Modeling

Preparation: Get to know the Java coordinate system. 3. How is the background color of the window specified? Copy the exact code:

Computer Graphics Seminar

On Your Own. ). Another way is to multiply the. ), and the image. Applications. Unit 3 _ _

Computer Graphics - Treasure Hunter

Lesson 1 Parametric Modeling Fundamentals

CSCI 4620/8626. The 2D Viewing Pipeline

Something noteworthy

Computer Graphics I. Midterm Examination. October 23, This is a closed-book exam; only one double-sided sheet of notes is permitted.

In this lesson, you ll learn how to:

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

Introduction to Computer Graphics with WebGL

CS559 Computer Graphics Fall 2015

Modeling Transform. Chapter 4 Geometric Transformations. Overview. Instancing. Specify transformation for objects 李同益

Transcription:

Computer Graphics Hands-on Two-Dimensional OpenGL Transformations Objectives To get hands-on experience manipulating the OpenGL current transformation (MODELVIEW) matrix to achieve desired effects To gain experience using the OpenGL matrix stack To see how new models can be created out of multiple, transformed instances of other models Background OpenGL functions gltranslate*, glscale*, glrotate*, glpushmatrix, and glpopmatrix. A basic understanding of the current transformation (MODELVIEW) matrix and the matrix stack. Software Tool Applet posted online http://www.csc.villanova.edu/~mdamian/graphics/applets/opengltransformations.html Courtesy of Dr. Robin Flatland, Siena College. Activities Start the OpenGLTransformations applet (you may need to view it in full screen mode to see it all). On the right side of the window are a series of text boxes in which you can enter a code fragment consisting of calls to OpenGL functions and functions that draw various objects. To see which functions are available, click the down arrow next to a text box. The buttons below the text boxes allow you to step through the execution of the code. At the bottom of the window the OpenGL stack of transformation matrices is displayed. The top matrix on this stack (pointed to by the green arrow) is the current transformation matrix that is applied to objects before they are drawn. If the arrow points to nothing, as it does when the tool first starts, it means the current transformation matrix is the identity matrix.

Part 1: Warm-up Activities Activity 0: To master the controls of this tool, begin by typing (or selecting) the line of code below into the first text box. Now press the Reset button and then the Step button to execute the line and make the smiley face appear on the display. Notice that the green arrow of the matrix stack is pointing to nothing when the function drawsmiley executes, thus no transformations are applied to the face. Activity 1: Add three more lines of code in the next three text boxes so that the fragment looks like that below: gltranslated( 2, 2, 0 ); glscaled( 3, 0.5, 1 ); Press the Reset button and then press the Step button four times to execute the code fragment, observing what happens after each line executes. Notice that when the gltranslated function call executes, it modifies the current transformation shown in the matrix stack at the bottom of the window. After the glscaled function executes, the current transformation matrix is the product of a translation and a scale matrix. On the display this is shown as: T(2,2,0) S(3,0.5,1) Notice that when the second face is drawn, each point making up the face was multiplied by the current transformation matrix before being displayed. Thus, the face was first scaled by a factor of 3 on the x axis and by a factor of 0.5 on the y axis. Then it was translated by 2 on both x and y axes. The order in which these transformations were applied may seem backwards at first. The reason for the confusion is that in the code fragment you called gltranslated before glscaled, and yet the face was scaled first and then translated! To understand this apparent anomaly, you must remember that what the gltranslated function does (and similarly the glscaled function): it multiplies the current transformation matrix on the right by a translation (similarly scale) matrix. When the object is drawn, each point is multiplied by the current transformation matrix, as shown below. Transformed Point = T(2,2,0) * S(3,0.5,1) * Point Therefore the point s coordinates are first scaled and then translated before being drawn on the display. 2

Activity 2: Now press the Clear button, and enter the code below in the first six text boxes: gltranslated( 2, 2, 0 ); glpushmatrix(); glscaled( 3, 0.5, 1 ); glpopmatrix(); Press the Reset button and then step through each of line of the new code fragment, observing what happens after each line executes. Notice that when the glpushmatrix() is executed, a copy of the current transformation matrix is pushed onto the stack and this copy (now pointed to by the green arrow) becomes the new current transformation matrix. The glscaled function called next effects only the top matrix on the stack, making it equal to T(2,2,0)S(3,0.5,1). When the first face is drawn, the transformation T(2,2,0)S(3,0.5,1) is applied to it making it appear long and thin in the top right quadrant. Before drawing the second face, the matrix stack is popped, thus restoring the current transformation matrix to what it was just before the glpushmatrix was encountered. When the second face is drawn, the transformation applied to it is just T(2,2,0). 3

Part 2: Manipulating the current transformation matrix Activity 3: To gain experience manipulating the current transformation matrix to achieve a desired effect, write a code fragment that makes the smiley face appear as shown below. Next to the figure, write down the code fragment you used to achieve this effect. Activity 4: Write a code fragment that makes the smiley face appear as shown below. Next to the figure, write down the code fragment you used to achieve this effect. 4

Part 3: Building a model out of parts Often times it is useful to create a model out of other, simpler models. For example, the smiley face is created out of three parts a circle, the eyes, and a smile. Using the software tool, you can draw these individual parts using the function calls drawcircle(), draweyes(), and drawsmile().try them now by writing a code fragment that draws the smiley face using these three function calls, instead of one call to drawsmiley(). Different models can be created out of the same set of parts by making the parts appear differently using the current transformation matrix. In this section of the lab you have the opportunity to create some new models out of parts. Activity 5: Write a code fragment that draws a frowning face, as shown below. Next to the figure, write down the code fragment you used to achieve this effect. Activity 6: Write a code fragment that displays the frowning face in the top right quadrant, as shown below. Next to the figure, write down the code fragment you used to achieve this effect. 5

Activity 7: Another model you can draw using this software tool is a square centered at the origin having side lengths of 1. The function that draws this model is called drawsquare(). Test this function now by typing it into the first textbox and executing it. Now use this function to create a model of table as shown below. Do it by calling drawsquare() three times, once for the table top and once for each leg. You will need to make sure the current transformation matrix is correctly set up before each call to drawsquare().your code fragment should not include any calls to glloadidentity(). Instead, use glpushmatrix() and glpopmatrix() to save and restore the current transformation as necessary. Write down the code fragment you used to achieve this (on a separate piece of paper, if necessary). 6 2 Activity 8: Be creative and write a code fragment that draws something of your choice. For example, you might try to create a person or a snowman. The only requirements are that it consist of three or more parts, that you use gltranslate*, glscale*, and glrotate* at least once each, and that you do not use glloadidentity(). Use Ctrl-Alt-Print Screen to get a picture of your creation and the code fragment that creates it. Print it out and attach a copy to the back of this handout. 6