SE 313 Computer Graphics Lecture 6 Transformations Lecturer

  • Slides: 24
Download presentation
SE 313 – Computer Graphics Lecture 6: Transformations Lecturer: Gazihan Alankuş Please look at

SE 313 – Computer Graphics Lecture 6: Transformations Lecturer: Gazihan Alankuş Please look at the last three slides for assignments (marked with TODO) 02. 11. 2012 1

Projects • Proposals need to have sufficient detail, saying “we’ll create models for our

Projects • Proposals need to have sufficient detail, saying “we’ll create models for our game in SE 320” without explaining the details of your game and the list of models is not enough • We will e-mail you back feedback about your proposals • You will start weekly meetings and send individual weekly meeting reports – Follow these guidelines here (the link is also in the course website): http: //homes. ieu. edu. tr/~galankus/teaching/12 fall/se 313/ weeklyreportpolicy. html 02. 11. 2012 2

Our Goal • Understand how 3 D transformations work in a conceptual level. Supplement

Our Goal • Understand how 3 D transformations work in a conceptual level. Supplement this knowledge with practice in Blender. 02. 11. 2012 3

3 D Transformations • Tools for setting the state of objects in space 02.

3 D Transformations • Tools for setting the state of objects in space 02. 11. 2012 4

3 D Transformations • Example: – I have an object that has the points

3 D Transformations • Example: – I have an object that has the points p 1 and p 2 • Their are (p 1 x, p 1 y, p 1 z) and (p 2 x, p 2 y, p 2 z) – I want the object to be somewhere else • Let the object be 3 meters to the right – I can change the coordinates of these points manually like this: (p 1 x+3, p 1 y, p 1 z) and (p 2 x+3, p 2 y, p 2 z) • This is tedious, considering that the object may have many points – Instead, I keep the original coordinate values of the object’s points (local coordinates), and apply a transformation operation to the whole object. 02. 11. 2012 5

Example in Blender • I look at the coordinates of a point • I

Example in Blender • I look at the coordinates of a point • I move the whole object to the right • The coordinate values of the point did not change – They were with respect to the pivot point • I rotate the object, they still do not change • I do Object->Apply->Rotation&Scale and Object->Transform->Origin to 3 D Cursor – Now I see that the coordinates of the point have changed, and the pivot point went back to the world’s origin. 02. 11. 2012 6

3 D Transformations are useful • You can manipulate your object without having to

3 D Transformations are useful • You can manipulate your object without having to forget the original coordinates of your object • Some more demonstrations in Blender – Translate – Rotate – Scale – Around what? (earth revolving around sun? ) 02. 11. 2012 7

Making the Earth revolve around the Sun • What if it is attached to

Making the Earth revolve around the Sun • What if it is attached to a pole? • What you are rotating around is important 02. 11. 2012 8

How do you rotate around an arbitrary position? • Mathematically, rotation is always around

How do you rotate around an arbitrary position? • Mathematically, rotation is always around the origin (0, 0, 0) – We will talk about the mathematical background next week • Therefore, to revolve around some other point, we need to translate first and then rotate 02. 11. 2012 9

Order of Transformations • I said “Translate, and then rotate” • How is this

Order of Transformations • I said “Translate, and then rotate” • How is this different? – (I’ll translate and rotate in blender) • The order of transformation operations is different! • Rotate and then translate, translate and then rotate – Confusing? Let’s make it not confusing! 02. 11. 2012 10

Intuitive Understanding of Combining Transformations 02. 11. 2012 11

Intuitive Understanding of Combining Transformations 02. 11. 2012 11

Intuitive Understanding of Combining Transformations • Combine and connect them like Legos one after

Intuitive Understanding of Combining Transformations • Combine and connect them like Legos one after the other 02. 11. 2012 12

Combining Transformations Order: Insert new ones near the object (world-to-local) 1 2 3 4

Combining Transformations Order: Insert new ones near the object (world-to-local) 1 2 3 4 02. 11. 2012 13

Combining Transformations Order: Insert new ones near the wall (local-to-world) 1 2 3 4

