BGE: Adding support for the Cast Only material option.

Note: This does not add support for the option in the viewport.
This commit is contained in:
Mitchell Stokes
2014-01-26 19:28:26 -08:00
parent 9d4b54b44f
commit e02b9c8a45
6 changed files with 18 additions and 2 deletions

View File

@@ -611,6 +611,10 @@ static bool ConvertMaterial(
// cast shadows? // cast shadows?
material->ras_mode |= ( mat->mode & MA_SHADBUF )?CAST_SHADOW:0; material->ras_mode |= ( mat->mode & MA_SHADBUF )?CAST_SHADOW:0;
// only shadows?
material->ras_mode |= ( mat->mode & MA_ONLYCAST )?ONLY_SHADOW:0;
MTex *mttmp = 0; MTex *mttmp = 0;
int valid_index = 0; int valid_index = 0;

View File

@@ -144,7 +144,8 @@ enum BL_ras_mode
WIRE=64, WIRE=64,
CAST_SHADOW=128, CAST_SHADOW=128,
TEX=256, TEX=256,
TWOSIDED=512 TWOSIDED=512,
ONLY_SHADOW=1024,
}; };
// ------------------------------------- // -------------------------------------

View File

@@ -110,6 +110,7 @@ void KX_BlenderMaterial::Initialize(
m_flag |= ((mMaterial->ras_mode & USE_LIGHT)!=0)? RAS_MULTILIGHT: 0; m_flag |= ((mMaterial->ras_mode & USE_LIGHT)!=0)? RAS_MULTILIGHT: 0;
m_flag |= (mMaterial->glslmat)? RAS_BLENDERGLSL: 0; m_flag |= (mMaterial->glslmat)? RAS_BLENDERGLSL: 0;
m_flag |= ((mMaterial->ras_mode & CAST_SHADOW)!=0)? RAS_CASTSHADOW: 0; m_flag |= ((mMaterial->ras_mode & CAST_SHADOW)!=0)? RAS_CASTSHADOW: 0;
m_flag |= ((mMaterial->ras_mode & ONLY_SHADOW)!=0)? RAS_ONLYSHADOW: 0;
// test the sum of the various modes for equality // test the sum of the various modes for equality
// so we can ether accept or reject this material // so we can ether accept or reject this material

View File

@@ -282,6 +282,11 @@ bool RAS_IPolyMaterial::CastsShadows() const
return (m_flag & RAS_CASTSHADOW) != 0; return (m_flag & RAS_CASTSHADOW) != 0;
} }
bool RAS_IPolyMaterial::OnlyShadow() const
{
return (m_flag & RAS_ONLYSHADOW) != 0;
}
bool RAS_IPolyMaterial::UsesObjectColor() const bool RAS_IPolyMaterial::UsesObjectColor() const
{ {
return !(m_flag & RAS_BLENDERGLSL); return !(m_flag & RAS_BLENDERGLSL);

View File

@@ -61,7 +61,8 @@ enum MaterialProps
RAS_NORMAL =256, RAS_NORMAL =256,
RAS_DEFMULTI =512, RAS_DEFMULTI =512,
RAS_BLENDERGLSL =1024, RAS_BLENDERGLSL =1024,
RAS_CASTSHADOW =2048 RAS_CASTSHADOW =2048,
RAS_ONLYSHADOW =4096,
}; };
/** /**
@@ -174,6 +175,7 @@ public:
virtual bool UsesLighting(RAS_IRasterizer *rasty) const; virtual bool UsesLighting(RAS_IRasterizer *rasty) const;
virtual bool UsesObjectColor() const; virtual bool UsesObjectColor() const;
virtual bool CastsShadows() const; virtual bool CastsShadows() const;
virtual bool OnlyShadow() const;
virtual void Replace_IScene(SCA_IScene *val) {} /* overridden by KX_BlenderMaterial */ virtual void Replace_IScene(SCA_IScene *val) {} /* overridden by KX_BlenderMaterial */

View File

@@ -587,6 +587,9 @@ bool RAS_MaterialBucket::ActivateMaterial(const MT_Transform& cameratrans, RAS_I
if (rasty->GetDrawingMode() == RAS_IRasterizer::KX_SHADOW && !m_material->CastsShadows()) if (rasty->GetDrawingMode() == RAS_IRasterizer::KX_SHADOW && !m_material->CastsShadows())
return false; return false;
if (rasty->GetDrawingMode() != RAS_IRasterizer::KX_SHADOW && m_material->OnlyShadow())
return false;
if (!rasty->SetMaterial(*m_material)) if (!rasty->SetMaterial(*m_material))
return false; return false;