16 : m_iMaxNumObjects( a_iMaxNumGlowObjects ), m_pHeadFreeObject(
TNULL )
19 m_pAllocObjects =
new GlowObject[ a_iMaxNumGlowObjects ];
22 for (
TLightID i = 0; i < a_iMaxNumGlowObjects - 1; i++ )
24 m_pAllocObjects[ i ].m_iID = i;
25 m_pAllocObjects[ i ].m_pNextObject = &m_pAllocObjects[ i + 1 ];
29 m_pAllocObjects[ a_iMaxNumGlowObjects - 1 ].
m_iID = a_iMaxNumGlowObjects - 1;
30 m_pAllocObjects[ a_iMaxNumGlowObjects - 1 ].m_pNextObject =
TNULL;
32 m_pHeadUsedObject =
TNULL;
33 m_pHeadFreeObject = m_pAllocObjects;
38 delete[] m_pAllocObjects;
43 if ( m_pHeadFreeObject ==
TNULL )
56 m_pHeadUsedObject = pGlowObject;
63 if ( a_pGlowObject ==
TNULL )
72 if ( pGlowObject == a_pGlowObject )
75 pPrevObject = pGlowObject;
79 TASSERT( pGlowObject == a_pGlowObject );
81 if ( pPrevObject !=
TNULL )
86 m_pHeadFreeObject = pGlowObject;
91 m_pHeadUsedObject = m_pHeadUsedObject->m_pNextObject;
93 m_pHeadFreeObject = pGlowObject;
102 for (
GlowObject* pGlowObject = m_pHeadUsedObject; pGlowObject !=
TNULL; pGlowObject = pGlowObject->m_pNextObject )
105 if ( pGlowObject->IsEnabled() &&
106 ( pGlowObject->IsNightLight() || AGameTimeManager::GetSingleton()->IsItNight() ) &&
110 a_rLightIDs[ iNumLights++ ] = pGlowObject->m_iID;
126 for (
GlowObject* pGlowObject = m_pHeadUsedObject; pGlowObject !=
TNULL; pGlowObject = pGlowObject->m_pNextObject )
128 if (
TSceneObject* pSceneObject = pGlowObject->m_pSceneObject )
133 if ( !pModelInstance )
144 pSceneObject->GetTransform().GetLocalMatrixImp( oLightTransform );
147 oLightTransform.
Multiply( oBoneTransform );
157 oLightTransform.
Multiply( pGlowObject->m_oTransform );
159 switch ( pGlowObject->m_eTransformType )
162 oLightTransform.
Scale( -1.0f, -1.0f, -1.0f );
165 oLightTransform.
Scale( -1.0f, -1.0f, -1.0f );
171 oLightTransform.
Scale( -1.0f, -1.0f, -1.0f );
183 pGlowObject->Setup( oLightTransform, pGlowObject->m_oViewportParams, pGlowObject->m_oProjectionParams, pGlowObject->m_eCameraMode );
186 pRenderContext->
AddLight( pGlowObject->m_iID );
191 TVector4 vLightDir( 1.0f, -1.1f, 0.0f );
203 1.0f, 0.0f, 0.0f, 0.0f,
204 0.0f, 0.0f, 1.0f, 0.0f,
205 0.0f, -1.0f, 0.0f, 0.0f,
206 0.0f, 0.0f, 0.0f, 1.0f
210 pGlowObject->m_oMVP = oMVP;
226 oViewportParams.
fX = 0.0f;
227 oViewportParams.
fY = 0.0f;
228 oViewportParams.
fMinZ = 0.0f;
229 oViewportParams.
fMaxZ = 1.0f;
230 oViewportParams.
fWidth = 1.0f;
231 oViewportParams.
fHeight = 1.0f;
245void AGlowViewport::GlowObject::Setup(
const Toshi::TMatrix44& a_rcTransform,
const Toshi::TRenderContext::VIEWPORTPARAMS& a_rcViewportParams,
const Toshi::TRenderContext::PROJECTIONPARAMS& a_rcProjectionParams, Toshi::TRenderContext::CameraMode a_eCameraMode )
266 oTransformInverted.
Invert( a_rcTransform );
273 m_oMVP.Multiply( oProjection, a_rcTransform );
TPlane[WORLDPLANE_NUMOF] TFrustum
Rendering system interface for the Toshi engine.
#define TOSHI_NAMESPACE_USING
TFORCEINLINE constexpr TFLOAT DegToRad(TFLOAT fDeg)
static constexpr void TransformVector(TVector3 &a_rOutVector, const TMatrix44 &a_rMatrix, const TVector3 &a_rVector)
constexpr void Scale(TFLOAT a_fScalar1, TFLOAT a_fScalar2, TFLOAT a_fScalar3)
static void TransformPlaneOrthogonal(TPlane &a_rOutPlane, const TMatrix44 &a_rMatrix, const TPlane &a_rcSourcePlane)
TBOOL Invert(const TMatrix44 &a_rRight)
static constinit TMatrix44 IDENTITY
TVector4 & GetTranslation()
const TVector4 & AsBasisVector4(BASISVECTOR a_iIndex) const
void Multiply(const TMatrix44 &a_rLeft, const TMatrix44 &a_rRight)
void SetVectorDirection(const TVector3 &a_rVec3, const TVector3 &a_rVec3_2)
static constinit const TVector3 VEC_POSZ
constexpr void Negate4(const TVector4 &vec)
static void Swap(TVector4 &a_rVec1, TVector4 &a_rVec2)
constexpr void Negate3(const TVector4 &vec)
TSkeletonInstance * GetSkeletonInstance() const
static constexpr TINT MAX_NUM_LIGHTS
static TBOOL CullSphereToFrustumSimple(const TSphere &a_rSphere, const TPlane *a_pPlanes, TINT a_iNumPlanes)
@ CameraMode_Orthographic
static void ComputeOrthographicFrustum(TFrustum &a_rcFrustum, const VIEWPORTPARAMS &a_rViewportParams, const PROJECTIONPARAMS &a_rProjParams)
static void ComputeOrthographicProjection(TMatrix44 &a_rOutProjection, const VIEWPORTPARAMS &a_rViewportParams, const PROJECTIONPARAMS &a_rProjParams)
void AddLight(TLightID a_iLightId)
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)
void SetFromFOV(TFLOAT a_fViewportWidth, TFLOAT a_fViewportHeight, TFLOAT a_fFOV, TFLOAT a_fNearPlane, TFLOAT a_fFarPlane)
TRenderContext * GetCurrentContext() const
const TMatrix44 & GetBoneTransformCurrent(TINT a_iBone)
static TFORCEINLINE TRenderInterface * GetSingleton()
void RemoveGlowObject(GlowObject *a_pGlowObject)
void GetInfluencingLightIDs(const Toshi::TSphere &a_rcSphere, Toshi::TLightIDList &a_rLightIDs)
AGlowViewport(TINT a_iMaxNumGlowingObjects)
GlowObject * CreateGlowObject()
Toshi::TFrustum m_oFrustum
GlowObject * m_pNextObject
Toshi::TRenderContext::VIEWPORTPARAMS m_oViewportParams
void Setup(const Toshi::TMatrix44 &a_rcTransform, const Toshi::TRenderContext::VIEWPORTPARAMS &a_rcViewportParams, const Toshi::TRenderContext::PROJECTIONPARAMS &a_rcProjectionParams, Toshi::TRenderContext::CameraMode a_eCameraMode)
Toshi::TRenderContext::PROJECTIONPARAMS m_oProjectionParams
Toshi::TMatrix44 m_oTransform
Toshi::TSceneObject * m_pSceneObject
Toshi::TRenderContext::CameraMode m_eCameraMode