[add] Terrain 스플래팅 적용
This commit is contained in:
@@ -1317,10 +1317,10 @@ HRESULT CModel::Initialize(void* pArg)
|
||||
m_pTransform = m_pOwner->Get_Component<CTransform>();
|
||||
SAFE_ADDREF(m_pTransform);
|
||||
|
||||
Create_Con();
|
||||
/*Create_Con();
|
||||
|
||||
if (FAILED(Create_CS()))
|
||||
return E_FAIL;
|
||||
return E_FAIL;*/
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -6,6 +6,19 @@ CQuadTree::CQuadTree()
|
||||
{
|
||||
}
|
||||
|
||||
void CQuadTree::Set_CullingRadius(_float fRadius)
|
||||
{
|
||||
m_fCullingRadius = fRadius;
|
||||
|
||||
if (nullptr == m_pChildren[CORNER_LT])
|
||||
return;
|
||||
|
||||
for (_uint i = 0; i < CORNER_END; i++)
|
||||
{
|
||||
m_pChildren[i]->Set_CullingRadius(fRadius);
|
||||
}
|
||||
}
|
||||
|
||||
void CQuadTree::Culling(CGameInstance* pGameInstance, const _float3* pVertexPositions, _uint* pIndices, _uint* pNumIndices)
|
||||
{
|
||||
/* 해당 노드에서 그릴건지 확인 */
|
||||
@@ -158,7 +171,7 @@ void CQuadTree::Culling(CGameInstance* pGameInstance, const _float3* pVertexPosi
|
||||
/* Range 는 사각형의 중심에서 꼭짓점까지의 거리 */
|
||||
_float fRange = XMVector3Length(XMLoadFloat3(&pVertexPositions[m_iCorners[CORNER_LT]]) - XMLoadFloat3(&pVertexPositions[m_iCenter])).m128_f32[0];
|
||||
|
||||
if (true == pGameInstance->isIn_LocalFrustum(XMLoadFloat3(&pVertexPositions[m_iCenter]), fRange))
|
||||
if (true == pGameInstance->isIn_LocalFrustum(XMLoadFloat3(&pVertexPositions[m_iCenter]), fRange * 1.5f))
|
||||
{
|
||||
for (size_t i = 0; i < CORNER_END; i++)
|
||||
{
|
||||
@@ -262,9 +275,9 @@ _bool CQuadTree::Set_Y(CGameInstance* pGameInstance, const _float3* pVertexPosit
|
||||
{
|
||||
if (nullptr == m_pChildren[CORNER_LT])
|
||||
{
|
||||
pVertices[m_iCorners[CORNER_LT]].vPosition.y = fY;
|
||||
pVertices[m_iCorners[CORNER_RT]].vPosition.y = fY;
|
||||
pVertices[m_iCorners[CORNER_RB]].vPosition.y = fY;
|
||||
pVertices[m_iCorners[CORNER_LT]].vPosition.y += fY;
|
||||
pVertices[m_iCorners[CORNER_RT]].vPosition.y += fY;
|
||||
pVertices[m_iCorners[CORNER_RB]].vPosition.y += fY;
|
||||
|
||||
XMStoreFloat3(&Out, XMVector3TransformCoord(XMLoadFloat3(&Out), WorldMatrix));
|
||||
return true;
|
||||
@@ -276,9 +289,9 @@ _bool CQuadTree::Set_Y(CGameInstance* pGameInstance, const _float3* pVertexPosit
|
||||
{
|
||||
if (nullptr == m_pChildren[CORNER_LT])
|
||||
{
|
||||
pVertices[m_iCorners[CORNER_LT]].vPosition.y = fY;
|
||||
pVertices[m_iCorners[CORNER_RB]].vPosition.y = fY;
|
||||
pVertices[m_iCorners[CORNER_LB]].vPosition.y = fY;
|
||||
pVertices[m_iCorners[CORNER_LT]].vPosition.y += fY;
|
||||
pVertices[m_iCorners[CORNER_RB]].vPosition.y += fY;
|
||||
pVertices[m_iCorners[CORNER_LB]].vPosition.y += fY;
|
||||
|
||||
XMStoreFloat3(&Out, XMVector3TransformCoord(XMLoadFloat3(&Out), WorldMatrix));
|
||||
return true;
|
||||
@@ -303,7 +316,7 @@ _bool CQuadTree::isDraw(CGameInstance* pGameInstance, const _float3* pVertexPosi
|
||||
_vector vCamPos = XMLoadFloat4(pGameInstance->Get_CamPosition());
|
||||
_vector vCenter = XMLoadFloat3(&pVertexPositions[m_iCenter]);
|
||||
|
||||
if (m_iCorners[CORNER_RT] - m_iCorners[CORNER_LT] < XMVectorGetX(XMVector3Length(vCamPos - vCenter)) * 0.2f)
|
||||
if (m_iCorners[CORNER_RT] - m_iCorners[CORNER_LT] < XMVectorGetX(XMVector3Length(vCamPos - vCenter)) * 0.04f)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
|
||||
@@ -104,23 +104,23 @@ HRESULT CVIBuffer_Terrain::Initialize_Prototype(const _char* pFilePath, _uint iS
|
||||
VTXNORTEX* pVertices = new VTXNORTEX[m_iNumVertices];
|
||||
ZeroMemory(pVertices, sizeof(VTXNORTEX) * m_iNumVertices);
|
||||
|
||||
m_pVertexPositions = new _float3[m_iNumVertices];
|
||||
m_pVertexPositions = new _float3[m_iNumVertices];
|
||||
ZeroMemory(m_pVertexPositions, sizeof(_float3) * m_iNumVertices);
|
||||
|
||||
for (_uint i = 0; i < m_iNumVerticesZ - 1; i++)
|
||||
for (_uint i = 0; i < m_iNumVerticesZ; i++)
|
||||
{
|
||||
for (_uint j = 0; j < m_iNumVerticesX - 1; j++)
|
||||
for (_uint j = 0; j < m_iNumVerticesX; j++)
|
||||
{
|
||||
_uint iIndex = i * m_iNumVerticesX + j;
|
||||
|
||||
m_pVertexPositions[iIndex] = pVertices[iIndex].vPosition = _float3(
|
||||
(_float)j * m_iNumVerticesX / (m_iNumVerticesX - 1.f),
|
||||
(_float)(pPixels[iIndex]) * 5 * 256.f,
|
||||
(_float)(pPixels[iIndex]) * 10.f * 256.f - 256.f,
|
||||
(_float)i * m_iNumVerticesZ / (m_iNumVerticesZ -1.f)
|
||||
);
|
||||
|
||||
m_HeigthValues.push_back((_float)(pPixels[iIndex]) * 10.f * 256.f - 256.f);
|
||||
pVertices[iIndex].vNormal = _float3(0.f, 0.f, 0.f);
|
||||
pVertices[iIndex].vTexcoord = _float2((_float)j / (m_iNumVerticesX - 1.f) / 32.f, (_float)i / (m_iNumVerticesZ - 1.f) / 32.f);
|
||||
pVertices[iIndex].vTexcoord = _float2((_float)j / (m_iNumVerticesX), (_float)i / m_iNumVerticesZ );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -281,6 +281,11 @@ void CVIBuffer_Terrain::Change_HeigthRatio(_float fRatio)
|
||||
m_pContext->Unmap(m_pVB, 0);
|
||||
}
|
||||
|
||||
void CVIBuffer_Terrain::Set_CullingRadius(_float fRaduis)
|
||||
{
|
||||
m_pQuadTree->Set_CullingRadius(fRaduis);
|
||||
}
|
||||
|
||||
CVIBuffer_Terrain* CVIBuffer_Terrain::Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext, const _char* pFilePath, _uint iSizeX, _uint iSizeZ)
|
||||
{
|
||||
CVIBuffer_Terrain* pInstance = new CVIBuffer_Terrain(pDevice, pContext);
|
||||
|
||||
@@ -14,6 +14,11 @@ class CQuadTree final : public CBase
|
||||
virtual ~CQuadTree() = default;
|
||||
|
||||
public:
|
||||
#ifdef _DEBUG
|
||||
void Set_CullingRadius(_float fRadius);
|
||||
#endif // _DEBUG
|
||||
|
||||
|
||||
void Culling(class CGameInstance* pGameInstance, const _float3* pVertexPositions, _uint* pIndices, _uint* pNumIndices);
|
||||
void SetUp_Neighbors();
|
||||
_bool Picking(class CGameInstance* pGameInstance, const _float3* pVertexPositions, _float3& Out, _fmatrix WorldMatrix);
|
||||
@@ -23,6 +28,8 @@ class CQuadTree final : public CBase
|
||||
_uint m_iCorners[CORNER_END] = { };
|
||||
_uint m_iCenter = {};
|
||||
|
||||
_float m_fCullingRadius = { 0.2f };
|
||||
|
||||
CQuadTree* m_pChildren[CORNER_END] = { nullptr };
|
||||
CQuadTree* m_pNeighbors[NEIGHBOR_END] = { nullptr, nullptr, nullptr, nullptr };
|
||||
|
||||
|
||||
@@ -27,6 +27,11 @@ class ENGINE_DLL CVIBuffer_Terrain final : public CVIBuffer
|
||||
void FitY(_fmatrix WorldMatrix, _float fY);
|
||||
void Change_HeigthRatio(_float fRatio);
|
||||
|
||||
#ifdef _DEBUG
|
||||
void Set_CullingRadius(_float fRaduis);
|
||||
#endif // _DEBUG
|
||||
|
||||
|
||||
private:
|
||||
_bool m_bChange = {};
|
||||
_uint m_iNumVerticesX = {};
|
||||
|
||||
Reference in New Issue
Block a user