1057 lines
27 KiB
C++
1057 lines
27 KiB
C++
/**==========================================================*\
|
|
|
|
@file : SGameCloud.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"
|
|
|
|
#include "SGameWeatherAttr.h"
|
|
|
|
class KSeqForm;
|
|
class K3DCamera;
|
|
class SGameMilesSoundMgr;
|
|
|
|
#ifdef SKYBOX_CLOUD
|
|
#else
|
|
struct SCloudObject;
|
|
|
|
namespace env_fx {
|
|
struct SThunderAttr;
|
|
struct SLightningAttr;
|
|
class SGameLightning;
|
|
}
|
|
#endif
|
|
|
|
|
|
#ifdef SKYBOX_CLOUD
|
|
class SCloudEx : public SGameEnv
|
|
{
|
|
public:
|
|
|
|
enum EStep { APPEAR, DISAPPEAR, MOVE };
|
|
enum EVtxPos { UL, UR, BL, BR };
|
|
|
|
SCloudEx();
|
|
SCloudEx(int nType, int nCount, int nDepth, int nZoneWidth, int nZoneHeight);
|
|
virtual ~SCloudEx();
|
|
|
|
void InitVariable();
|
|
void Create(int type, int nCount, int nDepth, int nZoneWidth, int nZoneHeight);
|
|
void Destroy();
|
|
|
|
void Update( DWORD _time, const KColor& _cloud_color );
|
|
|
|
virtual void Init( K3DRenderDevice *pDevice, K3DIndexBuffer * pIndexBuf=NULL );
|
|
virtual void Process( DWORD dwTime );
|
|
virtual void Render( KViewportObject *viewport );
|
|
|
|
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;
|
|
|
|
// 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; ///< 구름 상태
|
|
|
|
K3DVERTEX_CLOUD* m_pVertex;
|
|
WORD* m_pIndex;
|
|
class K3DRenderDevice* m_pDevice;
|
|
|
|
static float s_fFactor;
|
|
static float s_fLightningFactor;
|
|
static DWORD s_dwDuration;
|
|
static int s_nFlashCount;
|
|
static K3DColor s_sDestColor;
|
|
|
|
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 );
|
|
};
|
|
|
|
class SGameCloud : public SGameEnv
|
|
{
|
|
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; }
|
|
virtual void SetTransform( K3DMatrix* pParentMatrix );
|
|
SCloudEx* GetFirstDeactiveCloud();
|
|
void SetSoundManager( SGameMilesSoundMgr* pSoundMgr );
|
|
|
|
static void SetProcessPause( bool bFlag ) { m_bProcessPause = bFlag; }
|
|
static bool IsProcessPause() { return m_bProcessPause; }
|
|
|
|
public:
|
|
void CreateCloudByType( int type );
|
|
void DestroyCloud();
|
|
|
|
protected:
|
|
|
|
virtual void initVB();
|
|
virtual void updateVB( K3DVERTEX_CLOUD* vtx, const SCloudEx& cloud );
|
|
virtual void initCloudObjects();
|
|
virtual void procesSCloudEx( int nIndex );
|
|
void _addSoundEvent( const K3DVector& addedPosition );
|
|
void _procSoundEvent();
|
|
|
|
struct SFindFirstDeactiveCloud
|
|
{
|
|
bool operator () ( SCloudEx& 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;
|
|
SCloudEx* m_pCloud;
|
|
KColor m_CloudColor;
|
|
|
|
std::vector< SCloudEx* > m_vcCloud;
|
|
|
|
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();
|
|
|
|
};
|
|
#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 );
|
|
|
|
};
|
|
|
|
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
|
|
|
|
|
|
|
|
#ifdef CLOUD_LUA
|
|
//---------------------------------------------------------------------------------------
|
|
// Kind
|
|
#define MAX_KIND_GRADE 9
|
|
#define MAX_KIND_GRADE_F 9.0f
|
|
|
|
struct SCloudKind
|
|
{
|
|
BYTE v[MAX_KIND_GRADE]; // volume
|
|
};
|
|
|
|
class CCloudKindDB
|
|
{
|
|
public:
|
|
CCloudKindDB();
|
|
~CCloudKindDB();
|
|
|
|
int get_size() { return (int)m_vcKind.size(); }
|
|
void add(int id, SCloudKind* pKind);
|
|
void clear();
|
|
void size(int sz);
|
|
SCloudKind* find(int id);
|
|
float calculateRate(int nKindID, int nGrade, int nMaxGrade);
|
|
|
|
private:
|
|
std::vector< SCloudKind* > m_vcKind;
|
|
};
|
|
|
|
CCloudKindDB& GetCloudKindDB();
|
|
|
|
//---------------------------------------------------------------------------------------
|
|
// thickness
|
|
class CCloudThicknessDB
|
|
{
|
|
public:
|
|
CCloudThicknessDB();
|
|
~CCloudThicknessDB();
|
|
|
|
int get_size() { return (int)m_vcTickness.size(); }
|
|
void add(int id, int nThickness);
|
|
void clear();
|
|
void size(int sz);
|
|
int find(int id);
|
|
|
|
private:
|
|
std::vector< int > m_vcTickness;
|
|
};
|
|
|
|
CCloudThicknessDB& GetCloudThicknessDB();
|
|
|
|
//---------------------------------------------------------------------------------------
|
|
// thickness gap
|
|
class CCloudThicknessGapDB
|
|
{
|
|
public:
|
|
CCloudThicknessGapDB();
|
|
~CCloudThicknessGapDB();
|
|
|
|
int get_size() { return (int)m_vcTicknessGap.size(); }
|
|
void add(int id, float fThickness);
|
|
void clear();
|
|
void size(int sz);
|
|
float find(int id);
|
|
|
|
private:
|
|
std::vector< float > m_vcTicknessGap;
|
|
};
|
|
|
|
CCloudThicknessGapDB& GetCloudThicknessGapDB();
|
|
|
|
//---------------------------------------------------------------------------------------
|
|
// size
|
|
struct SCloudSize
|
|
{
|
|
float s; // min size
|
|
float e; // max size
|
|
};
|
|
class CCloudSizeDB
|
|
{
|
|
public:
|
|
CCloudSizeDB();
|
|
~CCloudSizeDB();
|
|
|
|
int get_size() { return (int)m_vcSize.size(); }
|
|
void add(int id, SCloudSize* pSize);
|
|
void clear();
|
|
void size(int sz);
|
|
SCloudSize* find(int id);
|
|
|
|
private:
|
|
std::vector< SCloudSize* > m_vcSize;
|
|
};
|
|
|
|
CCloudSizeDB& GetCloudSizeDB();
|
|
|
|
//---------------------------------------------------------------------------------------
|
|
// texture names
|
|
class CCloudTxrNames
|
|
{
|
|
public:
|
|
CCloudTxrNames();
|
|
~CCloudTxrNames();
|
|
|
|
int get_size() { return (int)m_vcName.size(); }
|
|
void add(int id, std::string* pStrTxrName);
|
|
void clear();
|
|
void size(int sz);
|
|
std::string* find(int id);
|
|
|
|
private:
|
|
std::vector< std::string* > m_vcName;
|
|
};
|
|
|
|
// texture name group
|
|
class CCloudTxrGroupDB
|
|
{
|
|
public:
|
|
CCloudTxrGroupDB();
|
|
~CCloudTxrGroupDB();
|
|
|
|
enum TXR_BRIGHTNESS_TYPE
|
|
{
|
|
NORMAL = 0,
|
|
MIDDLE = 1,
|
|
DARK = 2,
|
|
END
|
|
};
|
|
|
|
int get_size(int brightness_type);
|
|
void add(int brightness_type, int id, CCloudTxrNames* pTxrNames);
|
|
void clear(int brightness_type = TXR_BRIGHTNESS_TYPE::END);
|
|
void size(int brightness_type, int sz);
|
|
CCloudTxrNames* find(int brightness_type, int id);
|
|
std::string* find_str(int brightness_type, int id);
|
|
|
|
private:
|
|
std::vector< CCloudTxrNames* > m_vcNormal;
|
|
std::vector< CCloudTxrNames* > m_vcMiddle;
|
|
std::vector< CCloudTxrNames* > m_vcDark;
|
|
};
|
|
|
|
CCloudTxrGroupDB& GetCloudTxrGroupDB();
|
|
|
|
//---------------------------------------------------------------------------------------
|
|
// distribution
|
|
class CCloudDistributionDB
|
|
{
|
|
public:
|
|
CCloudDistributionDB();
|
|
~CCloudDistributionDB();
|
|
|
|
int get_size() { return (int)m_vcDistribution.size(); }
|
|
void add(int id, int nThickness);
|
|
void clear();
|
|
void size(int sz);
|
|
int find(int id);
|
|
|
|
private:
|
|
std::vector< int > m_vcDistribution;
|
|
};
|
|
|
|
CCloudDistributionDB& GetCloudDistributionDB();
|
|
|
|
//---------------------------------------------------------------------------------------
|
|
// distribution
|
|
class CCloudHeightRadomGapDB
|
|
{
|
|
public:
|
|
CCloudHeightRadomGapDB();
|
|
~CCloudHeightRadomGapDB();
|
|
|
|
int get_size() { return (int)m_vcRadomGap.size(); }
|
|
void add(int id, int nThickness);
|
|
void clear();
|
|
void size(int sz);
|
|
int find(int id);
|
|
|
|
private:
|
|
std::vector< int > m_vcRadomGap;
|
|
};
|
|
|
|
CCloudHeightRadomGapDB& GetCloudHeightRadomGapDB();
|
|
|
|
//---------------------------------------------------------------------------------------
|
|
// layer gap
|
|
class CCloudLayerGapDB
|
|
{
|
|
public:
|
|
CCloudLayerGapDB();
|
|
~CCloudLayerGapDB();
|
|
|
|
int get_size() { return (int)m_vcLayerGap.size(); }
|
|
void add(int id, int nThickness);
|
|
void clear();
|
|
void size(int sz);
|
|
int find(int id);
|
|
|
|
private:
|
|
std::vector< int > m_vcLayerGap;
|
|
};
|
|
|
|
CCloudLayerGapDB& GetCloudLayerGapDB();
|
|
|
|
//---------------------------------------------------------------------------------------
|
|
// move dir
|
|
class CCloudMoveDirDB
|
|
{
|
|
public:
|
|
CCloudMoveDirDB();
|
|
~CCloudMoveDirDB();
|
|
|
|
int get_size() { return (int)m_vcMoveDir.size(); }
|
|
void add(int id, int nThickness);
|
|
void clear();
|
|
void size(int sz);
|
|
int find(int id);
|
|
|
|
private:
|
|
std::vector< int > m_vcMoveDir;
|
|
};
|
|
|
|
CCloudMoveDirDB& GetCloudMoveDirDB();
|
|
|
|
//---------------------------------------------------------------------------------------
|
|
// path
|
|
struct SCloudPath
|
|
{
|
|
int start; // start height
|
|
int max; // max height
|
|
int finish; // finish height
|
|
};
|
|
|
|
struct SCalculateHeightParam
|
|
{
|
|
int nLayerGapType;
|
|
int nPathType;
|
|
int nDir;
|
|
float x;
|
|
float y;
|
|
float zoneX;
|
|
float zoneY;
|
|
};
|
|
|
|
class CCloudPathDB
|
|
{
|
|
public:
|
|
CCloudPathDB();
|
|
~CCloudPathDB();
|
|
|
|
int get_size() { return (int)m_vcPath.size(); }
|
|
void add(int id, SCloudPath* pPath);
|
|
void clear();
|
|
void size(int sz);
|
|
SCloudPath* find(int id);
|
|
// float calculateHeight(int nLayerGapType, int nPathType, int nDir, float x, float y, float zoneX, float zoneY);
|
|
float calculateHeight(SCalculateHeightParam& sParam);
|
|
|
|
private:
|
|
std::vector< SCloudPath* > m_vcPath;
|
|
};
|
|
|
|
CCloudPathDB& GetCloudPathDB();
|
|
|
|
//---------------------------------------------------------------------------------------
|
|
// cloud
|
|
struct SCloudTypeInfo
|
|
{
|
|
int type_size;
|
|
int type_thickness;
|
|
int type_thickness_gap;
|
|
int type_txr_normal;
|
|
int type_txr_middle;
|
|
int type_txr_dark;
|
|
float fMoveSpeed;
|
|
};
|
|
|
|
class CCloudTypeInfoDB
|
|
{
|
|
public:
|
|
CCloudTypeInfoDB();
|
|
~CCloudTypeInfoDB();
|
|
|
|
int get_size() { return (int)m_vcTypeInfo.size(); }
|
|
void add(int id, SCloudTypeInfo* pPath);
|
|
void clear();
|
|
void size(int sz);
|
|
SCloudTypeInfo* find(int id);
|
|
|
|
private:
|
|
std::vector< SCloudTypeInfo* > m_vcTypeInfo;
|
|
};
|
|
|
|
CCloudTypeInfoDB& GetCloudTypeInfoDB();
|
|
|
|
//---------------------------------------------------------------------------------------
|
|
// appear layer
|
|
struct SCloudShowInfo
|
|
{
|
|
int type_cloud;
|
|
int type_show_rate;
|
|
};
|
|
|
|
struct SCloudLayer
|
|
{
|
|
SCloudLayer(){}
|
|
|
|
int type_distribution;
|
|
int type_height_random_gap;
|
|
BYTE color[4]; // a=0, r=1, g=2, b=3
|
|
|
|
void add(int id, SCloudShowInfo* pPath);
|
|
void clear();
|
|
void size(int sz);
|
|
SCloudShowInfo* find(int id);
|
|
|
|
std::vector< SCloudShowInfo* > vcShowInfo;
|
|
};
|
|
|
|
class CCloudLayerDB
|
|
{
|
|
public:
|
|
CCloudLayerDB();
|
|
~CCloudLayerDB();
|
|
|
|
int get_size() { return (int)m_vcLayer.size(); }
|
|
void add(int id, SCloudLayer* pPath);
|
|
void clear();
|
|
void size(int sz);
|
|
SCloudLayer* find(int id);
|
|
|
|
private:
|
|
std::vector< SCloudLayer* > m_vcLayer;
|
|
};
|
|
|
|
CCloudLayerDB* GetCloudLayerDB();
|
|
|
|
//---------------------------------------------------------------------------------------
|
|
// appear layer
|
|
struct SCloudLayerInfo
|
|
{
|
|
int type_path;
|
|
int type_move_dir;
|
|
int type_layer;
|
|
int type_layer_gap;
|
|
};
|
|
|
|
struct SCloudLayerSet
|
|
{
|
|
SCloudLayerSet(){}
|
|
void add(int id, SCloudLayerInfo* pPath);
|
|
void clear();
|
|
void size(int sz);
|
|
SCloudLayerInfo* find(int id);
|
|
|
|
std::vector< SCloudLayerInfo* > vcLayerInfo;
|
|
};
|
|
|
|
class CCloudLayerSetDB
|
|
{
|
|
public:
|
|
CCloudLayerSetDB();
|
|
~CCloudLayerSetDB();
|
|
|
|
int get_size();
|
|
void add(int id, SCloudLayerSet* pPath);
|
|
void clear();
|
|
void size(int sz);
|
|
SCloudLayerSet* find(int id);
|
|
|
|
private:
|
|
std::vector< SCloudLayerSet* > m_vcLayerSet;
|
|
};
|
|
|
|
CCloudLayerSetDB* GetCloudLayerSetDB();
|
|
|
|
|
|
class CCloudMaker;
|
|
class CCloudLayerSet;
|
|
class CCloudLayer;
|
|
|
|
//---------------------------------------------------------------------------------------
|
|
#define ONE_CLOUD_PLANE_VTX_COUNT 4
|
|
#define ONE_CLOUD_PLANE_INDEX_COUNT 6
|
|
#define RATE_CONVERT_100 0.01f
|
|
#define ZONE_CLOUD_WIDTH 7000.0f
|
|
#define ZONE_CLOUD_HEIGHT 7000.0f
|
|
#define ZONE_CLOUD_WIDTH_D2 (ZONE_CLOUD_WIDTH / 2.0f)
|
|
#define ZONE_CLOUD_HEIGHT_D2 (ZONE_CLOUD_HEIGHT / 2.0f)
|
|
#define FADE_ALPHA_TIME 3000.0f
|
|
|
|
enum CHAGE_CLOUD_STATE
|
|
{
|
|
CHAGE_CLOUD_NONE = 10,
|
|
CHAGE_CLOUD_START,
|
|
CHAGE_CLOUD_END
|
|
};
|
|
|
|
enum FADE_STATE
|
|
{
|
|
FADE_NONE = 0,
|
|
FADE_IN,
|
|
FADE_IN_COMPLETE,
|
|
FADE_OUT,
|
|
FADE_OUT_COMPLETE
|
|
};
|
|
|
|
// cloud vertex buffer pack
|
|
struct SCloudVertexBufferPack
|
|
{
|
|
SCloudVertexBufferPack(){}
|
|
int get_size() { return (int)vcVB.size(); }
|
|
void add(int id, K3DVERTEX_CLOUD* pVtx);
|
|
void add(K3DVERTEX_CLOUD* pVtx);
|
|
void clear();
|
|
K3DVERTEX_CLOUD* find(int id);
|
|
|
|
std::vector< K3DVERTEX_CLOUD* > vcVB;
|
|
};
|
|
|
|
struct SCloudCreateParam
|
|
{
|
|
SCloudCreateParam()
|
|
{
|
|
nType = nLayerGapType = nPath = nDir = 0;
|
|
fStandardHeight = fx = fy = 0.0f;
|
|
color[0] = color[1] = color[2] = color[3] = 0;
|
|
}
|
|
|
|
int nType;
|
|
int nLayerGapType;
|
|
int nPath;
|
|
float fStandardHeight;
|
|
int nDir;
|
|
float fx;
|
|
float fy;
|
|
BYTE color[4]; // a=0, r=1, g=2, b=3
|
|
};
|
|
|
|
// cloud unit
|
|
class CCloudUnit : public SGameEnvCloud
|
|
{
|
|
public:
|
|
CCloudUnit();
|
|
virtual ~CCloudUnit();
|
|
|
|
void SetParent(CCloudLayer* pParent) { m_pParent = pParent; }
|
|
// int make(int nType, int nLayerGapType, int nPath, float fStandardHeight, int nDir, float fx, float fy);
|
|
int make(SCloudCreateParam& pr);
|
|
|
|
virtual void Init( K3DRenderDevice *pDevice, K3DIndexBuffer * pIndexBuf=NULL );
|
|
virtual void Process( DWORD dwTime ) {}
|
|
virtual void Render( KViewportObject *viewport );
|
|
int ProcessSecond( DWORD dwTime );
|
|
|
|
void SetID( int id ) { m_nID = id; }
|
|
int GetID() { return m_nID; }
|
|
void SetHeight( int i, float fz );
|
|
void SetPosition( float fx, float fy, float fz );
|
|
K3DVector& GetPosition();
|
|
void UpdatePosition( float fx, float fy, float fz );
|
|
virtual void SetTransform( K3DMatrix* pParentMatrix );
|
|
|
|
int IncreaseAlpha( DWORD dwTime );
|
|
int DecreaseAlpha( DWORD dwTime );
|
|
void UpdateAlpha( float fAlpha );
|
|
void UpdateAlphaBrightLayer();
|
|
|
|
void SetFadeState( int nState );
|
|
int GetFadeState() { return m_sFadeState; }
|
|
|
|
void SetAlpha( float fAlpha ) { m_fAlpha = fAlpha; }
|
|
|
|
void ChangeCloudColor(int nR, int nG, int nB);
|
|
|
|
protected:
|
|
virtual void initVB();
|
|
// virtual void updateVB( K3DVERTEX_CLOUD* vtx, const SCloudObject& cloud );
|
|
virtual void initCloudObjects();
|
|
// virtual void processCloudObject( int nIndex );
|
|
void GenerateCloudVertexBuffer();
|
|
void GenerateCloudTexture(int nColorType);
|
|
void UpdatePos( float fx, float fy, float fz );
|
|
|
|
// KColor m_CloudColor;
|
|
|
|
int m_nID;
|
|
int m_nType; // cloud type
|
|
int m_nTypeSize; // min 0 ~ max cloud_size.size_count
|
|
int m_nTypeThickness; // min 0 ~ max cloud_thickness.thickness_count
|
|
int m_nTypeThicknessGap; // min 0 ~ max cloud_thickness_gap.gap_count
|
|
int m_nTypeTxrGroup[C_MAX]; // min 0 ~ max cloud_texture_group.group_count
|
|
float m_fMoveSpeed; // min 0 ~ max 100.0f
|
|
int m_nDir; // min 0 ~ max cloud_move_dir.dir_count
|
|
int m_nLayerGap; // min 0 ~ max cloud_move_dir.dir_count
|
|
int m_nPath; // min 0 ~ max cloud_move_dir.dir_count
|
|
K3DVector m_vDir; // dir vector
|
|
DWORD m_dwTickOld; // tick
|
|
float m_fMoveFrame; // move frame
|
|
float m_fMovePosX; // move frame
|
|
float m_fMovePosY; // move frame
|
|
float m_fMovePosZ; // move frame
|
|
int m_sFadeState;
|
|
int m_nThickness;
|
|
float m_fAlpha;
|
|
// DWORD m_dwAlphaTick;
|
|
|
|
SCloudVertexBufferPack m_VBPack[C_MAX];
|
|
K3DMaterial* m_pMtl;
|
|
K3DVector m_vPos;
|
|
|
|
class K3DRenderDevice* m_pDevice;
|
|
CCloudLayer* m_pParent;
|
|
};
|
|
|
|
// cloud vertex buffer pack
|
|
struct SCloudParam
|
|
{
|
|
SCloudParam()
|
|
{
|
|
nTypeDistribution = 0;
|
|
nTypeCloudHeightRandomGap = 0;
|
|
nTypeCloud = 0;
|
|
nShowRate = 0;
|
|
nLayerGapType = 0;
|
|
nID = 0;
|
|
nTypePathType = 0;
|
|
nTypeMoveDir = 0;
|
|
nTypeLayer = 0;
|
|
pCloudShowInfo = NULL;
|
|
}
|
|
int nTypeDistribution; // min 0 ~ max cloud_distribution.distribution_count
|
|
int nTypeCloudHeightRandomGap; // min 0 ~ max cloud_height_random_gap.gap_count
|
|
int nTypeCloud; // min 0 ~ max cloud_type.type_count
|
|
int nShowRate; // min 0 ~ max 100
|
|
int nLayerGapType; // min 0 ~ max layer_gap max
|
|
int nID; // layer id
|
|
int nTypePathType; // min 0 ~ max cloud_path.path_count
|
|
int nTypeMoveDir; // min 0 ~ max cloud_move_dir.dir_count
|
|
int nTypeLayer; // min 0 ~ max cloud_appear_layer.layer_count
|
|
SCloudLayer* pCloudShowInfo;
|
|
};
|
|
|
|
//---------------------------------------------------------------------------------------
|
|
// cloud layer
|
|
class CCloudLayer
|
|
{
|
|
public:
|
|
CCloudLayer();
|
|
~CCloudLayer();
|
|
|
|
void SetParent(CCloudLayerSet* pParent) { m_pParent = pParent; }
|
|
void SetDevice(K3DRenderDevice* pDvc) { m_pDevice = pDvc; }
|
|
int get_size() { return (int)m_vcCloud.size(); }
|
|
void add(int id, CCloudUnit* pCUnit);
|
|
void clear();
|
|
void size(int sz);
|
|
CCloudUnit* find(int id);
|
|
|
|
int IncreaseAlpha( DWORD dwTime );
|
|
int DecreaseAlpha( DWORD dwTime );
|
|
void SetAlpha( float fAlpha );
|
|
void UpdateAlpha( float fAlpha );
|
|
void UpdateAlphaBrightLayer();
|
|
|
|
int Process( DWORD dwTime );
|
|
void Render( KViewportObject *viewport );
|
|
void SetPosition( float fx, float fy, float fz, int idCloud = -1 );
|
|
void UpdatePosition( float fx, float fy, float fz );
|
|
void FadeInOutCloud(int nFadeState);
|
|
void CompleteFadeIn();
|
|
void CompleteFadeOut();
|
|
void ChangeCloudColor(int nR, int nG, int nB);
|
|
|
|
// int makeClouds(int nDistribution, int nTypeHeightRandomGap, SCloudLayer* pCloudShowInfo, int nPathType, int nDir, int nLayerGapType);
|
|
int makeClouds(SCloudParam& sParam);
|
|
|
|
private:
|
|
SCloudParam m_sParam;
|
|
// int m_nTypeDistribution; // min 0 ~ max cloud_distribution.distribution_count
|
|
// int m_nTypeCloudHeightRandomGap; // min 0 ~ max cloud_height_random_gap.gap_count
|
|
// int m_nTypeCloud; // min 0 ~ max cloud_type.type_count
|
|
// int m_nShowRate; // min 0 ~ max 100
|
|
// int m_nLayerGapType; // min 0 ~ max layer_gap max
|
|
// int m_nID; // layer id
|
|
// int m_nTypePathType; // min 0 ~ max cloud_path.path_count
|
|
// int m_nTypeMoveDir; // min 0 ~ max cloud_move_dir.dir_count
|
|
// int m_nTypeLayer; // min 0 ~ max cloud_appear_layer.layer_count
|
|
|
|
std::vector< CCloudUnit* > m_vcCloud;
|
|
K3DRenderDevice* m_pDevice;
|
|
CCloudLayerSet* m_pParent;
|
|
};
|
|
|
|
//---------------------------------------------------------------------------------------
|
|
// cloud layer set
|
|
class CCloudLayerSet
|
|
{
|
|
public:
|
|
CCloudLayerSet();
|
|
~CCloudLayerSet();
|
|
|
|
void SetParent(CCloudMaker* pParent) { m_pParent = pParent; }
|
|
bool SetRenderCloudID( int id );
|
|
int GetRenderCloudID() const { return m_nRenderCloudID; }
|
|
void SetDevice(K3DRenderDevice* pDvc);
|
|
int get_size();
|
|
void add(int id, CCloudLayer* pCUnit);
|
|
void clear();
|
|
void size(int sz);
|
|
CCloudLayer* find(int id);
|
|
|
|
int IncreaseAlpha( DWORD dwTime );
|
|
int DecreaseAlpha( DWORD dwTime );
|
|
void SetAlpha( float fAlpha );
|
|
void UpdateAlpha( float fAlpha );
|
|
void UpdateAlphaBrightLayer();
|
|
|
|
int Process( DWORD dwTime );
|
|
void Render( KViewportObject *viewport );
|
|
void SetPosition( float fx, float fy, float fz );
|
|
void UpdatePosition( float fx, float fy, float fz );
|
|
void FadeInOutCloud(int nFadeState);
|
|
void CompleteFadeIn();
|
|
void CompleteFadeOut();
|
|
void ChangeCloudColor(int nR, int nG, int nB);
|
|
|
|
int makeLayer(int nLayerID, int nType, int nDir, int nPathType, int nLayerGapType);
|
|
|
|
private:
|
|
int m_nRenderCloudID;
|
|
// int m_nID; // layer id
|
|
// int m_nTypePathType; // min 0 ~ max cloud_path.path_count
|
|
// int m_nTypeMoveDir; // min 0 ~ max cloud_move_dir.dir_count
|
|
// int m_nTypeLayer; // min 0 ~ max cloud_appear_layer.layer_count
|
|
std::vector< CCloudLayer* > m_vcLayer;
|
|
K3DRenderDevice* m_pDevice;
|
|
CCloudMaker* m_pParent;
|
|
};
|
|
|
|
//---------------------------------------------------------------------------------------
|
|
// cloud maker
|
|
class CCloudMaker
|
|
{
|
|
public:
|
|
CCloudMaker();
|
|
~CCloudMaker();
|
|
|
|
void SetWillCloudID( int _id );
|
|
int GetWillCloudID() const { return m_nWillCloudID; }
|
|
|
|
int GetRenderCloudID() const;
|
|
void ClearRenderCloudID();
|
|
void SetDevice(K3DRenderDevice* pDvc);
|
|
int makeCloud(int id);
|
|
void clearCloud();
|
|
void Process( DWORD dwTime );
|
|
void Render( KViewportObject *viewport );
|
|
void SetPosition( float fx, float fy, float fz );
|
|
void UpdatePosition( float fx, float fy, float fz );
|
|
void FadeInOutCloud(int nFadeState);
|
|
void CompleteFadeIn();
|
|
void CompleteFadeOut();
|
|
bool CompareCloudID();
|
|
void ChangeCloudColor(int nR, int nG, int nB);
|
|
|
|
private:
|
|
int m_nWillCloudID;
|
|
|
|
K3DVector m_vPosOld;
|
|
bool m_bShow;
|
|
CCloudLayerSet* m_pCloud;
|
|
K3DRenderDevice* m_pDevice;
|
|
DWORD m_dwTickOld;
|
|
float m_fAlpha;
|
|
};
|
|
|
|
|
|
extern void CreateCloudDB();
|
|
extern void DestroyCloudDB();
|
|
#endif |