Draw selected nodes as tinted with wireframe, instead of drawing the bounding box

This commit is contained in:
parax0 2015-11-26 03:42:42 -07:00
parent 7a69346ff3
commit c132197df0
23 changed files with 101 additions and 69 deletions

View File

@ -118,29 +118,26 @@ void CColor::operator-=(const CColor& other)
CColor CColor::operator*(const CColor& other) const CColor CColor::operator*(const CColor& other) const
{ {
u16 NewR = r * other.r; CVector4f A = ToVector4f();
if (NewR > 255) NewR = 255; CVector4f B = other.ToVector4f();
u16 NewG = g * other.g;
if (NewG > 255) NewG = 255; float NewR = A.x * B.x;
u16 NewB = b * other.b; float NewG = A.y * B.y;
if (NewB > 255) NewB = 255; float NewB = A.z * B.z;
u16 NewA = a * other.a; float NewA = A.w * B.w;
if (NewA > 255) NewA = 255;
return CColor((u8) NewR, (u8) NewG, (u8) NewB, (u8) NewA); return CColor(NewR, NewG, NewB, NewA);
} }
void CColor::operator*=(const CColor& other) void CColor::operator*=(const CColor& other)
{ {
*this = (*this - other); *this = (*this * other);
} }
CColor CColor::operator*(const float other) const CColor CColor::operator*(const float other) const
{ {
u8 NewR = (u8) (r * other); CVector4f Vec4f = ToVector4f() * other;
u8 NewG = (u8) (g * other); return CColor(Vec4f.x, Vec4f.y, Vec4f.z, Vec4f.w);
u8 NewB = (u8) (b * other);
u8 NewA = (u8) (a * other);
return CColor(NewR, NewG, NewB, NewA);
} }
void CColor::operator*=(const float other) void CColor::operator*=(const float other)

View File

@ -316,12 +316,16 @@ void CDrawUtil::UseTextureShader(const CColor& TintColor)
CMaterial::KillCachedMaterial(); CMaterial::KillCachedMaterial();
} }
void CDrawUtil::UseCollisionShader() void CDrawUtil::UseCollisionShader(const CColor& TintColor /*= CColor::skWhite*/)
{ {
Init(); Init();
mpCollisionShader->SetCurrent(); mpCollisionShader->SetCurrent();
LoadCheckerboardTexture(0); LoadCheckerboardTexture(0);
GLuint TintColorLoc = mpCollisionShader->GetUniformLocation("TintColor");
CVector4f Tint4f = TintColor.ToVector4f();
glUniform4f(TintColorLoc, Tint4f.x, Tint4f.y, Tint4f.z, Tint4f.w);
CMaterial::KillCachedMaterial(); CMaterial::KillCachedMaterial();
} }

View File

