Presentation is loading. Please wait.

Presentation is loading. Please wait.

Applying Geometric Transformations

Similar presentations


Presentation on theme: "Applying Geometric Transformations"— Presentation transcript:

1 Applying Geometric Transformations
CSE 3541/5541 Matt Boggus

2 Outline Operations and the benefit to using them
Translate Rotate Scale Relevant Unity scripting features

3 Common 2D transformations
In class visualization of translate, rotate, scale

4 Translating an object Translate individual vertices by the same vector

5 Rotating an object q Rotate individual vertices by the same angle

6 Scaling an object Scale individual vertices by the same vector (4,4)
(2,2) (4,4) (1,1) (2,2) Sx = 2, Sy = 2 Scale individual vertices by the same vector

7 Animation by re-use of model and applying transformations over time
Fortress Quest Compare cost or effort to create main character motion to that from hand-drawn example shown in the animation history slides

8 Vectors (and Points) in Unity
Vector2 (reference page) Vector3 (reference page) Vector4 (reference page)

9 Vector3 Data members Operations/Operators x,y,z floats set(x,y,z)
+,- vector-vector operations *,/ vector-scalar operations == comparison (has some flexibility to handle nearly equal values) Normalize, Distance, Dot

10 Code example with Vector3
In a script attached to a GameObject: Vector3 temp; temp = new Vector3(3,5,8); transform.position = temp;

11 Transformations in Unity
transform (reference) Position, rotation, and scale of an object Methods Translate Rotate Data position rotation

12 transform.Translate function Translate ( translation : Vector3,
relativeTo : Space = Space.Self ) translation vector – tx,ty,tz Space.Self – local coordinate system Space.World – world coordinate system

13 transform.Rotate function Rotate ( eulerAngles : Vector3,
relativeTo : Space = Space.Self ) Applies a rotation eulerAngles.z degrees around the z axis, eulerAngles.x degrees around the x axis, and eulerAngles.y degrees around the y axis (in that order).

14 transform.Rotate function Rotate ( eulerAngles : Vector3,
relativeTo : Space = Space.Self ) Space.Self – rotate about local coordinate frame (center of prebuilt GameObjects, could be anywhere for an artist made model) Space.World – rotate about world coordinate frame (origin (0,0,0))

15 On your own activity with transform.Rotate
In your script for lab1, in Update() add the statement transform.Rotate(0,1,0); Run the animation and hold down the ‘a’ key, is the result what you were expecting? Try it again with transform.Rotate(0,1,0, Space.World); Also experiment with using Space.World in a call to Translate


Download ppt "Applying Geometric Transformations"

Similar presentations


Ads by Google