Blender V2.61 - r43446
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | Friends

KX_Camera Class Reference

#include <KX_Camera.h>

Inheritance diagram for KX_Camera:
Inheritance graph
[legend]

List of all members.

Public Types

enum  { INSIDE, INTERSECT, OUTSIDE }

Public Member Functions

 KX_Camera (void *sgReplicationInfo, SG_Callbacks callbacks, const RAS_CameraData &camdata, bool frustum_culling=true, bool delete_node=false)
virtual ~KX_Camera ()
virtual CValueGetReplica ()
virtual void ProcessReplica ()
MT_Transform GetWorldToCamera () const
MT_Transform GetCameraToWorld () const
void CorrectLookUp (MT_Scalar speed)
const MT_Point3 GetCameraLocation () const
const MT_Quaternion GetCameraOrientation () const
void SetProjectionMatrix (const MT_Matrix4x4 &mat)
void SetModelviewMatrix (const MT_Matrix4x4 &mat)
const MT_Matrix4x4GetProjectionMatrix () const
bool hasValidProjectionMatrix () const
void InvalidateProjectionMatrix (bool valid=false)
const MT_Matrix4x4GetModelviewMatrix () const
float GetLens () const
float GetScale () const
float GetSensorWidth () const
float GetSensorHeight () const
short GetSensorFit () const
float GetCameraNear () const
float GetCameraFar () const
float GetFocalLength () const
RAS_CameraDataGetCameraData ()
int SphereInsideFrustum (const MT_Point3 &center, const MT_Scalar &radius)
int BoxInsideFrustum (const MT_Point3 *box)
bool PointInsideFrustum (const MT_Point3 &x)
bool GetFrustumCulling () const
void EnableViewport (bool viewport)
void SetViewport (int left, int bottom, int right, int top)
bool GetViewport () const
int GetViewportLeft () const
int GetViewportBottom () const
int GetViewportRight () const
int GetViewportTop () const
virtual int GetGameObjectType ()

Protected Member Functions

void ExtractClipPlanes ()
void NormalizeClipPlanes ()
void ExtractFrustumSphere ()
MT_Vector4GetNormalizedClipPlanes ()

Protected Attributes

RAS_CameraData m_camdata
MT_Matrix4x4 m_projection_matrix
MT_Matrix4x4 m_modelview_matrix
bool m_dirty
bool m_normalized
MT_Vector4 m_planes [6]
bool m_frustum_culling
bool m_set_projection_matrix
MT_Point3 m_frustum_center
MT_Scalar m_frustum_radius
bool m_set_frustum_center
bool m_delete_node

Friends

class KX_Scene

Detailed Description

Definition at line 51 of file KX_Camera.h.


Member Enumeration Documentation

anonymous enum
Enumerator:
INSIDE 
INTERSECT 
OUTSIDE 

Definition at line 148 of file KX_Camera.h.


Constructor & Destructor Documentation

KX_Camera::KX_Camera ( void *  sgReplicationInfo,
SG_Callbacks  callbacks,
const RAS_CameraData camdata,
bool  frustum_culling = true,
bool  delete_node = false 
)

Definition at line 40 of file KX_Camera.cpp.

References m_modelview_matrix, KX_GameObject::m_name, and m_projection_matrix.

Referenced by GetReplica().

KX_Camera::~KX_Camera ( ) [virtual]

Definition at line 62 of file KX_Camera.cpp.

References m_delete_node, KX_GameObject::m_pSGNode, and NULL.


Member Function Documentation

int KX_Camera::BoxInsideFrustum ( const MT_Point3 box)

Tests the given eight corners of a box with the view frustum.

Parameters:
boxa pointer to eight MT_Point3 representing the world coordinates of the corners of the box.
Returns:
INSIDE, INTERSECT, or OUTSIDE depending on the box's relation to the frustum.

Definition at line 398 of file KX_Camera.cpp.

References ExtractClipPlanes(), INSIDE, INTERSECT, m_planes, OUTSIDE, and p.

Referenced by KX_Scene::MarkVisible().

void KX_Camera::CorrectLookUp ( MT_Scalar  speed)

Not implemented.

Definition at line 107 of file KX_Camera.cpp.

void KX_Camera::EnableViewport ( bool  viewport)

Sets this camera's viewport status.

Definition at line 461 of file KX_Camera.cpp.