@ -7,6 +7,9 @@
#include <Resource/model/CModel.h> #include <Resource/model/CModel.h>
#include <Resource/CLight.h> #include <Resource/CLight.h>
// todo: CDrawUtil should work with CRenderer to queue primitives for rendering
// rather than trying to draw them straight away, so that CDrawUtil functions can
// be called from anywhere in the codebase and still function correctly
class CDrawUtil class CDrawUtil
{ {
// 7x7 Grid // 7x7 Grid
@ -86,7 +89,7 @@ public:
static void UseColorShaderLighting(const CColor& Color); static void UseColorShaderLighting(const CColor& Color);
static void UseTextureShader(); static void UseTextureShader();
static void UseTextureShader(const CColor& TintColor); static void UseTextureShader(const CColor& TintColor);
static void UseCollisionShader(); static void UseCollisionShader(const CColor& TintColor = CColor::skWhite);
static CShader* GetTextShader(); static CShader* GetTextShader();
static void LoadCheckerboardTexture(u32 GLTextureUnit); static void LoadCheckerboardTexture(u32 GLTextureUnit);

View File

@ -2,6 +2,7 @@
#include <algorithm> #include <algorithm>
#include "CDrawUtil.h" #include "CDrawUtil.h"
#include "CGraphics.h" #include "CGraphics.h"
#include "CRenderer.h"
CRenderBucket::CRenderBucket() CRenderBucket::CRenderBucket()
{ {
@ -71,15 +72,17 @@ void CRenderBucket::Clear()
mSize = 0; mSize = 0;
} }
void CRenderBucket::Draw(ERenderOptions Options) void CRenderBucket::Draw(const SViewInfo& ViewInfo)
{ {
ERenderOptions Options = ViewInfo.pRenderer->RenderOptions();
for (u32 n = 0; n < mSize; n++) for (u32 n = 0; n < mSize; n++)
{ {
if (mRenderables[n].Command == eDrawMesh) if (mRenderables[n].Command == eDrawMesh)
mRenderables[n].pRenderable->Draw(Options); mRenderables[n].pRenderable->Draw(Options, ViewInfo);
else if (mRenderables[n].Command == eDrawAsset) else if (mRenderables[n].Command == eDrawAsset)
mRenderables[n].pRenderable->DrawAsset(Options, mRenderables[n].Asset); mRenderables[n].pRenderable->DrawAsset(Options, mRenderables[n].Asset, ViewInfo);
else if (mRenderables[n].Command == eDrawSelection) else if (mRenderables[n].Command == eDrawSelection)
mRenderables[n].pRenderable->DrawSelection(); mRenderables[n].pRenderable->DrawSelection();

View File

@ -27,7 +27,7 @@ public:
void Add(const SRenderablePtr& ptr); void Add(const SRenderablePtr& ptr);
void Sort(CCamera* pCamera); void Sort(CCamera* pCamera);
void Clear(); void Clear();
void Draw(ERenderOptions Options); void Draw(const SViewInfo& ViewInfo);
}; };
#endif // CRENDERBUCKET_H #endif // CRENDERBUCKET_H

View File

@ -172,10 +172,10 @@ void CRenderer::RenderBuckets(const SViewInfo& ViewInfo)
glDepthRange(0.f, 1.f); glDepthRange(0.f, 1.f);
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
mOpaqueBucket.Draw(mOptions); mOpaqueBucket.Draw(ViewInfo);
mOpaqueBucket.Clear(); mOpaqueBucket.Clear();
mTransparentBucket.Sort(ViewInfo.pCamera); mTransparentBucket.Sort(ViewInfo.pCamera);
mTransparentBucket.Draw(mOptions); mTransparentBucket.Draw(ViewInfo);
mTransparentBucket.Clear(); mTransparentBucket.Clear();
} }

View File

@ -13,8 +13,8 @@ public:
IRenderable() {} IRenderable() {}
virtual ~IRenderable() {} virtual ~IRenderable() {}
virtual void AddToRenderer(CRenderer* pRenderer, const SViewInfo& ViewInfo) = 0; virtual void AddToRenderer(CRenderer* pRenderer, const SViewInfo& ViewInfo) = 0;
virtual void Draw(ERenderOptions /*options*/) {} virtual void Draw(ERenderOptions /*options*/, const SViewInfo& /*ViewInfo*/) {}
virtual void DrawAsset(ERenderOptions /*options*/, u32 /*asset*/) {} virtual void DrawAsset(ERenderOptions /*options*/, u32 /*asset*/, const SViewInfo& /*ViewInfo*/) {}
virtual void DrawSelection() {} virtual void DrawSelection() {}
}; };

View File

@ -423,7 +423,7 @@ bool CShaderGenerator::CreatePixelShader(const CMaterial& Mat)
} }
} }
ShaderCode << " PixelColor = Prev.rgba;\n" ShaderCode << " PixelColor = Prev.rgba * TintColor;\n"
<< "}\n\n"; << "}\n\n";
// Done! // Done!

View File

