Files
Leviathan/Client/Game/game/Env/SGameLowQualityWater.h
2026-06-01 12:46:52 +02:00

206 lines
6.7 KiB
C++

#pragma once
#include "K3DTypes.h"
#include "SGameEnv.h"
class K3DCamera;
class K3DTexture;
class K3DRenderDevice;
class SGameWaterMng;
const char cMaxWaterTexture = 30; ///< 텍스처 개수
static float cTerrainVisibleDistance = 0.f; ///< 테스트 용
/// 텍스처 세트 정보들
struct WATER_TEXTURE_SET
{
K3DTextureSPtr m_spTextureArray[cMaxWaterTexture];
int m_nRef;
int m_nWaterType;
WATER_TEXTURE_SET()
{
m_nWaterType = 0;
m_nRef = 0;
}
~WATER_TEXTURE_SET()
{
}
void CreateTextureSet( int nID, struct LowQualityWater* pLowQualityWaterData );
int GetWaterType() { return m_nWaterType; }
K3DTextureSPtr* GetTextureSet();
bool Release();
};
/// 세부 세그먼트 정보들
struct WATER_DETAIL_SEGMENT
{
private:
K3DVERTEX_H_WATER* m_pVertex;
K3DBoundRotCube m_BoundCube;
K3DVector m_vMinVertex;
K3DVector m_vMaxVertex;
SEnvPrimitive* m_pPrimitive;
bool m_bVisibleSegment;
bool m_bCheckReservation;
public:
bool CreateDetailSegment( K3DVector* vMin, K3DVector* vMax, KColor sColor, K3DVector* vCenter, int nWidth, int nHeight, class SGame* pGame, bool bIsHigh = false );
bool IsCheckReservation(){ return m_bCheckReservation; }
K3DVector* GetBoundCube() { return (K3DVector*)m_BoundCube.GetVertices(); }
K3DVector* GetMinVertex() { return &m_vMinVertex; }
K3DVector* GetMaxVertex() { return &m_vMaxVertex; }
SEnvPrimitive* GetPrimitive() { return m_pPrimitive; }
const K3DVERTEX_H_WATER* GetVertex() { return m_pVertex; }
public:
void SetPrimitiveData( K3DINDEXED_WATER* pIndexed, K3DMatrix* pMatrix );
void SetVertexMinMax(K3DVector* vMin, K3DVector* vMax );
void SetChangeColor( KColor Color );
void SetCheckReservation( bool bCheck ) { m_bCheckReservation = bCheck; }
public:
WATER_DETAIL_SEGMENT()
{
m_pVertex = NULL;
m_pPrimitive = NULL;
m_vMinVertex = K3DVector( 0.0f, 0.0f, 0.0f );
m_vMaxVertex = K3DVector( 0.0f, 0.0f, 0.0f );
m_bCheckReservation = false;
}
~WATER_DETAIL_SEGMENT()
{
SAFE_DELETE( m_pPrimitive );
SAFE_DELETE_ARRAY(m_pVertex);
}
};
/// 세그먼트 정보들
class SWater : public SGameEnv
{
class SGame* m_pGame;
K3DVERTEX_H_WATER* m_pHWaterPrimitive; ///< 고사양 물
K3DINDEXED_WATER* m_pIndexed;
std::vector< WATER_DETAIL_SEGMENT* > m_vWaterSegment;
int m_nSegMentCount;
int m_nWaterType;
K3DTextureSPtr* m_spTextureArray;
K3DCamera* m_pCamera;
int m_nMapX;
int m_nMapY;
DWORD m_dwStartTime; ///< 텍스처 애니마숑 시작
DWORD m_dwChangeTime; ///< 텍스처 교체 시간
float m_fAniCount; ///< 텍스처 애니마숑 현재 프레임
KColor m_Color; ///< 컬러 값
float m_fRadius;
K3DBoundRotCube m_BoundCube;
K3DVector m_vMinVertex;
K3DVector m_vMaxVertex;
K3DVector m_vCenterPoint;
K3DMatrix m_matWorld;
bool m_bIsHighQualityWater;
bool m_bTextureAnimation;
bool m_bUVAnimation;
DWORD m_dwUAniTime;
DWORD m_dwVAniTime;
DWORD m_dwStartUTime;
DWORD m_dwStartVTime;
float m_fUCoord;
float m_fVCoord;
public:
virtual void Init( K3DRenderDevice *pDevice, K3DIndexBuffer * pIndexBuf=NULL );
virtual void Process( DWORD dwTime );
virtual void Render( KViewportObject *viewport );
void CreateSegment( K3DVector* vLeftTop, K3DVector* vRightBottom, K3DVector* vCenter, float fTileLength );
void CreateSegment( K3DVector* vLeftTop, K3DVector* vRightBottom, K3DVector* vCenter );
public:
K3DVector* GetBoundCube();
K3DVector* GetMinVertex() { return &m_vMinVertex; }
K3DVector* GetMaxVertex() { return &m_vMaxVertex; }
K3DVector* GetCenterPoint() { return &m_vCenterPoint; }
float GetRadius() { return m_fRadius; }
int GetWaterType() { return m_nWaterType; }
const bool IsHighQualityWater() { return m_bIsHighQualityWater; }
public:
void SetWaterInfoData( int nWaterType, int nMapX, int nMapY, K3DCamera* pCamera, WATER_TEXTURE_SET* pTextureSet = NULL );
void SetColor( KColor sColor ) { m_Color = sColor; }
void SetChangeTimeTexture( DWORD dwTime ) { m_dwChangeTime = dwTime; }
void SetHighQualityWater( bool bIsHighQuality ) { m_bIsHighQualityWater = bIsHighQuality; }
void SetChangeColor( KColor Color, bool bNewColor );
void SetChangeTextureTime( DWORD dwTime );
void SetHqWaterColor( BYTE r, BYTE g, BYTE b, BYTE a );
public:
bool CheckReservation( WATER_DETAIL_SEGMENT* pDetail );
bool CheckMap( int nMapX, int nMapY )
{
if( nMapX == m_nMapX && nMapY == m_nMapY )
return true;
return false;
}
public:
SWater( class SGame* pGame );
virtual ~SWater();
};
class SGameLowQualityWater
{
private:
class SGame* m_pGame;
K3DCamera* m_pCamera;
std::vector< WATER_TEXTURE_SET*> m_vTextureSet;
std::vector< SWater* > m_vWaterPrimitive;
float m_fTerrainVisibleDistance;
public:
bool Init();
void Process(DWORD dwTime, float fTerrainVisibleDistance );
virtual void Render( KViewportObject *viewport );
public:
void AddLowQualityWater( int nMapX, int nMapY, struct WATERAREA_HEADER* pWaterInfo, float fTileLength );
void AddHighQualityWater( int nMapX, int nMapY, struct WATERAREA_HEADER* pWaterInfo );
bool CheckHeight( K3DVector* vMin, K3DVector* vMax, K3DVector* vCenter );
void RemoveWater( int nMapX, int nMapY );
void SetGame( SGame* pGame );
void SetCamera( K3DCamera* pCamera );
WATER_TEXTURE_SET* GetTextureSetData( int nWaterType );
void RemoveTextureSet( int nWaterType );
SWater* GetHightQualityWater();
bool PlayerInsideWaterExistence( K3DVector & vPlayerPos );
bool GetWaterHeight( K3DVector & vPlayerPos, float & fHeight );
/// { [sonador][COLLIDABLE_CAMERA]
bool GetLineCrossedPoint( const K3DVector& vNear
, const K3DVector& vFar
, const float fRadius
, float& fNearestT
, K3DVector& p );
// }
/// { [sonador][7.1.7]충돌 처리 개선(Swept Shpere Collision Detection)
bool GetEllipsoidCrossedPoint( const K3DVector& vBase
, const K3DVector& vVelocity
, const K3DVector& vRadius
, float& fNearestT
, K3DVector& vPickedPoint
#ifdef _DEBUG
, K3DVector* pCollidedPolygon
#endif
) const;
// }
public:
/// 치트
void SetLowQualityWaterColor( KColor Color, bool bNewColor = false );
void SetLowQualityWaterChangeTextureTime( DWORD dwTime );
public:
SGameLowQualityWater();
virtual ~SGameLowQualityWater();
};