mirror of
https://github.com/AxioDL/PrimeWorldEditor.git
synced 2025-12-10 14:07:56 +00:00
Draw wire sphere on selected lights to visualize light radius
This commit is contained in:
@@ -26,6 +26,9 @@ CModel *CDrawUtil::mpDoubleSidedSphereModel;
|
||||
CToken CDrawUtil::mSphereToken;
|
||||
CToken CDrawUtil::mDoubleSidedSphereToken;
|
||||
|
||||
CModel *CDrawUtil::mpWireSphereModel;
|
||||
CToken CDrawUtil::mWireSphereToken;
|
||||
|
||||
CShader *CDrawUtil::mpColorShader;
|
||||
CShader *CDrawUtil::mpColorShaderLighting;
|
||||
CShader *CDrawUtil::mpBillboardShader;
|
||||
@@ -199,6 +202,28 @@ void CDrawUtil::DrawSphere(const CColor &kColor)
|
||||
DrawSphere(false);
|
||||
}
|
||||
|
||||
void CDrawUtil::DrawWireSphere(const CVector3f& Position, float Radius, const CColor& Color /*= CColor::skWhite*/)
|
||||
{
|
||||
Init();
|
||||
|
||||
// Create model matrix
|
||||
CTransform4f Transform;
|
||||
Transform.Scale(Radius);
|
||||
Transform.Translate(Position);
|
||||
CGraphics::sMVPBlock.ModelMatrix = Transform.ToMatrix4f();
|
||||
CGraphics::UpdateMVPBlock();
|
||||
|
||||
// Set other render params
|
||||
UseColorShader(Color);
|
||||
CMaterial::KillCachedMaterial();
|
||||
glBlendFunc(GL_ONE, GL_ZERO);
|
||||
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
|
||||
glDepthMask(GL_TRUE);
|
||||
|
||||
// Draw
|
||||
mpWireSphereModel->Draw(eNoMaterialSetup, 0);
|
||||
}
|
||||
|
||||
void CDrawUtil::DrawBillboard(CTexture* pTexture, const CVector3f& Position, const CVector2f& Scale /*= CVector2f::skOne*/, const CColor& Tint /*= CColor::skWhite*/)
|
||||
{
|
||||
Init();
|
||||
@@ -375,6 +400,7 @@ void CDrawUtil::Init()
|
||||
InitCube();
|
||||
InitWireCube();
|
||||
InitSphere();
|
||||
InitWireSphere();
|
||||
InitShaders();
|
||||
InitTextures();
|
||||
mDrawUtilInitialized = true;
|
||||
@@ -512,6 +538,13 @@ void CDrawUtil::InitSphere()
|
||||
mDoubleSidedSphereToken = CToken(mpDoubleSidedSphereModel);
|
||||
}
|
||||
|
||||
void CDrawUtil::InitWireSphere()
|
||||
{
|
||||
Log::Write("Creating wire sphere");
|
||||
mpWireSphereModel = (CModel*) gResCache.GetResource("../resources/WireSphere.cmdl");
|
||||
mWireSphereToken = CToken(mpWireSphereModel);
|
||||
}
|
||||
|
||||
void CDrawUtil::InitShaders()
|
||||
{
|
||||
Log::Write("Creating shaders");
|
||||
|
||||
@@ -38,6 +38,10 @@ class CDrawUtil
|
||||
static CToken mSphereToken;
|
||||
static CToken mDoubleSidedSphereToken;
|
||||
|
||||
// Wire Sphere
|
||||
static CModel *mpWireSphereModel;
|
||||
static CToken mWireSphereToken;
|
||||
|
||||
// Shaders
|
||||
static CShader *mpColorShader;
|
||||
static CShader *mpColorShaderLighting;
|
||||
@@ -81,6 +85,8 @@ public:
|
||||
static void DrawSphere(bool DoubleSided = false);
|
||||
static void DrawSphere(const CColor& Color);
|
||||
|
||||
static void DrawWireSphere(const CVector3f& Position, float Radius, const CColor& Color = CColor::skWhite);
|
||||
|
||||
static void DrawBillboard(CTexture* pTexture, const CVector3f& Position, const CVector2f& Scale = CVector2f::skOne, const CColor& Tint = CColor::skWhite);
|
||||
|
||||
static void DrawLightBillboard(ELightType Type, const CColor& LightColor, const CVector3f& Position, const CVector2f& Scale = CVector2f::skOne, const CColor& Tint = CColor::skWhite);
|
||||
@@ -106,6 +112,7 @@ private:
|
||||
static void InitCube();
|
||||
static void InitWireCube();
|
||||
static void InitSphere();
|
||||
static void InitWireSphere();
|
||||
static void InitShaders();
|
||||
static void InitTextures();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user