[add] Hogwart AlphaMap 추가

[add] Hogwart HeightMap 추가
[fix] Lake Data 수정
This commit is contained in:
Chanbin Kim
2026-01-03 17:57:58 +09:00
parent 5d9f2fda63
commit a2ded247cb
18 changed files with 179 additions and 97 deletions
@@ -201,7 +201,6 @@ HRESULT CLevel_GamePlay::Ready_Lights()
Desc.vSpecular = _float4(0.0f, 0.0f, 0.0f, 0.0f); Desc.vSpecular = _float4(0.0f, 0.0f, 0.0f, 0.0f);
} }
if (FAILED(m_pGameInstance->Add_GameObject_ToLayer<CLight_Main>(ENUM_CLASS(LEVEL::STATIC), NEXT_LEVEL, LAYER_LIGHT, &Desc))) { if (FAILED(m_pGameInstance->Add_GameObject_ToLayer<CLight_Main>(ENUM_CLASS(LEVEL::STATIC), NEXT_LEVEL, LAYER_LIGHT, &Desc))) {
return E_FAIL; return E_FAIL;
} }
@@ -306,6 +305,10 @@ HRESULT CLevel_GamePlay::Ready_Background()
if (FAILED(m_pGameInstance->Add_GameObject_ToLayer<CLand>(g_iStaticLevel, NEXT_LEVEL, LAYER_BACKGROUND, &Land_Desc))) if (FAILED(m_pGameInstance->Add_GameObject_ToLayer<CLand>(g_iStaticLevel, NEXT_LEVEL, LAYER_BACKGROUND, &Land_Desc)))
return E_FAIL; return E_FAIL;
/* 물 오브젝트 */
if (FAILED(CInfoInstance::GetInstance()->Load_WaterElemet("Element_Water_Info"))) {
return E_FAIL;
}
// --------------------------------- // ---------------------------------
// >> M A P Configuration << // >> M A P Configuration <<
@@ -367,11 +370,6 @@ HRESULT CLevel_GamePlay::Ready_Background()
if (FAILED(Ready_Layer_Hogwart())) if (FAILED(Ready_Layer_Hogwart()))
return E_FAIL; return E_FAIL;
} }
/* 물 오브젝트 */
if (FAILED(CInfoInstance::GetInstance()->Load_WaterElemet("Element_Water_Info"))) {
return E_FAIL;
}
#endif #endif
if (FAILED(Ready_IntstanceProp())) if (FAILED(Ready_IntstanceProp()))
@@ -94,6 +94,9 @@ HRESULT CMapElement_Lake::Render()
if (FAILED(m_pModelComs[0]->Render(0))) { if (FAILED(m_pModelComs[0]->Render(0))) {
return E_FAIL; return E_FAIL;
} }
if (FAILED(m_pShallowModels[0]->Render(0))) {
return E_FAIL;
}
return S_OK; return S_OK;
} }
@@ -22,12 +22,12 @@
<Object Type="4" Name="HN_LakeA" Lod_Level="0"> <Object Type="4" Name="HN_LakeA" Lod_Level="0">
<PrototypeTag>Prototype_Component_Hogwart_Lake</PrototypeTag> <PrototypeTag>Prototype_Component_Hogwart_Lake</PrototypeTag>
<ShollowPrototypeTag>Prototype_Component_Hogwart_LakeSurFace</ShollowPrototypeTag> <ShollowPrototypeTag>Prototype_Component_Hogwart_LakeSurFace</ShollowPrototypeTag>
<Position x="-92" y="-77.900002" z="-611"/> <Position x="-89.2" y="-61.6" z="-657.8"/>
<Scale x="1.1" y="1.1" z="1.1"/> <Scale x="1.3" y="1" z="1.3"/>
<Rotation x="0" y="0" z="0"/> <Rotation x="0" y="0" z="0"/>
<Radius value="472.7"/> <Radius value="472.7"/>
<TimeSpeed value="0.0099999998"/> <TimeSpeed value="0.0099999998"/>
<RefractionStrength value="0.029999999"/> <RefractionStrength value="0.08"/>
<RefractionPow value="1.5"/> <RefractionPow value="1.5"/>
<UVValue1 value="10"/> <UVValue1 value="10"/>
<UVValue2 value="20"/> <UVValue2 value="20"/>
@@ -35,7 +35,7 @@
<UVSpeed x="0.1" y="0"/> <UVSpeed x="0.1" y="0"/>
<LargeUVSpeed x="0.30000001" y="0.1"/> <LargeUVSpeed x="0.30000001" y="0.1"/>
<SubUVSpeed3 x="100" y="1"/> <SubUVSpeed3 x="100" y="1"/>
<RefractionColor x="0.80590719" y="0.89926827" z="1" w="1"/> <RefractionColor x="0.3" y="0.3" z="0.3" w="1"/>
<SurfaceColor x="1" y="0" z="1" w="1"/> <SurfaceColor x="0.25" y="0" z="1" w="1"/>
</Object> </Object>
</MapObjects_Water> </MapObjects_Water>
@@ -737,7 +737,7 @@ PS_OUT PS_LAKE(PS_IN In)
float4 vMtrlDiffuse = g_DiffuseTexture.Sample(AnisoTropy_BLUR_Sampler, In.vTexcoord * 30.f); float4 vMtrlDiffuse = g_DiffuseTexture.Sample(AnisoTropy_BLUR_Sampler, In.vTexcoord * 30.f);
float3 vNoise = (g_NoiseTexture.Sample(AnisoTropy_BLUR_Sampler, In.vTexcoord + g_fTime * 0.1f).rgb - 0.5f) * 0.3f; float3 vNoise = (g_NoiseTexture.Sample(AnisoTropy_BLUR_Sampler, In.vTexcoord + g_fTime * 0.1f).rgb - 0.5f) * 0.3f;
float4 vCaustics = g_CausticsTexture.Sample(AnisoTropy_BLUR_Sampler, In.vTexcoord * 30.f + vNoise.g); float4 vCaustics = g_CausticsTexture.Sample(AnisoTropy_BLUR_Sampler, In.vTexcoord * 10.f + vNoise.g);
float3 vNormalDecoded = DecodeNormalFromRG(g_NormalTexture, AnisoTropy_BLUR_Sampler, vUV + vNoise.g); float3 vNormalDecoded = DecodeNormalFromRG(g_NormalTexture, AnisoTropy_BLUR_Sampler, vUV + vNoise.g);
float3 vNormalLarge = DecodeNormalFromRG(g_NormalLargeTexture, AnisoTropy_BLUR_Sampler, vUVLarge + vNoise.r); float3 vNormalLarge = DecodeNormalFromRG(g_NormalLargeTexture, AnisoTropy_BLUR_Sampler, vUVLarge + vNoise.r);
@@ -51,7 +51,7 @@ HRESULT CLevel_MapViewer::Initialize()
return E_FAIL; return E_FAIL;
} }
if (FAILED(m_pGameInstance->Add_GameObject_ToLayer<CEffectPool>(g_iStaticLevel, NEXT_LEVEL, TEXT("Layer_EffectPool")))) //플레이어보다 먼저 생성해야함! if (FAILED(m_pGameInstance->Add_GameObject_ToLayer<CEffectPool>(g_iStaticLevel, NEXT_LEVEL, TEXT("Z_Layer_EffectPool")))) //플레이어보다 먼저 생성해야함!
{ {
return E_FAIL; return E_FAIL;
} }
@@ -189,31 +189,31 @@ HRESULT CLevel_MapViewer::Ready_Layer_Terrain(const _wstring& strLayerTag)
CMapElement_Lake::MAPOBJECT_LAKE_DESC Lake_Desc = {}; CMapElement_Lake::MAPOBJECT_LAKE_DESC Lake_Desc = {};
//vector<_wstring> ModelPrototypeTags; vector<_wstring> ModelPrototypeTags;
//vector<_wstring> ShallowModelPrototypeTags; vector<_wstring> ShallowModelPrototypeTags;
//ModelPrototypeTags.push_back(TEXT("Prototype_Component_Hogwart_Lake")); ModelPrototypeTags.push_back(TEXT("Prototype_Component_Hogwart_Lake"));
//ShallowModelPrototypeTags.push_back(TEXT("Prototype_Component_Hogwart_LakeSurFace")); ShallowModelPrototypeTags.push_back(TEXT("Prototype_Component_Hogwart_LakeSurFace"));
//Lake_Desc.bEdit = false; Lake_Desc.bEdit = false;
//Lake_Desc.iMaxLodLevel = 0; Lake_Desc.iMaxLodLevel = 0;
//Lake_Desc.iRenderType = 4; Lake_Desc.iRenderType = 4;
//Lake_Desc.vPosition = _float3(-144.f, -61.9f, -115.f); Lake_Desc.vPosition = _float3(-89.2f, -61.6f, -657.8f);
//Lake_Desc.vRotation = _float3(0.f, 0.f, 0.f); Lake_Desc.vRotation = _float3(0.f, 0.f, 0.f);
//Lake_Desc.vScale = _float3(1.f, 1.f, 1.f); Lake_Desc.vScale = _float3(1.3f, 1.f, 1.3f);
//Lake_Desc.fTimeSpeed = _float(0.02f); Lake_Desc.fTimeSpeed = _float(0.02f);
//Lake_Desc.fRefractionStrength = _float(); Lake_Desc.fRefractionStrength = 0.08f;
//Lake_Desc.fRefractionPow = _float(); Lake_Desc.fRefractionPow = 1.5f;
//Lake_Desc.fUVValue1 = _float(); Lake_Desc.fUVValue1 = 10.f;
//Lake_Desc.fUVValue2 = _float(); Lake_Desc.fUVValue2 = 20.f;
//Lake_Desc.fUVValue3 = _float(); Lake_Desc.fUVValue3 = 20.f;
//Lake_Desc.vUVSpeed = _float2(); Lake_Desc.vUVSpeed = _float2(0.1f, 0.f);
//Lake_Desc.vLargeUVSpeed = _float2(); Lake_Desc.vLargeUVSpeed = _float2(0.3f, 0.1f);
//Lake_Desc.vSubUVSpeed3 = _float2(); Lake_Desc.vSubUVSpeed3 = _float2(10.f, 0.f);
//Lake_Desc.vRefractionColor = _float4(); Lake_Desc.vRefractionColor = _float4(0.35f, 0.35f, 0.35f, 1.f);
//Lake_Desc.vSurfaceColor = _float4(); Lake_Desc.vSurfaceColor = _float4(0.25f, 0.f, 1.f, 1.f);
//Lake_Desc.ModelPrototypeTags = ModelPrototypeTags; Lake_Desc.ModelPrototypeTags = ModelPrototypeTags;
//Lake_Desc.ShallowModelPrototypeTags = ShallowModelPrototypeTags; Lake_Desc.ShallowModelPrototypeTags = ShallowModelPrototypeTags;
//if (FAILED(m_pGameInstance->Add_GameObject_ToLayer<CMapElement_Lake>(g_iStaticLevel, NEXT_LEVEL, strLayerTag, &Lake_Desc))) if (FAILED(m_pGameInstance->Add_GameObject_ToLayer<CMapElement_Lake>(g_iStaticLevel, NEXT_LEVEL, strLayerTag, &Lake_Desc)))
// return E_FAIL; return E_FAIL;
return S_OK; return S_OK;
+3 -13
View File
@@ -2948,7 +2948,7 @@ HRESULT CLoader::Loading_For_MapViewer()
#pragma endregion #pragma endregion
_bool bLoadHogsmeade = false; _bool bLoadHogsmeade = true;
if (bLoadHogsmeade) if (bLoadHogsmeade)
{ {
#pragma region HOGSMEADE_OBJECT #pragma region HOGSMEADE_OBJECT
@@ -3335,10 +3335,10 @@ if (FAILED(MapFolderLoad("C:\\MeshTable\\Game\\Environment\\Sanctum_Dungeon\\Mes
vector<future<void>> jobFutures; vector<future<void>> jobFutures;
_uint iLoadCount = 46; _uint iLoadCount = 44;
vector<vector<FOLDER_LOAD*>*> Contents(iLoadCount); vector<vector<FOLDER_LOAD*>*> Contents(iLoadCount);
_bool isLoad_Map = { false }; _bool isLoad_Map = { true };
if(isLoad_Map) if(isLoad_Map)
{ {
{ /* Terrain */ { /* Terrain */
@@ -3417,11 +3417,6 @@ if(isLoad_Map)
)); ));
} }
{ /* BLDG_HogsheadInn */ { /* BLDG_HogsheadInn */
jobFutures.emplace_back(Deferred_FolderLoad(
"../Bin/Resources/Models/MapMesh/Game/Environment/Hogsmeade/BLDG_HogsheadInn/Meshes",
".bin", false,
&Contents[jobFutures.size()]
));
jobFutures.emplace_back(Deferred_FolderLoad( jobFutures.emplace_back(Deferred_FolderLoad(
"../Bin/Resources/Models/MapMesh/Game/Environment/Hogsmeade/BLDG_HogsheadInn/Collision", "../Bin/Resources/Models/MapMesh/Game/Environment/Hogsmeade/BLDG_HogsheadInn/Collision",
".bin", false, ".bin", false,
@@ -3489,11 +3484,6 @@ if(isLoad_Map)
)); ));
} }
{ /* BLDG_Potions */ { /* BLDG_Potions */
jobFutures.emplace_back(Deferred_FolderLoad(
"../Bin/Resources/Models/MapMesh/Game/Environment/Hogsmeade/BLDG_Potions/Meshes",
".bin", false,
&Contents[jobFutures.size()]
));
jobFutures.emplace_back(Deferred_FolderLoad( jobFutures.emplace_back(Deferred_FolderLoad(
"../Bin/Resources/Models/MapMesh/Game/Environment/Hogsmeade/BLDG_Potions/Collisions", "../Bin/Resources/Models/MapMesh/Game/Environment/Hogsmeade/BLDG_Potions/Collisions",
".bin", false, ".bin", false,
@@ -51,8 +51,21 @@ HRESULT CMapElement_Lake::Initialize(void* pArg)
m_pTransformCom->Rotation(XMConvertToRadians(m_vRotation.x), XMConvertToRadians(m_vRotation.y), XMConvertToRadians(m_vRotation.z)); m_pTransformCom->Rotation(XMConvertToRadians(m_vRotation.x), XMConvertToRadians(m_vRotation.y), XMConvertToRadians(m_vRotation.z));
#endif // _DEBUG #endif // _DEBUG
m_vRefractionColor = _float4(1.f, 1.f, 1.f, 1.f); m_fTimeSpeed = pDesc->fTimeSpeed;
m_vSurfaceColor = _float4(1.f, 1.f, 1.f, 1.f);
m_fRefractionStrength = pDesc->fRefractionStrength;
m_fRefractionPow = pDesc->fRefractionPow;
m_fUVValue1 = pDesc->fUVValue1;
m_fUVValue2 = pDesc->fUVValue2;
m_fUVValue3 = pDesc->fUVValue3;
m_vUVSpeed = pDesc->vUVSpeed;
m_vLargeUVSpeed = pDesc->vLargeUVSpeed;
m_vSubUVSpeed3 = pDesc->vSubUVSpeed3;
memcpy(&m_vRefractionColor, &pDesc->vRefractionColor, sizeof(_float4));
memcpy(&m_vSurfaceColor, &pDesc->vSurfaceColor, sizeof(_float4));
return S_OK; return S_OK;
} }
@@ -120,7 +120,7 @@ void CMapObject_LOD::Late_Update(_float fTimeDelta)
m_fCamDepth = XMVectorGetX(XMVector3LengthSq(vCamPosition - XMLoadFloat4(&m_vExtentPosition))); m_fCamDepth = XMVectorGetX(XMVector3LengthSq(vCamPosition - XMLoadFloat4(&m_vExtentPosition)));
m_iLodIndex = min(m_iMaxLodLevel, (_uint)(m_fCamDepth / (fRaius * fRaius + 40000.f))); m_iLodIndex = min(m_iMaxLodLevel, (_uint)(m_fCamDepth / (fRaius * fRaius + 10000.f)));
if (m_pGameInstance->Key_Pressing(DIK_Z)) if (m_pGameInstance->Key_Pressing(DIK_Z))
m_iLodIndex = 0; m_iLodIndex = 0;
@@ -65,8 +65,8 @@ HRESULT CMapObject_Manager::Initialize(void* pArg)
m_iContainerObjectIndex = 99; m_iContainerObjectIndex = 99;
//if (FAILED(Load_MapData("Hogsmeade_MapContainer_Data", LAYER_HOGSMEADE))) if (FAILED(Load_MapData("Hogsmeade_MapContainer_Data", LAYER_HOGSMEADE)))
// return E_FAIL; return E_FAIL;
//m_pContainer = m_pGameInstance->Get_Layer(ENUM_CLASS(LEVEL::MAP), TEXT("Layer_Building"))->Get_Object<CBuildingContainer>(); //m_pContainer = m_pGameInstance->Get_Layer(ENUM_CLASS(LEVEL::MAP), TEXT("Layer_Building"))->Get_Object<CBuildingContainer>();
+15 -13
View File
@@ -182,10 +182,6 @@ HRESULT CTerrain::Bind_ShaderResources()
return E_FAIL; return E_FAIL;
} }
if (FAILED(m_pShaderCom->Bind_RawValue("g_fFar", m_pGameInstance->Get_CurrentCameraFar(), sizeof(_float)))) {
return E_FAIL;
}
if (FAILED(m_pDiffuseTextureCom->Bind_ShaderResources(m_pShaderCom, "g_DiffuseTextures", 0, m_pDiffuseTextureCom->Get_Size()))) { if (FAILED(m_pDiffuseTextureCom->Bind_ShaderResources(m_pShaderCom, "g_DiffuseTextures", 0, m_pDiffuseTextureCom->Get_Size()))) {
return E_FAIL; return E_FAIL;
} }
@@ -199,6 +195,12 @@ HRESULT CTerrain::Bind_ShaderResources()
return E_FAIL; return E_FAIL;
} }
if (FAILED(m_pShaderCom->Bind_RawValue("g_fFar", m_pGameInstance->Get_CurrentCameraFar(), sizeof(_float)))) {
return E_FAIL;
}
if (FAILED(m_pShaderCom->Bind_RawValue("g_fUsingSurfaceParams", &m_fUsingSurfaceParams, sizeof(_float)))) if (FAILED(m_pShaderCom->Bind_RawValue("g_fUsingSurfaceParams", &m_fUsingSurfaceParams, sizeof(_float))))
return E_FAIL; return E_FAIL;
@@ -317,21 +319,21 @@ void CTerrain::Describe_Entity()
m_pAlphaMap->Load_ToFile("Hogwart_AlphaMap.bin"); m_pAlphaMap->Load_ToFile("Hogwart_AlphaMap.bin");
} }
m_iMaskRange = max(1, m_iMaskRange);
//GUI::DragFloat("Up", &m_fUpValue, 0.01f, -1.0f, 1.f); GUI::DragFloat("Up", &m_fUpValue, 0.01f, -1.0f, 1.f);
if (m_pGameInstance->Mouse_Pressing(DIM_LBUTTON)) if (m_pGameInstance->Mouse_Pressing(DIM_LBUTTON))
{ {
if (m_pGameInstance->isPicking(&m_vPickingPosition)) if (m_pGameInstance->isPicking(&m_vPickingPosition))
{ {
if (m_pGameInstance->Key_Pressing(DIK_PERIOD)) //if (m_pGameInstance->Key_Pressing(DIK_PERIOD))
m_pVIBufferCom->FitY(m_pTransformCom->Get_XMWorldMatrix(), m_fUpValue); // m_pVIBufferCom->FitY(m_pTransformCom->Get_XMWorldMatrix(), m_fUpValue, m_vPickingPosition, m_iMaskRange);
if (m_pGameInstance->Key_Pressing(DIK_COMMA)) //if (m_pGameInstance->Key_Pressing(DIK_COMMA))
m_pVIBufferCom->FitY(m_pTransformCom->Get_XMWorldMatrix(), m_fUpValue * -1.f); // m_pVIBufferCom->FitY(m_pTransformCom->Get_XMWorldMatrix(), m_fUpValue * -1.f, m_vPickingPosition, m_iMaskRange);
XMStoreFloat3(&m_vPickingPosition, XMVector3TransformCoord(XMLoadFloat3(&m_vPickingPosition), m_pTransformCom->Get_WorldMatrixInv())); XMStoreFloat3(&m_vPickingPosition, XMVector3TransformCoord(XMLoadFloat3(&m_vPickingPosition), m_pTransformCom->Get_WorldMatrixInv()));
if(m_pGameInstance->Key_Pressing(DIK_M))
m_pAlphaMap->Update(m_vPickingPosition, m_iColorIndex, m_fMaskValue, m_iMaskRange); m_pAlphaMap->Update(m_vPickingPosition, m_iColorIndex, m_fMaskValue, m_iMaskRange);
} }
@@ -341,9 +343,9 @@ void CTerrain::Describe_Entity()
#pragma region HEIGHT MAP #pragma region HEIGHT MAP
HRESULT hr = {}; HRESULT hr = {};
if(GUI::Button("Save HeightMap")) if(GUI::Button("Save HeightMap"))
hr = m_pVIBufferCom->Save_HeightMap("Hogwart_Height.bin"); hr = m_pVIBufferCom->Save_HeightMap("Hogwart_HeightMap.bin");
if(GUI::Button("Load HeightMap")) if(GUI::Button("Load HeightMap"))
hr = m_pVIBufferCom->Load_HeightMap("Hogwart_Height.bin"); hr = m_pVIBufferCom->Load_HeightMap("Hogwart_HeightMap.bin");
#pragma endregion #pragma endregion
_float4 vPos = {}; _float4 vPos = {};
@@ -455,31 +455,106 @@ void CVIBuffer_Terrain::Culling(_fmatrix WorldMatrix)
m_iNumIndices = iNumIndices; m_iNumIndices = iNumIndices;
} }
void CVIBuffer_Terrain::FitY(_fmatrix WorldMatrix, _float fY) void CVIBuffer_Terrain::FitY(_fmatrix WorldMatrix, _float fY, _float3 vPickingPos, _uint iRange)
{ {
m_pGameInstance->Transform_Frustum_ToLocalSpace(XMMatrixInverse(nullptr, WorldMatrix)); m_pGameInstance->Transform_Frustum_ToLocalSpace(XMMatrixInverse(nullptr, WorldMatrix));
D3D11_MAPPED_SUBRESOURCE SubResource{}; //D3D11_MAPPED_SUBRESOURCE SubResource{};
m_pContext->Map(m_pVB, 0, D3D11_MAP_READ_WRITE, 0, &SubResource); //m_pContext->Map(m_pVB, 0, D3D11_MAP_READ_WRITE, 0, &SubResource);
VTXNORTEX* pVertices = static_cast<VTXNORTEX*>(SubResource.pData); //VTXNORTEX* pVertices = static_cast<VTXNORTEX*>(SubResource.pData);
//_matrix WorldInv = XMMatrixInverse(nullptr, WorldMatrix);
//m_pQuadTree->Set_Y(m_pGameInstance, m_pVertexPositions, pVertices, WorldMatrix, fY);
//for (_uint i = 0; i < m_iNumVertices; ++i)
//{
// memcpy(&m_pVertexPositions[i], &pVertices[i].vPosition, sizeof(_float3));
//}
_float3 Out{};
_float3 vLocalPosition = {};
_matrix WorldInv = XMMatrixInverse(nullptr, WorldMatrix); _matrix WorldInv = XMMatrixInverse(nullptr, WorldMatrix);
m_pGameInstance->Ray_WorldToLocal(&WorldInv); m_pGameInstance->Ray_WorldToLocal(&WorldInv);
XMStoreFloat3(&vLocalPosition, XMVector3TransformCoord(XMVectorSetW(XMLoadFloat3(&vPickingPos), 1.f), WorldInv));
_uint iIndex = static_cast<_uint>(vLocalPosition.x) + static_cast<_uint>(vLocalPosition.z) * m_iNumVerticesX;
m_pQuadTree->Set_Y(m_pGameInstance, m_pVertexPositions, pVertices, WorldMatrix, fY); _uint iIndices[4] = {
iIndex + m_iNumVerticesX,
for (_uint i = 0; i < m_iNumVertices; ++i) iIndex + m_iNumVerticesX + 1,
{ iIndex + 1,
memcpy(&m_pVertexPositions[i], &pVertices[i].vPosition, sizeof(_float3)); iIndex
} };
D3D11_MAPPED_SUBRESOURCE SubResource{};
m_pContext->Map(m_pVB, 0, D3D11_MAP_READ_WRITE, 0, &SubResource);
VTXNORTEX* pVertices = static_cast<VTXNORTEX*>(SubResource.pData);
Add_Y(pVertices, iIndex, fY);
Add_NeighborY(pVertices, static_cast<_uint>(vLocalPosition.x), static_cast<_uint>(vLocalPosition.z), fY, iRange);
m_pContext->Unmap(m_pVB, 0); m_pContext->Unmap(m_pVB, 0);
} }
void CVIBuffer_Terrain::Add_NeighborY(VTXNORTEX* pVertices, _uint iX, _uint iZ, _float fY, _uint iRange)
{
_int Range = iRange; // 이웃 범위 설정
for (_int dz = -Range; dz <= Range; ++dz)
{
for (_int dx = -Range; dx <= Range; ++dx)
{
_int nx = iX + dx;
_int nz = iZ + dz;
// 범위 체크 (0 ~ m_iNumVerticesX/Z-1)
if (nx < 0 || nz < 0 ||
nx >= (_int)m_iNumVerticesX ||
nz >= (_int)m_iNumVerticesZ)
continue;
_uint iNeighborIndex =
static_cast<_uint>(nx) +
static_cast<_uint>(nz) * m_iNumVerticesX;
Add_Y(pVertices, iNeighborIndex, fY);
}
}
}
void CVIBuffer_Terrain::Add_Y(VTXNORTEX* pVertices, _uint iIndex, _float fY)
{
_uint iIndices[4] = {
iIndex + m_iNumVerticesX,
iIndex + m_iNumVerticesX + 1,
iIndex + 1,
iIndex
};
for (_uint i = 0; i < 4; i++)
{
if (0 > iIndices[i] || m_iNumVertices <= iIndices[i])
return;
}
_float fHieght = { };
_float fAvgHieght = { };
for (_uint i = 0; i < 4; i++)
{
fHieght += pVertices[iIndices[i]].vPosition.y;
}
fAvgHieght = fHieght / 4.f;
for (_uint i = 0; i < 4; i++)
{
pVertices[iIndices[i]].vPosition.y = fAvgHieght + fY;
memcpy(&m_pVertexPositions[iIndices[i]], &pVertices[iIndices[i]].vPosition, sizeof(_float3));
}
}
HRESULT CVIBuffer_Terrain::Load_HeightMap(const _char* pFilePath) HRESULT CVIBuffer_Terrain::Load_HeightMap(const _char* pFilePath)
{ {
@@ -28,8 +28,9 @@ class ENGINE_DLL CVIBuffer_Terrain final : public CVIBuffer
_bool Picking(_fmatrix WorldMatrix, _float3* pOut); _bool Picking(_fmatrix WorldMatrix, _float3* pOut);
void Culling(_fmatrix WorldMatrix); void Culling(_fmatrix WorldMatrix);
void FitY(_fmatrix WorldMatrix, _float fY); void FitY(_fmatrix WorldMatrix, _float fY, _float3 vPickingPos, _uint iRange);
void Add_NeighborY(VTXNORTEX* pVertices, _uint iX, _uint iZ, _float fY, _uint iRange);
void Add_Y(VTXNORTEX* pVertices, _uint iIndex, _float fY);
HRESULT Load_HeightMap(const _char* pFilePath); HRESULT Load_HeightMap(const _char* pFilePath);
#ifdef EDITOR_PROJECT #ifdef EDITOR_PROJECT