Upcoming SlideShare
×

# 아이폰 3D 프로그래밍 챕터2

461 views

Published on

블루사이드 스터디 발표 자료

Published in: Technology
0 Likes
Statistics
Notes
• Full Name
Comment goes here.

Are you sure you want to Yes No
• Be the first to comment

• Be the first to like this

Views
Total views
461
On SlideShare
0
From Embeds
0
Number of Embeds
4
Actions
Shares
0
4
0
Likes
0
Embeds 0
No embeds

No notes for slide

### 아이폰 3D 프로그래밍 챕터2

1. 1. iPhone 3D Programming Chapter 02. Math and Metaphors 2012. 01. 26. Sanghoon LeeSunday, December 9, 12
2. 2. 수학과 비유 Graphics Rendering Pipeline & Metaphor Transforms Matrix stack Vector Beautiﬁcation with C++ HelloConeSunday, December 9, 12
3. 3. Sunday, December 9, 12
4. 4. What we’re going to study!Sunday, December 9, 12
5. 5. Different kind of topologySunday, December 9, 12
6. 6. Different kind of topology The ﬁrst argument speciﬁes the topologySunday, December 9, 12
7. 7. Drawing rectangleSunday, December 9, 12
8. 8. Properties with VerticesSunday, December 9, 12
9. 9. Setting vertex properties examplesSunday, December 9, 12
10. 10. Homogeneous coordinates Internally, the OpenGL implementation always converts it into a 4D ﬂoating-point number. It’s an artiﬁcial construction that allows all transformations to be represented with matrix multiplication. These 4D coordinates are known as homogeneous coordinates. So, shortly after entering the assembly line, all vertex positions become 4D; don’t they need to become 2D at some point? The answer is yes.Sunday, December 9, 12
11. 11. The Life of a Vertex Perspective transform ( removal of w )Sunday, December 9, 12
12. 12. Vertex goes from 4D to 2D Early life of a vertex. Top row is conceptual; bottom row is OpenGL’s viewSunday, December 9, 12
13. 13. Vertex goes from 4D to 2DSunday, December 9, 12
14. 14. The photography metaphor 1. Arrange the various dishes on the table. 2. Arrange one or more light sources. 3. Position the camera. 4. Aim the camera toward the food. 5. Adjust the zoom lens. 6. Snap the picture. 1. Adjust the camera’s ﬁeld-of-view angle. (projection matrix) 2. Position the camera and aim it in the appropriate direction. (view matrix) 3. For each object: a. Scale, rotate, and translate. (model matrix) b. Render the object.Sunday, December 9, 12
15. 15. ES 1.1 ES 2.0Sunday, December 9, 12
16. 16. Matrix MultiplicationSunday, December 9, 12
17. 17. Model Matrix The three most common operations when positioning an object in a scene Scale Translation RotationSunday, December 9, 12
18. 18. Setting the Model Matrix (Scale)Sunday, December 9, 12
19. 19. Setting the Model Matrix (Scale)Sunday, December 9, 12
20. 20. Setting the Model Matrix (Translation)Sunday, December 9, 12
21. 21. Setting the Model Matrix (Translation)Sunday, December 9, 12
22. 22. Setting the Model Matrix (Rotation ES 1.1) glRotatef(m_currentAngle, 0, 0, 1); counter-clockwise rotation about the Z-axis angle in degrees the latter three arguments deﬁne the axis of rotationSunday, December 9, 12
23. 23. Setting the Model Matrix (Rotation ES 2.0)Sunday, December 9, 12
24. 24. Setting the Model Matrix (Rotation) arbitrary axis rotation * ES 1.1 glRotatef generates the matrix for you glRotatef only rotates about the originSunday, December 9, 12
25. 25. Setting the Model Matrix (Rotation) arbitrary axis rotation * ES 2.0Sunday, December 9, 12
26. 26. What we have been throughSunday, December 9, 12
27. 27. Setting the View TransformSunday, December 9, 12
28. 28. Setting the View Transform The simplest way to create a view matrixSunday, December 9, 12
29. 29. Setting the Projection Transform think of the projection as being the cameras "zoom lens"Sunday, December 9, 12
30. 30. Setting the Projection Transform ES 1.1Sunday, December 9, 12
31. 31. Setting the Projection Transform Perspective Orthographic ES 2.0Sunday, December 9, 12
32. 32. Matrix stacksSunday, December 9, 12
33. 33. Matrix stacksSunday, December 9, 12
34. 34. Matrix stacks Only ES 1.1 supports You need to create by yourself in ES 2.0Sunday, December 9, 12
35. 35. InterpolationsSunday, December 9, 12
36. 36. Example of easing equationsSunday, December 9, 12
37. 37. Quaternions For position keyframes and color keyframes Its easy What if interpolating between two orientations?Sunday, December 9, 12
38. 38. Quaternions Storing an angle for each joint would be insufﬁcient youd also need the axis of rotation This is known as Axis-Angle notation requires a total of four ﬂoating-point values for each jointSunday, December 9, 12
39. 39. Quaternions Storing an angle for each joint would be insufﬁcient youd also need the axis of rotation Quaternions This is known as Axis-Angle notation requires a total of four ﬂoating-point values for each jointSunday, December 9, 12
40. 40. Quaternions Storing an angle for each joint would be insufﬁcient Study of rotation youd also need the axis and This is understand it!! known as Axis-Angle notation requires a total of four ﬂoating-point values for each jointSunday, December 9, 12
41. 41. Vector Beautiﬁcation template <typename T> Vector3 Cross(const Vector3& v) const struct Vector3 { { return Vector3(y * v.z - z * v.y, Vector3() {} z * v.x - x * v.z, Vector3(T x, T y, T z) : x(x), y(y), z(z) {} x * v.y - y * v.x); void Normalize() } { T Dot(const Vector3& v) const ﬂoat length = std::sqrt(x * x + y * y + z * z); { x /= length; return x * v.x + y * v.y + z * v.z; y /= length; } z /= length; Vector3 operator-() const } { return Vector3(-x, -y, -z); Vector3 Normalized() const } { Vector3 v = *this; bool operator==(const Vector3& v) const v.Normalize(); { return v; return x == v.x && y == v.y && z == v.z; } } T x; T y; T z; };Sunday, December 9, 12
42. 42. Vector Beautiﬁcation vec3 z; normalize(&z, &(eye-target)); vec3 cross; vec3 z = (eye - target).Normalized(); cross(&cross, &up, &z); vec3 x; vec3 x = up.Cross(z).Normalized(); normalize(&x, &cross); vec3 y = z.Cross(x).Normalized(); cross(&cross, &up, &z); vec3 y; normalize(&y, &cross);Sunday, December 9, 12
43. 43. Hello Cone Fixed FunctionSunday, December 9, 12