133 lines
3.2 KiB
C++
133 lines
3.2 KiB
C++
/**==========================================================*\
|
|
|
|
@file : SGameLightning.h
|
|
@brief : rappelz lightning effect header
|
|
@date : 2007.04.24
|
|
@author : sonador
|
|
|
|
\*===========================================================*/
|
|
#pragma once
|
|
|
|
#include "SGameWeather.h"
|
|
|
|
// foward declaration
|
|
class SGame;
|
|
class K3DRenderDeviceDX;
|
|
class KViewportObject;
|
|
struct K3DSPRITEVERTEX;
|
|
|
|
namespace env_fx
|
|
{
|
|
class SLightningThread
|
|
{
|
|
public:
|
|
|
|
SLightningThread();
|
|
~SLightningThread();
|
|
|
|
void Process( DWORD dwTime_msec_, const SLightningAttr& Attr );
|
|
void Primitive( const SLightningAttr& Attr
|
|
, K3DSPRITEVERTEX* pVtx
|
|
, const K3DVector& vBill );
|
|
void SetAlive( bool bAlive );
|
|
bool IsAlive() const { return m_bAlive; }
|
|
bool IsActive( const SLightningAttr& Attr ) const;
|
|
void SetPosition( const K3DVector& vPosition );
|
|
void SetBirthTime( DWORD dwBirthTime_msec_ );
|
|
void SetGeomIndex( int nIndex ) { m_nGeomIndex = nIndex; }
|
|
int GetGeomIndex() const { return m_nGeomIndex; }
|
|
|
|
private:
|
|
|
|
DWORD m_dwTime_msec_;
|
|
DWORD m_dwBirthTime_msec_;
|
|
K3DVector m_vPosition;
|
|
KColor m_dwDiffuse;
|
|
bool m_bAlive;
|
|
int m_nGeomIndex;
|
|
};
|
|
|
|
namespace _private {
|
|
|
|
struct SFindDeadThread
|
|
{
|
|
bool operator()( const SLightningThread* thread )
|
|
{
|
|
return !thread->IsAlive();
|
|
}
|
|
};
|
|
|
|
struct SSortThreadsByGeomIndex
|
|
{
|
|
bool operator()( const SLightningThread* lhs, const SLightningThread* rhs ) const
|
|
{
|
|
return lhs->GetGeomIndex() < rhs->GetGeomIndex();
|
|
}
|
|
};
|
|
|
|
void LoadLightningScript();
|
|
|
|
}
|
|
|
|
|
|
class SGameLightning
|
|
{
|
|
public:
|
|
|
|
SGameLightning( int nMaxLightning );
|
|
~SGameLightning();
|
|
|
|
virtual void Init( K3DRenderDevice* pDevice );
|
|
virtual void Process( DWORD dwTime_msec_ );
|
|
virtual void Render( KViewportObject* pViewport );
|
|
void Emit( const K3DVector& vPosition );
|
|
|
|
void SetTime( DWORD dwTime_msec_ );
|
|
void SetRenderDevice( K3DRenderDevice* pDevice );
|
|
void SetBillboardMatrix( const K3DMatrix& mBillboard );
|
|
void SetCameraPosition( const K3DVector& vCamPos );
|
|
void SetTexture( K3DTexture* pTexture );
|
|
void SetAttribute( const SLightningAttr& Attr );
|
|
void SetPosition( const K3DVector& vPosition );
|
|
void SetParentMatrix( K3DMatrix* pmParent );
|
|
const env_fx::SLightningAttr& GetAttribute() const;
|
|
|
|
private:
|
|
|
|
void initGeometry();
|
|
void createLightningThread();
|
|
|
|
typedef std::vector< SLightningThread* > LightningThreadVector;
|
|
LightningThreadVector m_ctLightningThreads;
|
|
|
|
DWORD m_dwTime_msec_;
|
|
DWORD m_dwTimeDiff_msec_;
|
|
DWORD m_dwTimeBirth_msec_;
|
|
bool m_bAlive;
|
|
SLightningAttr m_Attribute;
|
|
K3DVector m_vPosition;
|
|
|
|
int m_nMaxLightning;
|
|
unsigned int m_uiThreadCap;
|
|
unsigned int m_uiGeomCap;
|
|
|
|
int m_nWaitThreadIndex;
|
|
|
|
K3DMatrix m_mWorld;
|
|
K3DMatrix* m_pmParent;
|
|
K3DMatrix m_mBillboard;
|
|
K3DVector m_vCamPos;
|
|
|
|
K3DRenderDevice* m_pRenderDevice;
|
|
SEnvPrimitive* m_pPrimitive;
|
|
K3DTextureSPtr m_spTexture;
|
|
K3DMaterial* m_pMtrl;
|
|
K3DSPRITEVERTEX* m_pVtx;
|
|
WORD* m_pIdx;
|
|
|
|
// disabled
|
|
|
|
SGameLightning( const SGameLightning& rhs );
|
|
SGameLightning& operator = ( const SGameLightning& rhs );
|
|
};
|
|
} |