From c132197df02f2103da3a8e927c3242e675c4ff8b Mon Sep 17 00:00:00 2001 From: parax0 Date: Thu, 26 Nov 2015 03:42:42 -0700 Subject: [PATCH] Draw selected nodes as tinted with wireframe, instead of drawing the bounding box --- Common/CColor.cpp | 27 ++++++++++++--------------- Core/CDrawUtil.cpp | 6 +++++- Core/CDrawUtil.h | 5 ++++- Core/CRenderBucket.cpp | 9 ++++++--- Core/CRenderBucket.h | 2 +- Core/CRenderer.cpp | 4 ++-- Core/IRenderable.h | 4 ++-- OpenGL/CShaderGenerator.cpp | 2 +- Scene/CCollisionNode.cpp | 8 ++------ Scene/CCollisionNode.h | 3 +-- Scene/CLightNode.cpp | 8 ++------ Scene/CLightNode.h | 3 +-- Scene/CModelNode.cpp | 14 ++++++++++++-- Scene/CModelNode.h | 5 +++-- Scene/CRootNode.h | 4 ++-- Scene/CSceneNode.cpp | 11 ++++++++--- Scene/CSceneNode.h | 5 ++--- Scene/CScriptNode.cpp | 22 +++++++++++++++------- Scene/CScriptNode.h | 6 ++++-- Scene/CStaticNode.cpp | 13 +++++++++++-- Scene/CStaticNode.h | 5 +++-- UI/CGizmo.cpp | 2 +- UI/CGizmo.h | 2 +- 23 files changed, 101 insertions(+), 69 deletions(-) diff --git a/Common/CColor.cpp b/Common/CColor.cpp index 23ae8d85..3e133061 100644 --- a/Common/CColor.cpp +++ b/Common/CColor.cpp @@ -118,29 +118,26 @@ void CColor::operator-=(const CColor& other) CColor CColor::operator*(const CColor& other) const { - u16 NewR = r * other.r; - if (NewR > 255) NewR = 255; - u16 NewG = g * other.g; - if (NewG > 255) NewG = 255; - u16 NewB = b * other.b; - if (NewB > 255) NewB = 255; - u16 NewA = a * other.a; - if (NewA > 255) NewA = 255; - return CColor((u8) NewR, (u8) NewG, (u8) NewB, (u8) NewA); + CVector4f A = ToVector4f(); + CVector4f B = other.ToVector4f(); + + float NewR = A.x * B.x; + float NewG = A.y * B.y; + float NewB = A.z * B.z; + float NewA = A.w * B.w; + + return CColor(NewR, NewG, NewB, NewA); } void CColor::operator*=(const CColor& other) { - *this = (*this - other); + *this = (*this * other); } CColor CColor::operator*(const float other) const { - u8 NewR = (u8) (r * other); - u8 NewG = (u8) (g * other); - u8 NewB = (u8) (b * other); - u8 NewA = (u8) (a * other); - return CColor(NewR, NewG, NewB, NewA); + CVector4f Vec4f = ToVector4f() * other; + return CColor(Vec4f.x, Vec4f.y, Vec4f.z, Vec4f.w); } void CColor::operator*=(const float other) diff --git a/Core/CDrawUtil.cpp b/Core/CDrawUtil.cpp index 78e83979..35fd12db 100644 --- a/Core/CDrawUtil.cpp +++ b/Core/CDrawUtil.cpp @@ -316,12 +316,16 @@ void CDrawUtil::UseTextureShader(const CColor& TintColor) CMaterial::KillCachedMaterial(); } -void CDrawUtil::UseCollisionShader() +void CDrawUtil::UseCollisionShader(const CColor& TintColor /*= CColor::skWhite*/) { Init(); mpCollisionShader->SetCurrent(); LoadCheckerboardTexture(0); + GLuint TintColorLoc = mpCollisionShader->GetUniformLocation("TintColor"); + CVector4f Tint4f = TintColor.ToVector4f(); + glUniform4f(TintColorLoc, Tint4f.x, Tint4f.y, Tint4f.z, Tint4f.w); + CMaterial::KillCachedMaterial(); } diff --git a/Core/CDrawUtil.h b/Core/CDrawUtil.h index cc07ab6f..e991459a 100644 --- a/Core/CDrawUtil.h +++ b/Core/CDrawUtil.h @@ -7,6 +7,9 @@ #include #include +// 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 { // 7x7 Grid @@ -86,7 +89,7 @@ public: static void UseColorShaderLighting(const CColor& Color); static void UseTextureShader(); static void UseTextureShader(const CColor& TintColor); - static void UseCollisionShader(); + static void UseCollisionShader(const CColor& TintColor = CColor::skWhite); static CShader* GetTextShader(); static void LoadCheckerboardTexture(u32 GLTextureUnit); diff --git a/Core/CRenderBucket.cpp b/Core/CRenderBucket.cpp index 7e9a8162..45dda2e1 100644 --- a/Core/CRenderBucket.cpp +++ b/Core/CRenderBucket.cpp @@ -2,6 +2,7 @@ #include #include "CDrawUtil.h" #include "CGraphics.h" +#include "CRenderer.h" CRenderBucket::CRenderBucket() { @@ -71,15 +72,17 @@ void CRenderBucket::Clear() 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++) { if (mRenderables[n].Command == eDrawMesh) - mRenderables[n].pRenderable->Draw(Options); + mRenderables[n].pRenderable->Draw(Options, ViewInfo); 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) mRenderables[n].pRenderable->DrawSelection(); diff --git a/Core/CRenderBucket.h b/Core/CRenderBucket.h index 2f2ffd0a..92026e56 100644 --- a/Core/CRenderBucket.h +++ b/Core/CRenderBucket.h @@ -27,7 +27,7 @@ public: void Add(const SRenderablePtr& ptr); void Sort(CCamera* pCamera); void Clear(); - void Draw(ERenderOptions Options); + void Draw(const SViewInfo& ViewInfo); }; #endif // CRENDERBUCKET_H diff --git a/Core/CRenderer.cpp b/Core/CRenderer.cpp index 885e1337..ca529ec4 100644 --- a/Core/CRenderer.cpp +++ b/Core/CRenderer.cpp @@ -172,10 +172,10 @@ void CRenderer::RenderBuckets(const SViewInfo& ViewInfo) glDepthRange(0.f, 1.f); glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); - mOpaqueBucket.Draw(mOptions); + mOpaqueBucket.Draw(ViewInfo); mOpaqueBucket.Clear(); mTransparentBucket.Sort(ViewInfo.pCamera); - mTransparentBucket.Draw(mOptions); + mTransparentBucket.Draw(ViewInfo); mTransparentBucket.Clear(); } diff --git a/Core/IRenderable.h b/Core/IRenderable.h index 13e6bdf3..729a76c7 100644 --- a/Core/IRenderable.h +++ b/Core/IRenderable.h @@ -13,8 +13,8 @@ public: IRenderable() {} virtual ~IRenderable() {} virtual void AddToRenderer(CRenderer* pRenderer, const SViewInfo& ViewInfo) = 0; - virtual void Draw(ERenderOptions /*options*/) {} - virtual void DrawAsset(ERenderOptions /*options*/, u32 /*asset*/) {} + virtual void Draw(ERenderOptions /*options*/, const SViewInfo& /*ViewInfo*/) {} + virtual void DrawAsset(ERenderOptions /*options*/, u32 /*asset*/, const SViewInfo& /*ViewInfo*/) {} virtual void DrawSelection() {} }; diff --git a/OpenGL/CShaderGenerator.cpp b/OpenGL/CShaderGenerator.cpp index 8716058d..a8f18cf0 100644 --- a/OpenGL/CShaderGenerator.cpp +++ b/OpenGL/CShaderGenerator.cpp @@ -423,7 +423,7 @@ bool CShaderGenerator::CreatePixelShader(const CMaterial& Mat) } } - ShaderCode << " PixelColor = Prev.rgba;\n" + ShaderCode << " PixelColor = Prev.rgba * TintColor;\n" << "}\n\n"; // Done! diff --git a/Scene/CCollisionNode.cpp b/Scene/CCollisionNode.cpp index 068264ba..03d2da9d 100644 --- a/Scene/CCollisionNode.cpp +++ b/Scene/CCollisionNode.cpp @@ -27,7 +27,7 @@ void CCollisionNode::AddToRenderer(CRenderer *pRenderer, const SViewInfo& ViewIn pRenderer->AddOpaqueMesh(this, 0, AABox(), eDrawSelection); } -void CCollisionNode::Draw(ERenderOptions) +void CCollisionNode::Draw(ERenderOptions, const SViewInfo& ViewInfo) { // Not using parameter 1 (ERenderOptions - Options) if (!mpCollision) return; @@ -38,16 +38,12 @@ void CCollisionNode::Draw(ERenderOptions) glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); glDepthMask(GL_TRUE); - CDrawUtil::UseCollisionShader(); + CDrawUtil::UseCollisionShader(TintColor(ViewInfo)); mpCollision->Draw(); CDrawUtil::UseColorShader(CColor::skTransparentBlack); mpCollision->DrawWireframe(); } -void CCollisionNode::DrawAsset(ERenderOptions /*Options*/, u32 /*asset*/) -{ -} - SRayIntersection CCollisionNode::RayNodeIntersectTest(const CRay& /*Ray*/, u32 /*AssetID*/, const SViewInfo& /*ViewInfo*/) { // todo diff --git a/Scene/CCollisionNode.h b/Scene/CCollisionNode.h index a6daef56..0b3853f9 100644 --- a/Scene/CCollisionNode.h +++ b/Scene/CCollisionNode.h @@ -13,8 +13,7 @@ public: CCollisionNode(CSceneManager *pScene, CSceneNode *pParent = 0, CCollisionMeshGroup *pCollision = 0); ENodeType NodeType(); void AddToRenderer(CRenderer *pRenderer, const SViewInfo& ViewInfo); - void Draw(ERenderOptions Options); - void DrawAsset(ERenderOptions Options, u32 asset); + void Draw(ERenderOptions Options, const SViewInfo& ViewInfo); SRayIntersection RayNodeIntersectTest(const CRay &Ray, u32 AssetID, const SViewInfo& ViewInfo); void SetCollision(CCollisionMeshGroup *pCollision); }; diff --git a/Scene/CLightNode.cpp b/Scene/CLightNode.cpp index cec6cdd4..8bc7717c 100644 --- a/Scene/CLightNode.cpp +++ b/Scene/CLightNode.cpp @@ -33,9 +33,9 @@ void CLightNode::AddToRenderer(CRenderer *pRenderer, const SViewInfo& ViewInfo) 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 /*float r = mLight->GetRadius(); @@ -43,10 +43,6 @@ void CLightNode::Draw(ERenderOptions /*Options*/) pRenderer->DrawBoundingBox(mLight->GetColor(), AABB);*/ } -void CLightNode::DrawAsset(ERenderOptions /*Options*/, u32 /*asset*/) -{ -} - void CLightNode::RayAABoxIntersectTest(CRayCollisionTester &Tester) { CVector2f BillScale = BillboardScale(); diff --git a/Scene/CLightNode.h b/Scene/CLightNode.h index 9a1f6f53..cace7961 100644 --- a/Scene/CLightNode.h +++ b/Scene/CLightNode.h @@ -11,8 +11,7 @@ public: CLightNode(CSceneManager *pScene, CSceneNode *pParent = 0, CLight *Light = 0); ENodeType NodeType(); void AddToRenderer(CRenderer *pRenderer, const SViewInfo& ViewInfo); - void Draw(ERenderOptions Options); - void DrawAsset(ERenderOptions Options, u32 asset); + void Draw(ERenderOptions Options, const SViewInfo& ViewInfo); void RayAABoxIntersectTest(CRayCollisionTester& Tester); SRayIntersection RayNodeIntersectTest(const CRay &Ray, u32 AssetID, const SViewInfo& ViewInfo); CLight* Light(); diff --git a/Scene/CModelNode.cpp b/Scene/CModelNode.cpp index 76fa6dec..48df61ff 100644 --- a/Scene/CModelNode.cpp +++ b/Scene/CModelNode.cpp @@ -1,5 +1,6 @@ #include "CModelNode.h" #include +#include #include #include @@ -45,7 +46,7 @@ void CModelNode::AddToRenderer(CRenderer *pRenderer, const SViewInfo& ViewInfo) pRenderer->AddOpaqueMesh(this, 0, AABox(), eDrawSelection); } -void CModelNode::Draw(ERenderOptions Options) +void CModelNode::Draw(ERenderOptions Options, const SViewInfo& ViewInfo) { if (!mpModel) return; 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.TintColor = TintColor(ViewInfo).ToVector4f(); LoadModelMatrix(); 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 (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.TintColor = TintColor(ViewInfo).ToVector4f(); LoadModelMatrix(); mpModel->DrawSurface(Options, Asset, mActiveMatSet); } +void CModelNode::DrawSelection() +{ + if (!mpModel) return; + LoadModelMatrix(); + mpModel->DrawWireframe(eNoRenderOptions, WireframeColor()); +} + void CModelNode::RayAABoxIntersectTest(CRayCollisionTester &Tester) { if (!mpModel) return; diff --git a/Scene/CModelNode.h b/Scene/CModelNode.h index c1d73fe3..ad571e35 100644 --- a/Scene/CModelNode.h +++ b/Scene/CModelNode.h @@ -17,8 +17,9 @@ public: virtual ENodeType NodeType(); virtual void AddToRenderer(CRenderer *pRenderer, const SViewInfo& ViewInfo); - virtual void Draw(ERenderOptions Options); - virtual void DrawAsset(ERenderOptions Options, u32 asset); + virtual void Draw(ERenderOptions Options, const SViewInfo& ViewInfo); + virtual void DrawAsset(ERenderOptions Options, u32 asset, const SViewInfo& ViewInfo); + virtual void DrawSelection(); virtual void RayAABoxIntersectTest(CRayCollisionTester &Tester); virtual SRayIntersection RayNodeIntersectTest(const CRay &Ray, u32 AssetID, const SViewInfo& ViewInfo); diff --git a/Scene/CRootNode.h b/Scene/CRootNode.h index 7d297847..cad84961 100644 --- a/Scene/CRootNode.h +++ b/Scene/CRootNode.h @@ -16,8 +16,8 @@ public: } inline void AddToRenderer(CRenderer *, const SViewInfo&) {} - inline void Draw(ERenderOptions) {} - inline void DrawAsset(ERenderOptions, u32) {} + inline void Draw(ERenderOptions, const SViewInfo&) {} + inline void DrawAsset(ERenderOptions, u32, const SViewInfo&) {} inline void RayAABoxIntersectTest(CRayCollisionTester &) {} inline SRayIntersection RayNodeIntersectTest(const CRay &, u32, const SViewInfo&) { diff --git a/Scene/CSceneNode.cpp b/Scene/CSceneNode.cpp index de445927..13b5b84e 100644 --- a/Scene/CSceneNode.cpp +++ b/Scene/CSceneNode.cpp @@ -10,7 +10,7 @@ #include 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) { @@ -71,6 +71,11 @@ bool CSceneNode::IsVisible() const return mVisible; } +CColor CSceneNode::WireframeColor() const +{ + return CColor::skWhite; +} + // ************ MAIN FUNCTIONALITY ************ void CSceneNode::Unparent() { @@ -303,10 +308,10 @@ CSceneManager* CSceneNode::Scene() return mpScene; } -CColor CSceneNode::TintColor() const +CColor CSceneNode::TintColor(const SViewInfo& ViewInfo) const { // 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 diff --git a/Scene/CSceneNode.h b/Scene/CSceneNode.h index 212a2e37..6c36a31d 100644 --- a/Scene/CSceneNode.h +++ b/Scene/CSceneNode.h @@ -54,12 +54,11 @@ public: virtual ~CSceneNode(); virtual ENodeType NodeType() = 0; virtual TString PrefixedName() const; - virtual void Draw(ERenderOptions options) = 0; - virtual void DrawAsset(ERenderOptions options, u32 asset) = 0; virtual void DrawSelection(); virtual void RayAABoxIntersectTest(CRayCollisionTester& Tester); virtual SRayIntersection RayNodeIntersectTest(const CRay& Ray, u32 AssetID, const SViewInfo& ViewInfo) = 0; virtual bool IsVisible() const; + virtual CColor WireframeColor() const; void Unparent(); void RemoveChild(CSceneNode *pChild); @@ -83,7 +82,7 @@ public: TString Name() const; CSceneNode* Parent() const; CSceneManager* Scene(); - CColor TintColor() const; + CColor TintColor(const SViewInfo& ViewInfo) const; CVector3f LocalPosition() const; CVector3f AbsolutePosition() const; CQuaternion LocalRotation() const; diff --git a/Scene/CScriptNode.cpp b/Scene/CScriptNode.cpp index 1a5c09df..05fbaadf 100644 --- a/Scene/CScriptNode.cpp +++ b/Scene/CScriptNode.cpp @@ -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; @@ -173,13 +173,14 @@ void CScriptNode::Draw(ERenderOptions Options) { LoadModelMatrix(); LoadLights(); + CGraphics::sPixelBlock.TintColor = TintColor(ViewInfo).ToVector4f(); mpActiveModel->Draw(Options, 0); } // Draw billboard 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 @@ -192,12 +193,12 @@ void CScriptNode::Draw(ERenderOptions Options) LoadLights(); CGraphics::UpdateVertexBlock(); CGraphics::UpdateLightBlock(); - CDrawUtil::DrawShadedCube(CColor::skTransparentPurple); + CDrawUtil::DrawShadedCube(CColor::skTransparentPurple * TintColor(ViewInfo)); return; } } -void CScriptNode::DrawAsset(ERenderOptions Options, u32 Asset) +void CScriptNode::DrawAsset(ERenderOptions Options, u32 Asset, const SViewInfo& ViewInfo) { if (!mpInstance) return; if (!mpActiveModel) return; @@ -207,6 +208,7 @@ void CScriptNode::DrawAsset(ERenderOptions Options, u32 Asset) else CGraphics::sVertexBlock.COLOR0_Amb = CGraphics::skDefaultAmbientColor.ToVector4f(); + CGraphics::sPixelBlock.TintColor = TintColor(ViewInfo).ToVector4f(); LoadModelMatrix(); LoadLights(); @@ -217,11 +219,12 @@ void CScriptNode::DrawSelection() { 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) { LoadModelMatrix(); - CDrawUtil::DrawWireCube(AABox(), CColor::skTransparentWhite); + CModel *pModel = (mpActiveModel ? mpActiveModel : CDrawUtil::GetCubeModel()); + pModel->DrawWireframe(eNoRenderOptions, WireframeColor()); } if (mpInstance) @@ -383,10 +386,15 @@ SRayIntersection CScriptNode::RayNodeIntersectTest(const CRay& Ray, u32 AssetID, 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()); } +CColor CScriptNode::WireframeColor() const +{ + return CColor((u8) 12, 135, 194, 255); +} + CScriptObject* CScriptNode::Object() { return mpInstance; diff --git a/Scene/CScriptNode.h b/Scene/CScriptNode.h index 3edae38d..4aaa520a 100644 --- a/Scene/CScriptNode.h +++ b/Scene/CScriptNode.h @@ -27,12 +27,14 @@ public: ENodeType NodeType(); TString PrefixedName() const; void AddToRenderer(CRenderer *pRenderer, const SViewInfo& ViewInfo); - void Draw(ERenderOptions Options); - void DrawAsset(ERenderOptions Options, u32 Asset); + void Draw(ERenderOptions Options, const SViewInfo& ViewInfo); + void DrawAsset(ERenderOptions Options, u32 Asset, const SViewInfo& ViewInfo); void DrawSelection(); void RayAABoxIntersectTest(CRayCollisionTester &Tester); SRayIntersection RayNodeIntersectTest(const CRay &Ray, u32 AssetID, const SViewInfo& ViewInfo); bool IsVisible() const; + CColor WireframeColor() const; + CScriptObject* Object(); CModel* ActiveModel(); void GeneratePosition(); diff --git a/Scene/CStaticNode.cpp b/Scene/CStaticNode.cpp index 2493aa96..afc988e7 100644 --- a/Scene/CStaticNode.cpp +++ b/Scene/CStaticNode.cpp @@ -42,13 +42,14 @@ void CStaticNode::AddToRenderer(CRenderer *pRenderer, const SViewInfo& ViewInfo) pRenderer->AddOpaqueMesh(this, 0, AABox(), eDrawSelection); } -void CStaticNode::Draw(ERenderOptions Options) +void CStaticNode::Draw(ERenderOptions Options, const SViewInfo& ViewInfo) { if (!mpModel) return; CGraphics::sVertexBlock.COLOR0_Amb = CVector4f(0, 0, 0, 1); float Multiplier = CGraphics::sWorldLightMultiplier; CGraphics::sPixelBlock.TevColor = CVector4f(Multiplier,Multiplier,Multiplier,1); + CGraphics::sPixelBlock.TintColor = TintColor(ViewInfo).ToVector4f(); CGraphics::sNumLights = 0; CGraphics::UpdateLightBlock(); LoadModelMatrix(); @@ -56,12 +57,13 @@ void CStaticNode::Draw(ERenderOptions Options) mpModel->Draw(Options); } -void CStaticNode::DrawAsset(ERenderOptions Options, u32 Asset) +void CStaticNode::DrawAsset(ERenderOptions Options, u32 Asset, const SViewInfo& ViewInfo) { if (!mpModel) return; CGraphics::sVertexBlock.COLOR0_Amb = CVector4f(0,0,0,1); CGraphics::sPixelBlock.TevColor = CVector4f(1,1,1,1); + CGraphics::sPixelBlock.TintColor = TintColor(ViewInfo).ToVector4f(); CGraphics::sNumLights = 0; CGraphics::UpdateLightBlock(); LoadModelMatrix(); @@ -70,6 +72,13 @@ void CStaticNode::DrawAsset(ERenderOptions Options, u32 Asset) //CDrawUtil::DrawWireCube(mpModel->GetSurfaceAABox(Asset), CColor::skWhite); } +void CStaticNode::DrawSelection() +{ + if (!mpModel) return; + LoadModelMatrix(); + mpModel->DrawWireframe(eNoRenderOptions, WireframeColor()); +} + void CStaticNode::RayAABoxIntersectTest(CRayCollisionTester &Tester) { if ((!mpModel) || (mpModel->IsOccluder())) diff --git a/Scene/CStaticNode.h b/Scene/CStaticNode.h index f3059e11..b5dd4365 100644 --- a/Scene/CStaticNode.h +++ b/Scene/CStaticNode.h @@ -12,8 +12,9 @@ public: CStaticNode(CSceneManager *pScene, CSceneNode *pParent = 0, CStaticModel *pModel = 0); ENodeType NodeType(); void AddToRenderer(CRenderer *pRenderer, const SViewInfo& ViewInfo); - void Draw(ERenderOptions Options); - void DrawAsset(ERenderOptions Options, u32 asset); + void Draw(ERenderOptions Options, const SViewInfo& ViewInfo); + void DrawAsset(ERenderOptions Options, u32 asset, const SViewInfo& ViewInfo); + void DrawSelection(); void RayAABoxIntersectTest(CRayCollisionTester &Tester); SRayIntersection RayNodeIntersectTest(const CRay &Ray, u32 AssetID, const SViewInfo& ViewInfo); }; diff --git a/UI/CGizmo.cpp b/UI/CGizmo.cpp index 0ab2c50d..f603707b 100644 --- a/UI/CGizmo.cpp +++ b/UI/CGizmo.cpp @@ -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 if (asset >= mNumCurrentParts) return; diff --git a/UI/CGizmo.h b/UI/CGizmo.h index d09b4118..e23eacbe 100644 --- a/UI/CGizmo.h +++ b/UI/CGizmo.h @@ -125,7 +125,7 @@ public: ~CGizmo(); 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 DecrementSize();