WINTERMUTE: Implement fog
This commit is contained in:
parent
38bb27fb98
commit
25ea38c3bc
7 changed files with 81 additions and 0 deletions
|
@ -1697,6 +1697,19 @@ Wintermute::TShadowType Wintermute::AdGame::getMaxShadowType(Wintermute::BaseObj
|
|||
|
||||
return MIN(ret, _scene->_maxShadowType);
|
||||
}
|
||||
|
||||
bool Wintermute::AdGame::getFogParams(bool *fogEnabled, uint32 *fogColor, float *fogStart, float *fogEnd) {
|
||||
if (_scene) {
|
||||
*fogEnabled = _scene->_fogEnabled;
|
||||
*fogColor = _scene->_fogColor;
|
||||
*fogStart = _scene->_fogStart;
|
||||
*fogEnd = _scene->_fogEnd;
|
||||
|
||||
return true;
|
||||
} else {
|
||||
return BaseGame::getFogParams(fogEnabled, fogColor, fogStart, fogEnd);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
|
|
@ -97,6 +97,8 @@ public:
|
|||
uint32 getAmbientLightColor() override;
|
||||
|
||||
TShadowType getMaxShadowType(BaseObject *object) override;
|
||||
|
||||
bool getFogParams(bool *fogEnabled, uint32 *fogColor, float *fogStart, float *fogEnd) override;
|
||||
#endif
|
||||
|
||||
bool getVersion(byte *verMajor, byte *verMinor, byte *extMajor, byte *extMinor) const override;
|
||||
|
|
|
@ -105,6 +105,11 @@ void AdScene::setDefaults() {
|
|||
|
||||
_maxShadowType = SHADOW_FLAT;
|
||||
_ambientLightColor = 0x00000000;
|
||||
|
||||
_fogEnabled = false;
|
||||
_fogColor = 0x00FFFFFF;
|
||||
_fogStart = 0.0f;
|
||||
_fogEnd = 0.0f;
|
||||
#endif
|
||||
|
||||
_pfPointsNum = 0;
|
||||
|
@ -2083,6 +2088,31 @@ bool AdScene::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack,
|
|||
stack->pushBool(false);
|
||||
return STATUS_OK;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// EnableFog
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
else if (strcmp(name, "EnableFog") == 0) {
|
||||
stack->correctParams(3);
|
||||
_fogEnabled = true;
|
||||
_fogColor = stack->pop()->getInt();
|
||||
_fogStart = stack->pop()->getFloat();
|
||||
_fogEnd = stack->pop()->getFloat();
|
||||
|
||||
stack->pushNULL();
|
||||
return STATUS_OK;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// DisableFog
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
else if (strcmp(name, "DisableFog") == 0) {
|
||||
stack->correctParams(0);
|
||||
_fogEnabled = false;
|
||||
|
||||
stack->pushNULL();
|
||||
return STATUS_OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
@ -2915,8 +2945,13 @@ bool AdScene::persist(BasePersistenceManager *persistMgr) {
|
|||
persistMgr->transferFloat(TMEMBER(_farPlane));
|
||||
persistMgr->transferSint32(TMEMBER_INT(_maxShadowType));
|
||||
persistMgr->transferUint32(TMEMBER(_ambientLightColor));
|
||||
persistMgr->transferBool(TMEMBER(_fogEnabled));
|
||||
persistMgr->transferUint32(TMEMBER(_fogColor));
|
||||
persistMgr->transferFloat(TMEMBER(_fogStart));
|
||||
persistMgr->transferFloat(TMEMBER(_fogEnd));
|
||||
} else {
|
||||
_sceneGeometry = nullptr;
|
||||
_fogEnabled = false;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -67,6 +67,11 @@ public:
|
|||
float _fov;
|
||||
float _nearPlane;
|
||||
float _farPlane;
|
||||
|
||||
bool _fogEnabled;
|
||||
uint32 _fogColor;
|
||||
float _fogStart;
|
||||
float _fogEnd;
|
||||
#endif
|
||||
bool afterLoad();
|
||||
|
||||
|
|
|
@ -610,6 +610,11 @@ TShadowType BaseGame::getMaxShadowType(BaseObject *object) {
|
|||
uint32 BaseGame::getAmbientLightColor() {
|
||||
return 0x00000000;
|
||||
}
|
||||
|
||||
bool BaseGame::getFogParams(bool *fogEnabled, uint32 *fogColor, float *fogStart, float *fogEnd) {
|
||||
*fogEnabled = false;
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -169,6 +169,8 @@ public:
|
|||
virtual TShadowType getMaxShadowType(BaseObject *object);
|
||||
|
||||
virtual uint32 getAmbientLightColor();
|
||||
|
||||
virtual bool getFogParams(bool *fogEnabled, uint32 *fogColor, float *fogStart, float *fogEnd);
|
||||
#endif
|
||||
BaseSoundMgr *_soundMgr;
|
||||
#if EXTENDED_DEBUGGER_ENABLED
|
||||
|
|
|
@ -383,6 +383,25 @@ bool BaseRenderOpenGL3D::setup3D(Camera3D *camera, bool force) {
|
|||
glGetFloatv(GL_MODELVIEW_MATRIX, _lastViewMatrix.getData());
|
||||
}
|
||||
|
||||
bool fogEnabled;
|
||||
uint32 fogColor;
|
||||
float fogStart;
|
||||
float fogEnd;
|
||||
|
||||
_gameRef->getFogParams(&fogEnabled, &fogColor, &fogStart, &fogEnd);
|
||||
|
||||
if (fogEnabled) {
|
||||
glEnable(GL_FOG);
|
||||
glFogi(GL_FOG_MODE, GL_LINEAR);
|
||||
glFogf(GL_FOG_START, fogStart);
|
||||
glFogf(GL_FOG_END, fogEnd);
|
||||
|
||||
GLfloat color[4] = { RGBCOLGetR(fogColor) / 255.0f, RGBCOLGetG(fogColor) / 255.0f, RGBCOLGetB(fogColor) / 255.0f, RGBCOLGetA(fogColor) / 255.0f };
|
||||
glFogfv(GL_FOG_COLOR, color);
|
||||
} else {
|
||||
glDisable(GL_FOG);
|
||||
}
|
||||
|
||||
setProjection();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue