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