Computer Graphics Coursework Cookbook original from Anthony Jones modified Dan Cornford (Oct 2010)

Slides:



Advertisements
Similar presentations
This terms course Last term we both worked on learning 2 things –Processing –The concepts of graphics etc. This term will focus more on the basic concepts.
Advertisements

Using GLU/GLUT Objects GLU/GLUT provides very simple object primitives glutWireCube glutWireCone gluCylinder glutWireTeapot.
Translation and Rotation in 2D and 3D David Meredith Aalborg University.
SE 313 – Computer Graphics Lecture 13: Lighting and Materials Practice Lecturer: Gazihan Alankuş 1.
SE 313 – Computer Graphics Lecture 14: Armatures Lecturer: Gazihan Alankuş 1.
Shading in OpenGL CS4395: Computer Graphics 1 Mohan Sridharan Based on slides created by Edward Angel.
1 3D modelling with OpenGL Brian Farrimond Robina Hetherington.
Shading in OpenGL Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts University of New Mexico.
, Fall 2006IAT 800 Lab 2: Polygons, Transformations, and Arrays.
Further Programming for 3D applications CE Introduction to Further Programming for 3D application Bob Hobbs Faculty of Computing, Engineering and.
Computer Graphics (Spring 2008) COMS 4160, Lecture 14: OpenGL 3
Scenes, Cameras & Lighting. Outline  Constructing a scene  Using hierarchy  Camera models  Light models.
CSC 123 – Animating characters Hierarchical modeling Zoë Wood.
3D Rendering with JOGL Introduction to Java OpenGL Graphic Library By Ricardo Veguilla
University of Texas at Austin CS 378 – Game Technology Don Fussell CS 378: Computer Game Technology 3D Engines and Scene Graphs Spring 2012.
Hierarchical Transformations Hierarchical Models Scene Graphs
IAT 355 Lecture 4 Computer Graphics: Rocket. May 9, 2014IAT 3552 Outline  Programming concepts –Programming Computer Graphics –Transformations –Methods.
COMP 175: Computer Graphics March 10, 2015
COMP 175: Computer Graphics March 24, 2015
Computer Animation Rick Parent Computer Animation Algorithms and Techniques Kinematic Linkages.
1 OpenGL Basics A Graphics Standard ©Mel Slater, Anthony Steed
CS324e - Elements of Graphics and Visualization Checkerboard World.
Shading in OpenGL.
EEC-693/793 Applied Computer Vision with Depth Cameras Lecture 13 Wenbing Zhao
Image Synthesis Rabie A. Ramadan, PhD 2. 2 Java OpenGL Using JOGL: Using JOGL: Wiki: You can download JOGL from.
OpenGL - Lighting, Shading and Material Properties
Computer Graphics I, Fall 2010 Shading in OpenGL.
Homogeneous Form, Introduction to 3-D Graphics Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Monday, October 20,
Problem of the Day  Why are manhole covers round?
UFCFS D Technologies for the Web Unity 3D: Review of Topics and Related Concepts.
Lecture 6: 3D graphics Concepts 1  Principles of Interactive Graphics  CMSCD2012  Dr David England, Room 718,  ex 2271 
Lecture 11: Exam Revision 1  Principles of Interactive Graphics  CMSCD2012  Dr David England, Room 718,  ex 2271  Coursework.
Kinematics Jehee Lee Seoul National University. Kinematics How to animate skeletons (articulated figures) Kinematics is the study of motion without regard.
SE 320 – Introduction to Game Development Lecture 3: Unity’s Interface and Concepts Lecturer: Gazihan Alankuş Please look at the last two slides for assignments.
Computer Science Term 1, 2006 Tutorial 2 Assignment 3 – The Virtual World.
Project 5 Lamp Shader Fri, Nov 7, 2003 Due Mon, Nov 17, 2003.
UFCEK-20-3Web Games Programming Unity 3D: Review of Topics Publishing for the Web.
Sky Boxes and Vector Math 2 Course Information CVG: Programming 4 My Name: Mark Walsh Website:
1cs426-winter-2008 Notes  Will add references to splines on web page.
1/50 CS148: Introduction to Computer Graphics and Imaging Transforms CS148: Introduction to Computer Graphics and Imaging Transforms.
Computation as an Expressive Medium Lab 2: Polygons, Transformations, and Arrays Evan.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
Where We Stand So far we know how to: –Transform between spaces –Rasterize –Decide what’s in front Next –Deciding its intensity and color.
Written by: Itzik Ben Shabat Technion - Israel Institute of Technology Faculty of Mechanical Engineering Laboratory for CAD & Lifecycle Engineering Lab.
Computation as an Expressive Medium Lab 2: Polygons, Transformations, and Arrays (Oh My) Micah.
Computer Graphics Imaging Lecture 13 and 14 UV Mapping.
Object Animation CMT3317. Do you need to do animation? We consider ways of animating composite objects – that have a number of different parts e.g. a.
3D Ojbects: Transformations and Modeling. Matrix Operations Matrices have dimensions: Vectors can be thought of as matrices: v=[2,3,4,1] is a 1x4 matrix.
Introduction to 3-D Viewing Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Monday, October 27, 2003.
Chapter 5. Lighting Computer Graphics (spring, 2009) School of Computer Science University of Seoul.
EEC-693/793 Applied Computer Vision with Depth Cameras
Quick Intro to Unity Lecture 2.
© University of Wisconsin, CS559 Spring 2004
EEC-693/793 Applied Computer Vision with Depth Cameras
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.
Hierarchical Transformations Hierarchical Models Scene Graphs
EEC-693/793 Applied Computer Vision with Depth Cameras
Shading in OpenGL Ed Angel
Computer Graphics Imaging
Projection in 3-D Glenn G. Chappell
Lighting Phong's Lighting Model normals
Lighting and Materials
Hierarchical Modeling & Constructive Solid Geometry
IAT 265 Lecture 2: Java Loops, Arrays Processing setup, draw, mouse Shapes Transformations, Push/Pop.
Computer Graphics 4Practical Lesson
EEC-693/793 Applied Computer Vision with Depth Cameras
Computer Graphics Material Colours and Lighting
Computation as an Expressive Medium
Dr. Chih-Kuo Yeh 葉智國 Computer Graphics Dr. Chih-Kuo Yeh 葉智國
Presentation transcript:

