22 if ( a_bEnable )
m_eFlags |= a_eFlag;
43 :
m_pRenderer( a_pRenderer ),
m_eFlags(
FLAG_DIRTY ),
m_eClipFlags( 0x3F ),
m_eCameraMode(
CameraMode_Perspective ),
m_pCurrentSkeletonInstance(
TNULL ),
m_pCurrentCameraObject(
TNULL ),
m_AmbientColor( 1.0f, 1.0f, 1.0f, 0.0f ),
m_FogColor( 1.0f, 1.0f, 1.0f, 0.0f ),
m_fFogDistanceStart( 10.0f ),
m_fFogDistanceEnd( 1000.0f ),
m_fAlphaBlend( 1.0f ),
m_fShadeCoeff( 0.0f )
51 auto pMode = pDevice->GetMode();
122 a_rOutProjection.
m_f11 = ( a_rProjParams.
m_Proj.
x * 2.0f ) / a_rViewportParams.
fWidth;
123 a_rOutProjection.
m_f12 = 0.0f;
124 a_rOutProjection.
m_f13 = 0.0f;
125 a_rOutProjection.
m_f14 = 0.0f;
126 a_rOutProjection.
m_f21 = 0.0f;
127 a_rOutProjection.
m_f22 = -( ( a_rProjParams.
m_Proj.
y * 2.0f ) / a_rViewportParams.
fHeight );
128 a_rOutProjection.
m_f23 = 0.0f;
129 a_rOutProjection.
m_f24 = 0.0f;
131 a_rOutProjection.
m_f32 = -( ( a_rProjParams.
m_Centre.
y * 2.0f ) / a_rViewportParams.
fHeight - 1.0f );
133 a_rOutProjection.
m_f34 = 1.0f;
134 a_rOutProjection.
m_f41 = 0.0f;
135 a_rOutProjection.
m_f42 = 0.0f;
137 a_rOutProjection.
m_f44 = 0.0f;
152 a_rOutProjection.
m_f11 = ( a_rProjParams.
m_Proj.
x * 2.0f ) / a_rViewportParams.
fWidth;
153 a_rOutProjection.
m_f12 = 0.0f;
154 a_rOutProjection.
m_f13 = 0.0f;
155 a_rOutProjection.
m_f14 = 0.0f;
156 a_rOutProjection.
m_f21 = 0.0f;
157 a_rOutProjection.
m_f22 = -( ( a_rProjParams.
m_Proj.
y * 2.0f ) / a_rViewportParams.
fHeight );
158 a_rOutProjection.
m_f23 = 0.0f;
159 a_rOutProjection.
m_f24 = 0.0f;
160 a_rOutProjection.
m_f31 = 0.0f;
161 a_rOutProjection.
m_f32 = 0.0f;
163 a_rOutProjection.
m_f34 = 0.0f;
165 a_rOutProjection.
m_f42 = -( ( a_rProjParams.
m_Centre.
y * 2.0f ) / a_rViewportParams.
fHeight - 1.0f );
167 a_rOutProjection.
m_f44 = 1.0f;
212 TINT iLeftPlanes = a_iClipFlags & a_iClipFlagsMask;
216 if ( iLeftPlanes == 0 )
221 if ( iLeftPlanes & iPlaneFlag )
232 a_iClipFlags &= ~iPlaneFlag;
235 iLeftPlanes &= ~iPlaneFlag;
238 iPlaneFlag = iPlaneFlag << 1;
319 a_rcFrustum[
WORLDPLANE_TOP ].AsVector4().CrossProduct( vec1, vec2 );
352 a_rcFrustum[
WORLDPLANE_LEFT ].Set( -1.0f, 0.0f, 0.0f, fCentreX * fProjXOverOne );
353 a_rcFrustum[
WORLDPLANE_RIGHT ].Set( 1.0f, 0.0f, 0.0f, ( fWidth - fCentreX ) * fProjXOverOne );
354 a_rcFrustum[
WORLDPLANE_BOTTOM ].Set( 0.0f, -1.0f, 0.0f, fCentreY * fProjYOverOne );
355 a_rcFrustum[
WORLDPLANE_TOP ].Set( 0.0f, 1.0f, 0.0f, ( fHeight - fCentreY ) * fProjYOverOne );
362 TFLOAT fHalfWidth = a_fViewportWidth * 0.5f;
363 TFLOAT fHalfHeight = a_fViewportHeight * 0.5f;
376 for (
TINT i = 0; i < 4; i++ )
378 if (
aIDs[ i ] == -1 )
380 aIDs[ i ] = a_iLightId;
397 return aIDs[ a_iIndex ];
TPlane[WORLDPLANE_NUMOF] TFrustum
Rendering system interface for the Toshi engine.
#define HASANYFLAG(STATE, FLAG)
#define TOSHI_NAMESPACE_START
#define TOSHI_NAMESPACE_END
TFORCEINLINE TFLOAT Tan(TFLOAT fVal)
TFORCEINLINE TBOOL IsFinite(TFLOAT fVal)
TFORCEINLINE TBOOL IsNaN(TFLOAT fVal)
TFORCEINLINE constexpr TFLOAT DegToRad(TFLOAT fDeg)
static void TransformPlaneOrthogonal(TPlane &a_rOutPlane, const TMatrix44 &a_rMatrix, const TPlane &a_rcSourcePlane)
TFORCEINLINE TVector4 & AsVector4()
TFORCEINLINE constexpr TFLOAT GetD() const
TFORCEINLINE TVector4 & AsVector4()
constexpr TFORCEINLINE TFLOAT GetRadius() const
TFLOAT constexpr DotProduct3(const TVector4 &vec) const
TLightID aIDs[MAX_NUM_LIGHTS]
TLightID & operator[](TINT a_iIndex)
void Add(TLightID a_iLightId)
static constexpr TINT MAX_NUM_LIGHTS
PROJECTIONPARAMS m_oProjParams
static TBOOL CullSphereToFrustumSimple(const TSphere &a_rSphere, const TPlane *a_pPlanes, TINT a_iNumPlanes)
TRenderContext(TRenderInterface *pRender)
TMatrix44 m_oViewWorldMatrix
void SetProjectionParams(const PROJECTIONPARAMS &a_rParams)
virtual ~TRenderContext()
static void ComputeOrthographicFrustum(TFrustum &a_rcFrustum, const VIEWPORTPARAMS &a_rViewportParams, const PROJECTIONPARAMS &a_rProjParams)
TUINT SetClipFlags(TUINT a_uiClipFlags)
void SetFlag(FLAG a_eFlag, TBOOL a_bEnable)
virtual void SetWorldViewMatrix(const TMatrix44 &a_rMatrix)
TFrustum m_aFrustumPlanes1
TFLOAT m_fFogDistanceStart
const TPlane * GetWorldPlanes()
const TMatrix44 & GetModelWorldMatrix()
void SetViewportParameters(const VIEWPORTPARAMS &a_rParams)
VIEWPORTPARAMS m_oViewportParams
static void ComputeOrthographicProjection(TMatrix44 &a_rOutProjection, const VIEWPORTPARAMS &a_rViewportParams, const PROJECTIONPARAMS &a_rProjParams)
TMatrix44 m_oModelWorldMatrix
TMatrix44 m_oWorldViewMatrix
static TINT CullSphereToFrustum(const TSphere &a_rSphere, const TPlane *a_pPlanes, TINT a_iClipFlags, TINT a_iClipFlagsMask)
TMatrix44 m_oModelViewMatrix
void AddLight(TLightID a_iLightId)
void SetFogDistance(TFLOAT a_fStart, TFLOAT a_fEnd)
TUINT GetClipFlags() const
void SetDirty(TBOOL a_bDirty)
virtual void SetModelViewMatrix(const TMatrix44 &a_rMatrix)
TRenderInterface * m_pRenderer
TSkeletonInstance * m_pCurrentSkeletonInstance
static void ComputePerspectiveProjection(TMatrix44 &a_rOutProjection, const VIEWPORTPARAMS &a_rViewportParams, const PROJECTIONPARAMS &a_rProjParams)
static void ComputePerspectiveFrustum(TFrustum &a_rcFrustum, const VIEWPORTPARAMS &a_rViewportParams, const PROJECTIONPARAMS &a_rProjParams)
const TMatrix44 & GetViewWorldMatrix()
const TMatrix44 & GetWorldModelMatrix()
void EnableFog(TBOOL a_bEnable)
@ FLAG_HAS_MODELWORLDMATRIX
@ FLAG_DIRTY_VIEWMODELMATRIX
@ FLAG_HAS_VIEWWORLDMATRIX
@ FLAG_DIRTY_WORLDMODELMATRIX
const TMatrix44 & GetViewModelMatrix()
TMatrix44 m_oWorldModelMatrix
TCameraObject * m_pCurrentCameraObject
void SetCameraMode(CameraMode a_eCameraMode)
TMatrix44 m_oViewModelMatrix
void SetFromFOV(TFLOAT a_fViewportWidth, TFLOAT a_fViewportHeight, TFLOAT a_fFOV, TFLOAT a_fNearPlane, TFLOAT a_fFarPlane)