Added CRadiusSphereExtra for RadialDamage and Repulsor objects

This commit is contained in:
parax0 2015-12-16 16:10:36 -07:00
parent 4eaf4d9440
commit 2a38fb5b09
11 changed files with 122 additions and 7 deletions

View File

@ -177,7 +177,8 @@ HEADERS += \
OpenGL/CUniformBuffer.h \
OpenGL/CVertexArrayManager.h \
OpenGL/CVertexBuffer.h \
OpenGL/GLCommon.h
OpenGL/GLCommon.h \
ScriptExtra/CRadiusSphereExtra.h
# Source Files
SOURCES += \
@ -259,4 +260,5 @@ SOURCES += \
OpenGL/CUniformBuffer.cpp \
OpenGL/CVertexArrayManager.cpp \
OpenGL/CVertexBuffer.cpp \
OpenGL/GLCommon.cpp
OpenGL/GLCommon.cpp \
ScriptExtra/CRadiusSphereExtra.cpp

View 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;
}

View 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

View File

@ -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;
}
}

View File

@ -158,11 +158,21 @@ CAABox CAABox::operator+(const CVector3f& translate) const
return CAABox(mMin + translate, mMax + translate);
}
void CAABox::operator+=(const CVector3f& translate)
{
*this = *this + translate;
}
CAABox CAABox::operator*(float scalar) const
{
return CAABox(mMin * scalar, mMax * scalar);
}
void CAABox::operator*=(float scalar)
{
*this = *this * scalar;
}
bool CAABox::operator==(const CAABox& Other) const
{
return ((mMin == Other.mMin) && (mMax == Other.mMax));

View File

@ -43,7 +43,9 @@ public:
// Operators
CAABox operator+(const CVector3f& translate) const;
void operator+=(const CVector3f& translate);
CAABox operator*(float scalar) const;
void operator*=(float scalar);
bool operator==(const CAABox& Other) const;
bool operator!=(const CAABox& Other) const;

View File

@ -6,7 +6,7 @@
<property ID="0x01" name="Position" type="vector3f"/>
<property ID="0x02" name="Active" type="bool"/>
<struct ID="0x03" name="DamageInfo" template="Structs/DamageInfo.xml"/>
<property ID="0x04" name="Unknown 1" type="float"/>
<property ID="0x04" name="Radius" type="float"/>
</properties>
<editor>
<properties>

View File

@ -5,7 +5,7 @@
<property ID="0x00" name="Name" type="string"/>
<property ID="0x01" name="Position" type="vector3f"/>
<property ID="0x02" name="Active" type="bool"/>
<property ID="0x03" name="Unknown 1" type="float"/>
<property ID="0x03" name="Radius" type="float"/>
</properties>
<editor>
<properties>

View File

@ -5,7 +5,7 @@
<property ID="0x00" name="Name" type="string"/>
<property ID="0x01" name="Position" type="vector3f"/>
<property ID="0x02" name="Volume" type="vector3f"/>
<property ID="0x03" name="Unknown 1" type="bool"/>
<property ID="0x03" name="Active" type="bool"/>
<property ID="0x04" name="AnimationParameters" type="animparams"/>
<struct ID="0x05" name="ActorParameters" template="Structs/ActorParameters.xml"/>
<property ID="0x06" name="Unknown 2" type="float"/>
@ -33,6 +33,7 @@
<property name="InstanceName" ID="0x00"/>
<property name="Position" ID="0x01"/>
<property name="Scale" ID="0x02"/>
<property name="Active" ID="0x03"/>
<property name="LightParameters" ID="0x05:0x00"/>
</properties>
<assets>

View File

@ -1975,7 +1975,7 @@
<property ID="0x787855E6" name="Unknown" type="float"/>
<struct ID="0x78A13CA0" name="Unknown"/>
<property ID="0x78BE3B8D" name="Unknown" type="unknown"/>
<property ID="0x78C507EB" name="Unknown" type="float"/>
<property ID="0x78C507EB" name="Radius" type="float"/>
<property ID="0x78D03A32" name="Unknown" type="array"/>
<struct ID="0x78D76034" name="Unknown"/>
<property ID="0x78E22D1B" name="Unknown" type="float"/>

View File

@ -2495,7 +2495,7 @@
<property ID="0x787855E6" name="Unknown" type="float"/>
<property ID="0x78871CE9" name="Unknown" type="float"/>
<struct ID="0x78A69A53" name="Unknown"/>
<property ID="0x78C507EB" name="Unknown" type="float"/>
<property ID="0x78C507EB" name="Radius" type="float"/>
<struct ID="0x78D03A32" name="Unknown" template="Structs/ArrayType1.xml"/>
<struct ID="0x78DF0B7D" name="Unknown"/>
<property ID="0x78DF0E7F" name="CAUD" type="file" ext="CAUD"/>