References m_camdata, and RAS_CameraData::m_viewport.

void KX_Camera::ExtractClipPlanes ( ) [protected]

Extracts the camera clip frames from the projection and world-to-camera matrices.

Definition at line 248 of file KX_Camera.cpp.

References m_dirty, m_modelview_matrix, m_normalized, m_planes, and m_projection_matrix.

Referenced by BoxInsideFrustum(), GetNormalizedClipPlanes(), PointInsideFrustum(), and SphereInsideFrustum().

void KX_Camera::ExtractFrustumSphere ( ) [protected]
RAS_CameraData * KX_Camera::GetCameraData ( )

Gets all camera data.

Definition at line 243 of file KX_Camera.cpp.

References m_camdata.

Referenced by KX_LightObject::BindShadowBuffer(), ImageRender::Render(), KX_Dome::RotateCamera(), and KX_CameraIpoSGController::Update().

float KX_Camera::GetCameraFar ( ) const

Gets the far clip distance.

Definition at line 231 of file KX_Camera.cpp.

References m_camdata, and RAS_CameraData::m_clipend.

Referenced by BL_ConvertBlenderObjects(), KX_Dome::CalculateFrustum(), and ImageRender::Render().

const MT_Point3 KX_Camera::GetCameraLocation ( ) const

Definition at line 113 of file KX_Camera.cpp.

References KX_GameObject::NodeGetWorldPosition().

Referenced by KX_Scene::MarkVisible().

float KX_Camera::GetCameraNear ( ) const

Gets the near clip distance.

Definition at line 224 of file KX_Camera.cpp.

References m_camdata, and RAS_CameraData::m_clipstart.

Referenced by BL_ConvertBlenderObjects(), KX_Dome::CalculateFrustum(), and ImageRender::Render().

const MT_Quaternion KX_Camera::GetCameraOrientation ( ) const

Definition at line 128 of file KX_Camera.cpp.

References KX_GameObject::NodeGetWorldOrientation().

MT_Transform KX_Camera::GetCameraToWorld ( ) const
float KX_Camera::GetFocalLength ( ) const

Gets the focal length (only used for stereo rendering)

Definition at line 236 of file KX_Camera.cpp.

References m_camdata, and RAS_CameraData::m_focallength.

bool KX_Camera::GetFrustumCulling ( ) const

Gets this camera's culling status.

Definition at line 456 of file KX_Camera.cpp.

References m_frustum_culling.

Referenced by KX_Scene::MarkVisible().

virtual int KX_Camera::GetGameObjectType ( ) [inline, virtual]

Reimplemented from SCA_IObject.

Definition at line 278 of file KX_Camera.h.

References SCA_IObject::OBJ_CAMERA.

float KX_Camera::GetLens ( ) const

Gets the aperture.

Definition at line 193 of file KX_Camera.cpp.

References m_camdata, and RAS_CameraData::m_lens.

Referenced by ImageRender::Render().

const MT_Matrix4x4 & KX_Camera::GetModelviewMatrix ( ) const

Gets the modelview matrix that is used by the rasterizer.

Warning:
If the Camera is a dynamic object then this method may return garbage. Use GetCameraToWorld() instead.

Gets the modelview matrix that is used by the rasterizer.

Definition at line 173 of file KX_Camera.cpp.

References m_modelview_matrix.

MT_Vector4* KX_Camera::GetNormalizedClipPlanes ( ) [inline, protected]

return the clip plane

Definition at line 139 of file KX_Camera.h.

References ExtractClipPlanes(), m_planes, and NormalizeClipPlanes().

Referenced by KX_Scene::CalculateVisibleMeshes().

const MT_Matrix4x4 & KX_Camera::GetProjectionMatrix ( ) const

Gets the projection matrix that is used by the rasterizer.

Definition at line 163 of file KX_Camera.cpp.

References m_projection_matrix.

Referenced by ImageRender::Render(), and KX_Dome::RenderDomeFrame().

CValue * KX_Camera::GetReplica ( void  ) [virtual]

Inherited from CValue -- return a new copy of this instance allocated on the heap. Ownership of the new object belongs with the caller.

Reimplemented from KX_GameObject.

Definition at line 73 of file KX_Camera.cpp.

References KX_Camera(), and ProcessReplica().

float KX_Camera::GetScale ( ) const

Gets the ortho scale.