Combining Transformations Order: Insert new ones near the wall (local-to-world) 1 2 3 4 02. 11. 2012 14

Ordering Transformation Combinations • When I say “first translate and then rotate” you need

Ordering Transformation Combinations • When I say “first translate and then rotate” you need to ask “in which order? ” • It’s either world-to-local or local-to-world – World-to-local: New transformations are applied in the local coordinate frame of the object. – Local-to-world: New transformations are applied in the world coordinate frame. • Once you know the order, you know exactly how to apply the transformations 02. 11. 2012 15

Implementation • Games heavily use ordered combination of transformations. Game developers have to be

Implementation • Games heavily use ordered combination of transformations. Game developers have to be very comfortable with these concepts. – Implemented as matrices, euler angles, quaternions, etc. (we will see them next week) • In Blender, combining transformations is not very straightforward. We will do it using parent relationships. 02. 11. 2012 16

Blender and Transformations • Every object has three transformations attached to them in this

Blender and Transformations • Every object has three transformations attached to them in this order: – Translate, rotate, scale (world-to-local) 02. 11. 2012 17

Blender and Transformations • We can use the parent-child relationships between objects to combine

Blender and Transformations • We can use the parent-child relationships between objects to combine these transformations • Parent (translate, rotate, scale) – Child (translate, rotate, scale) • Grandchild (translate, rotate, scale) • You can drag objects in the outliner or select them and do Object->Parent 02. 11. 2012 18

Let’s do it • Two small cubes, one large cube • You can use

Let’s do it • Two small cubes, one large cube • You can use this to implement any order of transformations (by ignoring some in between) • You can also download a sample of it here: – http: //homes. ieu. edu. tr/~galankus/teaching/12 fall/se 313/material/day 6/chaining%20 transformations. blen d 02. 11. 2012 19

Question: Why? • Why should we chain transformations like this anyway? – If I

Question: Why? • Why should we chain transformations like this anyway? – If I want to put the box there, I can just use one box, translate it and rotate it to be exactly there. 02. 11. 2012 20

Answer: Animation! • It matters when you are animating things. – You want the

Answer: Animation! • It matters when you are animating things. – You want the Moon to revolve around the Earth, which is also revolving around the Sun. – You want the robot’s fingers to move with the robot’s arm • Calculating these separately for each object is very difficult • Chaining transformations and changing some of the transformations in between makes it simple. 02. 11. 2012 21

Animating in Blender 1. Go to a frame in the timeline below with right-click

Animating in Blender 1. Go to a frame in the timeline below with right-click dragging 2. Set the state of your objects to how you want them to be at that frame (rotate, etc. ) 3. Select the objects that you want to animate 4. Hit Object->Animation->Insert Keyframe… ->Loc. Rot. Scale • (or others if you want to be more specific) 5. Go to step 1 for the next keyframe. Set some keyframes in time and Blender will fill the rest with a smooth animation. 02. 11. 2012 22

Lab Assignment • Part 1: – – Create a yellow sphere for the Sun

Lab Assignment • Part 1: – – Create a yellow sphere for the Sun Create a blue sphere for the Earth Create a gray sphere for the Moon Let the Sun be the parent of the Earth and the Earth be the parent of the Moon (see slide 18) • Part 2: – Create an animation to revolve the Earth around the Sun and the Moon around the Earth – Implement revolving by rotating the parent • Part 3 (bonus) – Make the Earth and the Moon rotate around themselves as well without breaking the revolving motion – Use some visual cues to show that the rotations around themselves are independent of any other motion (e. g. children revolving around them) 02. 11. 2012 23

TODO: Homework 4 (deliverable) • Create a full-body robot. • You can use scaled

TODO: Homework 4 (deliverable) • Create a full-body robot. • You can use scaled cubes and spheres, or your own small models for the pieces of the robot. • You do not need to create fingers, but I want a nose. • Animate the robot in a creative way by rotating its body parts. • Tips: – You need to use parent-child relationships – You can place spheres where the joints should be and rotate those spheres. • Due next week (as usual) 02. 11. 2012 24