Computer Graphics Coursework Cookbook original from Anthony Jones modified Dan Cornford (Oct 2010)

Introduction Me – Dan Cornford – Used to teach this before I got sacked... You – Computer graphics students – Attending labs? This lecture – Aims to help you with your coursework – Available online... 2

Lecture Outline The specification Approaching the problem – Simplification – Paper designs as stepping stones – Scene graphs – Objects – Animations – Lights – Cameras Lecture outcomes Where to get further help 3

The Specification It’s a checklist – Covering everything you’ll see in the labs Try to tick off as much as you can – Some items are easier or harder than others – Some items are related The checklist is flexible – Remi will give you marks where you deserve them! A total of 100 marks is available and will be allocated along the following lines: Basic 3D OpenGL program which renders correctly [10] A basic animation (e.g. movement) of a simple object [5] with basic user interaction [5] A self created, well defined 3D object with correct normals [10] Sensible use of lighting, materials and textures [15] Advanced animation (not just static objects moving, but components that move relative to each other) [10] The clarity of the code [5], and good documentation of the program [5] A clear introductory description of the program [5], and a correct scene graph [5] Innovation and novelty in the animation (your ideas - can't tell you this bit!) [25] A total of 100 marks is available and will be allocated along the following lines: Basic 3D OpenGL program which renders correctly [10] A basic animation (e.g. movement) of a simple object [5] with basic user interaction [5] A self created, well defined 3D object with correct normals [10] Sensible use of lighting, materials and textures [15] Advanced animation (not just static objects moving, but components that move relative to each other) [10] The clarity of the code [5], and good documentation of the program [5] A clear introductory description of the program [5], and a correct scene graph [5] Innovation and novelty in the animation (your ideas - can't tell you this bit!) [25] 4

