Renamed transparency to ghost mode
parent
9a07c1d858
commit
39b6621463
|
@ -54,22 +54,22 @@ namespace Gfx
|
||||||
const float MOUSE_EDGE_MARGIN = 0.01f;
|
const float MOUSE_EDGE_MARGIN = 0.01f;
|
||||||
|
|
||||||
//! Changes the level of transparency of an object and objects transported (battery & cargo)
|
//! Changes the level of transparency of an object and objects transported (battery & cargo)
|
||||||
static void SetTransparency(CObject* obj, float value)
|
static void SetGhostMode(CObject* obj, bool enabled)
|
||||||
{
|
{
|
||||||
obj->SetTransparency(value);
|
obj->SetGhostMode(enabled);
|
||||||
|
|
||||||
if (obj->Implements(ObjectInterfaceType::Carrier))
|
if (obj->Implements(ObjectInterfaceType::Carrier))
|
||||||
{
|
{
|
||||||
CObject* cargo = dynamic_cast<CCarrierObject&>(*obj).GetCargo();
|
CObject* cargo = dynamic_cast<CCarrierObject&>(*obj).GetCargo();
|
||||||
if (cargo != nullptr)
|
if (cargo != nullptr)
|
||||||
cargo->SetTransparency(value);
|
cargo->SetGhostMode(enabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (obj->Implements(ObjectInterfaceType::Powered))
|
if (obj->Implements(ObjectInterfaceType::Powered))
|
||||||
{
|
{
|
||||||
CObject* power = dynamic_cast<CPoweredObject&>(*obj).GetPower();
|
CObject* power = dynamic_cast<CPoweredObject&>(*obj).GetPower();
|
||||||
if (power != nullptr)
|
if (power != nullptr)
|
||||||
power->SetTransparency(value);
|
power->SetGhostMode(enabled);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -262,7 +262,7 @@ void CCamera::SetType(CameraType type)
|
||||||
if (IsObjectBeingTransported(obj))
|
if (IsObjectBeingTransported(obj))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
SetTransparency(obj, 0.0f); // opaque object
|
SetGhostMode(obj, false); // opaque object
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -839,7 +839,7 @@ void CCamera::IsCollisionBack()
|
||||||
if (IsObjectBeingTransported(obj))
|
if (IsObjectBeingTransported(obj))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
SetTransparency(obj, 0.0f); // opaque object
|
SetGhostMode(obj, false); // opaque object
|
||||||
|
|
||||||
if (obj == m_cameraObj) continue;
|
if (obj == m_cameraObj) continue;
|
||||||
|
|
||||||
|
@ -899,7 +899,7 @@ void CCamera::IsCollisionBack()
|
||||||
float len = glm::distance(m_actualEye, proj);
|
float len = glm::distance(m_actualEye, proj);
|
||||||
if (len > del) continue;
|
if (len > del) continue;
|
||||||
|
|
||||||
SetTransparency(obj, 1.0f); // transparent object
|
SetGhostMode(obj, true); // ghost mode
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -830,7 +830,7 @@ void CEngine::DebugObject(int objRank)
|
||||||
l->Debug(" type = %d\n", m_objects[objRank].type);
|
l->Debug(" type = %d\n", m_objects[objRank].type);
|
||||||
l->Debug(" distance = %f\n", m_objects[objRank].distance);
|
l->Debug(" distance = %f\n", m_objects[objRank].distance);
|
||||||
l->Debug(" shadowRank = %d\n", m_objects[objRank].shadowRank);
|
l->Debug(" shadowRank = %d\n", m_objects[objRank].shadowRank);
|
||||||
l->Debug(" transparency = %f\n", m_objects[objRank].transparency);
|
l->Debug(" ghost = %s\n", m_objects[objRank].ghost ? "true" : "false");
|
||||||
|
|
||||||
l->Debug(" baseObj:\n");
|
l->Debug(" baseObj:\n");
|
||||||
int baseObjRank = m_objects[objRank].baseObjRank;
|
int baseObjRank = m_objects[objRank].baseObjRank;
|
||||||
|
@ -984,11 +984,11 @@ void CEngine::SetObjectDrawFront(int objRank, bool draw)
|
||||||
m_objects[objRank].drawFront = draw;
|
m_objects[objRank].drawFront = draw;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CEngine::SetObjectTransparency(int objRank, float value)
|
void CEngine::SetObjectGhostMode(int objRank, bool enabled)
|
||||||
{
|
{
|
||||||
assert(objRank >= 0 && objRank < static_cast<int>( m_objects.size() ));
|
assert(objRank >= 0 && objRank < static_cast<int>( m_objects.size() ));
|
||||||
|
|
||||||
m_objects[objRank].transparency = value;
|
m_objects[objRank].ghost = enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CEngine::GetObjectBBox(int objRank, glm::vec3& min, glm::vec3& max)
|
void CEngine::GetObjectBBox(int objRank, glm::vec3& min, glm::vec3& max)
|
||||||
|
@ -3544,7 +3544,7 @@ void CEngine::Draw3DScene()
|
||||||
{
|
{
|
||||||
EngineBaseObjDataTier& p3 = p2.next[l3];
|
EngineBaseObjDataTier& p3 = p2.next[l3];
|
||||||
|
|
||||||
if (m_objects[objRank].transparency != 0.0f) // transparent ?
|
if (m_objects[objRank].ghost) // transparent ?
|
||||||
{
|
{
|
||||||
transparent = true;
|
transparent = true;
|
||||||
continue;
|
continue;
|
||||||
|
@ -3629,7 +3629,7 @@ void CEngine::Draw3DScene()
|
||||||
{
|
{
|
||||||
EngineBaseObjDataTier& p3 = p2.next[l3];
|
EngineBaseObjDataTier& p3 = p2.next[l3];
|
||||||
|
|
||||||
if (m_objects[objRank].transparency == 0.0f)
|
if (!m_objects[objRank].ghost)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
float dirty = (p3.state & ENG_RSTATE_DUAL_BLACK) && m_dirty ? 1.0 : 0.0;
|
float dirty = (p3.state & ENG_RSTATE_DUAL_BLACK) && m_dirty ? 1.0 : 0.0;
|
||||||
|
@ -5646,10 +5646,10 @@ const glm::mat4& CEngine::GetStaticMeshWorldMatrix(int meshHandle)
|
||||||
return m_objects[objRank].transform;
|
return m_objects[objRank].transform;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CEngine::SetStaticMeshTransparency(int meshHandle, float value)
|
void CEngine::SetStaticMeshGhostMode(int meshHandle, bool enabled)
|
||||||
{
|
{
|
||||||
int objRank = meshHandle;
|
int objRank = meshHandle;
|
||||||
SetObjectTransparency(objRank, value);
|
SetObjectGhostMode(objRank, enabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CEngine::SetDebugLights(bool debugLights)
|
void CEngine::SetDebugLights(bool debugLights)
|
||||||
|
|
|
@ -274,8 +274,8 @@ struct EngineObject
|
||||||
float distance = 0.0f;
|
float distance = 0.0f;
|
||||||
//! Rank of the associated shadow
|
//! Rank of the associated shadow
|
||||||
int shadowRank = -1;
|
int shadowRank = -1;
|
||||||
//! Transparency of the object [0, 1]
|
//! Ghost mode
|
||||||
float transparency = 0.0f;
|
bool ghost = false;
|
||||||
|
|
||||||
//! Loads default values
|
//! Loads default values
|
||||||
inline void LoadDefault()
|
inline void LoadDefault()
|
||||||
|
@ -706,7 +706,7 @@ public:
|
||||||
const glm::mat4& GetStaticMeshWorldMatrix(int meshHandle);
|
const glm::mat4& GetStaticMeshWorldMatrix(int meshHandle);
|
||||||
|
|
||||||
//! Sets transparency for static mesh
|
//! Sets transparency for static mesh
|
||||||
void SetStaticMeshTransparency(int meshHandle, float value);
|
void SetStaticMeshGhostMode(int meshHandle, bool enabled);
|
||||||
|
|
||||||
|
|
||||||
/* *************** Object management *************** */
|
/* *************** Object management *************** */
|
||||||
|
@ -767,7 +767,7 @@ public:
|
||||||
void SetObjectDrawFront(int objRank, bool draw);
|
void SetObjectDrawFront(int objRank, bool draw);
|
||||||
|
|
||||||
//! Sets the transparency level for given object
|
//! Sets the transparency level for given object
|
||||||
void SetObjectTransparency(int objRank, float value);
|
void SetObjectGhostMode(int objRank, bool enabled);
|
||||||
|
|
||||||
//! Returns the bounding box for an object
|
//! Returns the bounding box for an object
|
||||||
void GetObjectBBox(int objRank, glm::vec3& min, glm::vec3& max);
|
void GetObjectBBox(int objRank, glm::vec3& min, glm::vec3& max);
|
||||||
|
|
|
@ -162,8 +162,8 @@ public:
|
||||||
// TODO: remove from here once no longer necessary
|
// TODO: remove from here once no longer necessary
|
||||||
void SetCameraCollisionSphere(const Math::Sphere& sphere);
|
void SetCameraCollisionSphere(const Math::Sphere& sphere);
|
||||||
|
|
||||||
//! Sets the transparency of object
|
//! Sets object's ghost mode
|
||||||
virtual void SetTransparency(float value) = 0;
|
virtual void SetGhostMode(bool enabled) = 0;
|
||||||
|
|
||||||
//! Sets flag controlling animation effect on level reset
|
//! Sets flag controlling animation effect on level reset
|
||||||
void SetAnimateOnReset(bool animateOnReset);
|
void SetAnimateOnReset(bool animateOnReset);
|
||||||
|
|
|
@ -2547,7 +2547,7 @@ float COldObject::GetReactorRange()
|
||||||
|
|
||||||
// Management of transparency of the object.
|
// Management of transparency of the object.
|
||||||
|
|
||||||
void COldObject::SetTransparency(float value)
|
void COldObject::SetGhostMode(bool enabled)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
@ -2560,7 +2560,7 @@ void COldObject::SetTransparency(float value)
|
||||||
if ( i != 9 ) continue; // no central pillar?
|
if ( i != 9 ) continue; // no central pillar?
|
||||||
}
|
}
|
||||||
|
|
||||||
m_engine->SetObjectTransparency(m_objectPart[i].object, value);
|
m_engine->SetObjectGhostMode(m_objectPart[i].object, enabled);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -209,7 +209,7 @@ public:
|
||||||
void SetReactorRange(float reactorRange) override;
|
void SetReactorRange(float reactorRange) override;
|
||||||
float GetReactorRange() override;
|
float GetReactorRange() override;
|
||||||
|
|
||||||
void SetTransparency(float value) override;
|
void SetGhostMode(bool enabled) override;
|
||||||
|
|
||||||
Math::Sphere GetJostlingSphere() const override;
|
Math::Sphere GetJostlingSphere() const override;
|
||||||
bool JostleObject(float force) override;
|
bool JostleObject(float force) override;
|
||||||
|
|
|
@ -105,9 +105,9 @@ void CStaticObject::TransformCameraCollisionSphere(Math::Sphere& collisionSphere
|
||||||
Math::Transform(worldMatrix, collisionSphere.pos);
|
Math::Transform(worldMatrix, collisionSphere.pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CStaticObject::SetTransparency(float value)
|
void CStaticObject::SetGhostMode(bool enabled)
|
||||||
{
|
{
|
||||||
m_engine->SetStaticMeshTransparency(m_meshHandle, value);
|
m_engine->SetStaticMeshGhostMode(m_meshHandle, enabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CStaticObject::IsStaticObject(ObjectType type)
|
bool CStaticObject::IsStaticObject(ObjectType type)
|
||||||
|
|
|
@ -53,7 +53,7 @@ public:
|
||||||
void Read(CLevelParserLine* line) override;
|
void Read(CLevelParserLine* line) override;
|
||||||
void Write(CLevelParserLine* line) override;
|
void Write(CLevelParserLine* line) override;
|
||||||
|
|
||||||
void SetTransparency(float value) override;
|
void SetGhostMode(bool enabled) override;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static bool IsStaticObject(ObjectType type);
|
static bool IsStaticObject(ObjectType type);
|
||||||
|
|
Loading…
Reference in New Issue