2016-04-16 21:49:47 +00:00
|
|
|
#include "CParticleGenInfo.hpp"
|
2017-01-21 06:03:37 +00:00
|
|
|
#include "Graphics/IRenderer.hpp"
|
2016-04-16 21:49:47 +00:00
|
|
|
#include "Particle/CParticleGen.hpp"
|
2017-01-21 06:03:37 +00:00
|
|
|
#include "GameGlobalObjects.hpp"
|
|
|
|
#include "World/CGameLight.hpp"
|
|
|
|
#include "CStateManager.hpp"
|
|
|
|
#include "Graphics/CBooRenderer.hpp"
|
|
|
|
#include "TCastTo.hpp"
|
2016-04-16 21:49:47 +00:00
|
|
|
|
|
|
|
namespace urde
|
|
|
|
{
|
|
|
|
|
|
|
|
CParticleGenInfo::CParticleGenInfo(const SObjectTag& part, int frameCount, const std::string& boneName,
|
2017-01-21 06:03:37 +00:00
|
|
|
const zeus::CVector3f& scale, CParticleData::EParentedMode parentMode, int a, int b)
|
|
|
|
: x4_part(part)
|
|
|
|
, xc_seconds(frameCount / 60.f)
|
|
|
|
, x10_boneName(boneName)
|
|
|
|
, x28_parentMode(parentMode)
|
|
|
|
, x2c_a(a)
|
|
|
|
, x30_particleScale(scale)
|
|
|
|
, x80_(b)
|
2016-04-16 21:49:47 +00:00
|
|
|
{
|
2017-01-21 06:03:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static TUniqueId _initializeLight(const std::weak_ptr<CParticleGen>& system, CStateManager& stateMgr, TAreaId areaId,
|
|
|
|
int lightId)
|
|
|
|
{
|
|
|
|
TUniqueId ret = kInvalidUniqueId;
|
2016-04-16 21:49:47 +00:00
|
|
|
std::shared_ptr<CParticleGen> systemRef = system.lock();
|
|
|
|
if (systemRef->SystemHasLight())
|
|
|
|
{
|
2017-01-21 06:03:37 +00:00
|
|
|
ret = stateMgr.AllocateUniqueId();
|
|
|
|
stateMgr.AddObject(
|
|
|
|
new CGameLight(ret, areaId, false, "ParticleLight",
|
|
|
|
zeus::CTransform(systemRef->GetOrientation().buildMatrix3f(), systemRef->GetTranslation()),
|
|
|
|
kInvalidUniqueId, systemRef->GetLight(), lightId, 0, 0.f));
|
2016-04-16 21:49:47 +00:00
|
|
|
}
|
2017-01-21 06:03:37 +00:00
|
|
|
return ret;
|
2016-04-16 21:49:47 +00:00
|
|
|
}
|
|
|
|
|
2017-01-21 06:03:37 +00:00
|
|
|
CParticleGenInfoGeneric::CParticleGenInfoGeneric(const SObjectTag& part, const std::weak_ptr<CParticleGen>& system,
|
2016-04-16 21:49:47 +00:00
|
|
|
int frameCount, const std::string& boneName,
|
2017-01-21 06:03:37 +00:00
|
|
|
const zeus::CVector3f& scale, CParticleData::EParentedMode parentMode,
|
|
|
|
int a, CStateManager& stateMgr, TAreaId areaId, int lightId, int b)
|
|
|
|
: CParticleGenInfo(part, frameCount, boneName, scale, parentMode, a, b), x84_system(system)
|
2016-04-16 21:49:47 +00:00
|
|
|
{
|
|
|
|
if (lightId == -1)
|
2017-01-21 06:03:37 +00:00
|
|
|
x88_lightId = kInvalidUniqueId;
|
2016-04-16 21:49:47 +00:00
|
|
|
else
|
2017-01-21 06:03:37 +00:00
|
|
|
x88_lightId = _initializeLight(system, stateMgr, lightId, areaId);
|
2016-04-16 21:49:47 +00:00
|
|
|
}
|
|
|
|
|
2017-01-21 06:03:37 +00:00
|
|
|
void CParticleGenInfoGeneric::AddToRenderer() { g_Renderer->AddParticleGen(*x84_system.get()); }
|
2016-04-16 21:49:47 +00:00
|
|
|
|
2017-01-21 06:03:37 +00:00
|
|
|
void CParticleGenInfoGeneric::Render() { x84_system->Render(); }
|
2016-04-16 21:49:47 +00:00
|
|
|
|
|
|
|
void CParticleGenInfoGeneric::Update(float dt, CStateManager& stateMgr)
|
|
|
|
{
|
2017-01-21 06:03:37 +00:00
|
|
|
x84_system->Update(dt);
|
|
|
|
|
|
|
|
if (x88_lightId != kInvalidUniqueId)
|
|
|
|
{
|
|
|
|
TCastToPtr<CGameLight> gl(stateMgr.ObjectById(x88_lightId));
|
|
|
|
if (gl)
|
|
|
|
gl->SetLight(x84_system->GetLight());
|
|
|
|
}
|
2016-04-16 21:49:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CParticleGenInfoGeneric::SetOrientation(const zeus::CTransform& xf, CStateManager& stateMgr)
|
|
|
|
{
|
2017-01-21 06:03:37 +00:00
|
|
|
x84_system->SetOrientation(xf);
|
|
|
|
|
|
|
|
if (x88_lightId != kInvalidUniqueId)
|
|
|
|
{
|
|
|
|
TCastToPtr<CGameLight> gl(stateMgr.ObjectById(x88_lightId));
|
|
|
|
if (gl)
|
|
|
|
gl->SetRotation(zeus::CQuaternion(xf.buildMatrix3f()));
|
|
|
|
}
|
2016-04-16 21:49:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CParticleGenInfoGeneric::SetTranslation(const zeus::CVector3f& trans, CStateManager& stateMgr)
|
|
|
|
{
|
2017-01-21 06:03:37 +00:00
|
|
|
x84_system->SetTranslation(trans);
|
|
|
|
|
|
|
|
if (x88_lightId != kInvalidUniqueId)
|
|
|
|
{
|
|
|
|
TCastToPtr<CGameLight> gl(stateMgr.ObjectById(x88_lightId));
|
|
|
|
if (gl)
|
|
|
|
gl->SetTranslation(trans);
|
|
|
|
}
|
2016-04-16 21:49:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CParticleGenInfoGeneric::SetGlobalOrientation(const zeus::CTransform& xf, CStateManager& stateMgr)
|
|
|
|
{
|
2017-01-21 06:03:37 +00:00
|
|
|
x84_system->SetGlobalOrientation(xf);
|
|
|
|
|
|
|
|
if (x88_lightId != kInvalidUniqueId)
|
|
|
|
{
|
|
|
|
TCastToPtr<CGameLight> gl(stateMgr.ObjectById(x88_lightId));
|
|
|
|
if (gl)
|
|
|
|
gl->SetRotation(zeus::CQuaternion(xf.buildMatrix3f()));
|
|
|
|
}
|
2016-04-16 21:49:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CParticleGenInfoGeneric::SetGlobalTranslation(const zeus::CVector3f& trans, CStateManager& stateMgr)
|
|
|
|
{
|
2017-01-21 06:03:37 +00:00
|
|
|
x84_system->SetGlobalTranslation(trans);
|
2016-04-16 21:49:47 +00:00
|
|
|
|
2017-01-21 06:03:37 +00:00
|
|
|
if (x88_lightId != kInvalidUniqueId)
|
|
|
|
{
|
|
|
|
TCastToPtr<CGameLight> gl(stateMgr.ObjectById(x88_lightId));
|
|
|
|
if (gl)
|
|
|
|
gl->SetTranslation(trans);
|
|
|
|
}
|
2016-04-16 21:49:47 +00:00
|
|
|
}
|
|
|
|
|
2017-01-21 06:03:37 +00:00
|
|
|
void CParticleGenInfoGeneric::SetGlobalScale(const zeus::CVector3f& scale) { x84_system->SetGlobalScale(scale); }
|
2016-04-16 21:49:47 +00:00
|
|
|
|
2017-01-21 06:03:37 +00:00
|
|
|
void CParticleGenInfoGeneric::SetParticleEmission(bool emission, CStateManager& stateMgr)
|
2016-04-16 21:49:47 +00:00
|
|
|
{
|
2017-01-21 06:03:37 +00:00
|
|
|
x84_system->SetParticleEmission(emission);
|
2016-04-16 21:49:47 +00:00
|
|
|
|
2017-01-21 06:03:37 +00:00
|
|
|
TCastToPtr<CGameLight> gl(stateMgr.ObjectById(x88_lightId));
|
2016-04-16 21:49:47 +00:00
|
|
|
|
2017-01-21 06:03:37 +00:00
|
|
|
if (gl)
|
|
|
|
gl->SetActive(emission);
|
2016-04-16 21:49:47 +00:00
|
|
|
}
|
|
|
|
|
2017-01-21 06:03:37 +00:00
|
|
|
bool CParticleGenInfoGeneric::IsSystemDeletable() const { return x84_system->IsSystemDeletable(); }
|
2016-04-16 21:49:47 +00:00
|
|
|
|
2017-01-21 06:03:37 +00:00
|
|
|
rstl::optional_object<zeus::CAABox> CParticleGenInfoGeneric::GetBounds() const { return x84_system->GetBounds(); }
|
2016-04-16 21:49:47 +00:00
|
|
|
|
2017-01-21 06:03:37 +00:00
|
|
|
bool CParticleGenInfoGeneric::HasActiveParticles() const { return x84_system->GetParticleCount() != 0; }
|
|
|
|
|
|
|
|
void CParticleGenInfoGeneric::DestroyParticles() { x84_system->DestroyParticles(); }
|
|
|
|
|
|
|
|
bool CParticleGenInfoGeneric::HasLight() const { return x84_system->SystemHasLight(); }
|
|
|
|
|
|
|
|
TUniqueId CParticleGenInfoGeneric::GetLightId() const { return x88_lightId; }
|
2016-04-16 21:49:47 +00:00
|
|
|
|
2017-01-21 06:03:37 +00:00
|
|
|
void CParticleGenInfoGeneric::DeleteLight(CStateManager& mgr)
|
2016-04-16 21:49:47 +00:00
|
|
|
{
|
2017-01-21 06:03:37 +00:00
|
|
|
if (x88_lightId != kInvalidUniqueId)
|
|
|
|
mgr.DeleteObjectRequest(x88_lightId);
|
2016-04-16 21:49:47 +00:00
|
|
|
}
|
|
|
|
|
2017-01-21 06:03:37 +00:00
|
|
|
void CParticleGenInfoGeneric::SetModulationColor(const zeus::CColor& color) { x84_system->SetModulationColor(color); }
|
2016-04-16 21:49:47 +00:00
|
|
|
}
|