mirror of
https://github.com/AxioDL/PrimeWorldEditor.git
synced 2025-12-12 22:56:13 +00:00
Added CRadiusSphereExtra for RadialDamage and Repulsor objects
This commit is contained in:
72
src/Core/ScriptExtra/CRadiusSphereExtra.cpp
Normal file
72
src/Core/ScriptExtra/CRadiusSphereExtra.cpp
Normal file
@@ -0,0 +1,72 @@
|
||||
#include "CRadiusSphereExtra.h"
|
||||
#include "Core/Render/CDrawUtil.h"
|
||||
#include "Core/Render/CRenderer.h"
|
||||
|
||||
CRadiusSphereExtra::CRadiusSphereExtra(CScriptObject *pInstance, CSceneManager *pScene, CSceneNode *pParent)
|
||||
: CScriptExtra(pInstance, pScene, pParent)
|
||||
, mpRadius(nullptr)
|
||||
{
|
||||
mObjectType = pInstance->ObjectTypeID();
|
||||
|
||||
switch (mObjectType)
|
||||
{
|
||||
case 0x63: // Repulsor (MP1)
|
||||
mpRadius = (CFloatProperty*) pInstance->Properties()->PropertyByID(0x3);
|
||||
break;
|
||||
|
||||
case 0x68: // RadialDamage (MP1)
|
||||
mpRadius = (CFloatProperty*) pInstance->Properties()->PropertyByID(0x4);
|
||||
break;
|
||||
|
||||
case 0x5245504C: // "REPL" Repulsor (MP2/MP3)
|
||||
case 0x52414444: // "RADD" RadialDamage (MP2/MP3/DKCR)
|
||||
mpRadius =(CFloatProperty*) pInstance->Properties()->PropertyByID(0x78C507EB);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void CRadiusSphereExtra::AddToRenderer(CRenderer *pRenderer, const SViewInfo& rkViewInfo)
|
||||
{
|
||||
if (!rkViewInfo.GameMode && mpRadius && mpParent->IsVisible() && mpParent->IsSelected())
|
||||
{
|
||||
CAABox BoundingBox = Bounds();
|
||||
|
||||
if (rkViewInfo.ViewFrustum.BoxInFrustum(BoundingBox))
|
||||
pRenderer->AddOpaqueMesh(this, -1, BoundingBox, eDrawMesh);
|
||||
}
|
||||
}
|
||||
|
||||
void CRadiusSphereExtra::Draw(ERenderOptions /*Options*/, int /*ComponentIndex*/, const SViewInfo& /*rkViewInfo*/)
|
||||
{
|
||||
glBlendFunc(GL_ONE, GL_ZERO);
|
||||
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
|
||||
glDepthMask(GL_TRUE);
|
||||
|
||||
CDrawUtil::DrawWireSphere(mpInstance->Position(), mpRadius->Get(), Color());
|
||||
}
|
||||
|
||||
CColor CRadiusSphereExtra::Color() const
|
||||
{
|
||||
switch (mObjectType)
|
||||
{
|
||||
// Repulsor
|
||||
case 0x63:
|
||||
case 0x5245504C:
|
||||
return CColor::skGreen;
|
||||
|
||||
// RadialDamage
|
||||
case 0x68:
|
||||
case 0x52414444:
|
||||
return CColor::skRed;
|
||||
|
||||
default:
|
||||
return CColor::skWhite;
|
||||
}
|
||||
}
|
||||
|
||||
CAABox CRadiusSphereExtra::Bounds() const
|
||||
{
|
||||
CAABox Bounds = CAABox::skOne * 2.f * mpRadius->Get();
|
||||
Bounds += mpParent->AbsolutePosition();
|
||||
return Bounds;
|
||||
}
|
||||
20
src/Core/ScriptExtra/CRadiusSphereExtra.h
Normal file
20
src/Core/ScriptExtra/CRadiusSphereExtra.h
Normal file
@@ -0,0 +1,20 @@
|
||||
#ifndef CRADIUSSPHEREEXTRA_H
|
||||
#define CRADIUSSPHEREEXTRA_H
|
||||
|
||||
#include "CScriptExtra.h"
|
||||
|
||||
class CRadiusSphereExtra : public CScriptExtra
|
||||
{
|
||||
// Sphere visualization for objects that have a float radius property.
|
||||
u32 mObjectType;
|
||||
CFloatProperty *mpRadius;
|
||||
|
||||
public:
|
||||
explicit CRadiusSphereExtra(CScriptObject *pInstance, CSceneManager *pScene, CSceneNode *pParent = 0);
|
||||
void AddToRenderer(CRenderer *pRenderer, const SViewInfo& rkViewInfo);
|
||||
void Draw(ERenderOptions Options, int ComponentIndex, const SViewInfo& rkViewInfo);
|
||||
CColor Color() const;
|
||||
CAABox Bounds() const;
|
||||
};
|
||||
|
||||
#endif // CRADIUSSPHEREEXTRA_H
|
||||
@@ -5,6 +5,7 @@
|
||||
#include "CSpacePirateExtra.h"
|
||||
#include "CPointOfInterestExtra.h"
|
||||
#include "CDoorExtra.h"
|
||||
#include "CRadiusSphereExtra.h"
|
||||
|
||||
CScriptExtra* CScriptExtra::CreateExtra(CScriptNode *pNode)
|
||||
{
|
||||
@@ -42,6 +43,13 @@ CScriptExtra* CScriptExtra::CreateExtra(CScriptNode *pNode)
|
||||
case 0x444F4F52: // "DOOR" Door (MP2/MP3)
|
||||
pExtra = new CDoorExtra(pObj, pNode->Scene(), pNode);
|
||||
break;
|
||||
|
||||
case 0x63: // Repulsor (MP1)
|
||||
case 0x68: // RadialDamage (MP1)
|
||||
case 0x5245504C: // "REPL" Repulsor (MP2/MP3)
|
||||
case 0x52414444: // "RADD" RadialDamage (MP2/MP3/DKCR)
|
||||
pExtra = new CRadiusSphereExtra(pObj, pNode->Scene(), pNode);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user