Definition at line 198 of file KX_Camera.cpp.

References m_camdata, and RAS_CameraData::m_scale.

Referenced by ImageRender::Render().

short KX_Camera::GetSensorFit ( ) const

Gets the mode FOV is calculating from sensor dimensions

Definition at line 219 of file KX_Camera.cpp.

References m_camdata, and RAS_CameraData::m_sensor_fit.

Referenced by ImageRender::Render().

float KX_Camera::GetSensorHeight ( ) const

Gets the vertical size of the sensor - for camera matching

Definition at line 214 of file KX_Camera.cpp.

References m_camdata, and RAS_CameraData::m_sensor_y.

Referenced by ImageRender::Render().

float KX_Camera::GetSensorWidth ( ) const

Gets the horizontal size of the sensor - for camera matching

Definition at line 206 of file KX_Camera.cpp.

References m_camdata, and RAS_CameraData::m_sensor_x.

Referenced by ImageRender::Render().

bool KX_Camera::GetViewport ( ) const

Gets this camera's viewport status.

Definition at line 474 of file KX_Camera.cpp.

References m_camdata, and RAS_CameraData::m_viewport.

Referenced by ImageRender::calcImage(), KX_KetsjiEngine::GetSceneViewport(), KX_KetsjiEngine::Render(), and KX_KetsjiEngine::RenderDome().

int KX_Camera::GetViewportBottom ( ) const

Gets this camera's viewport bottom.

Definition at line 484 of file KX_Camera.cpp.

References m_camdata, and RAS_CameraData::m_viewportbottom.

Referenced by KX_KetsjiEngine::GetSceneViewport().

int KX_Camera::GetViewportLeft ( ) const

Gets this camera's viewport left.

Definition at line 479 of file KX_Camera.cpp.

References m_camdata, and RAS_CameraData::m_viewportleft.

Referenced by KX_KetsjiEngine::GetSceneViewport().

int KX_Camera::GetViewportRight ( ) const

Gets this camera's viewport right.

Definition at line 489 of file KX_Camera.cpp.

References m_camdata, and RAS_CameraData::m_viewportright.

Referenced by KX_KetsjiEngine::GetSceneViewport().

int KX_Camera::GetViewportTop ( ) const

Gets this camera's viewport top.

Definition at line 494 of file KX_Camera.cpp.

References m_camdata, and RAS_CameraData::m_viewporttop.

Referenced by KX_KetsjiEngine::GetSceneViewport().

MT_Transform KX_Camera::GetWorldToCamera ( ) const
bool KX_Camera::hasValidProjectionMatrix ( ) const

returns true if this camera has been set a projection matrix.

Definition at line 179 of file KX_Camera.cpp.

References m_set_projection_matrix.

Referenced by ImageRender::Render().

void KX_Camera::InvalidateProjectionMatrix ( bool  valid = false)

Sets the validity of the projection matrix. Call this if you change camera data (eg lens, near plane, far plane) and require the projection matrix to be recalculated.

Definition at line 184 of file KX_Camera.cpp.

References m_set_projection_matrix.

Referenced by KX_CameraIpoSGController::Update().

void KX_Camera::NormalizeClipPlanes ( ) [protected]

Normalize the camera clip frames.

Definition at line 271 of file KX_Camera.cpp.

References m_normalized, m_planes, MT_fuzzyZero(), p, and sqrt().

Referenced by GetNormalizedClipPlanes(), and SphereInsideFrustum().

bool KX_Camera::PointInsideFrustum ( const MT_Point3 x)

Tests the given point against the view frustum.

Returns:
true if the given point is inside or on the view frustum; false if it is outside.

Definition at line 386 of file KX_Camera.cpp.

References ExtractClipPlanes(), i, and m_planes.

void KX_Camera::ProcessReplica ( ) [virtual]

Inherited from CValue -- Makes sure any internal data owned by this class is deep copied. Called internally

Reimplemented from KX_GameObject.

Definition at line 83 of file KX_Camera.cpp.

References m_delete_node.

Referenced by GetReplica().

void KX_Camera::SetModelviewMatrix ( const MT_Matrix4x4 mat)

Sets the modelview matrix that is used by the rasterizer.

Definition at line 151 of file KX_Camera.cpp.

References m_dirty, m_modelview_matrix, and m_set_frustum_center.

