Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 By Dr. HANY ELSALAMONY.  We have seen how to create models in the 3D world. We discussed transforms in lecture 3, and we have used some transformations.

Similar presentations


Presentation on theme: "1 By Dr. HANY ELSALAMONY.  We have seen how to create models in the 3D world. We discussed transforms in lecture 3, and we have used some transformations."— Presentation transcript:

1 1 By Dr. HANY ELSALAMONY

2  We have seen how to create models in the 3D world. We discussed transforms in lecture 3, and we have used some transformations to view our 3D models effectively.  Let us look into 3D transformations in more detail. 2 By Dr. HANY ELSALAMONY

3  Just as 2D transformations can be represented by 3 x 3 matrices using homogenous coordinates.  3D transformations can be represented by 4 x 4 matrices.  3D homogenous coordinates are represented as a quadruplet (x, y, z, W).  We discuss the representation of the three most commonly used transformations: translation, scaling, and rotation. 3 By Dr. HANY ELSALAMONY

4  The translation matrix T(Tx, Ty, Tz) is defined as:  so any vertex point: 4 By Dr. HANY ELSALAMONY

5 5

6  Scaling is similarly extended to be defined as: By Dr. HANY ELSALAMONY 6

7  Recall from Lecture 3 that scaling occurs about a point. This point is called the pivot point. The scaling matrix defined above scales about the origin.  You can define models to have different pivot points by setting the transformation stack appropriately. By Dr. HANY ELSALAMONY 7

8  Rotation matrices are defined uniquely based on the axis of rotation and the pivot point.  The axis of rotation is a normalized vector defining the axis in 3D space along which the rotation will occur. By Dr. HANY ELSALAMONY 8

9  (A 3D vector will simply be the triplet (x, y, z) defining the direction of the axis). The 2D rotation we saw earlier is a 3D rotation about the z-axis (the vector (0,0,1)), and the world origin (0,0,0) and is defined as: By Dr. HANY ELSALAMONY 9

10  Similarly the rotation matrix about the x- axis is defined to be:  and about the y-axis as: By Dr. HANY ELSALAMONY 10

11  Just as with 2D transforms, 3D transforms can be composed together to provide desired effects.  The order in which the transforms are applied is important.  Recall from our previous section that the OpenGL commands for matrix operations By Dr. HANY ELSALAMONY 11

12  sets the current matrix to be the 4 x 4 identity matrix.  sets the matrix passed in to be the current transformation matrix.  multiplies the current matrix by the matrix passed in as the argument. By Dr. HANY ELSALAMONY 12

13  Additionally, OpenGL provides three utility functions for the most commonly used transformations.  multiplies the current transformation matrix by the matrix to move an object by (Tx, Ty, Tz) units By Dr. HANY ELSALAMONY 13

14  multiplies the current transformation matrix by a matrix that rotates an object in a counterclockwise direction by theta degrees about the axis defined by the vector (x, y, z).  multiplies the current transformation matrix by a matrix that scales an object by the factors, (Sx, Sy, Sz). By Dr. HANY ELSALAMONY 14

15  All three commands are equivalent to producing an appropriate translation, rotation, or scaling matrix and then calling glMultMatrixf0 with that matrix as the argument.  For example, Let us apply some transformations to the famous pyramid that we created earlier. By Dr. HANY ELSALAMONY 15

16  We rotate the pyramid about the y-axis and use double buffering to display the rotation as an animation. By Dr. HANY ELSALAMONY 16

17  In lecture 3, we saw how to map a two- dimensional world onto the two dimensional screen.  The process was a simple mapping of 2D world coordinates onto the 2D viewport of the window.  Model positions are first clipped against the 2D world coordinates and then mapped into the viewport of the window for display. By Dr. HANY ELSALAMONY 17


Download ppt "1 By Dr. HANY ELSALAMONY.  We have seen how to create models in the 3D world. We discussed transforms in lecture 3, and we have used some transformations."

Similar presentations


Ads by Google