#pragma once #include "K3DTypes.h" #include "KViewport.h" #include "KPrimitive.h" namespace { struct NatureInfo { K3DVector m_vWind; ///< 바람 방향 float m_fWindSpeed; ///< 풍속 float m_fGravity; ///< 중력 float m_fAcceleration; ///< 가속도 NatureInfo() : m_vWind( 0.0f, 0.0f, 0.0f ), m_fWindSpeed( 0.0f ), m_fGravity( 0.0f ), m_fAcceleration( 0.0f ) {} }; struct WeatherParticle { K3DVector m_vPosition; DWORD m_dwLifeTime; float m_fMass; float m_fWidth; float m_fHeight; bool m_bAlive; bool m_bNewParticle; WeatherParticle() : m_vPosition( 0.0f, 0.0f, 0.0f ), m_dwLifeTime( 3000 ), m_fMass( 0.0f ), m_fWidth( 0.0f ), m_fHeight( 0.0f ), m_bAlive( false ), m_bNewParticle( false ) {} bool Update( DWORD dwTime, NatureInfo & nature ) { if( dwTime > m_dwLifeTime ) return false; m_dwLifeTime = m_dwLifeTime - dwTime; if( m_dwLifeTime <= 0 ) return false; /////////////////////////////// //계산 return true; } bool IsAlive() { return m_bAlive; } void New() { m_bAlive = true; m_bNewParticle = true; } void Delete() { m_bAlive = false; } float GetWidth() { return m_fWidth; } float GetHeight() { return m_fHeight; } const K3DVector* GetPosition() { return &m_vPosition; } void SetPosition( K3DVector & vPos ) { m_vPosition = vPos; } void SetMass( float fMass ) { m_fMass = fMass; } void SetWidth( float fWidth ) { m_fWidth = fWidth; } void SetHeight( float fHeight ) { m_fHeight = fHeight; } void SetLifeTime( DWORD dwTime ) { m_dwLifeTime = dwTime; } }; } class SGameWeatherFx : public K3DPrimitive { public: SGameWeatherFx(); virtual ~SGameWeatherFx(); public: virtual void Initialize( class SGame* pGame ); virtual void Process( DWORD dwTime, K3DVector & vCurPos ) = 0; virtual void RenderWeatherFx( KViewportObject *viewport ) = 0; virtual void Render( KViewportObject *viewport, class K3DRenderDevice *dev, bool bUseAccum = true ); public: //치트키 void SetPositioin( K3DVector & vPosition ); void SetEmitRadius( K3DVector & vEmitRadius ); void SetEmitRate( float fMin, float fMax ); void SetWidth( float fMin, float fMax ); void SetHeight( float fMin, float fMax ); protected: DWORD m_dwDeadTime; K3DPoint m_vWidth; K3DPoint m_vHeight; float m_fGravity; K3DVector m_vMinDir; K3DVector m_vMaxDir; K3DVector m_vPosition; K3DVector m_vEmitRadius; K3DPoint m_vEmitRate; int m_nCreateInterval; protected: int m_nParticleNum; int m_nParticlesToRender; int m_nUsedElements; int m_nEmitRate; DWORD m_dwOldTime; K3DMatrix m_matBillBoard; protected: K3DTextureSPtr m_spTexture; K3DSPRITEVERTEX* m_pVertexBuffer; WORD* m_pIndexBuffer; K3DRenderDeviceDX* m_pDevice; WeatherParticle* m_pWtParticle; class SGame * m_pGame; NatureInfo* m_pNatureInfo; }; class SGameSnowFx : public SGameWeatherFx { public: SGameSnowFx(); virtual ~SGameSnowFx(); public: void Initialize( class SGame* pGame ); void Process( DWORD dwTime, K3DVector & vCurPos ); void RenderWeatherFx( KViewportObject *viewport ); }; class SGameRainFx : public SGameWeatherFx { public: SGameRainFx(); virtual ~SGameRainFx(); public: void Initialize( class SGame* pGame ); void Process( DWORD dwTime, K3DVector & vCurPos ); void RenderWeatherFx( KViewportObject *viewport ); };