@ -27,7 +27,7 @@ void CCollisionNode::AddToRenderer(CRenderer *pRenderer, const SViewInfo& ViewIn
pRenderer->AddOpaqueMesh(this, 0, AABox(), eDrawSelection); pRenderer->AddOpaqueMesh(this, 0, AABox(), eDrawSelection);
} }
void CCollisionNode::Draw(ERenderOptions) void CCollisionNode::Draw(ERenderOptions, const SViewInfo& ViewInfo)
{ {
// Not using parameter 1 (ERenderOptions - Options) // Not using parameter 1 (ERenderOptions - Options)
if (!mpCollision) return; if (!mpCollision) return;
@ -38,16 +38,12 @@ void CCollisionNode::Draw(ERenderOptions)
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
glDepthMask(GL_TRUE); glDepthMask(GL_TRUE);
CDrawUtil::UseCollisionShader(); CDrawUtil::UseCollisionShader(TintColor(ViewInfo));
mpCollision->Draw(); mpCollision->Draw();
CDrawUtil::UseColorShader(CColor::skTransparentBlack); CDrawUtil::UseColorShader(CColor::skTransparentBlack);
mpCollision->DrawWireframe(); mpCollision->DrawWireframe();
} }
void CCollisionNode::DrawAsset(ERenderOptions /*Options*/, u32 /*asset*/)
{
}
SRayIntersection CCollisionNode::RayNodeIntersectTest(const CRay& /*Ray*/, u32 /*AssetID*/, const SViewInfo& /*ViewInfo*/) SRayIntersection CCollisionNode::RayNodeIntersectTest(const CRay& /*Ray*/, u32 /*AssetID*/, const SViewInfo& /*ViewInfo*/)
{ {
// todo // todo

View File

@ -13,8 +13,7 @@ public:
CCollisionNode(CSceneManager *pScene, CSceneNode *pParent = 0, CCollisionMeshGroup *pCollision = 0); CCollisionNode(CSceneManager *pScene, CSceneNode *pParent = 0, CCollisionMeshGroup *pCollision = 0);
ENodeType NodeType(); ENodeType NodeType();
void AddToRenderer(CRenderer *pRenderer, const SViewInfo& ViewInfo); void AddToRenderer(CRenderer *pRenderer, const SViewInfo& ViewInfo);
void Draw(ERenderOptions Options); void Draw(ERenderOptions Options, const SViewInfo& ViewInfo);
void DrawAsset(ERenderOptions Options, u32 asset);
SRayIntersection RayNodeIntersectTest(const CRay &Ray, u32 AssetID, const SViewInfo& ViewInfo); SRayIntersection RayNodeIntersectTest(const CRay &Ray, u32 AssetID, const SViewInfo& ViewInfo);
void SetCollision(CCollisionMeshGroup *pCollision); void SetCollision(CCollisionMeshGroup *pCollision);
}; };

View File