Referenced by KX_LightObject::BindShadowBuffer(), ImageRender::Render(), KX_Dome::RenderDomeFrame(), and KX_Dome::RotateCamera().

void KX_Camera::SetProjectionMatrix ( const MT_Matrix4x4 mat)

Sets the projection matrix that is used by the rasterizer.

Definition at line 138 of file KX_Camera.cpp.

References m_dirty, m_projection_matrix, m_set_frustum_center, and m_set_projection_matrix.

Referenced by KX_LightObject::BindShadowBuffer(), ImageRender::Render(), and KX_Dome::RenderDomeFrame().

void KX_Camera::SetViewport ( int  left,
int  bottom,
int  right,
int  top 
)
int KX_Camera::SphereInsideFrustum ( const MT_Point3 center,
const MT_Scalar radius 
)

Tests if the given sphere is inside this camera's view frustum.

Parameters:
centerThe center of the sphere, in world coordinates.
radiusThe radius of the sphere.
Returns:
INSIDE, INTERSECT, or OUTSIDE depending on the sphere's relation to the frustum.

Definition at line 430 of file KX_Camera.cpp.

References distance(), MT_Point3::distance2(), ExtractClipPlanes(), ExtractFrustumSphere(), fabs(), INSIDE, intersect(), INTERSECT, m_frustum_center, m_frustum_radius, m_planes, NormalizeClipPlanes(), OUTSIDE, and p.

Referenced by KX_Scene::MarkVisible().


Friends And Related Function Documentation

friend class KX_Scene [friend]

Definition at line 55 of file KX_Camera.h.


Member Data Documentation

Camera parameters (clips distances, focal length). These params are closely tied to Blender. In the gameengine, only the projection and modelview matrices are relevant. There's a conversion being done in the engine class. Why is it stored here? It doesn't really have a function here.

Definition at line 61 of file KX_Camera.h.

Referenced by EnableViewport(), GetCameraData(), GetCameraFar(), GetCameraNear(), GetFocalLength(), GetLens(), GetScale(), GetSensorFit(), GetSensorHeight(), GetSensorWidth(), GetViewport(), GetViewportBottom(), GetViewportLeft(), GetViewportRight(), GetViewportTop(), and SetViewport().

bool KX_Camera::m_delete_node [protected]

whether the camera should delete the node itself (only for shadow camera)

Definition at line 122 of file KX_Camera.h.

Referenced by ProcessReplica(), and ~KX_Camera().

bool KX_Camera::m_dirty [protected]

true if the view frustum (modelview/projection matrix) has changed - the clip planes (m_planes) will have to be regenerated.

Definition at line 90 of file KX_Camera.h.

Referenced by ExtractClipPlanes(), SetModelviewMatrix(), and SetProjectionMatrix().

The center point of the frustum.

Definition at line 115 of file KX_Camera.h.

Referenced by ExtractFrustumSphere(), and SphereInsideFrustum().

bool KX_Camera::m_frustum_culling [protected]

This camera is frustum culling. Some cameras (ie if the game was started from a non camera view should not cull.)

Definition at line 105 of file KX_Camera.h.

Referenced by GetFrustumCulling().

Definition at line 116 of file KX_Camera.h.

Referenced by ExtractFrustumSphere(), and SphereInsideFrustum().

Storage for the modelview matrix that is passed to the rasterizer.

Definition at line 83 of file KX_Camera.h.

Referenced by ExtractClipPlanes(), GetModelviewMatrix(), KX_Camera(), and SetModelviewMatrix().

bool KX_Camera::m_normalized [protected]

true if the frustum planes have been normalized.

Definition at line 94 of file KX_Camera.h.

Referenced by ExtractClipPlanes(), and NormalizeClipPlanes().

Storage for the projection matrix that is passed to the rasterizer.

Definition at line 77 of file KX_Camera.h.

Referenced by ExtractClipPlanes(), ExtractFrustumSphere(), GetProjectionMatrix(), KX_Camera(), and SetProjectionMatrix().

Definition at line 117 of file KX_Camera.h.

Referenced by ExtractFrustumSphere(), SetModelviewMatrix(), and SetProjectionMatrix().

true if this camera has a valid projection matrix.

Definition at line 110 of file KX_Camera.h.

Referenced by hasValidProjectionMatrix(), InvalidateProjectionMatrix(), and SetProjectionMatrix().


The documentation for this class was generated from the following files: