1. 程式人生 > >PBRT_V2 總結記錄 <15> Transform 和 Coordinate Spaces

PBRT_V2 總結記錄 <15> Transform 和 Coordinate Spaces

Transform 類

class Transform {
public:
Transform Public Methods
private:
Transform Private Data
};

類的作用:

(Transform 代表的就是一個矩陣,這個矩陣是 行為主的,也就是類似為OpenGL的矩陣計算方式)

A transformation is represented by the elements of the matrix m[4][4], a Matrix4x4 object. The low-level Matrix4x4 class is defined in Section A.6.2. m is stored in row-major form, so element m[i][j] corresponds to mi , j, where i is the row number and j is the column number.

Coordinate Spaces

1. Object space:

This is the coordinate system in which geometric primitives are defined. For example, spheres in pbrt are defined to be centered at the origin of object space.

2. World space:

While each primitive may have its own object space, all objects in the scene are placed in relation to a single world space. Each primitive has an objectto- world transformation that determines where it is located in world space. World space is the standard frame that all spaces are defined in terms of.

3. Camera space:

(相機空間 座標系,座標系的 +Z軸  就是 Camera 的 Forward)

A virtual camera is placed in the scene at some world space point with a particular viewing direction and orientation. This defines a new coordinate system with its origin at the camera’s location. The z axis of this coordinate system is mapped to the viewing direction, and the y axis is mapped to the up direction.

This is a handy(便利) space for reasoning about which objects are potentially(可能) visible to the camera. For example, if an object’s camera space bounding box is entirely behind the z = 0 plane (and the camera doesn’t have a field of view wider than 180 degrees), the object will not be visible to the camera.

4. Screen space:

(注意,這裡的 "Screen space" 其實就是 並不是 平時理解的螢幕空間座標)

Screen space is defined on the image plane. The camera projects objects in camera space onto the image plane; the parts inside the screen window are visible in the image that is generated. Depth z values in screen space range from zero to one, corresponding to points at the near and far clipping planes, respectively. Note that, although this is called “screen” space, it is still a 3D coordinate system, since z values are meaningful.