Class 12 Complex object with moving parts

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
Graphics Pipeline.
2 COEN Computer Graphics I Evening’s Goals n Discuss the fundamentals of lighting in computer graphics n Analyze OpenGL’s lighting model n Show.
The View Frustum and the Camera Lecture 19 Fri, Oct 10, 2003.
Computer Graphics Through OpenGL: From Theory to Experiments, Second Edition Chapter 4.
David Luebke5/16/2015 Administrivia l Back on track: canceling OpenGL lecture 2 l Assignment 1 –Greg Yukl found an alternate XForms site:
Viewing and Transformation
Viewing and Projections
OpenGL (II). How to Draw a 3-D object on Screen?
Development of Interactive 3D Virtual World Applications
3D Rendering with JOGL Introduction to Java OpenGL Graphic Library By Ricardo Veguilla
Introduction to 3D Graphics John E. Laird. Basic Issues u Given a internal model of a 3D world, with textures and light sources how do you project it.
Introduction to 3D viewing 3D is just like taking a photograph!
Picking. What is picking? Selecting an object on the screen What does this require? –Get Mouse Location –Compute what objects are rendered at the position.
Computer Graphics, KKU. Lecture 131 Transformation and Viewing in OpenGL.
The Viewing Pipeline (Chapter 4) 5/26/ Overview OpenGL viewing pipeline: OpenGL viewing pipeline: – Modelview matrix – Projection matrix Parallel.
Geometric transformations The Pipeline
CS559: Computer Graphics Lecture 9: Projection Li Zhang Spring 2008.
Korea University Korea University Computer Graphics Laboratory Computer Graphics Laboratory Jung Lee, Chapter 13.
Homogeneous Form, Introduction to 3-D Graphics Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Monday, October 20,
Introduction to OpenGL 1. 2 OpenGL A Graphics rendering API introduced in 1992 by Silicon Graphics Inc Provide the low-level functions to access graphics.
Stages of Vertex Transformation To specify viewing, modeling, and projection transformations, you construct a 4 × 4 matrix M, which is then multiplied.
Computer Graphics Bing-Yu Chen National Taiwan University.
Computer Graphics I, Fall 2010 Computer Viewing.
Modeling with OpenGL Practice with OpenGL transformations.
Computer Science Term 1, 2006 Tutorial 2 Assignment 3 – The Virtual World.
1 Perception and VR MONT 104S, Fall 2008 Lecture 21 More Graphics for VR.
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.
Graphics Graphics Korea University kucg.korea.ac.kr Viewing 고려대학교 컴퓨터 그래픽스 연구실.
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.
Chapters 5 2 March Classical & Computer Viewing Same elements –objects –viewer –projectors –projection plane.
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.
Taxonomy of Projections FVFHP Figure Taxonomy of Projections.
 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
