#pragma once #include //#include #include "K3DTypes.h" #include "KRenderDevice.h" #include "GameDefine.h" #include "KObject.h" struct WorldLocationBase; class SGameSky; class SGameLensFlare; class SGameWeatherService; class SGameMilesSoundMgr; namespace env_fx { /* //=================================================================== // SEnvProperty //=================================================================== struct SEnvProperty { public: SEnvProperty(); void Reset(); //void SetByWorldLocation( const WorldLocationBase* pData ); //void LerpByWorldLocation( const WorldLocationBase* pDestData // , const WorldLocationBase* pSrcData // , float fLerpTime ); SEnvProperty& operator = ( const SEnvProperty& rhs ); void SetSkyColor( int nR, int nG, int nB, int nA ); void SetFogColor( int nR, int nG, int nB, int nA ); void SetTerrainLight( int type, K3DColor col ); void SetEffectLight( int type, K3DColor col ); void SetTerrainLightPos( int nX, int nY, int nZ ); void SetTerrainLightDir( float fX, float fY, float fZ ); void SetFogLinearStart( float fUnit ); void SetFogLinearEnd( float fUnit ); void SetFogHeightStart( float fUnit ); void SetFogHeightEnd( float fUnit ); void SetSkyColorStart( int nR, int nG, int nB ); void SetSkyColorMid( int nR, int nG, int nB ); void SetSkyColorEnd( int nR, int nG, int nB ); void SetSkyColorMaxHeight( float fMaxHeight ); void SetSkyColorMidHeightPercent( float fMidHeightPercent ); void SetSkyColorMinHeight( float fMinHeight ); void SetCurrentTime( const tm& tmTime ); void SetEnvironmentInfo( int nInfo ); tm m_tmTime; int m_nEnvironmentInfo; KColor m_FillColor; bool m_bIsCustomFog; KColor m_FogColor; float m_fHeightFogStart; float m_fHeightFogEnd; float m_fLinearFogStart; float m_fLinearFogEnd; K3DColor m_SkyColorStart; K3DColor m_SkyColorMid; K3DColor m_SkyColorEnd; float m_fSkyColorMaxHeight; float m_fSkyColorMinHeight; float m_fSkyMidHeightPercent; K3DColor m_CloudColor; float m_fTerrainSpecular; K3DColor m_TerrainLightAmbient; K3DColor m_TerrainLightDiffuse; K3DColor m_TerrainLightSpecular; float m_fCharSkinAmbiantFactor; float m_fCharSkinDiffuseFactor; float m_fDryVolume; float m_fWetVolume; K3DLight m_TerrainLight; K3DLight m_EffectLight; K3DLight m_AvatarLight; }; */ struct SEnvironmentContext { SEnvironmentContext() : sky( 0 ), lensFlare( 0 ), weatherService( 0 ) {} SGameSky* sky; SGameLensFlare* lensFlare; SGameWeatherService* weatherService; }; class SSimpleTm { public: SSimpleTm() { ::memset( &m_tm, 0, sizeof( tm ) ); } SSimpleTm( const tm& tmTime ) { ::memcpy( &m_tm, &tmTime, sizeof( tm ) ); } SSimpleTm& operator = ( const SSimpleTm& tmTime ) { if( &tmTime == this ) return *this; ::memcpy( &m_tm, &tmTime.m_tm, sizeof( tm ) ); return *this; } SSimpleTm( int hour, int min, int sec ) { ::memset( &m_tm, 0, sizeof( tm ) ); m_tm.tm_hour = hour; m_tm.tm_min = min; m_tm.tm_sec = sec; } operator tm& () { return m_tm; } operator const tm& () const { return m_tm; } // compare with other tm( accuracy : minites ) bool operator < ( const SSimpleTm& other ) const { if( m_tm.tm_hour != other.m_tm.tm_hour ) return ( m_tm.tm_hour < other.m_tm.tm_hour ) ? true : false; if( m_tm.tm_min < other.m_tm.tm_min ) return true; return false; } bool operator > ( const SSimpleTm& other ) const { if( m_tm.tm_hour != other.m_tm.tm_hour ) return ( m_tm.tm_hour > other.m_tm.tm_hour ) ? true : false; if( m_tm.tm_min > other.m_tm.tm_min ) return true; return false; } bool operator >= ( const SSimpleTm& other ) const { return !this->operator < ( other ); } bool operator <= ( const SSimpleTm& other ) const { return !this->operator > ( other ); } int GetDiffMinitesFrom( const tm& rhs ) { int minites = 0; if( m_tm.tm_hour >= rhs.tm_hour ) { minites = ( m_tm.tm_hour - rhs.tm_hour ) * 60; } else { minites = ( 24 - ( rhs.tm_hour - m_tm.tm_hour ) ) * 60; } if( m_tm.tm_min >= rhs.tm_min ) { minites += m_tm.tm_min - rhs.tm_min; } else { minites -= rhs.tm_min - m_tm.tm_min; } return minites; } unsigned int GetMinites() { return ( m_tm.tm_hour * 60 ) + m_tm.tm_min; } tm m_tm; }; struct SLerpArgument { enum { LERP_NONE, LERP_PREV, LERP_NEXT }; SLerpArgument() : time ( 0 ) , timeState ( -1 ) , calcMinites ( 0 ) , lerpTime ( 0 ) , lerpAction ( LERP_NONE ) , isIndoor ( false ) , localID ( 0 ) , weatherID ( 0 ) , weatherOptionFactor( 1.0f ) , weatherChanged ( false ) , locData ( 0 ) , locLerpData ( 0 ) , context ( 0 ) , configMode ( false ) { } bool isValid() const { return ( locData == 0 || ( locLerpData == 0 && lerpAction != LERP_NONE ) ) ? false : true; } DWORD time; SSimpleTm tmTime; int timeState; ///< enum GAME_DEFINE::WORLD_TIME_INFO unsigned int calcMinites; float lerpTime; char lerpAction; bool isIndoor; int localID; int weatherID; float weatherOptionFactor; bool weatherChanged; const WorldLocationBase* locData; const WorldLocationBase* locLerpData; SEnvironmentContext* context; bool configMode; }; class SEnvironmentService; class IEnvironmentState { public: IEnvironmentState( const tm& tmBegin, const tm& tmEnd, int nLerpDuration ) : m_tmBegin( tmBegin ), m_tmEnd( tmEnd ), m_nLerpDuration_min_( nLerpDuration ) { m_nActiveDuration_min_ = m_tmEnd.GetDiffMinitesFrom( m_tmBegin ); } virtual ~IEnvironmentState() { } virtual GAME_DEFINE::WORLD_TIME_INFO GetStateType() const = 0; virtual void OnEnter( SLerpArgument& arg ) = 0; virtual void OnLeave( SLerpArgument& arg ) = 0; virtual void OnPerform( SLerpArgument& arg ) = 0; virtual bool IsValid( const SLerpArgument& arg ) const; virtual void PrepareLerp( SLerpArgument& arg ); virtual const WorldLocationBase* GetLocationDB( SLerpArgument& arg ); private: SSimpleTm m_tmBegin; SSimpleTm m_tmEnd; int m_nLerpDuration_min_; int m_nActiveDuration_min_; }; class SEnvironmentDawn : public IEnvironmentState { public: SEnvironmentDawn( const tm& tmBegin, const tm& tmEnd, int nLerpDuration ) : IEnvironmentState( tmBegin, tmEnd, nLerpDuration ) { } virtual GAME_DEFINE::WORLD_TIME_INFO GetStateType() const { return GAME_DEFINE::WORLD_TIME_DAWN; } virtual void OnEnter( SLerpArgument& arg ); virtual void OnLeave( SLerpArgument& arg ); virtual void OnPerform( SLerpArgument& arg ); }; class SEnvironmentDaylight : public IEnvironmentState { public: SEnvironmentDaylight( const tm& tmBegin, const tm& tmEnd, int nLerpDuration ) : IEnvironmentState( tmBegin, tmEnd, nLerpDuration ) { } virtual GAME_DEFINE::WORLD_TIME_INFO GetStateType() const { return GAME_DEFINE::WORLD_TIME_DAYLIGHT; } virtual void OnEnter( SLerpArgument& arg ); virtual void OnLeave( SLerpArgument& arg ); virtual void OnPerform( SLerpArgument& arg ); }; class SEnvironmentEvening : public IEnvironmentState { public: SEnvironmentEvening( const tm& tmBegin, const tm& tmEnd, int nLerpDuration ) : IEnvironmentState( tmBegin, tmEnd, nLerpDuration ) { } virtual GAME_DEFINE::WORLD_TIME_INFO GetStateType() const { return GAME_DEFINE::WORLD_TIME_EVENING; } virtual void OnEnter( SLerpArgument& arg ); virtual void OnLeave( SLerpArgument& arg ); virtual void OnPerform( SLerpArgument& arg ); }; class SEnvironmentNight : public IEnvironmentState { public: SEnvironmentNight( const tm& tmBegin, const tm& tmEnd, int nLerpDuration ) : IEnvironmentState( tmBegin, tmEnd, nLerpDuration ) { } virtual GAME_DEFINE::WORLD_TIME_INFO GetStateType() const { return GAME_DEFINE::WORLD_TIME_NIGHT; } virtual void OnEnter( SLerpArgument& arg ); virtual void OnLeave( SLerpArgument& arg ); virtual void OnPerform( SLerpArgument& arg ); }; class SEnvironmentService { public: SEnvironmentService( SGameSky* pSky, SGameLensFlare* pLensFlare, SGameWeatherService* pWeather, SGameMilesSoundMgr* pSoundMgr ); ~SEnvironmentService(); void Perform( SLerpArgument& arg ); private: void _prepareLerpArgument( SLerpArgument& arg ); IEnvironmentState* _switchState( const SLerpArgument& arg ); IEnvironmentState* _getNextState( int nCurrentState ); IEnvironmentState* _getPrevState( int nCurrentState ); // sonador 1.1.20 환경값 보간 오류 수정 typedef std::vector< IEnvironmentState* > world_time_state_vector; world_time_state_vector m_ctEnvironmentStates; IEnvironmentState* m_pCurrentState; IEnvironmentState* m_pPreviousState; SEnvironmentContext* m_pContext; SGameMilesSoundMgr* m_pSoundMgr; }; /* //=================================================================== // IObserverEnvProp //=================================================================== class IEnvPropObserver { public: virtual ~IEnvPropObserver() {} virtual void OnUpdateEnvProp( const SEnvProperty& Property ) = 0; }; //=================================================================== // IEnvPropSubject //=================================================================== class IEnvPropSubject { public: typedef std::vector< IEnvPropObserver* > tyObserverVector; virtual ~IEnvPropSubject(); virtual void NotifyEnvProp(); virtual void AddEnvPropObserver( IEnvPropObserver& observer ); virtual void RmvEnvPropObserver( IEnvPropObserver& observer ); protected: tyObserverVector m_ctEnvPropObservers; SEnvProperty* m_pEnvProp; };*/ }