440 lines
13 KiB
C++
440 lines
13 KiB
C++
/**==========================================================*\
|
|
|
|
@file : SGameSky.h
|
|
@brief : rappelz sky / cloud / sun & moon class header
|
|
@date : 200x.xx.xx
|
|
@author : xxx
|
|
@history : [2007.04.25] refactoring 'SGameCloud' by sonador
|
|
[2007.05.03] refactoring 'SGameCloud' by sonador
|
|
|
|
\*===========================================================*/
|
|
#pragma once
|
|
|
|
//Sky Box와 Cloud들을 관리 한다.
|
|
|
|
#include <Windows.h>
|
|
#include <queue>
|
|
#include "K3DTypes.h"
|
|
#include "SGameEnv.h"
|
|
|
|
#ifdef DISTANCE_VIEW
|
|
#include "SGameWeatherAttr.h"
|
|
#include "SGameCloud.h"
|
|
#else
|
|
#include "SGameCloud.h"
|
|
#endif
|
|
|
|
class KSeqForm;
|
|
class K3DCamera;
|
|
class SGameMilesSoundMgr;
|
|
|
|
namespace env_fx {
|
|
struct SThunderAttr;
|
|
struct SLightningAttr;
|
|
class SGameLightning;
|
|
}
|
|
|
|
const int RAIN_MAX = 500;
|
|
/* [sonador]
|
|
//비
|
|
class SGameRain : public SGameEnv
|
|
{
|
|
public:
|
|
SGameRain();
|
|
~SGameRain();
|
|
};
|
|
*/
|
|
|
|
#ifdef SKYBOX_CLOUD
|
|
#else
|
|
////위치에 따른 각도 조절 추가 하자.
|
|
///// 구름
|
|
//struct SCloudObject
|
|
//{
|
|
//public:
|
|
//
|
|
// enum EStep { APPEAR, DISAPPEAR, MOVE, THUNDER };
|
|
// enum EVtxPos { UL, UR, BL, BR };
|
|
//
|
|
// SCloudObject();
|
|
// virtual ~SCloudObject() {}
|
|
//
|
|
// void Update( DWORD _time, const KColor& _cloud_color );
|
|
//
|
|
// bool IsOutOfBound() const;
|
|
// bool IsStep( EStep step ) { return eStep == step; }
|
|
// bool IsActive() const { return bActive; }
|
|
// void ChangeStep( EStep step );
|
|
// void ResetStartTime();
|
|
// void SetPosition( float x, float y, float z );
|
|
// void SetVisibility( float _visibility );
|
|
// void SetVisibilityCap( float _cap );
|
|
// void SetColor( const K3DColor& _color );
|
|
// void SetColor( const KColor& _color );
|
|
// void SetActivity( bool _active ) { bActive = _active; }
|
|
// K3DVector GetVertexPosition( EVtxPos _pos_type ) const;
|
|
// bool IsLightningEnable() const { return bLightningEnable; }
|
|
// void SetLightningEnable( bool bEnable ) { bLightningEnable = bEnable; }
|
|
//
|
|
// // cloud fx parameter
|
|
// int nWidth; ///< 너비
|
|
// int nHeight; ///< 길이
|
|
// K3DVector vPosition; ///< 위치
|
|
// K3DVector vStartPosition; ///< 생성 위치
|
|
// float fVisibilityCap; ///< visibility max
|
|
// float fVisibility; ///< visibility
|
|
// KColor color; ///< 색깔
|
|
// bool bActive; ///< 활성화 여부
|
|
// K3DVector * pVecCloud; ///< ???
|
|
// DWORD dwStartTime; ///< 시작 시간
|
|
// DWORD dwOldTime; ///< 이전 시간
|
|
// float fRotSpeed; ///< 회전 속도
|
|
// EStep eStep; ///< 구름 상태
|
|
//
|
|
// // thunder fx parameter
|
|
// DWORD dwThunderBegin; ///< 천둥효과가 시작된 시간
|
|
// // lightning fx parameter
|
|
// bool bLightningEnable; ///< 번개효과 활성화 여부
|
|
//
|
|
// static float s_fFactor;
|
|
// static float s_fLightningFactor;
|
|
// static DWORD s_dwDuration;
|
|
// static int s_nFlashCount;
|
|
// static K3DColor s_sDestColor;
|
|
// static std::string s_strSound;
|
|
// static float s_fSoundSpeed;
|
|
//
|
|
// static void LoadScript();
|
|
//
|
|
//protected:
|
|
//
|
|
// void checkStartTime( DWORD dwTime_msec_ );
|
|
// void processByStep( DWORD elapsed_time, const KColor& _cloud_color );
|
|
// void resetPosition();
|
|
// void movePosition();
|
|
// virtual void onAppear( DWORD elapsed_time );
|
|
// virtual void onDisappear( DWORD elapsed_time );
|
|
// virtual void onMove( DWORD elapsed_time );
|
|
// virtual void onThunder( DWORD elapsed_time );
|
|
//};
|
|
//
|
|
//
|
|
//struct SThunderCloudObject : public SCloudObject
|
|
//{
|
|
//public:
|
|
//
|
|
// SThunderCloudObject();
|
|
// virtual ~SThunderCloudObject();
|
|
//
|
|
//protected:
|
|
//
|
|
// virtual void onAppear( DWORD elapsed_time );
|
|
// virtual void onDisappear( DWORD elapsed_time );
|
|
// virtual void onMove( DWORD elapsed_time );
|
|
// virtual void onThunder( DWORD elapsed_time );
|
|
//
|
|
//};
|
|
#endif
|
|
|
|
#ifdef SKYBOX_CLOUD
|
|
//class SGameCloud : public SGameEnv
|
|
//{
|
|
//public:
|
|
//
|
|
// typedef env_fx::SGameLightning lightning_type;
|
|
//
|
|
//public:
|
|
//
|
|
// SGameCloud( int cloud_count );
|
|
// virtual ~SGameCloud();
|
|
//
|
|
// virtual void Init( K3DRenderDevice *pDevice, K3DIndexBuffer * pIndexBuf=NULL );
|
|
// virtual void Process( DWORD dwTime );
|
|
// virtual void Render( KViewportObject *viewport );
|
|
//
|
|
// int GetCloudCount() { return m_nCloudCount; }
|
|
// void SetHeight( int i, float fz );
|
|
// void SetPosition( int i, float fx, float fy, float fz );
|
|
// void SetActive( int i, bool bActive ) { m_pCloud[i].SetActivity( bActive ); }
|
|
// void SetVectorCloud( K3DVector * pVecCloud ) { /*m_pVecCloud = pVecCloud;*/ }
|
|
// void SetSpeed( int i, float fSpeed ) { m_pCloud[i].fRotSpeed = fSpeed; }
|
|
// void SetMaxVisibility( int i, float fVis );
|
|
// void SetVisibility( int i, float fVis );
|
|
// void SetCloudColor( int i, K3DColor & color );
|
|
// void SetCloudColor( KColor & color );
|
|
// KColor GetCloudColor() { return m_CloudColor; }
|
|
// void SetEnableThunderFx( bool bEnable );
|
|
// void SetThunderCloud( SGameCloud* pThunderCloud );
|
|
// void SetLightning( env_fx::SGameLightning* pLightning );
|
|
// virtual void SetTransform( K3DMatrix* pParentMatrix );
|
|
// SCloudObject* GetFirstDeactiveCloud();
|
|
// void SetSoundManager( SGameMilesSoundMgr* pSoundMgr );
|
|
//
|
|
// static void SetProcessPause( bool bFlag ) { m_bProcessPause = bFlag; }
|
|
// static bool IsProcessPause() { return m_bProcessPause; }
|
|
//
|
|
//protected:
|
|
//
|
|
// virtual void initVB();
|
|
// virtual void updateVB( K3DVERTEX_CLOUD* vtx, const SCloudObject& cloud );
|
|
// virtual void initCloudObjects();
|
|
// virtual void processCloudObject( int nIndex );
|
|
// void _addSoundEvent( const K3DVector& addedPosition );
|
|
// void _procSoundEvent();
|
|
//
|
|
// struct SFindFirstDeactiveCloud
|
|
// {
|
|
// bool operator () ( SCloudObject& cloud )
|
|
// {
|
|
// return !cloud.IsActive();
|
|
// }
|
|
// };
|
|
//
|
|
// struct SSoundEvent
|
|
// {
|
|
// DWORD activeTime;
|
|
// K3DVector activePos;
|
|
// };
|
|
//
|
|
// typedef std::queue< SSoundEvent* > sound_event_queue;
|
|
//
|
|
// static bool m_bProcessPause;
|
|
// DWORD m_dwTime;
|
|
// int m_nCloudCount;
|
|
// SCloudObject* m_pCloud;
|
|
// KColor m_CloudColor;
|
|
// bool m_bEnableThunder;
|
|
// SGameCloud* m_pThunderCloud;
|
|
// lightning_type* m_pLightning;
|
|
//
|
|
// K3DVERTEX_CLOUD* m_pVertex;
|
|
// WORD* m_pIndex;
|
|
// class K3DRenderDevice* m_pDevice;
|
|
//
|
|
// SGameMilesSoundMgr* m_pSoundMgr;
|
|
// sound_event_queue m_ctSoundEvents;
|
|
//};
|
|
|
|
//class SGameThunderCloud : public SGameCloud
|
|
//{
|
|
//public:
|
|
//
|
|
// SGameThunderCloud( int cloud_count );
|
|
// virtual ~SGameThunderCloud();
|
|
//
|
|
//protected:
|
|
//
|
|
// virtual void initCloudObjects();
|
|
//
|
|
//};
|
|
#endif
|
|
|
|
#define MAX_AURORA 3
|
|
|
|
class SGameSunMoon
|
|
{
|
|
private:
|
|
class KSeqModel* m_pSun;
|
|
class KSeqModel* m_pMoon;
|
|
class KSeqModel* m_pAurora[MAX_AURORA];
|
|
|
|
K3DVector m_vPlayerPos;
|
|
K3DVector m_vSunPos;
|
|
K3DVector m_vMoonPos;
|
|
|
|
float m_fScale;
|
|
float m_fRadiusX;
|
|
float m_fRadiusZ;
|
|
|
|
int m_nHour;
|
|
int m_nMin;
|
|
int m_nSec;
|
|
|
|
DWORD m_dwOldTime;
|
|
DWORD m_dwVisibleTime;
|
|
|
|
bool m_bVisibleSun;
|
|
bool m_bVisibleMoon;
|
|
bool m_bVisibleAurora[MAX_AURORA];
|
|
|
|
float m_fVisibilitySun;
|
|
float m_fVisibilityMoon;
|
|
float m_fVisibilityAurora[MAX_AURORA];
|
|
|
|
K3DMatrix m_matAurora[MAX_AURORA];
|
|
float m_fScaleAurora[MAX_AURORA];
|
|
float m_fHeightAurora[MAX_AURORA];
|
|
float m_fAngleAurora[MAX_AURORA];
|
|
|
|
public:
|
|
virtual void Process( DWORD dwTime );
|
|
virtual void Render( KViewportObject *viewport );
|
|
void SetUniformScale( float scale );
|
|
void SetPosition( const K3DVector* vPos );
|
|
K3DVector* GetSunPos() { return &m_vSunPos; }
|
|
K3DVector* GetMoonPos() { return &m_vMoonPos; }
|
|
|
|
// Aurora.
|
|
float GetAuroraTransparency( int index ) { return m_fVisibilityAurora[ index ]; }
|
|
float GetAuroraScale( int index ) { return m_fScaleAurora[ index ]; }
|
|
float GetAuroraAngle( int index ) { return m_fAngleAurora[ index ]; }
|
|
float GetAuroraHeight( int index ) { return m_fHeightAurora[ index ]; }
|
|
|
|
void SetTime( int nHour, int nMin, int nSec );
|
|
void SetVisibilitySun( bool bVisible, float fVisibility, DWORD dwOldTime );
|
|
void SetVisibilityMoon( bool bVisible, float fVisibility, DWORD dwOldTime );
|
|
void SetVisibilityAurora( int nAurora, bool bVisible, float fVisibility, DWORD dwOldTime );
|
|
|
|
void SetAngleAurora( int nAurora, float fAngle );
|
|
void SetScaleAurora( int nAurora, float fScale );
|
|
void SetHeightAurora( int nAurora, float fHeight );
|
|
void RecalcAuroraMatrix( int nAurora );
|
|
|
|
#ifdef _DEV_AURORA
|
|
void SetVisibilityAurora( bool bVisible ); // * bintitle
|
|
// Aurora 를 무작위로 선정하여 ON. * bintitle
|
|
// return : 선정된 Aurora Index.
|
|
int RandomizeOnAurora( float fVisibility, float fAngle, float fScale, float fHeight, DWORD dwOldTime );
|
|
#endif
|
|
|
|
|
|
public:
|
|
SGameSunMoon();
|
|
~SGameSunMoon();
|
|
};
|
|
|
|
class SGameSky
|
|
{
|
|
public:
|
|
SGameSky();
|
|
~SGameSky();
|
|
|
|
bool Init( K3DRenderDevice *pDevice );
|
|
|
|
bool SetSkyType( DWORD dwSkyType );
|
|
|
|
void SetIndexBuffer( K3DIndexBuffer * pIB );
|
|
|
|
void SetPosition( const K3DVector &pos );
|
|
void SetPosition( float x, float y, float z );
|
|
void SetUniformScale( float scale );
|
|
|
|
void Process( DWORD dwTime );
|
|
void Render( KViewportObject *viewport );
|
|
|
|
K3DLight * GetSkyLight() { return m_pSkyLight; }
|
|
void SetCamera( K3DCamera * pCamera ) { m_pCamera = pCamera ; }
|
|
|
|
void SetVisibility( float fVisibility );
|
|
void SetCloudSpeed( float fSpeed );
|
|
void SetCloudColor( KColor color );
|
|
|
|
void SetThunderEnable( bool bEnable );
|
|
void SetLightningEnable( bool bEnable );
|
|
void SetThunderProcess( bool bFlag );
|
|
void SetLightningProcess( bool bFlag );
|
|
void SetThunderAttribute( const env_fx::SThunderAttr* pAttr );
|
|
void SetLightningAttribute( const env_fx::SLightningAttr* pAttr );
|
|
|
|
void SetCloudRender( bool bFlag );
|
|
|
|
K3DVector* GetSunPos() { return m_pSunMoon->GetSunPos(); }
|
|
void SetTime( int nHour, int nMin, int nSec ) { m_pSunMoon->SetTime( nHour, nMin, nSec ); }
|
|
KColor GetCloudColor() { return m_pCloud->GetCloudColor(); }
|
|
|
|
void SetVisibilitySun( bool bVisible, float fVisibility, DWORD dwOldTime );
|
|
void SetVisibilityMoon( bool bVisible, float fVisibility, DWORD dwOldTime );
|
|
void SetVisibilityAurora( int nAurora, bool bVisible, float fVisibility, DWORD dwOldTime );
|
|
void SetAngleAurora( int nAurora, float fAngle );
|
|
void SetScaleAurora( int nAurora, float fScale );
|
|
void SetHeightAurora( int nAurora, float fHeight );
|
|
|
|
#ifdef CLOUD_LUA
|
|
void ChangeCloudColor(int nR, int nG, int nB);
|
|
void ChangeCloud(int nCloudSetID);
|
|
void FadeInOutCloud(int nFadeState);
|
|
CCloudMaker* GetCloudMaker() { return &m_rCloudMaker; }
|
|
#endif
|
|
|
|
#ifdef DISTANCE_VIEW
|
|
env_fx::SSkyBoxAttr* GetSkyThemeInfo() const;
|
|
void SetSkyThemeInfo( env_fx::SSkyBoxAttr* pSkyBoxInfo );
|
|
env_fx::SDistanceViewAttr* GetDistanceViewInfo() const;
|
|
void SetDistanceViewInfo( env_fx::SDistanceViewAttr* pDistanceViewInfo );
|
|
#endif
|
|
|
|
// Aurora.
|
|
float GetVisibilityAurora( int nAurora) { return m_pSunMoon->GetAuroraTransparency( nAurora ); }
|
|
float GetAngleAurora( int nAurora ) { return m_pSunMoon->GetAuroraAngle( nAurora ); }
|
|
float GetScaleAurora( int nAurora ) { return m_pSunMoon->GetAuroraScale( nAurora ); }
|
|
float GetHeightAurora( int nAurora ) { return m_pSunMoon->GetAuroraHeight( nAurora ); }
|
|
void GetAuroraInfo( int nAurora, float & fAuroraTrans, float & fAuroraScale, float & fAuroraAngle, float & fAuroraHeight ) {
|
|
fAuroraTrans = m_pSunMoon->GetAuroraTransparency( nAurora ); fAuroraScale = m_pSunMoon->GetAuroraScale( nAurora );
|
|
fAuroraAngle = m_pSunMoon->GetAuroraAngle( nAurora ); fAuroraHeight = m_pSunMoon->GetAuroraHeight( nAurora );
|
|
}
|
|
|
|
#ifdef _DEV_AURORA
|
|
void SetAuroraRender( bool bFlag ); // *bintitle* 정의된 Aurora 전부를 OFF.
|
|
int RandomizeOnAurora( float fVisibility, float fAngle, float fScale, float fHeight, DWORD dwOldTime ); // *bintitle* 하나의 무작위 Aurora를 선택 ON. return : 선택된 Aurora Index.
|
|
#endif
|
|
|
|
protected:
|
|
|
|
void createThunderCloud();
|
|
//void destroyThunderCloud();
|
|
|
|
#ifdef DISTANCE_VIEW
|
|
public:
|
|
bool CreateCloudCluster( int nTypeCloud );
|
|
bool CreateCloudByType( int nTypeCloud );
|
|
bool CreateDistanceView( const char* pFileName );
|
|
bool ChangeDistanceView( int local_id );
|
|
|
|
protected:
|
|
env_fx::SDistanceViewAttr* m_pDistanceViewAttr; // distance view attribute
|
|
env_fx::SSkyBoxAttr* m_pSkyboxAttr; // skybox attribute
|
|
KSeqModel* m_pDistanceViewModel; // distance view model
|
|
std::string m_strDistanceViewModelFilename;
|
|
std::vector<SGameCloud*> m_vcCloud; // cloud pointer vector
|
|
#endif
|
|
|
|
#ifdef CLOUD_LUA
|
|
CCloudMaker m_rCloudMaker;
|
|
#endif
|
|
|
|
DWORD m_dwSkyType;
|
|
KSeqForm* m_pSkyBox;
|
|
SGameCloud* m_pCloud;
|
|
SGameCloud* m_pThunderCloud;
|
|
env_fx::SGameLightning* m_pLightning;
|
|
SGameSunMoon * m_pSunMoon;
|
|
|
|
K3DLight * m_pSkyLight;
|
|
|
|
K3DCamera * m_pCamera;
|
|
K3DVector m_VecCloud;
|
|
|
|
K3DTextureSPtr m_spTexture;
|
|
|
|
float m_fVisibilty;
|
|
|
|
K3DMatrix m_Mat;
|
|
|
|
class KSeqModel * m_pRain[RAIN_MAX];
|
|
|
|
K3DIndexBufferSPtr m_spIB;
|
|
K3DIndexBufferSPtr m_spIBThunderCloud;
|
|
|
|
DWORD m_dwTime;
|
|
DWORD m_dwStartTime;
|
|
K3DVector m_cPos;
|
|
K3DVector m_dPos;
|
|
|
|
bool m_bCloudRender;
|
|
bool m_bProcessThunder;
|
|
bool m_bProcessLightning;
|
|
bool m_bThunderEnabled;
|
|
class K3DRenderDevice *m_pDevice;
|
|
};
|
|
|