208 lines
7.2 KiB
C++
208 lines
7.2 KiB
C++
#pragma once
|
|
|
|
#include "KRenderObject.h"
|
|
#include "TerrainDefine.h"
|
|
#include "TerrainPropForGame.h"
|
|
#include "TerrainSpeedGrassForGame.h"
|
|
#include <toolkit/ILock.h>
|
|
|
|
class KViewportObject;
|
|
class CTerrainInfoForSegment;
|
|
class CTerrainTextureInfo;
|
|
class CTerrainPropInfo;
|
|
class CTerrainPrimitive;
|
|
class CTerrainCustomTexturePrimitive;
|
|
class CTerrainSpeedGrass;
|
|
|
|
enum TERRAIN_PICK_RESULT
|
|
{
|
|
TERRAIN_PICK_SUCCECED = 0,
|
|
TERRAIN_PICK_DISTANCE_FAILED,
|
|
TERRAIN_PICK_FAILED,
|
|
TERRAIN_STOOL_PICK_SUCCECED,
|
|
TERRAIN_STOOL_PICK_FAILED,
|
|
};
|
|
|
|
class CTerrainSegment
|
|
{
|
|
public:
|
|
CTerrainSegment
|
|
( class CTerrainInfoForSegment* pTerrainInfo
|
|
//, TERRAIN_FILTERING FilteringType
|
|
, TERRAIN_RENDERMODE RenderMode
|
|
, float fTileLength
|
|
, int nTileCount
|
|
, K3DIndexBuffer** ppCommonIndexBuffer
|
|
, CTerrainTextureInfo* pTextureInfo
|
|
, const CTerrainPropInfo* pPropInfo
|
|
, K3DRenderDevice* pDevice
|
|
, int nSegmentIndex
|
|
, bool& rResult
|
|
, DWORD dwRenderTime
|
|
, const K3DVertex* pOriginCorrection
|
|
, int segmentIndex
|
|
, int segmentX
|
|
, int segmentY
|
|
, bool bLoadLightmap);
|
|
|
|
virtual ~CTerrainSegment();
|
|
|
|
/// GameViewport에서 보일때만 켜놓도록 해놓음 - 01
|
|
bool IsVisible() const { return m_bVisible; }
|
|
DWORD GetRenderedTime() const { return m_dwRenderTime; }
|
|
|
|
const TERRAINMAP_PROPERTIES::COLORING& GetMapColoring() const;
|
|
void SetTerrainLight( const K3DLight& rLight, K3DRenderDevice* pDevice );
|
|
|
|
void SetCustomValid( bool bIsValid = false );
|
|
|
|
/// 세그먼트 상대 좌표가 아닌 월드 좌표를 넘겨줄 것.
|
|
WORD GetTile( float x, float y ) const;
|
|
float GetSegmentHeight( float x, float y ) const;
|
|
void GetSegmentTriangle(float x, float y, K3DVector& v1, K3DVector& v2, K3DVector& v3) const;
|
|
bool GetSegmentColor( float x, float y, KTripleColor &out ) const;
|
|
|
|
|
|
/// 세그먼트 상대 좌표 사용
|
|
bool GetAttribute( int nAttrX, int nAttrY ) const;
|
|
K3DVertex GetVertex( int nX, int nY ) const;
|
|
|
|
//void ResetStoolColor() const;
|
|
|
|
void TakeNeighborsPropInfo( CTerrainSegment *pNeighbor, K3DPoint & ptMinSegment, K3DPoint & ptMaxSegment );
|
|
void SetWindStrength( float fStrength );
|
|
void GetStoolLineCrossedPoint( const K3DVector& rNear, const K3DVector& rFar, K3DVector& rPickedPoint, TERRAIN_PICK_RESULT & nStoolPickResult, float & fStoolDistance, K3DVector & vtCurrentPoint, std::vector< CTerrainProp * > & check_list );
|
|
/// { [sonador][COLLIDABLE_CAMERA]
|
|
bool GetPropLineCrossedPointTwoSidesWithCollisionMesh
|
|
( const K3DVector& rayStart
|
|
, const K3DVector& rayEnd
|
|
, float& fNearestT
|
|
, K3DVector& vCandidateCollidedPoint
|
|
#ifdef _DEBUG
|
|
, K3DVector* pCollidedPolygon
|
|
#endif
|
|
);
|
|
// }
|
|
/// { [sonador][7.1.7]충돌 처리 개선(Swept Shpere Collision Detection)
|
|
bool GetPropEllipsoidCrossedPointTwoSidesWithCollisionMesh
|
|
( const K3DVector& rayStart
|
|
, const K3DVector& rayEnd
|
|
, const K3DVector& rayStartInESpace
|
|
, const K3DVector& rayEndInESpace
|
|
, const K3DMatrix& matCBM
|
|
, float& fNearestT
|
|
, K3DVector& vCandidateCollidedPoint
|
|
#ifdef _DEBUG
|
|
, K3DVector* pCollidedPolygon
|
|
#endif
|
|
);
|
|
// }
|
|
void GetPropLineCrossedPointTwoSides( const K3DVector& rNear, const K3DVector& rFar, float & fSmallestT, K3DVector& rCandidatePickedPoint );
|
|
bool GetStoolHeight( float x, float y, float& rGetHeight );
|
|
bool GetStoolTriangle( float x, float y, K3DVector& v1, K3DVector& v2, K3DVector& v3, float fTerrainHeight ) const;
|
|
float GetLineCrossedPointTwoSides( const K3DVector& rNear, const K3DVector& rFar, K3DVector& rPickedPoint ) const;
|
|
bool GetLineCrossedPoint( const K3DVector& rNear, const K3DVector& rFar, K3DVector& rPickedPoint ) const;
|
|
/// { [sonador][7.1.7]충돌 처리 개선(Swept Shpere Collision Detection)
|
|
bool GetEllipsoidCrossedPoint
|
|
( const K3DVector& rNear
|
|
, const K3DVector& rFar
|
|
, const K3DVector& rRadius
|
|
, const K3DVector& rBaseInESpace
|
|
, const K3DVector& rVelocityInESpace
|
|
, const K3DMatrix& rCBM
|
|
, float& fNearestT
|
|
, K3DVector& rPickedPoint
|
|
#ifdef _DEBUG
|
|
, K3DVector* pCollidedPolygon
|
|
, std::vector< std::pair< K3DVector, KColor > >& vecDebugLine
|
|
#endif
|
|
) const;
|
|
// }
|
|
CTerrainProp* GetTerrainProp( float x, float y, float& rGetHeight );
|
|
bool DrawSegment( const unsigned long uRenderBitVector, KViewportObject** ppViewportList, int nViewportCount, const K3DVector* pFrustum, const K3DVector& rCameraPos, float fVisibleDistance, float fLodDistance, float fDistanceRatio, DWORD dwCurrentTime, unsigned unCurrentRenderTick, int & nRenderPropCnt, int nLimitDistance=0 );
|
|
bool PVSDrawSegment( const unsigned long uRenderBitVector, KViewportObject** ppViewportList, int nViewportCount, const K3DVector* pFrustum, const K3DVector& rCameraPos, float fVisibleDistance, float fLodDistance, float fDistanceRatio, DWORD dwCurrentTime, unsigned unCurrentRenderTick, int & nRenderPropCnt, class PVSObjectManager* pPVSObjManager );
|
|
|
|
bool IsFrustumCollide( const K3DVector* pFrustum );
|
|
|
|
void AddProp(CTerrainPropForGame* pProp);
|
|
|
|
void LoadAllProps( const K3DVector* pFrustum = NULL );
|
|
/// 로딩 할 것들 옮기기
|
|
void ProcessLoadedProps();
|
|
|
|
bool IsPropLoadCompleted();
|
|
unsigned GetLastRenderedTick() const { return m_unLastRenderedTick; }
|
|
|
|
void SetMapXY( int nMapX, int nMapY )
|
|
{
|
|
m_nMapX = nMapX;
|
|
m_nMapY = nMapY;
|
|
}
|
|
int GetMapX() { return m_nMapX; }
|
|
int GetMapY() { return m_nMapY; }
|
|
|
|
static void ToogleCubeRender()
|
|
{
|
|
#ifdef _DEBUG
|
|
s_bCubeRender = !s_bCubeRender;
|
|
#endif
|
|
}
|
|
|
|
void AddSpeedGrass( CTerrainSpeedGrassForGame* pSpeedGrass );
|
|
int GetSpeedGrassSize() { return (int)m_vSpeedGrass.size(); }
|
|
|
|
int GetSegmentIndex() const { return m_nSegmentIndex; }
|
|
void RefreshTerrainLightmap(bool bLightmapEnable);
|
|
bool GetEnableLightmap() const { return m_bEnableLightmap; }
|
|
|
|
static void SetGlassRender( bool bFlag ) { s_bGlassRender = bFlag; }
|
|
|
|
TERRAIN_LOD_LEVEL CalcLength( const K3DVector& rCameraPos );
|
|
void SetNeighborsTerrainLoadLevel( TERRAIN_LOD_LEVEL nLevel, TERRAIN_LOD_CRACK nLodCrack );
|
|
private:
|
|
const CTerrainPropInfo* m_pPropInfo;
|
|
|
|
void applyProps();
|
|
|
|
//TERRAIN_FILTERING m_nFilteringType;
|
|
TERRAIN_RENDERMODE m_nRenderMode;
|
|
|
|
bool m_bVisible;
|
|
int m_nTileCount;
|
|
DWORD m_dwRenderTime;
|
|
unsigned m_unLastRenderedTick;
|
|
|
|
CTerrainInfoForSegment* m_pTerrainInfo;
|
|
XCriticalSection m_PropLock;
|
|
TERRAINPROP_VECTOR m_PropVector; ///< 전체 리스트. (걸친것 포함, NX3 로딩 안된것도 포함)
|
|
TERRAINPROP_VECTOR m_NotLoadedPropVector; ///< 전체 리스트. (걸친것 포함, NX3 로딩 안된것만.)
|
|
TERRAINPROP_VECTOR m_Loaded_PropVector; ///< 완료 되것.
|
|
TERRAINSPEEDGRASS_VECTOR m_vSpeedGrass;
|
|
|
|
int m_nPropVisibleFlagCount;
|
|
char* m_pPropVisibleFlag;
|
|
|
|
CTerrainPrimitive* m_pTerrainPrimitive;
|
|
CTerrainCustomTexturePrimitive* m_pTerrainShadowPrimitive;
|
|
|
|
float GetPropVisibility( float fSquareCameraDist, float fSquarePropVisibleDist, float fSquarePropAlphaDist ) const;
|
|
|
|
// TODO : 저사양 물 관련( 이 세그먼트가 어디 소속인지 알기 위해( 딴방법은 없나 ) )
|
|
int m_nMapX;
|
|
int m_nMapY;
|
|
|
|
int m_nSegmentX;
|
|
int m_nSegmentY;
|
|
int m_nSegmentIndex;
|
|
bool m_bEnableLightmap;
|
|
|
|
#ifdef _DEBUG
|
|
K3DBoundRotCube m_visible_cube; //include prop
|
|
K3DBoundRotCube m_segment_cube; //only segment
|
|
static bool s_bCubeRender;
|
|
#endif
|
|
|
|
static bool s_bGlassRender;
|
|
|
|
};
|