The Specification It’s a checklist – Covering everything you’ll see in the labs Try to tick off as much as you can – Some items are easier or harder than others – Some items are related The checklist is flexible – Remi will give you marks where you deserve them! A total of 100 marks is available and will be allocated along the following lines: Basic 3D OpenGL program which renders correctly [10] A basic animation (e.g. movement) of a simple object [5] with basic user interaction [5] A self created, well defined 3D object with correct normals [10] Sensible use of lighting, materials and textures [15] Advanced animation (not just static objects moving, but components that move relative to each other) [10] The clarity of the code [5], and good documentation of the program [5] A clear introductory description of the program [5], and a correct scene graph [5] Innovation and novelty in the animation (your ideas - can't tell you this bit!) [25] A total of 100 marks is available and will be allocated along the following lines: Basic 3D OpenGL program which renders correctly [10] A basic animation (e.g. movement) of a simple object [5] with basic user interaction [5] A self created, well defined 3D object with correct normals [10] Sensible use of lighting, materials and textures [15] Advanced animation (not just static objects moving, but components that move relative to each other) [10] The clarity of the code [5], and good documentation of the program [5] A clear introductory description of the program [5], and a correct scene graph [5] Innovation and novelty in the animation (your ideas - can't tell you this bit!) [25] 5

The Specification It’s a checklist – Covering everything you’ll see in the labs Try to tick off as much as you can – Some items are easier or harder than others – Some items are related The checklist is flexible – Remi will give you marks where you deserve them! A total of 100 marks is available and will be allocated along the following lines: Basic 3D OpenGL program which renders correctly [10] A basic animation (e.g. movement) of a simple object [5] with basic user interaction [5] A self created, well defined 3D object with correct normals [10] Sensible use of lighting, materials and textures [15] Advanced animation (not just static objects moving, but components that move relative to each other) [10] The clarity of the code [5], and good documentation of the program [5] A clear introductory description of the program [5], and a correct scene graph [5] Innovation and novelty in the animation (your ideas - can't tell you this bit!) [25] A total of 100 marks is available and will be allocated along the following lines: Basic 3D OpenGL program which renders correctly [10] A basic animation (e.g. movement) of a simple object [5] with basic user interaction [5] A self created, well defined 3D object with correct normals [10] Sensible use of lighting, materials and textures [15] Advanced animation (not just static objects moving, but components that move relative to each other) [10] The clarity of the code [5], and good documentation of the program [5] A clear introductory description of the program [5], and a correct scene graph [5] Innovation and novelty in the animation (your ideas - can't tell you this bit!) [25] 6

The Specification It’s a checklist – Covering everything you’ll see in the labs Try to tick off as much as you can – Some items are easier or harder than others – Some items are related The checklist is flexible – Remi will give you marks where you deserve them! A total of 100 marks is available and will be allocated along the following lines: Basic 3D OpenGL program which renders correctly [10] A basic animation (e.g. movement) of a simple object [5] with basic user interaction [5] A self created, well defined 3D object with correct normals [10] Sensible use of lighting, materials and textures [15] Advanced animation (not just static objects moving, but components that move relative to each other) [10] The clarity of the code [5], and good documentation of the program [5] A clear introductory description of the program [5], and a correct scene graph [5] Innovation and novelty in the animation (your ideas - can't tell you this bit!) [25] A total of 100 marks is available and will be allocated along the following lines: Basic 3D OpenGL program which renders correctly [10] A basic animation (e.g. movement) of a simple object [5] with basic user interaction [5] A self created, well defined 3D object with correct normals [10] Sensible use of lighting, materials and textures [15] Advanced animation (not just static objects moving, but components that move relative to each other) [10] The clarity of the code [5], and good documentation of the program [5] A clear introductory description of the program [5], and a correct scene graph [5] Innovation and novelty in the animation (your ideas - can't tell you this bit!) [25] 7

The Specification Topic changes every year – What is the topic this year? Lecture example: – Topic: “A sporting event” – Idea: England won the world cup in 1966 How do we turn this idea into code? 8