@ -33,9 +33,9 @@ void CLightNode::AddToRenderer(CRenderer *pRenderer, const SViewInfo& ViewInfo)
pRenderer->AddOpaqueMesh(this, 0, CAABox(mPosition + 0.5f, mPosition - 0.5f), eDrawMesh); pRenderer->AddOpaqueMesh(this, 0, CAABox(mPosition + 0.5f, mPosition - 0.5f), eDrawMesh);
} }
void CLightNode::Draw(ERenderOptions /*Options*/) void CLightNode::Draw(ERenderOptions /*Options*/, const SViewInfo& ViewInfo)
{ {
CDrawUtil::DrawLightBillboard(mpLight->GetType(), mpLight->GetColor(), mPosition, BillboardScale(), TintColor()); CDrawUtil::DrawLightBillboard(mpLight->GetType(), mpLight->GetColor(), mPosition, BillboardScale(), TintColor(ViewInfo));
// Below commented-out code is for light radius visualization as a bounding box // Below commented-out code is for light radius visualization as a bounding box
/*float r = mLight->GetRadius(); /*float r = mLight->GetRadius();
@ -43,10 +43,6 @@ void CLightNode::Draw(ERenderOptions /*Options*/)
pRenderer->DrawBoundingBox(mLight->GetColor(), AABB);*/ pRenderer->DrawBoundingBox(mLight->GetColor(), AABB);*/
} }
void CLightNode::DrawAsset(ERenderOptions /*Options*/, u32 /*asset*/)
{
}
void CLightNode::RayAABoxIntersectTest(CRayCollisionTester &Tester) void CLightNode::RayAABoxIntersectTest(CRayCollisionTester &Tester)
{ {
CVector2f BillScale = BillboardScale(); CVector2f BillScale = BillboardScale();

View File

@ -11,8 +11,7 @@ public:
CLightNode(CSceneManager *pScene, CSceneNode *pParent = 0, CLight *Light = 0); CLightNode(CSceneManager *pScene, CSceneNode *pParent = 0, CLight *Light = 0);
ENodeType NodeType(); ENodeType NodeType();
void AddToRenderer(CRenderer *pRenderer, const SViewInfo& ViewInfo); void AddToRenderer(CRenderer *pRenderer, const SViewInfo& ViewInfo);
void Draw(ERenderOptions Options); void Draw(ERenderOptions Options, const SViewInfo& ViewInfo);
void DrawAsset(ERenderOptions Options, u32 asset);
void RayAABoxIntersectTest(CRayCollisionTester& Tester); void RayAABoxIntersectTest(CRayCollisionTester& Tester);
SRayIntersection RayNodeIntersectTest(const CRay &Ray, u32 AssetID, const SViewInfo& ViewInfo); SRayIntersection RayNodeIntersectTest(const CRay &Ray, u32 AssetID, const SViewInfo& ViewInfo);
CLight* Light(); CLight* Light();

View File

@ -1,5 +1,6 @@
#include "CModelNode.h" #include "CModelNode.h"
#include <Common/Math.h> #include <Common/Math.h>
#include <Core/CDrawUtil.h>
#include <Core/CRenderer.h> #include <Core/CRenderer.h>
#include <Core/CGraphics.h> #include <Core/CGraphics.h>
@ -45,7 +46,7 @@ void CModelNode::AddToRenderer(CRenderer *pRenderer, const SViewInfo& ViewInfo)
pRenderer->AddOpaqueMesh(this, 0, AABox(), eDrawSelection); pRenderer->AddOpaqueMesh(this, 0, AABox(), eDrawSelection);
} }
void CModelNode::Draw(ERenderOptions Options) void CModelNode::Draw(ERenderOptions Options, const SViewInfo& ViewInfo)
{ {
if (!mpModel) return; if (!mpModel) return;
if (mForceAlphaOn) Options = (ERenderOptions) (Options & ~eNoAlpha); if (mForceAlphaOn) Options = (ERenderOptions) (Options & ~eNoAlpha);
@ -63,12 +64,13 @@ void CModelNode::Draw(ERenderOptions Options)
} }
CGraphics::sPixelBlock.TevColor = CVector4f(1,1,1,1); CGraphics::sPixelBlock.TevColor = CVector4f(1,1,1,1);
CGraphics::sPixelBlock.TintColor = TintColor(ViewInfo).ToVector4f();
LoadModelMatrix(); LoadModelMatrix();
mpModel->Draw(Options, mActiveMatSet); mpModel->Draw(Options, mActiveMatSet);
} }
void CModelNode::DrawAsset(ERenderOptions Options, u32 Asset) void CModelNode::DrawAsset(ERenderOptions Options, u32 Asset, const SViewInfo& ViewInfo)
{ {
if (!mpModel) return; if (!mpModel) return;
if (mForceAlphaOn) Options = (ERenderOptions) (Options & ~eNoAlpha); if (mForceAlphaOn) Options = (ERenderOptions) (Options & ~eNoAlpha);
@ -86,11 +88,19 @@ void CModelNode::DrawAsset(ERenderOptions Options, u32 Asset)
} }
CGraphics::sPixelBlock.TevColor = CVector4f(1,1,1,1); CGraphics::sPixelBlock.TevColor = CVector4f(1,1,1,1);
CGraphics::sPixelBlock.TintColor = TintColor(ViewInfo).ToVector4f();
LoadModelMatrix(); LoadModelMatrix();
mpModel->DrawSurface(Options, Asset, mActiveMatSet); mpModel->DrawSurface(Options, Asset, mActiveMatSet);
} }
void CModelNode::DrawSelection()
{
if (!mpModel) return;
LoadModelMatrix();
mpModel->DrawWireframe(eNoRenderOptions, WireframeColor());
}
void CModelNode::RayAABoxIntersectTest(CRayCollisionTester &Tester) void CModelNode::RayAABoxIntersectTest(CRayCollisionTester &Tester)
{ {
if (!mpModel) return; if (!mpModel) return;

View File

@ -17,8 +17,9 @@ public:
virtual ENodeType NodeType(); virtual ENodeType NodeType();
virtual void AddToRenderer(CRenderer *pRenderer, const SViewInfo& ViewInfo); virtual void AddToRenderer(CRenderer *pRenderer, const SViewInfo& ViewInfo);
virtual void Draw(ERenderOptions Options); virtual void Draw(ERenderOptions Options, const SViewInfo& ViewInfo);
virtual void DrawAsset(ERenderOptions Options, u32 asset); virtual void DrawAsset(ERenderOptions Options, u32 asset, const SViewInfo& ViewInfo);
virtual void DrawSelection();
virtual void RayAABoxIntersectTest(CRayCollisionTester &Tester); virtual void RayAABoxIntersectTest(CRayCollisionTester &Tester);
virtual SRayIntersection RayNodeIntersectTest(const CRay &Ray, u32 AssetID, const SViewInfo& ViewInfo); virtual SRayIntersection RayNodeIntersectTest(const CRay &Ray, u32 AssetID, const SViewInfo& ViewInfo);

View File

@ -16,8 +16,8 @@ public:
} }
inline void AddToRenderer(CRenderer *, const SViewInfo&) {} inline void AddToRenderer(CRenderer *, const SViewInfo&) {}
inline void Draw(ERenderOptions) {} inline void Draw(ERenderOptions, const SViewInfo&) {}
inline void DrawAsset(ERenderOptions, u32) {} inline void DrawAsset(ERenderOptions, u32, const SViewInfo&) {}
inline void RayAABoxIntersectTest(CRayCollisionTester &) {} inline void RayAABoxIntersectTest(CRayCollisionTester &) {}
inline SRayIntersection RayNodeIntersectTest(const CRay &, u32, const SViewInfo&) { inline SRayIntersection RayNodeIntersectTest(const CRay &, u32, const SViewInfo&) {

View File

@ -10,7 +10,7 @@
#include <algorithm> #include <algorithm>
u32 CSceneNode::smNumNodes = 0; u32 CSceneNode::smNumNodes = 0;
CColor CSceneNode::skSelectionTint((u8) 156, 133, 155, 255); CColor CSceneNode::skSelectionTint((u8) 39, 154, 167, 255);
CSceneNode::CSceneNode(CSceneManager *pScene, CSceneNode *pParent) CSceneNode::CSceneNode(CSceneManager *pScene, CSceneNode *pParent)
{ {
@ -71,6 +71,11 @@ bool CSceneNode::IsVisible() const
return mVisible; return mVisible;
} }
CColor CSceneNode::WireframeColor() const
{
return CColor::skWhite;
}
// ************ MAIN FUNCTIONALITY ************ // ************ MAIN FUNCTIONALITY ************
void CSceneNode::Unparent() void CSceneNode::Unparent()
{ {
@ -303,10 +308,10 @@ CSceneManager* CSceneNode::Scene()
return mpScene; return mpScene;
} }
CColor CSceneNode::TintColor() const CColor CSceneNode::TintColor(const SViewInfo& ViewInfo) const
{ {
// convenience; this is/will be a fairly common operation // convenience; this is/will be a fairly common operation
return (IsSelected() ? skSelectionTint : CColor::skWhite); return (IsSelected() && !ViewInfo.GameMode ? skSelectionTint : CColor::skWhite);
} }
CVector3f CSceneNode::LocalPosition() const CVector3f CSceneNode::LocalPosition() const

View File

@ -54,12 +54,11 @@ public:
virtual ~CSceneNode(); virtual ~CSceneNode();
virtual ENodeType NodeType() = 0; virtual ENodeType NodeType() = 0;
virtual TString PrefixedName() const; virtual TString PrefixedName() const;
virtual void Draw(ERenderOptions options) = 0;
virtual void DrawAsset(ERenderOptions options, u32 asset) = 0;
virtual void DrawSelection(); virtual void DrawSelection();
virtual void RayAABoxIntersectTest(CRayCollisionTester& Tester); virtual void RayAABoxIntersectTest(CRayCollisionTester& Tester);
virtual SRayIntersection RayNodeIntersectTest(const CRay& Ray, u32 AssetID, const SViewInfo& ViewInfo) = 0; virtual SRayIntersection RayNodeIntersectTest(const CRay& Ray, u32 AssetID, const SViewInfo& ViewInfo) = 0;
virtual bool IsVisible() const; virtual bool IsVisible() const;
virtual CColor WireframeColor() const;
void Unparent(); void Unparent();
void RemoveChild(CSceneNode *pChild); void RemoveChild(CSceneNode *pChild);
@ -83,7 +82,7 @@ public:
TString Name() const; TString Name() const;
CSceneNode* Parent() const; CSceneNode* Parent() const;
CSceneManager* Scene(); CSceneManager* Scene();
CColor TintColor() const; CColor TintColor(const SViewInfo& ViewInfo) const;
CVector3f LocalPosition() const; CVector3f LocalPosition() const;
CVector3f AbsolutePosition() const; CVector3f AbsolutePosition() const;
CQuaternion LocalRotation() const; CQuaternion LocalRotation() const;

View File

@ -164,7 +164,7 @@ void CScriptNode::AddToRenderer(CRenderer *pRenderer, const SViewInfo& ViewInfo)
} }
} }
void CScriptNode::Draw(ERenderOptions Options) void CScriptNode::Draw(ERenderOptions Options, const SViewInfo& ViewInfo)
{ {
if (!mpInstance) return; if (!mpInstance) return;
@ -173,13 +173,14 @@ void CScriptNode::Draw(ERenderOptions Options)
{ {
LoadModelMatrix(); LoadModelMatrix();
LoadLights(); LoadLights();
CGraphics::sPixelBlock.TintColor = TintColor(ViewInfo).ToVector4f();
mpActiveModel->Draw(Options, 0); mpActiveModel->Draw(Options, 0);
} }
// Draw billboard // Draw billboard
else if (mpBillboard) else if (mpBillboard)
{ {
CDrawUtil::DrawBillboard(mpBillboard, mPosition, BillboardScale(), TintColor()); CDrawUtil::DrawBillboard(mpBillboard, mPosition, BillboardScale(), TintColor(ViewInfo));
} }
// If no model or billboard, default to drawing a purple box // If no model or billboard, default to drawing a purple box
@ -192,12 +193,12 @@ void CScriptNode::Draw(ERenderOptions Options)
LoadLights(); LoadLights();
CGraphics::UpdateVertexBlock(); CGraphics::UpdateVertexBlock();
CGraphics::UpdateLightBlock(); CGraphics::UpdateLightBlock();
CDrawUtil::DrawShadedCube(CColor::skTransparentPurple); CDrawUtil::DrawShadedCube(CColor::skTransparentPurple * TintColor(ViewInfo));
return; return;
} }
} }
void CScriptNode::DrawAsset(ERenderOptions Options, u32 Asset) void CScriptNode::DrawAsset(ERenderOptions Options, u32 Asset, const SViewInfo& ViewInfo)
{ {
if (!mpInstance) return; if (!mpInstance) return;
if (!mpActiveModel) return; if (!mpActiveModel) return;
@ -207,6 +208,7 @@ void CScriptNode::DrawAsset(ERenderOptions Options, u32 Asset)
else else
CGraphics::sVertexBlock.COLOR0_Amb = CGraphics::skDefaultAmbientColor.ToVector4f(); CGraphics::sVertexBlock.COLOR0_Amb = CGraphics::skDefaultAmbientColor.ToVector4f();
CGraphics::sPixelBlock.TintColor = TintColor(ViewInfo).ToVector4f();
LoadModelMatrix(); LoadModelMatrix();
LoadLights(); LoadLights();
@ -217,11 +219,12 @@ void CScriptNode::DrawSelection()
{ {
glBlendFunc(GL_ONE, GL_ZERO); glBlendFunc(GL_ONE, GL_ZERO);
// Only draw bounding box for models; billboards get a tint color // Draw wireframe for models; billboards only get tinted
if (mpActiveModel || !mpBillboard) if (mpActiveModel || !mpBillboard)
{ {
LoadModelMatrix(); LoadModelMatrix();
CDrawUtil::DrawWireCube(AABox(), CColor::skTransparentWhite); CModel *pModel = (mpActiveModel ? mpActiveModel : CDrawUtil::GetCubeModel());
pModel->DrawWireframe(eNoRenderOptions, WireframeColor());
} }
if (mpInstance) if (mpInstance)
@ -383,10 +386,15 @@ SRayIntersection CScriptNode::RayNodeIntersectTest(const CRay& Ray, u32 AssetID,
bool CScriptNode::IsVisible() const bool CScriptNode::IsVisible() const
{ {
// Reimplementation of CSceneNode::IsHidden() to allow for layer and template visiblity to be taken into account // Reimplementation of CSceneNode::IsVisible() to allow for layer and template visiblity to be taken into account
return (mVisible && mpInstance->Layer()->IsVisible() && mpInstance->Template()->IsVisible()); return (mVisible && mpInstance->Layer()->IsVisible() && mpInstance->Template()->IsVisible());
} }
CColor CScriptNode::WireframeColor() const
{
return CColor((u8) 12, 135, 194, 255);
}
CScriptObject* CScriptNode::Object() CScriptObject* CScriptNode::Object()
{ {
return mpInstance; return mpInstance;

View File

@ -27,12 +27,14 @@ public:
ENodeType NodeType(); ENodeType NodeType();
TString PrefixedName() const; TString PrefixedName() const;
void AddToRenderer(CRenderer *pRenderer, const SViewInfo& ViewInfo); void AddToRenderer(CRenderer *pRenderer, const SViewInfo& ViewInfo);
void Draw(ERenderOptions Options); void Draw(ERenderOptions Options, const SViewInfo& ViewInfo);
void DrawAsset(ERenderOptions Options, u32 Asset); void DrawAsset(ERenderOptions Options, u32 Asset, const SViewInfo& ViewInfo);
void DrawSelection(); void DrawSelection();
void RayAABoxIntersectTest(CRayCollisionTester &Tester); void RayAABoxIntersectTest(CRayCollisionTester &Tester);
SRayIntersection RayNodeIntersectTest(const CRay &Ray, u32 AssetID, const SViewInfo& ViewInfo); SRayIntersection RayNodeIntersectTest(const CRay &Ray, u32 AssetID, const SViewInfo& ViewInfo);
bool IsVisible() const; bool IsVisible() const;
CColor WireframeColor() const;
CScriptObject* Object(); CScriptObject* Object();
CModel* ActiveModel(); CModel* ActiveModel();
void GeneratePosition(); void GeneratePosition();

View File

@ -42,13 +42,14 @@ void CStaticNode::AddToRenderer(CRenderer *pRenderer, const SViewInfo& ViewInfo)
pRenderer->AddOpaqueMesh(this, 0, AABox(), eDrawSelection); pRenderer->AddOpaqueMesh(this, 0, AABox(), eDrawSelection);
} }
void CStaticNode::Draw(ERenderOptions Options) void CStaticNode::Draw(ERenderOptions Options, const SViewInfo& ViewInfo)
{ {
if (!mpModel) return; if (!mpModel) return;
CGraphics::sVertexBlock.COLOR0_Amb = CVector4f(0, 0, 0, 1); CGraphics::sVertexBlock.COLOR0_Amb = CVector4f(0, 0, 0, 1);
float Multiplier = CGraphics::sWorldLightMultiplier; float Multiplier = CGraphics::sWorldLightMultiplier;
CGraphics::sPixelBlock.TevColor = CVector4f(Multiplier,Multiplier,Multiplier,1); CGraphics::sPixelBlock.TevColor = CVector4f(Multiplier,Multiplier,Multiplier,1);
CGraphics::sPixelBlock.TintColor = TintColor(ViewInfo).ToVector4f();
CGraphics::sNumLights = 0; CGraphics::sNumLights = 0;
CGraphics::UpdateLightBlock(); CGraphics::UpdateLightBlock();
LoadModelMatrix(); LoadModelMatrix();
@ -56,12 +57,13 @@ void CStaticNode::Draw(ERenderOptions Options)
mpModel->Draw(Options); mpModel->Draw(Options);
} }
void CStaticNode::DrawAsset(ERenderOptions Options, u32 Asset) void CStaticNode::DrawAsset(ERenderOptions Options, u32 Asset, const SViewInfo& ViewInfo)
{ {
if (!mpModel) return; if (!mpModel) return;
CGraphics::sVertexBlock.COLOR0_Amb = CVector4f(0,0,0,1); CGraphics::sVertexBlock.COLOR0_Amb = CVector4f(0,0,0,1);
CGraphics::sPixelBlock.TevColor = CVector4f(1,1,1,1); CGraphics::sPixelBlock.TevColor = CVector4f(1,1,1,1);
CGraphics::sPixelBlock.TintColor = TintColor(ViewInfo).ToVector4f();
CGraphics::sNumLights = 0; CGraphics::sNumLights = 0;
CGraphics::UpdateLightBlock(); CGraphics::UpdateLightBlock();
LoadModelMatrix(); LoadModelMatrix();
@ -70,6 +72,13 @@ void CStaticNode::DrawAsset(ERenderOptions Options, u32 Asset)
//CDrawUtil::DrawWireCube(mpModel->GetSurfaceAABox(Asset), CColor::skWhite); //CDrawUtil::DrawWireCube(mpModel->GetSurfaceAABox(Asset), CColor::skWhite);
} }
void CStaticNode::DrawSelection()
{
if (!mpModel) return;
LoadModelMatrix();
mpModel->DrawWireframe(eNoRenderOptions, WireframeColor());
}
void CStaticNode::RayAABoxIntersectTest(CRayCollisionTester &Tester) void CStaticNode::RayAABoxIntersectTest(CRayCollisionTester &Tester)
{ {
if ((!mpModel) || (mpModel->IsOccluder())) if ((!mpModel) || (mpModel->IsOccluder()))

View File

@ -12,8 +12,9 @@ public:
CStaticNode(CSceneManager *pScene, CSceneNode *pParent = 0, CStaticModel *pModel = 0); CStaticNode(CSceneManager *pScene, CSceneNode *pParent = 0, CStaticModel *pModel = 0);
ENodeType NodeType(); ENodeType NodeType();
void AddToRenderer(CRenderer *pRenderer, const SViewInfo& ViewInfo); void AddToRenderer(CRenderer *pRenderer, const SViewInfo& ViewInfo);
void Draw(ERenderOptions Options); void Draw(ERenderOptions Options, const SViewInfo& ViewInfo);
void DrawAsset(ERenderOptions Options, u32 asset); void DrawAsset(ERenderOptions Options, u32 asset, const SViewInfo& ViewInfo);
void DrawSelection();
void RayAABoxIntersectTest(CRayCollisionTester &Tester); void RayAABoxIntersectTest(CRayCollisionTester &Tester);
SRayIntersection RayNodeIntersectTest(const CRay &Ray, u32 AssetID, const SViewInfo& ViewInfo); SRayIntersection RayNodeIntersectTest(const CRay &Ray, u32 AssetID, const SViewInfo& ViewInfo);
}; };

View File

@ -69,7 +69,7 @@ void CGizmo::AddToRenderer(CRenderer *pRenderer, const SViewInfo&)
} }
} }
void CGizmo::DrawAsset(ERenderOptions /*options*/, u32 asset) void CGizmo::DrawAsset(ERenderOptions /*options*/, u32 asset, const SViewInfo& /*ViewInfo*/)
{ {
// Determine which SModelPart array to use // Determine which SModelPart array to use
if (asset >= mNumCurrentParts) return; if (asset >= mNumCurrentParts) return;

View File

@ -125,7 +125,7 @@ public:
~CGizmo(); ~CGizmo();
void AddToRenderer(CRenderer *pRenderer, const SViewInfo& ViewInfo); void AddToRenderer(CRenderer *pRenderer, const SViewInfo& ViewInfo);
void DrawAsset(ERenderOptions options, u32 asset); void DrawAsset(ERenderOptions options, u32 asset, const SViewInfo& ViewInfo);
void IncrementSize(); void IncrementSize();
void DecrementSize(); void DecrementSize();