mirror of
https://github.com/AxioDL/metaforce.git
synced 2025-06-08 20:33:28 +00:00
Implement CScriptActorKeyframe
This commit is contained in:
parent
e7c3942754
commit
0c49c8ea9e
@ -252,6 +252,7 @@ public:
|
|||||||
u32 GetPassedSoundPOICount() const { return x218_passedSoundCount; }
|
u32 GetPassedSoundPOICount() const { return x218_passedSoundCount; }
|
||||||
|
|
||||||
s32 GetCharacterIndex() const { return x204_charIdx; }
|
s32 GetCharacterIndex() const { return x204_charIdx; }
|
||||||
|
u16 GetDefaultAnimation() const { return x208_defaultAnim; }
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -2006,7 +2006,7 @@ CFrontEndUI::CFrontEndUI()
|
|||||||
|
|
||||||
m->ResetGameState();
|
m->ResetGameState();
|
||||||
g_GameState->SetCurrentWorldId(g_ResFactory->TranslateOriginalToNew(g_DefaultWorldTag.id));
|
g_GameState->SetCurrentWorldId(g_ResFactory->TranslateOriginalToNew(g_DefaultWorldTag.id));
|
||||||
g_GameState->CurrentWorldState().SetAreaId(0);
|
g_GameState->CurrentWorldState().SetAreaId(7);
|
||||||
g_GameState->GameOptions().ResetToDefaults();
|
g_GameState->GameOptions().ResetToDefaults();
|
||||||
g_GameState->WriteBackupBuf();
|
g_GameState->WriteBackupBuf();
|
||||||
|
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
#include "CParticleElectric.hpp"
|
#include "CParticleElectric.hpp"
|
||||||
#include "Graphics/CModel.hpp"
|
#include "Graphics/CModel.hpp"
|
||||||
#include "Graphics/Shaders/CElementGenShaders.hpp"
|
#include "Graphics/Shaders/CElementGenShaders.hpp"
|
||||||
|
#include "Character/CActorLights.hpp"
|
||||||
#include "CWarp.hpp"
|
#include "CWarp.hpp"
|
||||||
|
|
||||||
#define MAX_GLOBAL_PARTICLES 2560
|
#define MAX_GLOBAL_PARTICLES 2560
|
||||||
@ -885,7 +886,7 @@ u32 CElementGen::GetSystemCount()
|
|||||||
return (ret + (x25c_activeParticleCount != 0));
|
return (ret + (x25c_activeParticleCount != 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
void CElementGen::Render()
|
void CElementGen::Render(const CActorLights* actorLights)
|
||||||
{
|
{
|
||||||
CGenDescription* desc = x1c_genDesc.GetObj();
|
CGenDescription* desc = x1c_genDesc.GetObj();
|
||||||
|
|
||||||
@ -903,7 +904,7 @@ void CElementGen::Render()
|
|||||||
{
|
{
|
||||||
SParticleModel& pmdl = desc->x5c_x48_PMDL;
|
SParticleModel& pmdl = desc->x5c_x48_PMDL;
|
||||||
if (pmdl.m_found || desc->x45_24_x31_26_PMUS)
|
if (pmdl.m_found || desc->x45_24_x31_26_PMUS)
|
||||||
RenderModels();
|
RenderModels(actorLights);
|
||||||
|
|
||||||
if (x26c_31_LINE)
|
if (x26c_31_LINE)
|
||||||
RenderLines();
|
RenderLines();
|
||||||
@ -914,7 +915,7 @@ void CElementGen::Render()
|
|||||||
CParticleGlobals::g_currentParticleSystem = prevSystem;
|
CParticleGlobals::g_currentParticleSystem = prevSystem;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CElementGen::RenderModels()
|
void CElementGen::RenderModels(const CActorLights* actorLights)
|
||||||
{
|
{
|
||||||
CGenDescription* desc = x1c_genDesc.GetObj();
|
CGenDescription* desc = x1c_genDesc.GetObj();
|
||||||
|
|
||||||
@ -1134,6 +1135,8 @@ void CElementGen::RenderModels()
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
CModel* model = desc->x5c_x48_PMDL.m_token.GetObj();
|
CModel* model = desc->x5c_x48_PMDL.m_token.GetObj();
|
||||||
|
if (actorLights)
|
||||||
|
actorLights->ActivateLights(model->GetInstance());
|
||||||
if (g_subtractBlend)
|
if (g_subtractBlend)
|
||||||
{
|
{
|
||||||
model->Draw({5, 0, 1, zeus::CColor(1.f, 0.5f)});
|
model->Draw({5, 0, 1, zeus::CColor(1.f, 0.5f)});
|
||||||
|
@ -23,6 +23,7 @@ class IGenDescription;
|
|||||||
class CGenDescription;
|
class CGenDescription;
|
||||||
class CParticleSwoosh;
|
class CParticleSwoosh;
|
||||||
class CParticleElectric;
|
class CParticleElectric;
|
||||||
|
class CActorLights;
|
||||||
|
|
||||||
class CElementGen : public CParticleGen
|
class CElementGen : public CParticleGen
|
||||||
{
|
{
|
||||||
@ -203,13 +204,13 @@ public:
|
|||||||
void SetCEXTValue(int i, float v) { x9c_cextValues[i] = v; }
|
void SetCEXTValue(int i, float v) { x9c_cextValues[i] = v; }
|
||||||
|
|
||||||
bool InternalUpdate(double);
|
bool InternalUpdate(double);
|
||||||
void RenderModels();
|
void RenderModels(const CActorLights* actLights);
|
||||||
void RenderLines();
|
void RenderLines();
|
||||||
void RenderParticles();
|
void RenderParticles();
|
||||||
void RenderParticlesIndirectTexture();
|
void RenderParticlesIndirectTexture();
|
||||||
|
|
||||||
bool Update(double);
|
bool Update(double);
|
||||||
void Render();
|
void Render(const CActorLights* = nullptr);
|
||||||
void SetOrientation(const zeus::CTransform&);
|
void SetOrientation(const zeus::CTransform&);
|
||||||
void SetTranslation(const zeus::CVector3f&);
|
void SetTranslation(const zeus::CVector3f&);
|
||||||
void SetGlobalOrientation(const zeus::CTransform&);
|
void SetGlobalOrientation(const zeus::CTransform&);
|
||||||
|
@ -625,7 +625,7 @@ bool CParticleElectric::Update(double dt)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CParticleElectric::Render()
|
void CParticleElectric::Render(const CActorLights*)
|
||||||
{
|
{
|
||||||
if (x3e8_electricManagers.size())
|
if (x3e8_electricManagers.size())
|
||||||
{
|
{
|
||||||
|
@ -107,7 +107,7 @@ public:
|
|||||||
CParticleElectric(const TToken<CElectricDescription>& desc);
|
CParticleElectric(const TToken<CElectricDescription>& desc);
|
||||||
|
|
||||||
bool Update(double);
|
bool Update(double);
|
||||||
void Render();
|
void Render(const CActorLights* = nullptr);
|
||||||
void SetOrientation(const zeus::CTransform&);
|
void SetOrientation(const zeus::CTransform&);
|
||||||
void SetTranslation(const zeus::CVector3f&);
|
void SetTranslation(const zeus::CVector3f&);
|
||||||
void SetGlobalOrientation(const zeus::CTransform&);
|
void SetGlobalOrientation(const zeus::CTransform&);
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
namespace urde
|
namespace urde
|
||||||
{
|
{
|
||||||
class CWarp;
|
class CWarp;
|
||||||
|
class CActorLights;
|
||||||
|
|
||||||
struct CParticle
|
struct CParticle
|
||||||
{
|
{
|
||||||
@ -33,7 +34,7 @@ public:
|
|||||||
virtual ~CParticleGen() = default;
|
virtual ~CParticleGen() = default;
|
||||||
|
|
||||||
virtual bool Update(double)=0;
|
virtual bool Update(double)=0;
|
||||||
virtual void Render()=0;
|
virtual void Render(const CActorLights* = nullptr)=0;
|
||||||
virtual void SetOrientation(const zeus::CTransform&)=0;
|
virtual void SetOrientation(const zeus::CTransform&)=0;
|
||||||
virtual void SetTranslation(const zeus::CVector3f&)=0;
|
virtual void SetTranslation(const zeus::CVector3f&)=0;
|
||||||
virtual void SetGlobalOrientation(const zeus::CTransform&)=0;
|
virtual void SetGlobalOrientation(const zeus::CTransform&)=0;
|
||||||
|
@ -978,7 +978,7 @@ void CParticleSwoosh::Render2SidedNoSplineNoGaps()
|
|||||||
CGraphics::DrawArray(drawStart, m_cachedVerts.size() - drawStart);
|
CGraphics::DrawArray(drawStart, m_cachedVerts.size() - drawStart);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CParticleSwoosh::Render()
|
void CParticleSwoosh::Render(const CActorLights*)
|
||||||
{
|
{
|
||||||
if (x1b4_LENG < 2 || x1ac_particleCount <= 1)
|
if (x1b4_LENG < 2 || x1ac_particleCount <= 1)
|
||||||
return;
|
return;
|
||||||
|
@ -134,7 +134,7 @@ public:
|
|||||||
CSwooshDescription* GetDesc() { return x1c_desc.GetObj(); }
|
CSwooshDescription* GetDesc() { return x1c_desc.GetObj(); }
|
||||||
|
|
||||||
bool Update(double);
|
bool Update(double);
|
||||||
void Render();
|
void Render(const CActorLights* = nullptr);
|
||||||
void SetOrientation(const zeus::CTransform&);
|
void SetOrientation(const zeus::CTransform&);
|
||||||
void SetTranslation(const zeus::CVector3f&);
|
void SetTranslation(const zeus::CVector3f&);
|
||||||
void SetGlobalOrientation(const zeus::CTransform&);
|
void SetGlobalOrientation(const zeus::CTransform&);
|
||||||
|
@ -1,19 +1,26 @@
|
|||||||
#include "CScriptActorKeyframe.hpp"
|
#include "CScriptActorKeyframe.hpp"
|
||||||
|
#include "CStateManager.hpp"
|
||||||
|
#include "World/CScriptActor.hpp"
|
||||||
|
#include "World/CScriptPlatform.hpp"
|
||||||
|
#include "World/CAi.hpp"
|
||||||
#include "TCastTo.hpp"
|
#include "TCastTo.hpp"
|
||||||
|
|
||||||
namespace urde
|
namespace urde
|
||||||
{
|
{
|
||||||
CScriptActorKeyframe::CScriptActorKeyframe(TUniqueId uid, std::string_view name, const CEntityInfo& info, s32 animId,
|
CScriptActorKeyframe::CScriptActorKeyframe(TUniqueId uid, std::string_view name, const CEntityInfo& info, s32 animId,
|
||||||
bool b1, float f1, bool b2, u32 w2, bool active, float totalPlayback)
|
bool looping, float lifetime, bool b2, u32 w2, bool active, float totalPlayback)
|
||||||
: CEntity(uid, info, active, name)
|
: CEntity(uid, info, active, name)
|
||||||
, x34_animationId(animId)
|
, x34_animationId(animId)
|
||||||
, x38_(f1)
|
, x38_initialLifetime(lifetime)
|
||||||
, x3c_(totalPlayback)
|
, x3c_playbackRate(totalPlayback)
|
||||||
, x40_(f1)
|
, x40_lifetime(lifetime)
|
||||||
{
|
{
|
||||||
x44_24_ = b1;
|
x44_24_looping = looping;
|
||||||
x44_25_ = b2;
|
x44_25_disableUpdate = b2;
|
||||||
x44_26_ = w2;
|
x44_26_ = w2;
|
||||||
|
x44_27_ = w2;
|
||||||
|
x44_28_ = false;
|
||||||
|
x44_29_ = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CScriptActorKeyframe::Accept(IVisitor& visitor)
|
void CScriptActorKeyframe::Accept(IVisitor& visitor)
|
||||||
@ -21,14 +28,113 @@ void CScriptActorKeyframe::Accept(IVisitor& visitor)
|
|||||||
visitor.Visit(this);
|
visitor.Visit(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CScriptActorKeyframe::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId objId, CStateManager& stateMgr) {}
|
void CScriptActorKeyframe::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStateManager& mgr)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (msg == EScriptObjectMessage::Action)
|
||||||
|
{
|
||||||
|
if (GetActive())
|
||||||
|
{
|
||||||
|
if (!x44_25_disableUpdate)
|
||||||
|
{
|
||||||
|
for (const SConnection& conn : x20_conns)
|
||||||
|
{
|
||||||
|
if (conn.x0_state != EScriptObjectState::Play || conn.x4_msg != EScriptObjectMessage::Play)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
auto search = mgr.GetIdListForScript(conn.x8_objId);
|
||||||
|
for (auto it = search.first; it != search.second; ++it)
|
||||||
|
UpdateEntity(it->second, mgr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
x44_28_ = true;
|
||||||
|
SendScriptMsgs(EScriptObjectState::Play, mgr, EScriptObjectMessage::None);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (msg == EScriptObjectMessage::InitializedInArea)
|
||||||
|
{
|
||||||
|
if (x34_animationId == -1)
|
||||||
|
x34_animationId = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
CEntity::AcceptScriptMsg(msg, uid, mgr);
|
||||||
|
}
|
||||||
|
|
||||||
void CScriptActorKeyframe::Think(float dt, CStateManager& mgr)
|
void CScriptActorKeyframe::Think(float dt, CStateManager& mgr)
|
||||||
{
|
{
|
||||||
if (x44_25_)
|
if (!x44_25_disableUpdate || !x44_24_looping || !x44_27_ || !x44_28_ || x40_lifetime <= 0.f)
|
||||||
{
|
{
|
||||||
|
CEntity::Think(dt, mgr);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
x40_lifetime -= dt;
|
||||||
|
if (x40_lifetime <= 0.f)
|
||||||
|
{
|
||||||
|
CEntity::Think(dt, mgr);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
x44_28_ = false;
|
||||||
|
for (const SConnection& conn : x20_conns)
|
||||||
|
{
|
||||||
|
if (conn.x0_state != EScriptObjectState::Play || conn.x4_msg!= EScriptObjectMessage::Play)
|
||||||
|
continue;
|
||||||
|
CEntity* ent = mgr.ObjectById(mgr.GetIdForScript(conn.x8_objId));
|
||||||
|
if (TCastToPtr<CScriptActor> act = ent)
|
||||||
|
{
|
||||||
|
if (act->HasModelData() && act->GetModelData()->HasAnimData())
|
||||||
|
{
|
||||||
|
CAnimData* animData = act->ModelData()->AnimationData();
|
||||||
|
if (animData->IsAdditiveAnimation(x34_animationId))
|
||||||
|
animData->DelAdditiveAnimation(x34_animationId);
|
||||||
|
|
||||||
|
if (animData->GetDefaultAnimation() == x34_animationId)
|
||||||
|
animData->EnableLooping(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (TCastToPtr<CAi> ai = ent)
|
||||||
|
{
|
||||||
|
CAnimData* animData = act->ModelData()->AnimationData();
|
||||||
|
if (animData->IsAdditiveAnimation(x34_animationId))
|
||||||
|
animData->DelAdditiveAnimation(x34_animationId);
|
||||||
|
/* TODO: Finish */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CScriptActorKeyframe::UpdateEntity(TUniqueId, CStateManager&) {}
|
CEntity::Think(dt, mgr);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CScriptActorKeyframe::UpdateEntity(TUniqueId uid, CStateManager& mgr)
|
||||||
|
{
|
||||||
|
CEntity* ent = mgr.ObjectById(uid);
|
||||||
|
CActor* act = nullptr;
|
||||||
|
if (TCastToPtr<CScriptActor> tmp = ent)
|
||||||
|
act = tmp;
|
||||||
|
else if (TCastToPtr<CScriptPlatform> tmp = ent)
|
||||||
|
act = tmp;
|
||||||
|
|
||||||
|
if (act)
|
||||||
|
{
|
||||||
|
if (!act->GetActive())
|
||||||
|
mgr.SendScriptMsg(act, GetUniqueId(), EScriptObjectMessage::Activate);
|
||||||
|
act->SetDrawFlags({0, 0, 3, zeus::CColor::skWhite});
|
||||||
|
if (act->HasModelData() && act->GetModelData()->HasAnimData())
|
||||||
|
{
|
||||||
|
CAnimData* animData = act->ModelData()->AnimationData();
|
||||||
|
if (animData->IsAdditiveAnimation(x34_animationId))
|
||||||
|
{
|
||||||
|
animData->AddAdditiveAnimation(x34_animationId, 1.f, x44_24_looping, x44_26_);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
animData->SetAnimation(CAnimPlaybackParms(x34_animationId, -1, 1.f, true), false);
|
||||||
|
act->ModelData()->EnableLooping(x44_24_looping);
|
||||||
|
animData->MultiplyPlaybackRate(x3c_playbackRate);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* TODO: Finish */
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,14 +9,14 @@ class CScriptActorKeyframe : public CEntity
|
|||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
s32 x34_animationId;
|
s32 x34_animationId;
|
||||||
float x38_;
|
float x38_initialLifetime;
|
||||||
float x3c_;
|
float x3c_playbackRate;
|
||||||
float x40_;
|
float x40_lifetime;
|
||||||
union {
|
union {
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
bool x44_24_ : 1;
|
bool x44_24_looping : 1;
|
||||||
bool x44_25_ : 1;
|
bool x44_25_disableUpdate : 1;
|
||||||
bool x44_26_ : 1;
|
bool x44_26_ : 1;
|
||||||
bool x44_27_ : 1;
|
bool x44_27_ : 1;
|
||||||
bool x44_28_ : 1;
|
bool x44_28_ : 1;
|
||||||
|
@ -275,12 +275,14 @@ void CScriptEffect::AddToRenderer(const zeus::CFrustum& frustum, const CStateMan
|
|||||||
|
|
||||||
void CScriptEffect::Render(const CStateManager& mgr) const
|
void CScriptEffect::Render(const CStateManager& mgr) const
|
||||||
{
|
{
|
||||||
// if (x138_actorLights)
|
/* The following code is kept for reference, this is now performed in CElementGen
|
||||||
// x138_actorLights->ActivateLights();
|
if (x138_actorLights)
|
||||||
|
x138_actorLights->ActivateLights();
|
||||||
|
*/
|
||||||
if (x104_particleSystem && x104_particleSystem->GetParticleCountAll() > 0)
|
if (x104_particleSystem && x104_particleSystem->GetParticleCountAll() > 0)
|
||||||
{
|
{
|
||||||
g_NumParticlesRendered += x104_particleSystem->GetParticleCountAll();
|
g_NumParticlesRendered += x104_particleSystem->GetParticleCountAll();
|
||||||
x104_particleSystem->Render();
|
x104_particleSystem->Render(GetActorLights());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (xf4_electric && xf4_electric->GetParticleCount() > 0)
|
if (xf4_electric && xf4_electric->GetParticleCount() > 0)
|
||||||
|
@ -1181,17 +1181,17 @@ CEntity* ScriptLoader::LoadActorKeyframe(CStateManager& mgr, CInputStream& in, i
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
std::string name = mgr.HashInstanceName(in);
|
std::string name = mgr.HashInstanceName(in);
|
||||||
s32 w1 = in.readInt32Big();
|
s32 animId = in.readInt32Big();
|
||||||
bool b1 = in.readBool();
|
bool looping = in.readBool();
|
||||||
float f1 = in.readFloatBig();
|
float lifetime = in.readFloatBig();
|
||||||
bool active = in.readBool();
|
bool active = in.readBool();
|
||||||
u32 w2 = in.readUint32Big();
|
u32 w2 = in.readUint32Big();
|
||||||
float f2 = in.readFloatBig();
|
float totalPlayback = in.readFloatBig();
|
||||||
|
|
||||||
if (w1 == -1)
|
if (animId == -1)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
return new CScriptActorKeyframe(mgr.AllocateUniqueId(), name, info, w1, b1, f1, false, w2, active, f2);
|
return new CScriptActorKeyframe(mgr.AllocateUniqueId(), name, info, animId, looping, lifetime, false, w2, active, totalPlayback);
|
||||||
}
|
}
|
||||||
|
|
||||||
CEntity* ScriptLoader::LoadWater(CStateManager& mgr, CInputStream& in, int propCount, const CEntityInfo& info)
|
CEntity* ScriptLoader::LoadWater(CStateManager& mgr, CInputStream& in, int propCount, const CEntityInfo& info)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user