User Tools

Site Tools


CView (Camera Class)

The culling systems for the forest, terrain, grass, and shadow systems all use the CView class to communicate information about a camera. CView encapsulates many of the common values associated with a particular view like projection and modelview matrices and near and far clipping planes, but it also includes code for deriving values like camera azimuth and pitch, frustum planes and points, and a billboarding matrix.

CView requires the following data to derive the values needed for use in the SDK, as illustrated through the CView::Set() function:

st_bool CView::Set(const Vec3&   vCameraPos,
                   const Mat4x4& mProjection,
                   const Mat4x4& mModelview,
                   st_float32    fNearClip,
                   st_float32    fFarClip);

Set() will return true if the supplied values were different from the last values (it will skip deriving new values if they were unchanged).

In addition to the user-supplied values, the derived values that can be queried include:

  • Camera direction
  • Composite matrix (modelview * projection matrices)
  • Composite matrix with no translation element
  • Camera azimuth and pitch
  • Eight points defining the view frustum's geometry
  • Six planes defining the frustum
  • Axis-aligned bounding box of the frustum's geometry

LOD Reference Point

The LOD reference point is the point used for all LOD calculations in the forest culling system. It defaults to the camera's position, but in the case of shadow rendering, it is helpful for these to be separate values. Specifically, during shadow map rendering the light's position is camera position and the main camera is used as the LOD reference point to ensure that the tree's shadows cast with the same LOD that they were rendered with in the main view.

The LOD reference point must be specifically given through CView::SetLodRefPoint(), otherwise CView::GetLodRefPoint() will simply return the camera's position.