#include
Public Member Functions | |
ILINE void | SetMatrix (const Matrix34 &mat) |
ILINE void | SetMatrixNoUpdate (const Matrix34 &mat) |
ILINE const Matrix34 & | GetMatrix () const |
ILINE Vec3 | GetViewdir () const |
ILINE Matrix34 | GetViewMatrix () const |
ILINE Vec3 | GetPosition () const |
ILINE void | SetPosition (const Vec3 &p) |
ILINE void | SetPositionNoUpdate (const Vec3 &p) |
ILINE bool | Project (const Vec3 &p, Vec3 &result, Vec2i topLeft=Vec2i(0, 0), Vec2i widthHeight=Vec2i(0, 0)) const |
ILINE bool | Unproject (const Vec3 &viewportPos, Vec3 &result, Vec2i topLeft=Vec2i(0, 0), Vec2i widthHeight=Vec2i(0, 0)) const |
ILINE void | CalcScreenBounds (int *vOut, const AABB *pAABB, int nWidth, int nHeight) const |
ILINE Vec3 | GetUp () const |
ILINE const Matrix44 & | GetRenderViewMatrix () const |
ILINE const Matrix44 & | GetRenderProjectionMatrix () const |
ILINE const Vec3 | GetRenderVectorX () const |
ILINE const Vec3 | GetRenderVectorY () const |
ILINE const Vec3 | GetRenderVectorZ () const |
void | SetFrustum (int nWidth, int nHeight, f32 FOV=DEFAULT_FOV, f32 nearplane=DEFAULT_NEAR, f32 farpane=DEFAULT_FAR, f32 fPixelAspectRatio=1.0f) |
ILINE void | SetAsymmetry (float l, float r, float b, float t) |
ILINE int | GetViewSurfaceX () const |
ILINE int | GetViewSurfaceZ () const |
ILINE f32 | GetFov () const |
ILINE float | GetHorizontalFov () const |
ILINE f32 | GetNearPlane () const |
ILINE f32 | GetFarPlane () const |
ILINE f32 | GetProjRatio () const |
ILINE f32 | GetAngularResolution () const |
ILINE f32 | GetPixelAspectRatio () const |
ILINE Vec3 | GetEdgeP () const |
ILINE Vec3 | GetEdgeN () const |
ILINE Vec3 | GetEdgeF () const |
ILINE f32 | GetAsymL () const |
ILINE f32 | GetAsymR () const |
ILINE f32 | GetAsymB () const |
ILINE f32 | GetAsymT () const |
ILINE const Vec3 & | GetNPVertex (int nId) const |
get near-plane vertices More... | |
ILINE const Vec3 & | GetFPVertex (int nId) const |
get far-plane vertices More... | |
ILINE const Vec3 & | GetPPVertex (int nId) const |
get projection-plane vertices | |
ILINE const Plane * | GetFrustumPlane (int numplane) const |
ILINE void | GetAsymmetricFrustumParams (float &l, float &r, float &b, float &t) const |
ILINE void | CalcAsymmetricFrustumVertices (Vec3 vout[8]) const |
ILINE void | SetZRange (float zmin, float zmax) |
ILINE float | GetZRangeMin () const |
ILINE float | GetZRangeMax () const |
bool | IsPointVisible (const Vec3 &p) const |
Check if a point lies within camera's frustum. More... | |
bool | IsSphereVisible_F (const Sphere &s) const |
uint8 | IsSphereVisible_FH (const Sphere &s) const |
This is going to be the exact version of sphere-culling. More... | |
bool | IsAABBVisible_F (const AABB &aabb) const |
Fast. More... | |
uint8 | IsAABBVisible_FH (const AABB &aabb, bool *pAllInside) const |
uint8 | IsAABBVisible_FH (const AABB &aabb) const |
bool | IsAABBVisible_E (const AABB &aabb) const |
uint8 | IsAABBVisible_EH (const AABB &aabb, bool *pAllInside) const |
uint8 | IsAABBVisible_EH (const AABB &aabb) const |
bool | IsAABBVisible_EHM (const AABB &aabb, bool *pAllInside) const |
bool | IsAABBVisible_EM (const AABB &aabb) const |
bool | IsAABBVisible_FM (const AABB &aabb) const |
bool | IsOBBVisible_F (const Vec3 &wpos, const OBB &obb) const |
uint8 | IsOBBVisible_FH (const Vec3 &wpos, const OBB &obb) const |
Not yet implemented. | |
bool | IsOBBVisible_E (const Vec3 &wpos, const OBB &obb, f32 uscale) const |
uint8 | IsOBBVisible_EH (const Vec3 &wpos, const OBB &obb, f32 uscale) const |
void | GetFrustumVertices (Vec3 *pVerts) const |
void | GetFrustumVerticesCam (Vec3 *pVerts) const |
void | SetJustActivated (const bool justActivated) |
bool | IsJustActivated () const |
void | UpdateFrustum () |
Updates all parameters required by the render-engine: 3D-view-frustum and all matrices. More... | |
void | GetMemoryUsage (ICrySizer *pSizer) const |
EEye | GetEye () const |
void | SetEye (EEye eye) |
void | CalculateRenderMatrices () const |
void | SetObliqueClipPlane (const Plane &plane) |
const Plane & | GetObliqueClipPlane () const |
void | SetObliqueClipPlaneEnabled (bool bEnabled) |
bool | IsObliqueClipPlaneEnabled () const |
void | SetFrustumVertices (Vec3 *arrvVerts) |
void | SetPPVertex (int nId, const Vec3 &vVert) |
void | SetFrustumPlane (int i, const Plane &plane) |
Ang3 | GetAngles () const |
void | SetAngles (const Ang3 &angles) |
const Vec3 & | GetOccPos () const |
Static Public Member Functions | |
static ILINE Matrix33 | CreateOrientationYPR (const Ang3 &ypr) |
static ILINE Ang3 | CreateAnglesYPR (const Matrix33 &m) |
static ILINE Ang3 | CreateAnglesYPR (const Vec3 &vdir, f32 r=0) |
static ILINE Vec3 | CreateViewdir (const Ang3 &ypr) |
static ILINE Vec3 | CreateViewdir (const Matrix33 &m) |
Public Attributes | |
struct IVisArea * | m_pPortal |
Pointer to portal used to create this camera. | |
ScissorInfo | m_ScissorInfo |
class PodArray< CCamera > * | m_pMultiCamera |
Maybe used for culling instead of this camera. | |
Vec3 | m_OccPosition |
Position for calculate occlusions (needed for portals rendering). | |
int | m_JustActivated |
Camera activated in this frame, used for disabling motion blur effect at camera changes in movies. | |
bool | m_bOmniCamera = false |
int | m_curCubeFace = 0 |
Implements essential operations like calculation of a view-matrix and frustum-culling with simple geometric primitives (Point, Sphere, AABB, OBB). All calculation are based on the CRYENGINE coordinate-system. We are using a "right-handed" coordinate systems, where the positive X-Axis points to the right, the positive Y-Axis points away from the viewer and the positive Z-Axis points up. The following illustration shows our coordinate system.
z-axis ^ | | y-axis | / | / |/ +----------------> x-axis
This same system is also used in 3D-Studio-MAX. It is not unusual for 3D-APIs like D3D9 or OpenGL to use a different coordinate system. Currently in D3D9 we use a coordinate system in which the X-Axis points to the right, the Y-Axis points down and the Z-Axis points away from the viewer. To convert from the CryEngine system into D3D9 we are just doing a clockwise rotation of pi/2 about the X-Axis. This conversion happens in the renderer. The 6 DOFs (degrees-of-freedom) are stored in one single 3x4 matrix ("m_Matrix"). The 3 orientation-DOFs are stored in the 3x3 part and the 3 position-DOFs are stored in the translation- vector. You can use the member-functions "GetMatrix()" or "SetMatrix(Matrix34(orientation,positon))" to change or access the 6 DOFs. There are helper-function in Cry_Math.h to create the orientation: This function builds a 3x3 orientation matrix using a view-direction and a radiant to rotate about Y-axis. Matrix33 orientation=Matrix33::CreateOrientation( Vec3(0,1,0), 0 ); This function builds a 3x3 orientation matrix using Yaw-Pitch-Roll angles. Matrix33 orientation=CCamera::CreateOrientationYPR( Ang3(1.234f,0.342f,0) );
x-YAW y-PITCH (negative=looking down / positive=looking up) z-ROLL
x-YAW y-PITCH (negative=looking down / positive=looking up) z-ROLL (its not possile to extract a "roll" from a view-vector)
< Check if unit vector.
< Check if nonzero.
This function builds a 3x3 orientation matrix using YPR-angles Rotation order for the orientation-matrix is Z-X-Y. (Zaxis=YAW / Xaxis=PITCH / Yaxis=ROLL)
COORDINATE-SYSTEM z-axis ^ | | y-axis | / | / |/ +---------------> x-axis
Example: Matrix33 orientation=CCamera::CreateOrientationYPR( Ang3(1,2,3) );
< Zaxis = YAW.
< Xaxis = PITCH.
< Yaxis = ROLL.
x=yaw y=pitch z=roll (we ignore this element, since its not possible to convert the roll-component into a vector)
< all angles need to be in range between -pi and +pi
< YAW
< PITCH
< calculate the view-direction
ILINE const Vec3 & CCamera::GetFPVertex | ( | int | nId | ) | const |
get far-plane vertices
Get far-plane vertices.
|
inline |
pVerts | pointer to array of 8 elements |
ILINE const Vec3 & CCamera::GetNPVertex | ( | int | nId | ) | const |
get near-plane vertices
Get near-plane vertices.
|
inline |
This function checks if an AABB and the camera-frustum overlap. The AABB is assumed to be in world-space. This test can reject even such AABBs that overlap a frustum-plane far outside the view-frustum. IMPORTANT: This function is only useful if you really need exact-culling. It's about 30% slower then "IsAABBVisible_F(aabb)" Example: int InOut=camera.IsAABBVisible_E(aabb);
|
inline |
Improved approach to check if an AABB and the camera-frustum overlap, or if the AABB is totally inside the camera-frustum. The AABB is assumed to be in world-space. This test can reject even such AABBs that overlap a frustum-plane far outside the view-frustum. IMPORTANT: This function is only useful if you really need exact-culling. It's about 30% slower then "IsAABBVisible_FH(aabb)" Example: int InOut=camera.IsAABBVisible_EH(aabb);
|
inline |
Improved approach to check if an AABB and the camera-frustum overlap, or if the AABB is totally inside the camera-frustum. The AABB is assumed to be in world-space. This test can reject even such AABBs that overlap a frustum-plane far outside the view-frustum. IMPORTANT: This function is only useful if you really need exact-culling. It's about 30% slower then "IsAABBVisible_FH(aabb)" Example: int InOut=camera.IsAABBVisible_EH(aabb);
|
inline |
Makes culling taking into account presence of m_pMultiCamera. If m_pMultiCamera exists - object is visible if at least one of cameras see's it
ILINE bool CCamera::IsAABBVisible_EM | ( | const AABB & | aabb | ) | const |
Makes culling taking into account presence of m_pMultiCamera. If m_pMultiCamera exists - object is visible if at least one of cameras see's it
|
inline |
Fast.
Simple approach to check if an AABB and the camera-frustum overlap. The AABB is assumed to be in world-space. This is a very fast method, just one single dot-product is necessary to check an AABB against a plane. Actually there is no significant speed-different between culling a sphere or an AABB. Example: bool InOut=camera.IsAABBVisible_F(aabb);
|
inline |
|
inline |
ILINE bool CCamera::IsAABBVisible_FM | ( | const AABB & | aabb | ) | const |
Makes culling taking into account presence of m_pMultiCamera. If m_pMultiCamera exists - object is visible if at least one of cameras see's it
This function checks if an OBB and the camera-frustum overlap. This test can reject even such OBBs that overlap a frustum-plane far outside the view-frustum. IMPORTANT: It is about 10% slower then "IsOBBVisibleFast(obb)" Example: int InOut=camera.IsOBBVisible_E(OBB);
CULL_EXCLUSION | OBB outside of frustum (very fast rejection-test). |
CULL_OVERLAP | OBB intersects the borders of the frustum or is totally inside. |
Improved approach to check if an OBB and the camera-frustum intersect, or if the OBB is totally inside the camera-frustum. The bounding-box of the OBB is assumed to be in world-space. This test can reject even such OBBs that intersect a frustum-plane far outside the view-frustum. Example: int InOut=camera.IsOBBVisible_EH(obb);
CULL_EXCLUSION | OBB outside of frustum (very fast rejection-test) |
CULL_OVERLAP | OBB intersects the borders of the frustum, further checks necessary |
CULL_INCLUSION | OBB is complete inside the frustum, no further checks necessary |
Fast check if an OBB and the camera-frustum overlap, using the separating-axis-theorem (SAT). The center of the OOBB is assumed to be in world-space.
CULL_EXCLUSION | OBB outside of frustum (very fast rejection-test) |
CULL_OVERLAP | OBB and frustum intersects or OBB in totally inside frustum |
|
inline |
Check if a point lies within camera's frustum.
Check if a point lies within camera's frustum. Example: u8 InOut=camera.IsPointVisible(point);
|
inline |
Conventional method to check if a sphere and the camera-frustum overlap The center of the sphere is assumed to be in world-space. Example: u8 InOut=camera.IsSphereVisible_F(sphere);
|
inline |
This is going to be the exact version of sphere-culling.
Conventional method to check if a sphere and the camera-frustum overlap, or if the sphere is completely inside the camera-frustum. The center of the sphere is assumed to be in world-space. Example: u8 InOut=camera.IsSphereVisible_FH(sphere);
CULL_EXCLUSION | Sphere outside of frustum (very fast rejection-test). |
CULL_INTERSECT | Sphere intersects the borders of the frustum, further checks necessary. |
CULL_INCLUSION | Sphere is complete inside the frustum, no further checks necessary. |
p | World space position. |
result | Screen space pos. |
|
inline |
Z-Buffer ranges. This values are defining near/far clipping plane, it only used to specify z-buffer range. Use it only when you want to override default z-buffer range. Valid values for are: 0 <= zrange <= 1
|
inline |
Updates all parameters required by the render-engine: 3D-view-frustum and all matrices.
Calculate the six frustum-planes using the fustum edges in world-space.