CS559: Computer Graphics Lecture 12: OpenGL - Transformation Li Zhang Spring 2008.
OpenGL LAB III.
Introduction to 3-D Viewing Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Monday, October 27, 2003.
CSC Graphics Programming
Viewing 고려대학교 컴퓨터 그래픽스 연구실 kucg.korea.ac.kr.
Administrivia Back on track: canceling OpenGL lecture 2 Assignment 1
Viewing.
Computer Graphics - Chapter 5 Viewing
Transformations Introduction to Computer Graphics and Animation
Computer Viewing.
Courtesy of Drs. Carol O’Sullivan / Yann Morvan Trinity College Dublin
Camera Position (5.6) we specify the position and orientation of the camera to determine what will be seen. use gluLookAt (eye x, y, z, at x, y, z, up.
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.
Advanced Graphics Algorithms Ying Zhu Georgia State University
Class 11 timers Iron Maiden example Double Buffering BallAndTorus
Intro to lighting (Chapter 11)
Lecture 08 and 09 View & Projection
CSC4820/6820 Computer Graphics Algorithms Ying Zhu Georgia State University View & Projection.
Computer Graphics, KKU. Lecture 13
Chapter 4/5 glMatrixMode Modeling Transformations glTranslate glScale
Chapters 5/4 part2 understanding transformations working with matrices
Three-Dimensional viewing
Projection in 3-D Glenn G. Chappell
Lighting Phong's Lighting Model normals
Type of View Perspective View COP(Center of Plane) Diminution of size
The View Frustum Lecture 10 Fri, Sep 14, 2007.
Computer Graphics 3Practical Lesson
Chapter 3 Viewing.
Class 12 idle function timers Iron Maiden example Double Buffering
Collision Detection.
Presentation transcript:

Class 12 Complex object with moving parts Viewing Transformations: glLookAt Selection and Picking Intro to lighting (Chapter 11)

Assembling a Clown Head Run clown3.cpp head radius 2 ear radius 0.5 Hat: height 4 radius 2 Brim: inner radius 0.2 outer radius 2.2 ear to head 0 - 2 Hat sits 2 units from center of head Tilted 30o from vertical

clown3.cpp figure out placement of ears // Transformations of the left ear. glTranslatef(sin((PI/180.0)*angle), 0.0, 0.0); glTranslatef(3.5, 0.0, 0.0); // Transformations of the right ear. glTranslatef(-sin((PI/180.0)*angle), 0.0, 0.0); glTranslatef(-3.5, 0.0, 0.0);

clown3.cpp: spring to left ear // Transformations of the spring to the left ear. glTranslatef(-2.0, 0.0, 0.0); glScalef(-1 - sin( (PI/180.0) * angle ), 1.0, 1.0); // Spring to left ear. glColor3f(0.0, 1.0, 0.0); glBegin(GL_LINE_STRIP); for(t = 0.0; t <= 1.0; t += 0.05) glVertex3f(t, 0.25 * cos(10.0 * PI * t), 0.25 * sin(10.0 * PI * t)); glEnd();

clown3.cpp Study the code. Notice the order of transformations Notice the use of glPushMatrix() and glPopMatrix(). Observe how the animation is done.

floweringPlant.cpp run uses depth testing uses 3 sequential display list: stem segment, sepal, petal

Viewing Transformation gluLookAt( eyex, eyey,eyez, centerx, centery,centerz, upx, upy, upz ) eye is where the camera should be center is where it should be aimed up determines how we hold the camera

gluLookAt( eyex, eyey, eyez, centerx, centery, centerz, upx, upy, upz ) Line of Sight ( los) goes through eye and center. Vertex of pyramid that gives frustum is at eye. Near and Far measured from there. Line Of Sight runs through center of frustum "True up" is component of up perpendicular to los.

gluLookAt(0.0, 0.0, 0.0, 2.0, 0.0, 5.0, 0.0, 1.0, 0.0 ); 2 1 -4 -3 -2 -1 1 2 3 4 -1 -2 -3

gluLookAt(0.0, 0.0, 0.0, 2.0, 0.0, 5.0, 1.0, 0.0, 0.0 ); 2 1 -4 -3 -2 -1 1 2 3 4 -1 -2 -3

gluLookAt(2.0, 1.0, 0.0, 2.0, 0.0, 5.0, 0.0, 1.0, 0.0 ); 2 1 -4 -3 -2 -1 1 2 3 4 -1 -2 -3

gluLookAt( ); 2 1 -4 -3 -2 -1 1 2 3 4 -1 -2 -3

boxWithLookAt.cpp Run. Just like box, but with gluLookAt instead of glTranslate.

clown3.cpp Run. Modify to use gluLookAt instead of glTranslate. Look from front of sphere, just touching. What do you see?

clown3.cpp Run. Modify to use gluLookAt instead of glTranslate. Look from front of sphere, just touching. What do you see? Have to adjust glFrustum!

clown3.cpp Run. Modify to use glLookAt instead of glTranslate. Look down from well above hat. What do you want "up" to be?

gluLookAt( eyex, eyey, eyez, centerx, centery, centerz, upx, upy, upz ) Apply to the MODELVIEW matrix, not the PROJECTION matrix Code: Load the MODELVIEW matrix Set matrix to the identiry Place your cameral Build your world using reasonable world coordinates

gluLookAt(eyex, eyey, eyez, centerx, centery, centerz,upx, upy, upz) move the camera to (eyex, eyey, eyez) rotate till it is facing the center rotate about the line of sight till up is in the right direction. Is equivalent to moving the surrounding world: glRotate(B,0,0,1); glRotate(A, wx, wy, wz); glTranslate(-eyex, -eyey, -eyez);

gluLookAt(eyex, eyey, eyez, centerx, centery, centerz, upx, upy, upz) is equivalent to reverse of: Translate camera from eye to origin rotate the camera about the x-axis, till the line of sight lies on the x-z plane rotate the camera about the y-axis, (staying in the x-z plane) till the line of sight is pointing in the -z direction. rotate the camera about the line of sight ( = z-axis) till the top is pointing in the +y direction.

The 3 angles from the 3 "rotates" are the Euler angles.

simple shadow run ballAndTorusShadowed.cpp in drawFlyingBallAndTorus see if(shadow) code. in drawScene see 2 calls to drawFlyingBallAndTorus "Light" is at infinity, directly overhead.

Picking and Selection Run BallAndTorusPicking.cpp to understand the problem. How computer knows which shape or color to use for drawing. How can the computer "know" which shape belongs to a pixel to modify?

glRenderMode(GL_SELECT) Selection Tell computer you will be selecting glRenderMode(GL_SELECT) Specify a (new, small) viewing volume selection volume Redraw the scene, invisibly, recoding which items hit the viewing volume hit list

when hit records are written A hit record is written into the hit buffer when both a name stack manipulation or a glRenderMode() command is encountered a hit has occured - a primitive has been drawn that intersects the selection volume

what hit records contain the number of names in the name stack at the time of writing the record the min z-value‡ of primitives that hit selection volume since last hit record was written the max z-value‡ of primitives that hit selection volume since last hit record was written the sequence of names in the name stack at time of writing, bottom one first, may be none.

How to PICK the right selection volume?

gluPickMatrix(pickX, pickY, width, height, viewport[4]) glLoadIdentity(); gluPickMatrix(pickX, pickY,width,height, viewport[4]); glFrustrum(); or gluPerspective; or glOrtho; (same as resize function, or what the program is using.)

gluPickMatrix(pickX, pickY, width, height, viewport[4]) pickX and pickY are in gl screen coords. front face of selection volume is centered at (pickX, pickY) with given width and height. In pixels. viewport array supplies current viewport boundaries. Can use glGetIntegerv(GL_VIEWPORT,viewport)

min and max values ‡ min and max are "normalized" by dividing by depth of selection volume, so value is in range [0,1]. Then multiplied by 232-1 and stored as an unsigned int.

ballAndTorusPicking.cpp void drawBallAndTorus(void) void drawScene(void) // The mouse callback routine. void pickFunction(int button, int state, int x, int y) void findClosestHit(int hits, unsigned int buffer[]) void animate(int value)

ballAndTorusPicking Make these changes for better model In function drawBallAndTorus remove glutSwapBuffers(); In function drawScene add glutSwapBuffers();

collision detection Run spaceTravel.cpp Go through code - non-collision parts Notice class, constructors Notice viewports. Notice display list. Notice rand. In setup I added srand(time(0)); Need to include ctime I also changed FILL_PROBABILITY

geometry of the spacecraft radius 5 height 10 red center to edge of circle =sqrt(50) = 7.072

geometry of collisions Got to Here!!!!!!!!

collision detection spaceTravel.cpp static int isCollision = 0; // Is there collision between the spacecraft and an asteroid? functions: int checkSpheresIntersection(...) int asteroidCraftCollision(...) see specialKeyInput function

Articulated Figure On your own, run animateMan.cpp. Do the experiments in the book. Come back with questions.

Phong's Lighting Model Ambient light - even light all around. Direction of light and viewer don't matter. Diffuse - fine scale graininess of surface. Direction of light source matters, direction of viewer doesn't matter. Specular - shininess of surface. Direction of light source and viewer both matter.

Run sphereInBox1.cpp Observe box and ball materials and lighting. Look at code later.

Lots of thing to specify for each light and material of objects Ambient R, G, B Diffuse R, G, B Specular R, G, B For material, also emissive - looks like light coming from object. Specular also has a shininess component.

Normals To get proper reflection, we need to know "surface direction".

BoxAndSquaresPickingAndViews.cpp Cookie cutter approach – take advantage of it!