Approaching The Problem: Mind the Gap! protected void renderScene() { // draw the ground plane GL11.glPushMatrix(); { // position, scale and draw the ground plane GL11.glTranslatef(0.0f,-2.15f,-10.0f); GL11.glScaled(10.0f, 1.0f, 10.0f); drawUnitPlane(); } GL11.glPopMatrix(); // position, rotate and draw the person GL11.glTranslatef(0.0f,personOffsetY,-10.0f); GL11.glRotatef(personSpinY, 0.0f, 1.0f, 0.0f); person.draw(); } 9

The Wrong Approach 10

The Right Approach Methodical, incremental development based on a careful design Treat the specification as a checklist Customize the coursework template 11

The Right Approach Methodical, incremental development based on a careful design Treat the specification as a checklist Customize the coursework template Keep It Short & Simple! (KISS) “ Everything should be made as simple as possible, but no simpler.” ( Albert Einstein) 12

The Right Approach protected void renderScene() { // draw the ground plane GL11.glPushMatrix(); { // position, scale and draw the ground plane GL11.glTranslatef(0.0f,-2.15f,-10.0f); GL11.glScaled(10.0f, 1.0f, 10.0f); drawUnitPlane(); } GL11.glPopMatrix(); // position, rotate and draw the person GL11.glTranslatef(0.0f,personOffsetY,-10.0f); GL11.glRotatef(personSpinY, 0.0f, 1.0f, 0.0f); person.draw(); } Objects Animations Lights Cameras 13

Simplify Your 3D Scene Remember to KISS! Ideas  Paper design – Objects – Animations – Lights – Cameras Paper Design  Code 14

Simplify Your 3D Scene Remember to KISS! Ideas  Paper design – Objects – Animations – Lights – Cameras Paper Design  Code 15

Paper Design Pencil and paper – Remember to KISS! – Start in 2D and move to 3D later – Use different colours Understand your scene as: – Scene graph – Objects – Animations 16

Scene Graphs Nodes Arcs Sun Earth Moon 17

Scene Graphs Nodes – Scene objects – Based about a centroid Typically a central point Defines the object’s position “Object handle” Sun Earth Moon 18

Scene Graphs Arcs – Connect one node centroid to another – Create a node hierarchy Node ownership Node dependency Sun Earth Moon 19

Scene Graphs Body Head Arms: – Shoulder – Upper Arm – Elbow – Lower Arm 20

Scene Graphs Body Head Arms Waist Legs: – Hip – Upper Leg – Knee – Lower Leg – Foot 21

Each leg: Hip Upper leg Knee Lower leg Foot Body Hea d Waist World Origin Each arm: ● Shoulder ● Upper arm ● Elbow ● Lower arm 22

Exercise 1: Draw The Scene Graph Upper arm Elbow Lower arm Upper claw Lower claw Wrist Shoulder 23

Exercise 1: Solution Upper arm Elbow Lower arm Upper claw Lower claw Wrist World Origin Shoulder 24

Scene Graphs  Code Start at the world origin Traverse your scene graph Move from one object to another Move along the arcs Move down and right only Sun Earth Moon Mars Phobos Deimos Scene Origin 25

Scene Graphs  Code Each time you move along an arc, you need a matrix transform Typically a translation and/or a rotation Sometimes the identity matrix Sun Earth Moon Mars Phobos Deimos Scene Origin 26

Scene Graphs  Code When you reach an object, draw it Using your own objects Using GLUT quadrics Sun Earth Moon Mars Phobos Deimos Scene Origin 27

Scene Graphs  Code Traverse your scene graph Move from one object to another Move along the arcs Move down and right only What happens when you reach the Moon? You can’t go down and right! Sun Earth Moon Mars Phobos Deimos Scene Origin 28

Scene Graphs  Code Use the matrix stack to jump between nodes PushMatrix saves your current position PopMatrix restores the last saved position So... Push at the Sun Traverse to the Moon Pop back to the Sun Sun Earth Moon Mars Phobos Deimos Scene Origin (PUSH) 29

Scene Graphs  Code Once you’re back at the Sun... Traverse to Mars Push Mars Traverse to Phobos Pop back to Mars Traverse to Deimos Sun Earth Moon Mars Phobos Deimos Scene Origin (PUSH) 30

Scene Graphs  Code Simple rule: For each child in the current object’s children { PushMatrix(); Transform to child Draw child PopMatrix(); } Sun Earth Moon Mars Phobos Deimos Scene Origin 31

Paper Design Pencil and paper – Remember to KISS! – Start in 2D and move to 3D later – Use different colours Understand your scene as: – Scene graph – Objects – Animations 32

Objects Centroids – “Object handles” Unit sizes – Unit cube – Unit quad GLU Quadrics Your own objects Materials and textures 33

Objects Centroids – “Object handles” Unit sizes – Unit cube – Unit quad GLU Quadrics Your own objects Materials and textures 34 1 unit

Objects Centroids – “Object handles” Unit sizes – Unit cube – Unit quad GLU Quadrics Your own objects Materials and textures 35

GLU Quadrics “Automatic” objects Spheres, cylinders and disks Much of the work is done for you – Vertices calculated for you – Faces defined for you – Surface normals calculated for you Provide appropriate parameters – Commonly defined by radius, slices and stacks (disks have loops instead of stacks) Check the documentation 36

Objects Centroids – “Object handles” Unit sizes – Unit cube – Unit quad GLU Quadrics Your own objects Materials and textures 37

Defining Your Own Objects Position centroid – at {0.0, 0.0, 0.0} 1 unit 38

Defining Your Own Objects Position centroid Define vertices – A {-0.5,-0.5,+0.5} – B {-0.5,+0.5,+0.5} – C {+0.5,+0.5,+0.5} – D {+0.5,-0.5,+0.5} AD BC 1 unit 39

Defining Your Own Objects Position centroid Define vertices – A {-0.5,-0.5,+0.5} – B {-0.5,+0.5,+0.5} – C {+0.5,+0.5,+0.5} – D {+0.5,-0.5,+0.5} – E {-0.5,-0.5,-0.5} – F {-0.5,+0.5,-0.5} – G {+0.5,+0.5,-0.5} – H {+0.5,-0.5,-0.5} AD BC E FG H 1 unit 40

Defining Your Own Objects Position centroid Define vertices Define faces – Front {C, B, A, D} – Left {B, F, E, A} – Back {F, G, H, E} – Right {G, C, D, H} – Top {C, G, F, B} – Bottom {D, A, E, H} AD BC EFGH 1 unit 41

Defining Your Own Objects Position centroid Define vertices Define faces – Front {C, B, A, D} – Left {B, F, E, A} – Back {F, G, H, E} – Right {G, C, D, H} – Top {C, G, F, B} – Bottom {D, A, E, H} AD BC EFGH 1 unit 42

Defining Your Own Objects Position centroid Define vertices Define faces – Front {C, B, A, D} – Left {B, F, E, A} – Back {F, G, H, E} – Right {G, C, D, H} – Top {C, G, F, B} – Bottom {D, A, E, H} AD BC EFGH 1 unit 43

Defining Your Own Objects Position centroid Define vertices Define faces – Front {C, B, A, D} – Left {B, F, E, A} – Back {F, G, H, E} – Right {G, C, D, H} – Top {C, G, F, B} – Bottom {D, A, E, H} AD BC EFGH 1 unit 44

Defining Your Own Objects Position centroid Define vertices Define faces – Front {C, B, A, D} – Left {B, F, E, A} – Back {F, G, H, E} – Right {G, C, D, H} – Top {C, G, F, B} – Bottom {D, A, E, H} AD BC EFGH 1 unit 45

Defining Your Own Objects Position centroid Define vertices Define faces – Front {C, B, A, D} – Left {B, F, E, A} – Back {F, G, H, E} – Right {G, C, D, H} – Top {C, G, F, B} – Bottom {D, A, E, H} AD BC EFGH 1 unit 46

Defining Your Own Objects Position centroid Define vertices Define faces Normals – Java Normal class – 3 Vertex parameters – Same order as when defining faces – Should be clear from the lab code C E 1 unit 47

Exercise 2: Define The Pyramid Position centroid {0.0,0.0,0.0} Define vertices –A {-0.5,-h/2,+0.5} –B {?,?,?} –C {?,?,?} –D {?,?,?} –E {?,?,?} Define faces –Front {A, B, E} –Left {?,?,?} –Back {?,?,?} –Right {?,?,?} –Bottom {?,?,?,?} 1 unit h units ABCDE 48

Exercise 2: Solution Position centroid {0.0,0.0,0.0} Define vertices –A {-0.5,-h/2,+0.5} –B {+0.5,-h/2,+0.5} –C {-0.5,-h/2,-0.5} –D {+0.5,-h/2,-0.5} –E {0.0,+h/2, 0.0} Define faces –Front {A, B, E} –Left {C, A, E} –Back {D, C, E} –Right {B, D, E} –Bottom {C, D, B, A} 1 unit h units ABCDE 49

Objects Centroids – “Object handles” Unit sizes – Unit cube – Unit quad GLU Quadrics Your own objects Materials and textures 50

Materials And Textures Did you remember to KISS? Use materials and not colours – More marks for you! – Make sure you’ve removed any glColor calls Use Nate Robins’ online tutorial programs – Interactive – Choose material properties for your objects Only texture square faces – Ask in the labs for help with other shapes 51

Paper Design Pencil and paper – Remember to KISS! – Start in 2D and move to 3D later – Use different colours Understand your scene as: – Scene graph – Objects – Animations 52

Animations 2 types of animation 1.User controlled animation 2.Scripted animation 53

All Animations 5 simple steps: 1.Identify animated transforms 2.Declare variables for angles and offsets 3.Initialize your variables when they are declared 4.Update your variables in your updateScene method 5.Use your variables in your drawing methods 54

User Controlled Animations 5 simple steps: 1.Identify animated transforms 2.Declare variables for angles and offsets 3.Initialize your variables when they are declared 4.Update your variables in your updateScene checkSceneInput method 5.Use your variables in your drawing methods Adding user interaction to your animations – Don't update your variables in your updateScene method – Modify them in your checkSceneInput method instead 55

Scripted Animations 5 simple steps: 1.Identify animated transforms 2.Declare variables for angles and offsets 3.Initialize your variables when they are declared 4.Update your variables in your updateScene method 5.Use your variables in your drawing methods Use animation scripts in your updateScene method to change your scene at runtime according to a set of predefined rules 56

Scripted Animations Make the pendulum swing Frame 57

Scripted Animations Make the pendulum swing – 60 degree swing Frame 58

Scripted Animations Make the pendulum swing – 60 degree swing Frame frame = 0 swing =

Scripted Animations Make the pendulum swing – 60 degree swing Frame frame = 30 swing =

Scripted Animations Make the pendulum swing – 60 degree swing Frame frame = 90 swing =

Scripted Animations Make the pendulum swing – 60 degree swing Frame frame = 120 swing =

Scripted Animations Make the pendulum swing – 60 degree swing Frame frame = 0 swing =

Pendulum Code // increment the frame counter ++frame; 64

Pendulum Code // increment the frame counter ++frame; if (frame < 30) // During the first 30 frames, { swing = swing - 1.0; // swing the pendulum to the left } 65

Pendulum Code // increment the frame counter ++frame; if (frame < 30) // During the first 30 frames, { swing = swing - 1.0; // swing the pendulum to the left } else if (frame < 90) // During the next 60 frames, { swing = swing + 1.0; // swing the pendulum to the right } 66

Pendulum Code // increment the frame counter ++frame; if (frame < 30) // During the first 30 frames, { swing = swing - 1.0; // swing the pendulum to the left } else if (frame < 90) // During the next 60 frames, { swing = swing + 1.0; // swing the pendulum to the right } else if (frame < 120) // During the next 30 frames, { swing = swing - 1.0; // swing the pendulum back to 0 } 67

Pendulum Code // increment the frame counter ++frame; if (frame < 30) // During the first 30 frames, { swing = swing - 1.0; // swing the pendulum to the left } else if (frame < 90) // During the next 60 frames, { swing = swing + 1.0; // swing the pendulum to the right } else if (frame < 120) // During the next 30 frames, { swing = swing - 1.0; // swing the pendulum back to 0 } else { frame = 0; // Reset the animation } 68

Simplify Your 3D Scene Remember to KISS! Ideas  Paper design – Objects – Animations – Lights – Cameras Paper Design  Code 69

Lights Global properties Per-light properties 70

Lights // global ambient light level float globalAmbient[] = {0.2f, 0.2f, 0.2f, 1.0f}; // set the global ambient lighting glLightModel(GL_LIGHT_MODEL_AMBIENT, globalAmbient); // the first light for the scene is soft blue... float diffuse0[] = { 0.2f, 0.2f, 0.4f, 1.0f}; //...with a very dim ambient contribution... float ambient0[] = { 0.05f, 0.05f, 0.05f, 1.0f}; //...and is positioned above the viewpoint float position0[] = { 0.0f, 10.0f, 0.0f, 1.0f}; // supply OpenGL with the properties for the first light glLight(GL_LIGHT0, GL_AMBIENT, ambient0); glLight(GL_LIGHT0, GL_DIFFUSE, diffuse0); glLight(GL_LIGHT0, GL_POSITION, position0); // enable the first light glEnable(GL_LIGHT0); // enable lighting calculations glEnable(GL_LIGHTING); 71

Lights Global properties Per-light properties – 8 lights in total – Named GL_LIGHT0 to GL_LIGHT7 – Describe, enable and disable each one separately 72

Lights // global ambient light level float globalAmbient[] = {0.2f, 0.2f, 0.2f, 1.0f}; // set the global ambient lighting glLightModel(GL_LIGHT_MODEL_AMBIENT, globalAmbient); // the first light for the scene is soft blue... float diffuse0[] = { 0.2f, 0.2f, 0.4f, 1.0f}; //...with a very dim ambient contribution... float ambient0[] = { 0.05f, 0.05f, 0.05f, 1.0f}; //...and is positioned above the viewpoint float position0[] = { 0.0f, 10.0f, 0.0f, 1.0f}; // supply OpenGL with the properties for the first light glLight(GL_LIGHT0, GL_AMBIENT, ambient0); glLight(GL_LIGHT0, GL_DIFFUSE, diffuse0); glLight(GL_LIGHT0, GL_POSITION, position0); // enable the first light glEnable(GL_LIGHT0); // enable lighting calculations glEnable(GL_LIGHTING); 73

Cameras gluLookAt(x,y,z, x,y,z, x,y,z) – Camera position (x,y,z) – Target position (x,y,z) – Up vector (x,y,z) 74

Cameras gluLookAt – Camera position (x,y,z) – Target position (x,y,z) – Up vector (x,y,z) 75

Cameras gluLookAt – Camera position (x,y,z) – Target position (x,y,z) – Up vector (x,y,z) 76

Cameras gluLookAt – Camera position (x,y,z) – Target position (x,y,z) – Up vector (x,y,z) (0.0,1.0,0.0) in most cases 77

Cameras gluLookAt – Camera position (x,y,z) – Target position (x,y,z) – Up vector (x,y,z) (1.0,0.0,0.0) or (0.0,0.0,1.0) when looking down 78

Lecture Outcomes: A Better Approach 1.Design a simple scene – Think about how you can satisfy the coursework specification; treat it as a checklist 2.Understand your scene with a paper design – Scene graphs – Objects – Animations – Lights – Cameras 3.Translate your paper design to OpenGL code – A simplified process using scene graphs 79

Where To Get Help Did you remember to KISS? Return to pencil and paper Labs – Lab notes – Lab examples – Lab demonstrators Internet and others – But be careful to avoid collusion – It’s a bit obvious… Remi... 80

Lecture Summary The specification Approaching the problem – Simplification – Paper designs as stepping stones – Scene graphs – Objects – Animations – Lights – Cameras Lecture outcomes Where to get further help 81

Thanks for listening 82