Bunch of backend rendering reshuffling; getting rid of DrawAsset, adding convenience functions, renaming some things
This commit is contained in:
parent
4bad61acec
commit
9494d2276d
|
@ -19,6 +19,18 @@ void CRayCollisionTester::AddNode(CSceneNode *pNode, u32 AssetIndex, float Dista
|
|||
Intersection.Distance = Distance;
|
||||
}
|
||||
|
||||
void CRayCollisionTester::AddNodeModel(CSceneNode *pNode, CBasicModel *pModel)
|
||||
{
|
||||
// Check each of the model's surfaces and queue them for further testing if they hit
|
||||
for (u32 iSurf = 0; iSurf < pModel->GetSurfaceCount(); iSurf++)
|
||||
{
|
||||
std::pair<bool,float> SurfResult = pModel->GetSurfaceAABox(iSurf).Transformed(pNode->Transform()).IntersectsRay(mRay);
|
||||
|
||||
if (SurfResult.first)
|
||||
AddNode(pNode, iSurf, SurfResult.second);
|
||||
}
|
||||
}
|
||||
|
||||
SRayIntersection CRayCollisionTester::TestNodes(const SViewInfo& ViewInfo)
|
||||
{
|
||||
// Sort nodes by distance from ray
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include "SRayIntersection.h"
|
||||
#include "types.h"
|
||||
#include <Core/SViewInfo.h>
|
||||
#include <Resource/model/CBasicModel.h>
|
||||
|
||||
#include <list>
|
||||
|
||||
|
@ -22,6 +23,7 @@ public:
|
|||
~CRayCollisionTester();
|
||||
const CRay& Ray() const;
|
||||
void AddNode(CSceneNode *pNode, u32 AssetIndex, float Distance);
|
||||
void AddNodeModel(CSceneNode *pNode, CBasicModel *pModel);
|
||||
SRayIntersection TestNodes(const SViewInfo& ViewInfo);
|
||||
};
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@ void CGraphics::Initialize()
|
|||
mpPixelBlockBuffer = new CUniformBuffer(sizeof(sPixelBlock));
|
||||
mpLightBlockBuffer = new CUniformBuffer(sizeof(sLightBlock));
|
||||
|
||||
sLightMode = WorldLighting;
|
||||
sLightMode = eWorldLighting;
|
||||
sNumLights = 0;
|
||||
sWorldLightMultiplier = 1.f;
|
||||
|
||||
|
@ -162,6 +162,14 @@ void CGraphics::SetDefaultLighting()
|
|||
UpdateVertexBlock();
|
||||
}
|
||||
|
||||
void CGraphics::SetupAmbientColor()
|
||||
{
|
||||
if (sLightMode == eWorldLighting)
|
||||
sVertexBlock.COLOR0_Amb = sAreaAmbientColor.ToVector4f() * sWorldLightMultiplier;
|
||||
else
|
||||
sVertexBlock.COLOR0_Amb = skDefaultAmbientColor.ToVector4f();
|
||||
}
|
||||
|
||||
void CGraphics::SetIdentityMVP()
|
||||
{
|
||||
sMVPBlock.ModelMatrix = CMatrix4f::skIdentity;
|
||||
|
|
|
@ -68,7 +68,7 @@ public:
|
|||
static SLightBlock sLightBlock;
|
||||
|
||||
// Lighting-related
|
||||
enum ELightingMode { NoLighting, BasicLighting, WorldLighting };
|
||||
enum ELightingMode { eNoLighting, eBasicLighting, eWorldLighting };
|
||||
static ELightingMode sLightMode;
|
||||
static u32 sNumLights;
|
||||
static const CColor skDefaultAmbientColor;
|
||||
|
@ -92,6 +92,7 @@ public:
|
|||
static void ReleaseContext(u32 Index);
|
||||
static void SetActiveContext(u32 Index);
|
||||
static void SetDefaultLighting();
|
||||
static void SetupAmbientColor();
|
||||
static void SetIdentityMVP();
|
||||
};
|
||||
|
||||
|
|
|
@ -79,10 +79,7 @@ void CRenderBucket::Draw(const SViewInfo& ViewInfo)
|
|||
for (u32 n = 0; n < mSize; n++)
|
||||
{
|
||||
if (mRenderables[n].Command == eDrawMesh)
|
||||
mRenderables[n].pRenderable->Draw(Options, ViewInfo);
|
||||
|
||||
else if (mRenderables[n].Command == eDrawAsset)
|
||||
mRenderables[n].pRenderable->DrawAsset(Options, mRenderables[n].Asset, ViewInfo);
|
||||
mRenderables[n].pRenderable->Draw(Options, mRenderables[n].ComponentIndex, ViewInfo);
|
||||
|
||||
else if (mRenderables[n].Command == eDrawSelection)
|
||||
mRenderables[n].pRenderable->DrawSelection();
|
||||
|
|
|
@ -311,21 +311,21 @@ void CRenderer::RenderSky(CModel *pSkyboxModel, const SViewInfo& ViewInfo)
|
|||
pSkyboxModel->Draw(mOptions, 0);
|
||||
}
|
||||
|
||||
void CRenderer::AddOpaqueMesh(IRenderable *pRenderable, u32 AssetID, CAABox& AABox, ERenderCommand Command)
|
||||
void CRenderer::AddOpaqueMesh(IRenderable *pRenderable, int AssetID, CAABox& AABox, ERenderCommand Command)
|
||||
{
|
||||
SRenderablePtr ptr;
|
||||
ptr.pRenderable = pRenderable;
|
||||
ptr.Asset = AssetID;
|
||||
ptr.ComponentIndex = AssetID;
|
||||
ptr.AABox = AABox;
|
||||
ptr.Command = Command;
|
||||
mOpaqueBucket.Add(ptr);
|
||||
}
|
||||
|
||||
void CRenderer::AddTransparentMesh(IRenderable *pRenderable, u32 AssetID, CAABox& AABox, ERenderCommand Command)
|
||||
void CRenderer::AddTransparentMesh(IRenderable *pRenderable, int AssetID, CAABox& AABox, ERenderCommand Command)
|
||||
{
|
||||
SRenderablePtr ptr;
|
||||
ptr.pRenderable = pRenderable;
|
||||
ptr.Asset = AssetID;
|
||||
ptr.ComponentIndex = AssetID;
|
||||
ptr.AABox = AABox;
|
||||
ptr.Command = Command;
|
||||
mTransparentBucket.Add(ptr);
|
||||
|
|
|
@ -75,8 +75,8 @@ public:
|
|||
void RenderBuckets(const SViewInfo& ViewInfo);
|
||||
void RenderBloom();
|
||||
void RenderSky(CModel *pSkyboxModel, const SViewInfo& ViewInfo);
|
||||
void AddOpaqueMesh(IRenderable *pRenderable, u32 AssetID, CAABox& AABox, ERenderCommand Command);
|
||||
void AddTransparentMesh(IRenderable *pRenderable, u32 AssetID, CAABox& AABox, ERenderCommand Command);
|
||||
void AddOpaqueMesh(IRenderable *pRenderable, int AssetID, CAABox& AABox, ERenderCommand Command);
|
||||
void AddTransparentMesh(IRenderable *pRenderable, int AssetID, CAABox& AABox, ERenderCommand Command);
|
||||
void BeginFrame();
|
||||
void EndFrame();
|
||||
void ClearDepthBuffer();
|
||||
|
|
|
@ -4,9 +4,7 @@
|
|||
enum ERenderCommand
|
||||
{
|
||||
eDrawMesh,
|
||||
eDrawAsset,
|
||||
eDrawSelection,
|
||||
eDrawExtras
|
||||
eDrawSelection
|
||||
};
|
||||
|
||||
#endif // ERENDERCOMMAND
|
||||
|
|
|
@ -13,8 +13,7 @@ public:
|
|||
IRenderable() {}
|
||||
virtual ~IRenderable() {}
|
||||
virtual void AddToRenderer(CRenderer* pRenderer, const SViewInfo& ViewInfo) = 0;
|
||||
virtual void Draw(ERenderOptions /*options*/, const SViewInfo& /*ViewInfo*/) {}
|
||||
virtual void DrawAsset(ERenderOptions /*options*/, u32 /*asset*/, const SViewInfo& /*ViewInfo*/) {}
|
||||
virtual void Draw(ERenderOptions /*Options*/, int /*ComponentIndex*/, const SViewInfo& /*ViewInfo*/) {}
|
||||
virtual void DrawSelection() {}
|
||||
};
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
struct SRenderablePtr
|
||||
{
|
||||
IRenderable *pRenderable;
|
||||
u32 Asset;
|
||||
u32 ComponentIndex;
|
||||
CAABox AABox;
|
||||
ERenderCommand Command;
|
||||
};
|
||||
|
|
|
@ -21,15 +21,14 @@ void CCollisionNode::AddToRenderer(CRenderer *pRenderer, const SViewInfo& ViewIn
|
|||
if (!ViewInfo.ViewFrustum.BoxInFrustum(AABox())) return;
|
||||
if (ViewInfo.GameMode) return;
|
||||
|
||||
pRenderer->AddOpaqueMesh(this, 0, AABox(), eDrawMesh);
|
||||
pRenderer->AddOpaqueMesh(this, -1, AABox(), eDrawMesh);
|
||||
|
||||
if (mSelected)
|
||||
pRenderer->AddOpaqueMesh(this, 0, AABox(), eDrawSelection);
|
||||
pRenderer->AddOpaqueMesh(this, -1, AABox(), eDrawSelection);
|
||||
}
|
||||
|
||||
void CCollisionNode::Draw(ERenderOptions, const SViewInfo& ViewInfo)
|
||||
void CCollisionNode::Draw(ERenderOptions /*Options*/, int /*ComponentIndex*/, const SViewInfo& ViewInfo)
|
||||
{
|
||||
// Not using parameter 1 (ERenderOptions - Options)
|
||||
if (!mpCollision) return;
|
||||
|
||||
LoadModelMatrix();
|
||||
|
|
|
@ -13,7 +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, const SViewInfo& ViewInfo);
|
||||
void Draw(ERenderOptions Options, int ComponentIndex, const SViewInfo& ViewInfo);
|
||||
SRayIntersection RayNodeIntersectTest(const CRay &Ray, u32 AssetID, const SViewInfo& ViewInfo);
|
||||
void SetCollision(CCollisionMeshGroup *pCollision);
|
||||
};
|
||||
|
|
|
@ -30,10 +30,10 @@ void CLightNode::AddToRenderer(CRenderer *pRenderer, const SViewInfo& ViewInfo)
|
|||
if (!ViewInfo.ViewFrustum.BoxInFrustum(AABox())) return;
|
||||
if (ViewInfo.GameMode) return;
|
||||
|
||||
pRenderer->AddOpaqueMesh(this, 0, CAABox(mPosition + 0.5f, mPosition - 0.5f), eDrawMesh);
|
||||
pRenderer->AddOpaqueMesh(this, -1, AABox(), eDrawMesh);
|
||||
}
|
||||
|
||||
void CLightNode::Draw(ERenderOptions /*Options*/, const SViewInfo& ViewInfo)
|
||||
void CLightNode::Draw(ERenderOptions /*Options*/, int /*ComponentIndex*/, const SViewInfo& ViewInfo)
|
||||
{
|
||||
CDrawUtil::DrawLightBillboard(mpLight->GetType(), mpLight->GetColor(), mPosition, BillboardScale(), TintColor(ViewInfo));
|
||||
|
||||
|
|
|
@ -11,7 +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, const SViewInfo& ViewInfo);
|
||||
void Draw(ERenderOptions Options, int ComponentIndex, const SViewInfo& ViewInfo);
|
||||
void RayAABoxIntersectTest(CRayCollisionTester& Tester);
|
||||
SRayIntersection RayNodeIntersectTest(const CRay &Ray, u32 AssetID, const SViewInfo& ViewInfo);
|
||||
CLight* Light();
|
||||
|
|
|
@ -24,29 +24,15 @@ void CModelNode::AddToRenderer(CRenderer *pRenderer, const SViewInfo& ViewInfo)
|
|||
if (ViewInfo.GameMode) return;
|
||||
|
||||
if (!mpModel->HasTransparency(mActiveMatSet))
|
||||
pRenderer->AddOpaqueMesh(this, 0, AABox(), eDrawMesh);
|
||||
|
||||
pRenderer->AddOpaqueMesh(this, -1, AABox(), eDrawMesh);
|
||||
else
|
||||
{
|
||||
u32 SurfaceCount = mpModel->GetSurfaceCount();
|
||||
|
||||
for (u32 iSurf = 0; iSurf < SurfaceCount; iSurf++)
|
||||
{
|
||||
if (ViewInfo.ViewFrustum.BoxInFrustum(mpModel->GetSurfaceAABox(iSurf).Transformed(Transform())))
|
||||
{
|
||||
if (!mpModel->IsSurfaceTransparent(iSurf, mActiveMatSet))
|
||||
pRenderer->AddOpaqueMesh(this, iSurf, mpModel->GetSurfaceAABox(iSurf).Transformed(Transform()), eDrawAsset);
|
||||
else
|
||||
pRenderer->AddTransparentMesh(this, iSurf, mpModel->GetSurfaceAABox(iSurf).Transformed(Transform()), eDrawAsset);
|
||||
}
|
||||
}
|
||||
}
|
||||
AddSurfacesToRenderer(pRenderer, mpModel, mActiveMatSet, ViewInfo);
|
||||
|
||||
if (mSelected)
|
||||
pRenderer->AddOpaqueMesh(this, 0, AABox(), eDrawSelection);
|
||||
pRenderer->AddOpaqueMesh(this, -1, AABox(), eDrawSelection);
|
||||
}
|
||||
|
||||
void CModelNode::Draw(ERenderOptions Options, const SViewInfo& ViewInfo)
|
||||
void CModelNode::Draw(ERenderOptions Options, int ComponentIndex, const SViewInfo& ViewInfo)
|
||||
{
|
||||
if (!mpModel) return;
|
||||
if (mForceAlphaOn) Options = (ERenderOptions) (Options & ~eNoAlpha);
|
||||
|
@ -67,32 +53,10 @@ void CModelNode::Draw(ERenderOptions Options, const SViewInfo& ViewInfo)
|
|||
CGraphics::sPixelBlock.TintColor = TintColor(ViewInfo).ToVector4f();
|
||||
LoadModelMatrix();
|
||||
|
||||
mpModel->Draw(Options, mActiveMatSet);
|
||||
}
|
||||
|
||||
void CModelNode::DrawAsset(ERenderOptions Options, u32 Asset, const SViewInfo& ViewInfo)
|
||||
{
|
||||
if (!mpModel) return;
|
||||
if (mForceAlphaOn) Options = (ERenderOptions) (Options & ~eNoAlpha);
|
||||
|
||||
if (mLightingEnabled)
|
||||
{
|
||||
CGraphics::SetDefaultLighting();
|
||||
CGraphics::UpdateLightBlock();
|
||||
CGraphics::sVertexBlock.COLOR0_Amb = CGraphics::skDefaultAmbientColor.ToVector4f();
|
||||
}
|
||||
if (ComponentIndex < 0)
|
||||
mpModel->Draw(Options, mActiveMatSet);
|
||||
else
|
||||
{
|
||||
CGraphics::sNumLights = 0;
|
||||
CGraphics::sVertexBlock.COLOR0_Amb = CColor::skBlack.ToVector4f();
|
||||
}
|
||||
|
||||
CGraphics::sPixelBlock.TevColor = CVector4f(1,1,1,1);
|
||||
CGraphics::sPixelBlock.TintColor = TintColor(ViewInfo).ToVector4f();
|
||||
CGraphics::UpdatePixelBlock();
|
||||
LoadModelMatrix();
|
||||
|
||||
mpModel->DrawSurface(Options, Asset, mActiveMatSet);
|
||||
mpModel->DrawSurface(Options, ComponentIndex, mActiveMatSet);
|
||||
}
|
||||
|
||||
void CModelNode::DrawSelection()
|
||||
|
@ -110,15 +74,7 @@ void CModelNode::RayAABoxIntersectTest(CRayCollisionTester &Tester)
|
|||
std::pair<bool,float> BoxResult = AABox().IntersectsRay(Ray);
|
||||
|
||||
if (BoxResult.first)
|
||||
{
|
||||
for (u32 iSurf = 0; iSurf < mpModel->GetSurfaceCount(); iSurf++)
|
||||
{
|
||||
std::pair<bool,float> SurfResult = mpModel->GetSurfaceAABox(iSurf).IntersectsRay(Ray);
|
||||
|
||||
if (SurfResult.first)
|
||||
Tester.AddNode(this, iSurf, SurfResult.second);
|
||||
}
|
||||
}
|
||||
Tester.AddNodeModel(this, mpModel);
|
||||
}
|
||||
|
||||
SRayIntersection CModelNode::RayNodeIntersectTest(const CRay &Ray, u32 AssetID, const SViewInfo& ViewInfo)
|
||||
|
|
|
@ -17,8 +17,7 @@ public:
|
|||
|
||||
virtual ENodeType NodeType();
|
||||
virtual void AddToRenderer(CRenderer *pRenderer, const SViewInfo& ViewInfo);
|
||||
virtual void Draw(ERenderOptions Options, const SViewInfo& ViewInfo);
|
||||
virtual void DrawAsset(ERenderOptions Options, u32 asset, const SViewInfo& ViewInfo);
|
||||
virtual void Draw(ERenderOptions Options, int ComponentIndex, const SViewInfo& ViewInfo);
|
||||
virtual void DrawSelection();
|
||||
virtual void RayAABoxIntersectTest(CRayCollisionTester &Tester);
|
||||
virtual SRayIntersection RayNodeIntersectTest(const CRay &Ray, u32 AssetID, const SViewInfo& ViewInfo);
|
||||
|
|
|
@ -184,7 +184,7 @@ void CSceneNode::LoadLights(const SViewInfo& ViewInfo)
|
|||
{
|
||||
CGraphics::sNumLights = 0;
|
||||
|
||||
if (CGraphics::sLightMode == CGraphics::WorldLighting || ViewInfo.GameMode)
|
||||
if (CGraphics::sLightMode == CGraphics::eWorldLighting || ViewInfo.GameMode)
|
||||
{
|
||||
// World lighting: world ambient color, node dynamic lights
|
||||
CGraphics::sVertexBlock.COLOR0_Amb = mAmbientColor.ToVector4f();
|
||||
|
@ -193,14 +193,14 @@ void CSceneNode::LoadLights(const SViewInfo& ViewInfo)
|
|||
mLights[iLight]->Load();
|
||||
}
|
||||
|
||||
else if (CGraphics::sLightMode == CGraphics::BasicLighting)
|
||||
else if (CGraphics::sLightMode == CGraphics::eBasicLighting)
|
||||
{
|
||||
// Basic lighting: default ambient color, default dynamic lights
|
||||
CGraphics::SetDefaultLighting();
|
||||
CGraphics::sVertexBlock.COLOR0_Amb = CGraphics::skDefaultAmbientColor.ToVector4f();
|
||||
}
|
||||
|
||||
else if (CGraphics::sLightMode == CGraphics::NoLighting)
|
||||
else if (CGraphics::sLightMode == CGraphics::eNoLighting)
|
||||
{
|
||||
// No lighting: default ambient color, no dynamic lights
|
||||
CGraphics::sVertexBlock.COLOR0_Amb = CGraphics::skDefaultAmbientColor.ToVector4f();
|
||||
|
@ -214,6 +214,24 @@ void CSceneNode::DrawBoundingBox()
|
|||
CDrawUtil::DrawWireCube(AABox(), CColor::skWhite);
|
||||
}
|
||||
|
||||
void CSceneNode::AddSurfacesToRenderer(CRenderer *pRenderer, CModel *pModel, u32 MatSet, const SViewInfo& rkViewInfo)
|
||||
{
|
||||
u32 SurfaceCount = pModel->GetSurfaceCount();
|
||||
|
||||
for (u32 iSurf = 0; iSurf < SurfaceCount; iSurf++)
|
||||
{
|
||||
CAABox TransformedBox = pModel->GetSurfaceAABox(iSurf).Transformed(Transform());
|
||||
|
||||
if (rkViewInfo.ViewFrustum.BoxInFrustum(TransformedBox))
|
||||
{
|
||||
if (!pModel->IsSurfaceTransparent(iSurf, MatSet))
|
||||
pRenderer->AddOpaqueMesh(this, (int) iSurf, TransformedBox, eDrawMesh);
|
||||
else
|
||||
pRenderer->AddTransparentMesh(this, (int) iSurf, TransformedBox, eDrawMesh);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ************ TRANSFORM ************
|
||||
void CSceneNode::Translate(const CVector3f& translation, ETransformSpace transformSpace)
|
||||
{
|
||||
|
|
|
@ -70,6 +70,7 @@ public:
|
|||
void BuildLightList(CGameArea *pArea);
|
||||
void LoadLights(const SViewInfo& ViewInfo);
|
||||
void DrawBoundingBox();
|
||||
void AddSurfacesToRenderer(CRenderer *pRenderer, CModel *pModel, u32 MatSet, const SViewInfo& ViewInfo);
|
||||
|
||||
// Transform
|
||||
void Translate(const CVector3f& translation, ETransformSpace transformSpace);
|
||||
|
|
|
@ -134,33 +134,15 @@ void CScriptNode::AddToRenderer(CRenderer *pRenderer, const SViewInfo& ViewInfo)
|
|||
if (ViewInfo.ViewFrustum.BoxInFrustum(AABox()))
|
||||
{
|
||||
if (!mpActiveModel)
|
||||
pRenderer->AddOpaqueMesh(this, 0, AABox(), eDrawMesh);
|
||||
pRenderer->AddOpaqueMesh(this, -1, AABox(), eDrawMesh);
|
||||
|
||||
else
|
||||
{
|
||||
if (!mpActiveModel->IsBuffered())
|
||||
mpActiveModel->BufferGL();
|
||||
|
||||
if (!mpActiveModel->HasTransparency(0))
|
||||
pRenderer->AddOpaqueMesh(this, 0, AABox(), eDrawMesh);
|
||||
|
||||
pRenderer->AddOpaqueMesh(this, -1, AABox(), eDrawMesh);
|
||||
else
|
||||
{
|
||||
u32 SubmeshCount = mpActiveModel->GetSurfaceCount();
|
||||
|
||||
for (u32 s = 0; s < SubmeshCount; s++)
|
||||
{
|
||||
if (ViewInfo.ViewFrustum.BoxInFrustum(mpActiveModel->GetSurfaceAABox(s).Transformed(Transform())))
|
||||
{
|
||||
if (!mpActiveModel->IsSurfaceTransparent(s, 0))
|
||||
pRenderer->AddOpaqueMesh(this, s, mpActiveModel->GetSurfaceAABox(s).Transformed(Transform()), eDrawAsset);
|
||||
else
|
||||
pRenderer->AddTransparentMesh(this, s, mpActiveModel->GetSurfaceAABox(s).Transformed(Transform()), eDrawAsset);
|
||||
}
|
||||
}
|
||||
}
|
||||
AddSurfacesToRenderer(pRenderer, mpActiveModel, 0, ViewInfo);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -170,28 +152,46 @@ void CScriptNode::AddToRenderer(CRenderer *pRenderer, const SViewInfo& ViewInfo)
|
|||
// Script nodes always draw their selections regardless of frustum planes
|
||||
// in order to ensure that script connection lines don't get improperly culled.
|
||||
if (ShouldDraw)
|
||||
pRenderer->AddOpaqueMesh(this, 0, AABox(), eDrawSelection);
|
||||
pRenderer->AddOpaqueMesh(this, -1, AABox(), eDrawSelection);
|
||||
|
||||
if (mHasVolumePreview && (!mpExtra || mpExtra->ShouldDrawVolume()))
|
||||
mpVolumePreviewNode->AddToRenderer(pRenderer, ViewInfo);
|
||||
}
|
||||
}
|
||||
|
||||
void CScriptNode::Draw(ERenderOptions Options, const SViewInfo& ViewInfo)
|
||||
void CScriptNode::Draw(ERenderOptions Options, int ComponentIndex, const SViewInfo& ViewInfo)
|
||||
{
|
||||
if (!mpInstance) return;
|
||||
|
||||
// Draw model
|
||||
if (mpActiveModel)
|
||||
if (mpActiveModel || !mpBillboard)
|
||||
{
|
||||
CGraphics::SetupAmbientColor();
|
||||
CGraphics::UpdateVertexBlock();
|
||||
LoadModelMatrix();
|
||||
LoadLights(ViewInfo);
|
||||
|
||||
if (mpExtra) CGraphics::sPixelBlock.TevColor = mpExtra->TevColor().ToVector4f();
|
||||
else CGraphics::sPixelBlock.TevColor = CColor::skWhite.ToVector4f();
|
||||
// Draw model if possible!
|
||||
if (mpActiveModel)
|
||||
{
|
||||
if (mpExtra) CGraphics::sPixelBlock.TevColor = mpExtra->TevColor().ToVector4f();
|
||||
else CGraphics::sPixelBlock.TevColor = CColor::skWhite.ToVector4f();
|
||||
CGraphics::sPixelBlock.TintColor = TintColor(ViewInfo).ToVector4f();
|
||||
CGraphics::UpdatePixelBlock();
|
||||
|
||||
CGraphics::sPixelBlock.TintColor = TintColor(ViewInfo).ToVector4f();
|
||||
mpActiveModel->Draw(Options, 0);
|
||||
if (ComponentIndex < 0)
|
||||
mpActiveModel->Draw(Options, 0);
|
||||
else
|
||||
mpActiveModel->DrawSurface(Options, ComponentIndex, 0);
|
||||
}
|
||||
|
||||
// If no model or billboard, default to drawing a purple box
|
||||
else
|
||||
{
|
||||
glBlendFuncSeparate(GL_ONE, GL_ZERO, GL_ZERO, GL_ZERO);
|
||||
glDepthMask(GL_TRUE);
|
||||
CDrawUtil::DrawShadedCube(CColor::skTransparentPurple * TintColor(ViewInfo));
|
||||
}
|
||||
}
|
||||
|
||||
// Draw billboard
|
||||
|
@ -199,41 +199,6 @@ void CScriptNode::Draw(ERenderOptions Options, const SViewInfo& ViewInfo)
|
|||
{
|
||||
CDrawUtil::DrawBillboard(mpBillboard, mPosition, BillboardScale(), TintColor(ViewInfo));
|
||||
}
|
||||
|
||||
// If no model or billboard, default to drawing a purple box
|
||||
else
|
||||
{
|
||||
glBlendFuncSeparate(GL_ONE, GL_ZERO, GL_ZERO, GL_ZERO);
|
||||
glDepthMask(GL_TRUE);
|
||||
|
||||
LoadModelMatrix();
|
||||
LoadLights(ViewInfo);
|
||||
CGraphics::UpdateVertexBlock();
|
||||
CGraphics::UpdateLightBlock();
|
||||
CDrawUtil::DrawShadedCube(CColor::skTransparentPurple * TintColor(ViewInfo));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void CScriptNode::DrawAsset(ERenderOptions Options, u32 Asset, const SViewInfo& ViewInfo)
|
||||
{
|
||||
if (!mpInstance) return;
|
||||
if (!mpActiveModel) return;
|
||||
|
||||
if (CGraphics::sLightMode == CGraphics::WorldLighting)
|
||||
CGraphics::sVertexBlock.COLOR0_Amb = CGraphics::sAreaAmbientColor.ToVector4f() * CGraphics::sWorldLightMultiplier;
|
||||
else
|
||||
CGraphics::sVertexBlock.COLOR0_Amb = CGraphics::skDefaultAmbientColor.ToVector4f();
|
||||
|
||||
LoadModelMatrix();
|
||||
LoadLights(ViewInfo);
|
||||
|
||||
if (mpExtra) CGraphics::sPixelBlock.TevColor = mpExtra->TevColor().ToVector4f();
|
||||
else CGraphics::sPixelBlock.TevColor = CColor::skWhite.ToVector4f();
|
||||
|
||||
CGraphics::sPixelBlock.TintColor = TintColor(ViewInfo).ToVector4f();
|
||||
|
||||
mpActiveModel->DrawSurface(Options, Asset, 0);
|
||||
}
|
||||
|
||||
void CScriptNode::DrawSelection()
|
||||
|
@ -293,16 +258,7 @@ void CScriptNode::RayAABoxIntersectTest(CRayCollisionTester &Tester)
|
|||
|
||||
if (BoxResult.first)
|
||||
{
|
||||
if (mpActiveModel)
|
||||
{
|
||||
for (u32 iSurf = 0; iSurf < mpActiveModel->GetSurfaceCount(); iSurf++)
|
||||
{
|
||||
std::pair<bool,float> SurfResult = mpActiveModel->GetSurfaceAABox(iSurf).Transformed(Transform()).IntersectsRay(Ray);
|
||||
|
||||
if (SurfResult.first)
|
||||
Tester.AddNode(this, iSurf, SurfResult.second);
|
||||
}
|
||||
}
|
||||
if (mpActiveModel) Tester.AddNodeModel(this, mpActiveModel);
|
||||
else Tester.AddNode(this, 0, BoxResult.second);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,8 +29,7 @@ public:
|
|||
ENodeType NodeType();
|
||||
TString PrefixedName() const;
|
||||
void AddToRenderer(CRenderer *pRenderer, const SViewInfo& ViewInfo);
|
||||
void Draw(ERenderOptions Options, const SViewInfo& ViewInfo);
|
||||
void DrawAsset(ERenderOptions Options, u32 Asset, const SViewInfo& ViewInfo);
|
||||
void Draw(ERenderOptions Options, int ComponentIndex, const SViewInfo& ViewInfo);
|
||||
void DrawSelection();
|
||||
void RayAABoxIntersectTest(CRayCollisionTester &Tester);
|
||||
SRayIntersection RayNodeIntersectTest(const CRay &Ray, u32 AssetID, const SViewInfo& ViewInfo);
|
||||
|
|
|
@ -26,23 +26,25 @@ void CStaticNode::AddToRenderer(CRenderer *pRenderer, const SViewInfo& ViewInfo)
|
|||
if (!ViewInfo.ViewFrustum.BoxInFrustum(AABox())) return;
|
||||
|
||||
if (!mpModel->IsTransparent())
|
||||
pRenderer->AddOpaqueMesh(this, 0, AABox(), eDrawMesh);
|
||||
pRenderer->AddOpaqueMesh(this, -1, AABox(), eDrawMesh);
|
||||
|
||||
else
|
||||
{
|
||||
u32 sm_count = mpModel->GetSurfaceCount();
|
||||
for (u32 s = 0; s < sm_count; s++)
|
||||
u32 NumSurfaces = mpModel->GetSurfaceCount();
|
||||
for (u32 iSurf = 0; iSurf < NumSurfaces; iSurf++)
|
||||
{
|
||||
if (ViewInfo.ViewFrustum.BoxInFrustum(mpModel->GetSurfaceAABox(s).Transformed(Transform())))
|
||||
pRenderer->AddTransparentMesh(this, s, mpModel->GetSurfaceAABox(s).Transformed(Transform()), eDrawAsset);
|
||||
CAABox TransformedBox = mpModel->GetSurfaceAABox(iSurf).Transformed(Transform());
|
||||
|
||||
if (ViewInfo.ViewFrustum.BoxInFrustum(TransformedBox))
|
||||
pRenderer->AddTransparentMesh(this, iSurf, TransformedBox, eDrawMesh);
|
||||
}
|
||||
}
|
||||
|
||||
if (mSelected && !ViewInfo.GameMode)
|
||||
pRenderer->AddOpaqueMesh(this, 0, AABox(), eDrawSelection);
|
||||
pRenderer->AddOpaqueMesh(this, -1, AABox(), eDrawSelection);
|
||||
}
|
||||
|
||||
void CStaticNode::Draw(ERenderOptions Options, const SViewInfo& ViewInfo)
|
||||
void CStaticNode::Draw(ERenderOptions Options, int ComponentIndex, const SViewInfo& ViewInfo)
|
||||
{
|
||||
if (!mpModel) return;
|
||||
|
||||
|
@ -54,22 +56,10 @@ void CStaticNode::Draw(ERenderOptions Options, const SViewInfo& ViewInfo)
|
|||
CGraphics::UpdateLightBlock();
|
||||
LoadModelMatrix();
|
||||
|
||||
mpModel->Draw(Options);
|
||||
}
|
||||
|
||||
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();
|
||||
|
||||
mpModel->DrawSurface(Options, Asset);
|
||||
//CDrawUtil::DrawWireCube(mpModel->GetSurfaceAABox(Asset), CColor::skWhite);
|
||||
if (ComponentIndex < 0)
|
||||
mpModel->Draw(Options);
|
||||
else
|
||||
mpModel->DrawSurface(Options, ComponentIndex);
|
||||
}
|
||||
|
||||
void CStaticNode::DrawSelection()
|
||||
|
|
|
@ -12,8 +12,7 @@ public:
|
|||
CStaticNode(CSceneManager *pScene, CSceneNode *pParent = 0, CStaticModel *pModel = 0);
|
||||
ENodeType NodeType();
|
||||
void AddToRenderer(CRenderer *pRenderer, const SViewInfo& ViewInfo);
|
||||
void Draw(ERenderOptions Options, const SViewInfo& ViewInfo);
|
||||
void DrawAsset(ERenderOptions Options, u32 asset, const SViewInfo& ViewInfo);
|
||||
void Draw(ERenderOptions Options, int ComponentIndex, const SViewInfo& ViewInfo);
|
||||
void DrawSelection();
|
||||
void RayAABoxIntersectTest(CRayCollisionTester &Tester);
|
||||
SRayIntersection RayNodeIntersectTest(const CRay &Ray, u32 AssetID, const SViewInfo& ViewInfo);
|
||||
|
|
|
@ -89,12 +89,12 @@ void CWaypointExtra::AddToRenderer(CRenderer *pRenderer, const SViewInfo& ViewIn
|
|||
CScriptNode *pNode = mLinks[iLink].pWaypoint;
|
||||
|
||||
if (pNode->IsVisible() && !pNode->IsSelected() && ViewInfo.ViewFrustum.BoxInFrustum(mLinks[iLink].LineAABB))
|
||||
pRenderer->AddOpaqueMesh(this, iLink, mLinks[iLink].LineAABB, eDrawAsset);
|
||||
pRenderer->AddOpaqueMesh(this, iLink, mLinks[iLink].LineAABB, eDrawMesh);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CWaypointExtra::DrawAsset(ERenderOptions /*Options*/, u32 AssetID, const SViewInfo& /*ViewInfo*/)
|
||||
void CWaypointExtra::Draw(ERenderOptions /*Options*/, int ComponentIndex, const SViewInfo& /*ViewInfo*/)
|
||||
{
|
||||
glBlendFunc(GL_ONE, GL_ZERO);
|
||||
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
|
||||
|
@ -102,5 +102,5 @@ void CWaypointExtra::DrawAsset(ERenderOptions /*Options*/, u32 AssetID, const SV
|
|||
|
||||
CGraphics::sMVPBlock.ModelMatrix = CMatrix4f::skIdentity;
|
||||
CGraphics::UpdateMVPBlock();
|
||||
CDrawUtil::DrawLine(mpParent->AABox().Center(), mLinks[AssetID].pWaypoint->AABox().Center(), mColor);
|
||||
CDrawUtil::DrawLine(mpParent->AABox().Center(), mLinks[ComponentIndex].pWaypoint->AABox().Center(), mColor);
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ public:
|
|||
|
||||
void LinksModified();
|
||||
void AddToRenderer(CRenderer *pRenderer, const SViewInfo& ViewInfo);
|
||||
void DrawAsset(ERenderOptions Options, u32 AssetID, const SViewInfo& ViewInfo);
|
||||
void Draw(ERenderOptions Options, int ComponentIndex, const SViewInfo& ViewInfo);
|
||||
};
|
||||
|
||||
#endif // CWAYPOINTEXTRA_H
|
||||
|
|
|
@ -61,24 +61,24 @@ void CGizmo::AddToRenderer(CRenderer *pRenderer, const SViewInfo&)
|
|||
|
||||
// Add to renderer...
|
||||
if (pModel->HasTransparency(setID))
|
||||
pRenderer->AddTransparentMesh(this, iPart, pModel->AABox().Transformed(mTransform), eDrawAsset);
|
||||
pRenderer->AddTransparentMesh(this, iPart, pModel->AABox().Transformed(mTransform), eDrawMesh);
|
||||
else
|
||||
pRenderer->AddOpaqueMesh(this, iPart, pModel->AABox().Transformed(mTransform), eDrawAsset);
|
||||
pRenderer->AddOpaqueMesh(this, iPart, pModel->AABox().Transformed(mTransform), eDrawMesh);
|
||||
|
||||
pPart++;
|
||||
}
|
||||
}
|
||||
|
||||
void CGizmo::DrawAsset(ERenderOptions /*options*/, u32 asset, const SViewInfo& /*ViewInfo*/)
|
||||
void CGizmo::Draw(ERenderOptions /*Options*/, int ComponentIndex, const SViewInfo& /*ViewInfo*/)
|
||||
{
|
||||
// Determine which SModelPart array to use
|
||||
if (asset >= mNumCurrentParts) return;
|
||||
if (ComponentIndex >= (int) mNumCurrentParts) return;
|
||||
SModelPart *pPart = mpCurrentParts;
|
||||
|
||||
// Set model matrix
|
||||
if (pPart[asset].isBillboard)
|
||||
if (pPart[ComponentIndex].isBillboard)
|
||||
CGraphics::sMVPBlock.ModelMatrix = mBillboardTransform.ToMatrix4f();
|
||||
else if ((mMode == eScale) && ((mSelectedAxes & pPart[asset].modelAxes) != 0))
|
||||
else if ((mMode == eScale) && ((mSelectedAxes & pPart[ComponentIndex].modelAxes) != 0))
|
||||
CGraphics::sMVPBlock.ModelMatrix = mScaledTransform.ToMatrix4f();
|
||||
else
|
||||
CGraphics::sMVPBlock.ModelMatrix = mTransform.ToMatrix4f();
|
||||
|
@ -90,12 +90,12 @@ void CGizmo::DrawAsset(ERenderOptions /*options*/, u32 asset, const SViewInfo& /
|
|||
CGraphics::UpdatePixelBlock();
|
||||
|
||||
// Choose material set
|
||||
EGizmoAxes partAxes = pPart[asset].modelAxes;
|
||||
bool isHighlighted = (partAxes != eNone) && ((mSelectedAxes & partAxes) == pPart[asset].modelAxes);
|
||||
EGizmoAxes partAxes = pPart[ComponentIndex].modelAxes;
|
||||
bool isHighlighted = (partAxes != eNone) && ((mSelectedAxes & partAxes) == pPart[ComponentIndex].modelAxes);
|
||||
u32 setID = (isHighlighted ? 1 : 0);
|
||||
|
||||
// Draw model
|
||||
pPart[asset].pModel->Draw((ERenderOptions) 0, setID);
|
||||
pPart[ComponentIndex].pModel->Draw((ERenderOptions) 0, setID);
|
||||
}
|
||||
|
||||
void CGizmo::IncrementSize()
|
||||
|
|
|
@ -125,7 +125,7 @@ public:
|
|||
~CGizmo();
|
||||
|
||||
void AddToRenderer(CRenderer *pRenderer, const SViewInfo& ViewInfo);
|
||||
void DrawAsset(ERenderOptions options, u32 asset, const SViewInfo& ViewInfo);
|
||||
void Draw(ERenderOptions Options, int ComponentIndex, const SViewInfo& ViewInfo);
|
||||
|
||||
void IncrementSize();
|
||||
void DecrementSize();
|
||||
|
|
|
@ -377,7 +377,7 @@ void CWorldEditor::on_ActionDrawSky_triggered()
|
|||
|
||||
void CWorldEditor::on_ActionNoLighting_triggered()
|
||||
{
|
||||
CGraphics::sLightMode = CGraphics::NoLighting;
|
||||
CGraphics::sLightMode = CGraphics::eNoLighting;
|
||||
ui->ActionNoLighting->setChecked(true);
|
||||
ui->ActionBasicLighting->setChecked(false);
|
||||
ui->ActionWorldLighting->setChecked(false);
|
||||
|
@ -385,7 +385,7 @@ void CWorldEditor::on_ActionNoLighting_triggered()
|
|||
|
||||
void CWorldEditor::on_ActionBasicLighting_triggered()
|
||||
{
|
||||
CGraphics::sLightMode = CGraphics::BasicLighting;
|
||||
CGraphics::sLightMode = CGraphics::eBasicLighting;
|
||||
ui->ActionNoLighting->setChecked(false);
|
||||
ui->ActionBasicLighting->setChecked(true);
|
||||
ui->ActionWorldLighting->setChecked(false);
|
||||
|
@ -393,7 +393,7 @@ void CWorldEditor::on_ActionBasicLighting_triggered()
|
|||
|
||||
void CWorldEditor::on_ActionWorldLighting_triggered()
|
||||
{
|
||||
CGraphics::sLightMode = CGraphics::WorldLighting;
|
||||
CGraphics::sLightMode = CGraphics::eWorldLighting;
|
||||
ui->ActionNoLighting->setChecked(false);
|
||||
ui->ActionBasicLighting->setChecked(false);
|
||||
ui->ActionWorldLighting->setChecked(true);
|
||||
|
|
Loading…
Reference in New Issue