From 02305c9d744507eb7a6f35eac16632dd5581a7a1 Mon Sep 17 00:00:00 2001 From: Chanbin Kim Date: Sat, 29 Nov 2025 16:21:12 +0900 Subject: [PATCH] =?UTF-8?q?[add]=20Qcculsion=20Client=20=EC=A0=81=EC=9A=A9?= =?UTF-8?q?=20[add]=20MapContainer=20=EB=B6=84=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Client/Private/BuildingContainer.cpp | 83 ++++- Jusin154_Team3D/Client/Private/Loader.cpp | 11 + Jusin154_Team3D/Client/Private/MapInfo.cpp | 285 +++++++++++------- .../Client/Private/StreetContainer.cpp | 65 ---- .../Client/Public/BuildingContainer.h | 38 +-- Jusin154_Team3D/Client/Public/Client_Macro.h | 1 + Jusin154_Team3D/Client/Public/MapContainer.h | 19 ++ Jusin154_Team3D/Client/Public/MapInfo.h | 5 +- .../Client/Public/StreetContainer.h | 43 +-- .../Bin/Resources/Data/Map/ClientTest.xml | 12 + .../Engine/Private/VIBuffer_Box.cpp | 114 ++++--- Jusin154_Team3D/Engine/Public/VIBuffer_Box.h | 13 +- 12 files changed, 397 insertions(+), 292 deletions(-) diff --git a/Jusin154_Team3D/Client/Private/BuildingContainer.cpp b/Jusin154_Team3D/Client/Private/BuildingContainer.cpp index 35c1614a4..788f6ba07 100644 --- a/Jusin154_Team3D/Client/Private/BuildingContainer.cpp +++ b/Jusin154_Team3D/Client/Private/BuildingContainer.cpp @@ -24,16 +24,21 @@ void CBuildingContainer::Update(_float fTimeDelta) { __super::Update(fTimeDelta); + m_fCamDepth = XMVectorGetX(XMVector3Length(XMLoadFloat4(m_pGameInstance->Get_CamPosition()) - XMLoadFloat3(&m_vExtentWorldPosition))); + for (auto& pCollisiton : m_ColiisonPartObjects) pCollisiton->Update(fTimeDelta); } void CBuildingContainer::Late_Update(_float fTimeDelta) { - __super::Late_Update(fTimeDelta); + if (m_pOcclusionQueryCom->isDraw()) + __super::Late_Update(fTimeDelta); for (auto& pCollisiton : m_ColiisonPartObjects) pCollisiton->Late_Update(fTimeDelta); + + m_pGameInstance->Add_RenderGroup(RENDER::OCCLUSION, this); } HRESULT CBuildingContainer::Render() @@ -41,6 +46,38 @@ HRESULT CBuildingContainer::Render() return S_OK; } +HRESULT CBuildingContainer::Render_BoundingBox() +{ + /* Begin_Query, End_Query 사이에 Render */ + + m_pOcclusionQueryCom->Begin_Query(); + + if (FAILED(m_pShaderCom->Bind_Matrix("g_WorldMatrix", m_pTransformCom->Get_WorldMatrixPtr()))) { + return E_FAIL; + } + + if (FAILED(m_pShaderCom->Bind_Matrix("g_ViewMatrix", m_pGameInstance->Get_Transform_Float4x4(D3DTS::VIEW)))) { + return E_FAIL; + } + + if (FAILED(m_pShaderCom->Bind_Matrix("g_ProjMatrix", m_pGameInstance->Get_Transform_Float4x4(D3DTS::PROJ)))) { + return E_FAIL; + } + + if (FAILED(m_pShaderCom->Begin(0))) + return E_FAIL; + + if (FAILED(m_pVIBufferCom->Bind_Resources())) + return E_FAIL; + + if (FAILED(m_pVIBufferCom->Render())) + return E_FAIL; + + m_pOcclusionQueryCom->End_Query(); + + return S_OK; +} + HRESULT CBuildingContainer::Initialize_Prototype() { return S_OK; @@ -62,6 +99,8 @@ HRESULT CBuildingContainer::Initialize(void* pArg) m_pTransformCom->Set_Scale(pDesc->vScale); m_pTransformCom->Rotation(XMConvertToRadians(pDesc->vRotation.x), XMConvertToRadians(pDesc->vRotation.y), XMConvertToRadians(pDesc->vRotation.z)); + XMStoreFloat3(&m_vExtentWorldPosition, XMVector3TransformCoord(XMLoadFloat3(&m_vExtentWorldPosition), m_pTransformCom->Get_XMWorldMatrix())); + return S_OK; } @@ -71,6 +110,44 @@ HRESULT CBuildingContainer::Ready_Components(void* pArg) return E_FAIL; } + /* Com_Shader */ + if (FAILED(__super::Add_Asset_Component(g_iStaticLevel, FX_VTXPOS, + reinterpret_cast(&m_pShaderCom)))) + return E_FAIL; + + MAP_CONTAINER_DESC* pDesc = static_cast(pArg); + + _float3 vBoxCorners[8] = {}; + + vBoxCorners[0] = _float3(pDesc->vContainerMin.x, pDesc->vContainerMax.y, pDesc->vContainerMin.z); + vBoxCorners[1] = _float3(pDesc->vContainerMax.x, pDesc->vContainerMax.y, pDesc->vContainerMin.z); + vBoxCorners[2] = _float3(pDesc->vContainerMax.x, pDesc->vContainerMin.y, pDesc->vContainerMin.z); + vBoxCorners[3] = _float3(pDesc->vContainerMin.x, pDesc->vContainerMin.y, pDesc->vContainerMin.z); + vBoxCorners[4] = _float3(pDesc->vContainerMin.x, pDesc->vContainerMax.y, pDesc->vContainerMax.z); + vBoxCorners[5] = _float3(pDesc->vContainerMax.x, pDesc->vContainerMax.y, pDesc->vContainerMax.z); + vBoxCorners[6] = _float3(pDesc->vContainerMax.x, pDesc->vContainerMin.y, pDesc->vContainerMax.z); + vBoxCorners[7] = _float3(pDesc->vContainerMin.x, pDesc->vContainerMin.y, pDesc->vContainerMax.z); + + _float3 vRadius = {}; + + vRadius.x = (pDesc->vContainerMax.x - pDesc->vContainerMin.x) * 0.5f; + vRadius.y = (pDesc->vContainerMax.y - pDesc->vContainerMin.y) * 0.5f; + vRadius.z = (pDesc->vContainerMax.z - pDesc->vContainerMin.z) * 0.5f; + + m_vExtentWorldPosition.x = pDesc->vContainerMin.x + vRadius.x; + m_vExtentWorldPosition.y = pDesc->vContainerMin.y + vRadius.y; + m_vExtentWorldPosition.z = pDesc->vContainerMin.z + vRadius.z; + + /* Com_VIBuffer */ + if (FAILED(__super::Add_Asset_Component(g_iStaticLevel, TEXT("Prototype_Component_VIBuffer_Box"), + reinterpret_cast(&m_pVIBufferCom), &vBoxCorners))) + return E_FAIL; + + /* Com_OcclusionQuery */ + if (FAILED(__super::Add_Asset_Component(g_iStaticLevel, TEXT("Prototype_Component_OcclusionQuery"), + reinterpret_cast(&m_pOcclusionQueryCom)))) + return E_FAIL; + return S_OK; } @@ -109,6 +186,10 @@ void CBuildingContainer::Free() { __super::Free(); + SAFE_RELEASE(m_pShaderCom); + SAFE_RELEASE(m_pVIBufferCom); + SAFE_RELEASE(m_pOcclusionQueryCom); + for (auto& pCollision : m_ColiisonPartObjects) SAFE_RELEASE(pCollision); } diff --git a/Jusin154_Team3D/Client/Private/Loader.cpp b/Jusin154_Team3D/Client/Private/Loader.cpp index 90f386638..eb31490e5 100644 --- a/Jusin154_Team3D/Client/Private/Loader.cpp +++ b/Jusin154_Team3D/Client/Private/Loader.cpp @@ -72,6 +72,7 @@ #include "VIBuffer_Terrain.h" #include "VIBuffer_Model_Instance.h" #include "BuildingContainer.h" +#include "StreetContainer.h" #include "MapObject_Render.h" #include "MapObject_Collision.h" #include "InstancedProp.h" @@ -458,6 +459,12 @@ HRESULT CLoader::Loading_For_GamePlay() m_strMessage = TEXT("셰이더를(을) 로딩 중 입니다."); + if (FAILED(m_pGameInstance->Add_Asset_Prototype(g_iStaticLevel, FX_VTXPOS, + CShader::Create(m_pDevice, m_pContext, TEXT("../Bin/Resources/ShaderFiles/Shader_VtxPos.hlsl"), + VTXPOS::Elements, VTXPOS::iNumElements)))) { + return E_FAIL; + } + if (FAILED(m_pGameInstance->Add_Asset_Prototype(g_iStaticLevel, FX_MESH, CShader::Create(m_pDevice, m_pContext, TEXT("../Bin/Resources/ShaderFiles/Shader_VtxMesh.hlsl"), VTXMESH::Elements, VTXMESH::iNumElements)))) { @@ -1124,6 +1131,10 @@ HRESULT CLoader::Loading_For_GamePlay() if (FAILED(m_pGameInstance->Add_Prototype(g_iStaticLevel, CBuildingContainer::Create(m_pDevice, m_pContext)))) return E_FAIL; + /* For.Prototype_GameObject_CStreetContainer */ + if (FAILED(m_pGameInstance->Add_Prototype(g_iStaticLevel, CStreetContainer::Create(m_pDevice, m_pContext)))) + return E_FAIL; + /* For.Prototype_GameObject_CMapObject_Render */ if (FAILED(m_pGameInstance->Add_Prototype(g_iStaticLevel, CMapObject_Render::Create(m_pDevice, m_pContext)))) return E_FAIL; diff --git a/Jusin154_Team3D/Client/Private/MapInfo.cpp b/Jusin154_Team3D/Client/Private/MapInfo.cpp index ca6e5880e..29dfa63a4 100644 --- a/Jusin154_Team3D/Client/Private/MapInfo.cpp +++ b/Jusin154_Team3D/Client/Private/MapInfo.cpp @@ -3,6 +3,7 @@ #include "GameInstance.h" #include "InfoInstance.h" #include "BuildingContainer.h" +#include "StreetContainer.h" #include "MAPPartObject.h" #include "MapObject_Render.h" #include "MapObject_Collision.h" @@ -40,123 +41,28 @@ HRESULT CMapInfo::Load_MapObjects(const _char* pFileName) for (auto* Container = root->FirstChildElement("Container"); Container; Container = Container->NextSiblingElement("Container")) { const _char* pName = {}; - + _uint iMapContainerType = {}; Container->QueryStringAttribute("Name", &pName); -#pragma region ADD_CONTAINER_OBJECT + Container->QueryUnsignedAttribute("MapContainerType", &iMapContainerType); - CBuildingContainer* pContainerObject = { nullptr }; - CMapContainer::MAP_CONTAINER_DESC ContainerDesc = {}; + CMapContainer* pContainerObject = nullptr; - auto* ContainerPosition = Container->FirstChildElement("Position"); - ContainerPosition->QueryFloatAttribute("x", &ContainerDesc.vPosition.x); - ContainerPosition->QueryFloatAttribute("y", &ContainerDesc.vPosition.y); - ContainerPosition->QueryFloatAttribute("z", &ContainerDesc.vPosition.z); - - auto* ContainerScale = Container->FirstChildElement("Scale"); - ContainerScale->QueryFloatAttribute("x", &ContainerDesc.vScale.x); - ContainerScale->QueryFloatAttribute("y", &ContainerDesc.vScale.y); - ContainerScale->QueryFloatAttribute("z", &ContainerDesc.vScale.z); - - auto* ContainerRotation = Container->FirstChildElement("Rotation"); - ContainerRotation->QueryFloatAttribute("x", &ContainerDesc.vRotation.x); - ContainerRotation->QueryFloatAttribute("y", &ContainerDesc.vRotation.y); - ContainerRotation->QueryFloatAttribute("z", &ContainerDesc.vRotation.z); - - m_pGameInstance->Add_GameObject_ToLayer( - g_iStaticLevel, ENUM_CLASS(LEVEL::GAMEPLAY), LAYER_BACKGROUND, &ContainerDesc, nullptr, &pContainerObject); -#pragma endregion - -#pragma region ADD_PARTOBJECT - for (auto* PartObject = Container->FirstChildElement("PartObject"); PartObject; PartObject = PartObject->NextSiblingElement("PartObject")) + if (0 == iMapContainerType) { - _uint iLodLevel = {}; - _uint iKeyIndex = {}; - - PartObject->QueryUnsignedAttribute("Lod_Level", &iLodLevel); - PartObject->QueryUnsignedAttribute("Key_Index", &iKeyIndex); - -#pragma region MAPOBJECT_RENDER - CMapPartObject::MAPOBJECT_DESC Desc = {}; - string strTag = {}; - for (auto* PrototypeTag = PartObject->FirstChildElement("PrototypeTag"); PrototypeTag; PrototypeTag = PrototypeTag->NextSiblingElement("PrototypeTag")) - { - strTag = PrototypeTag->GetText(); - - Desc.ModelPrototypeTags.push_back(CMyTools::ToWstring(strTag)); - } - - Desc.iMaxLodLevel = iLodLevel; - Desc.pParentTransform = pContainerObject->Get_Component(); - const string strKey = CMyTools::ToString(Desc.ModelPrototypeTags.front()) + to_string(iKeyIndex); - - /* Position */ - tinyxml2::XMLElement* Position = PartObject->FirstChildElement("Position"); - Position->QueryFloatAttribute("x", &Desc.vPosition.x); - Position->QueryFloatAttribute("y", &Desc.vPosition.y); - Position->QueryFloatAttribute("z", &Desc.vPosition.z); - - /* Scale */ - tinyxml2::XMLElement* Scale = PartObject->FirstChildElement("Scale"); - Scale->QueryFloatAttribute("x", &Desc.vScale.x); - Scale->QueryFloatAttribute("y", &Desc.vScale.y); - Scale->QueryFloatAttribute("z", &Desc.vScale.z); - - /* Rotation */ - tinyxml2::XMLElement* Rotation = PartObject->FirstChildElement("Rotation"); - Rotation->QueryFloatAttribute("x", &Desc.vRotation.x); - Rotation->QueryFloatAttribute("y", &Desc.vRotation.y); - Rotation->QueryFloatAttribute("z", &Desc.vRotation.z); - - if (FAILED(pContainerObject->Add_Part(strKey, g_iStaticLevel, nullptr, &Desc))) - return E_FAIL; - -#pragma endregion - + Load_BuildingContainer(Container, &pContainerObject); } -#pragma endregion - -#pragma region ADD_COLLISION - for (auto* Collision = Container->FirstChildElement("Collision"); Collision; Collision = Collision->NextSiblingElement("Collision")) + else if (1 == iMapContainerType) { - _uint iLodLevel = {}; - _uint iKeyIndex = {}; - - Collision->QueryUnsignedAttribute("Lod_Level", &iLodLevel); - Collision->QueryUnsignedAttribute("Key_Index", &iKeyIndex); - -#pragma region MAPOBJECT_LOD - CMapPartObject::MAPOBJECT_DESC Desc = {}; - string strTag = {}; - for (auto* PrototypeTag = Collision->FirstChildElement("PrototypeTag"); PrototypeTag; PrototypeTag = PrototypeTag->NextSiblingElement("PrototypeTag")) - { - Desc.ModelPrototypeTags.push_back(CMyTools::ToWstring(PrototypeTag->GetText())); - } - Desc.iMaxLodLevel = iLodLevel; - Desc.pParentTransform = pContainerObject->Get_Component(); - - /* Position */ - tinyxml2::XMLElement* Position = Collision->FirstChildElement("Position"); - Position->QueryFloatAttribute("x", &Desc.vPosition.x); - Position->QueryFloatAttribute("y", &Desc.vPosition.y); - Position->QueryFloatAttribute("z", &Desc.vPosition.z); - - /* Scale */ - tinyxml2::XMLElement* Scale = Collision->FirstChildElement("Scale"); - Scale->QueryFloatAttribute("x", &Desc.vScale.x); - Scale->QueryFloatAttribute("y", &Desc.vScale.y); - Scale->QueryFloatAttribute("z", &Desc.vScale.z); - - /* Rotation */ - tinyxml2::XMLElement* Rotation = Collision->FirstChildElement("Rotation"); - Rotation->QueryFloatAttribute("x", &Desc.vRotation.x); - Rotation->QueryFloatAttribute("y", &Desc.vRotation.y); - Rotation->QueryFloatAttribute("z", &Desc.vRotation.z); - - pContainerObject->Add_Collision(g_iStaticLevel, &Desc); -#pragma endregion - + Load_StreetContainer(Container, &pContainerObject); } -#pragma endregion + else + return E_FAIL; + + if (FAILED(Load_MapRenderObjects(Container, pContainerObject))) + return E_FAIL; + + if (FAILED(Load_MapCollisionObjects(Container, pContainerObject))) + return E_FAIL; } for (auto* Object = root->FirstChildElement("Object"); Object; Object = Object->NextSiblingElement("Object")) @@ -201,6 +107,165 @@ HRESULT CMapInfo::Load_MapObjects(const _char* pFileName) return S_OK; } +HRESULT CMapInfo::Load_BuildingContainer(tinyxml2::XMLElement* Container, CMapContainer** ppContainerObject) +{ + CBuildingContainer::MAP_CONTAINER_DESC ContainerDesc = {}; + + auto* ContainerPosition = Container->FirstChildElement("Position"); + ContainerPosition->QueryFloatAttribute("x", &ContainerDesc.vPosition.x); + ContainerPosition->QueryFloatAttribute("y", &ContainerDesc.vPosition.y); + ContainerPosition->QueryFloatAttribute("z", &ContainerDesc.vPosition.z); + + auto* ContainerScale = Container->FirstChildElement("Scale"); + ContainerScale->QueryFloatAttribute("x", &ContainerDesc.vScale.x); + ContainerScale->QueryFloatAttribute("y", &ContainerDesc.vScale.y); + ContainerScale->QueryFloatAttribute("z", &ContainerDesc.vScale.z); + + auto* ContainerRotation = Container->FirstChildElement("Rotation"); + ContainerRotation->QueryFloatAttribute("x", &ContainerDesc.vRotation.x); + ContainerRotation->QueryFloatAttribute("y", &ContainerDesc.vRotation.y); + ContainerRotation->QueryFloatAttribute("z", &ContainerDesc.vRotation.z); + + auto* BoundingBox_Min = Container->FirstChildElement("BoundingBox_Min"); + BoundingBox_Min->QueryFloatAttribute("x", &ContainerDesc.vContainerMin.x); + BoundingBox_Min->QueryFloatAttribute("y", &ContainerDesc.vContainerMin.y); + BoundingBox_Min->QueryFloatAttribute("z", &ContainerDesc.vContainerMin.z); + + auto* BoundingBox_Max = Container->FirstChildElement("BoundingBox_Max"); + BoundingBox_Max->QueryFloatAttribute("x", &ContainerDesc.vContainerMax.x); + BoundingBox_Max->QueryFloatAttribute("y", &ContainerDesc.vContainerMax.y); + BoundingBox_Max->QueryFloatAttribute("z", &ContainerDesc.vContainerMax.z); + + m_pGameInstance->Add_GameObject_ToLayer( + g_iStaticLevel, ENUM_CLASS(LEVEL::GAMEPLAY), LAYER_BACKGROUND, &ContainerDesc, nullptr, reinterpret_cast(ppContainerObject)); + + return S_OK; +} + +HRESULT CMapInfo::Load_StreetContainer(tinyxml2::XMLElement* Container, CMapContainer** ppContainerObject) +{ + CMapContainer::MAP_CONTAINER_DESC ContainerDesc = {}; + + auto* ContainerPosition = Container->FirstChildElement("Position"); + ContainerPosition->QueryFloatAttribute("x", &ContainerDesc.vPosition.x); + ContainerPosition->QueryFloatAttribute("y", &ContainerDesc.vPosition.y); + ContainerPosition->QueryFloatAttribute("z", &ContainerDesc.vPosition.z); + + auto* ContainerScale = Container->FirstChildElement("Scale"); + ContainerScale->QueryFloatAttribute("x", &ContainerDesc.vScale.x); + ContainerScale->QueryFloatAttribute("y", &ContainerDesc.vScale.y); + ContainerScale->QueryFloatAttribute("z", &ContainerDesc.vScale.z); + + auto* ContainerRotation = Container->FirstChildElement("Rotation"); + ContainerRotation->QueryFloatAttribute("x", &ContainerDesc.vRotation.x); + ContainerRotation->QueryFloatAttribute("y", &ContainerDesc.vRotation.y); + ContainerRotation->QueryFloatAttribute("z", &ContainerDesc.vRotation.z); + + m_pGameInstance->Add_GameObject_ToLayer( + g_iStaticLevel, ENUM_CLASS(LEVEL::GAMEPLAY), LAYER_BACKGROUND, &ContainerDesc, nullptr, reinterpret_cast(ppContainerObject)); + + return S_OK; +} + +HRESULT CMapInfo::Load_MapRenderObjects(tinyxml2::XMLElement* Container, CMapContainer* pContainerObject) +{ +#pragma region ADD_PARTOBJECT + for (auto* PartObject = Container->FirstChildElement("PartObject"); PartObject; PartObject = PartObject->NextSiblingElement("PartObject")) + { + _uint iLodLevel = {}; + _uint iKeyIndex = {}; + + PartObject->QueryUnsignedAttribute("Lod_Level", &iLodLevel); + PartObject->QueryUnsignedAttribute("Key_Index", &iKeyIndex); + +#pragma region MAPOBJECT_RENDER + CMapPartObject::MAPOBJECT_DESC Desc = {}; + string strTag = {}; + for (auto* PrototypeTag = PartObject->FirstChildElement("PrototypeTag"); PrototypeTag; PrototypeTag = PrototypeTag->NextSiblingElement("PrototypeTag")) + { + strTag = PrototypeTag->GetText(); + + Desc.ModelPrototypeTags.push_back(CMyTools::ToWstring(strTag)); + } + + Desc.iMaxLodLevel = iLodLevel; + Desc.pParentTransform = pContainerObject->Get_Component(); + const string strKey = CMyTools::ToString(Desc.ModelPrototypeTags.front()) + to_string(iKeyIndex); + + /* Position */ + tinyxml2::XMLElement* Position = PartObject->FirstChildElement("Position"); + Position->QueryFloatAttribute("x", &Desc.vPosition.x); + Position->QueryFloatAttribute("y", &Desc.vPosition.y); + Position->QueryFloatAttribute("z", &Desc.vPosition.z); + + /* Scale */ + tinyxml2::XMLElement* Scale = PartObject->FirstChildElement("Scale"); + Scale->QueryFloatAttribute("x", &Desc.vScale.x); + Scale->QueryFloatAttribute("y", &Desc.vScale.y); + Scale->QueryFloatAttribute("z", &Desc.vScale.z); + + /* Rotation */ + tinyxml2::XMLElement* Rotation = PartObject->FirstChildElement("Rotation"); + Rotation->QueryFloatAttribute("x", &Desc.vRotation.x); + Rotation->QueryFloatAttribute("y", &Desc.vRotation.y); + Rotation->QueryFloatAttribute("z", &Desc.vRotation.z); + + if (FAILED(pContainerObject->Add_Part(strKey, g_iStaticLevel, nullptr, &Desc))) + return E_FAIL; +#pragma endregion + } + + return S_OK; +} + +HRESULT CMapInfo::Load_MapCollisionObjects(tinyxml2::XMLElement* Container, CMapContainer* pContainerObject) +{ +#pragma region ADD_COLLISION + for (auto* Collision = Container->FirstChildElement("Collision"); Collision; Collision = Collision->NextSiblingElement("Collision")) + { + _uint iLodLevel = {}; + _uint iKeyIndex = {}; + + Collision->QueryUnsignedAttribute("Lod_Level", &iLodLevel); + Collision->QueryUnsignedAttribute("Key_Index", &iKeyIndex); + +#pragma region MAPOBJECT_LOD + CMapPartObject::MAPOBJECT_DESC Desc = {}; + string strTag = {}; + for (auto* PrototypeTag = Collision->FirstChildElement("PrototypeTag"); PrototypeTag; PrototypeTag = PrototypeTag->NextSiblingElement("PrototypeTag")) + { + Desc.ModelPrototypeTags.push_back(CMyTools::ToWstring(PrototypeTag->GetText())); + } + Desc.iMaxLodLevel = iLodLevel; + Desc.pParentTransform = pContainerObject->Get_Component(); + + /* Position */ + tinyxml2::XMLElement* Position = Collision->FirstChildElement("Position"); + Position->QueryFloatAttribute("x", &Desc.vPosition.x); + Position->QueryFloatAttribute("y", &Desc.vPosition.y); + Position->QueryFloatAttribute("z", &Desc.vPosition.z); + + /* Scale */ + tinyxml2::XMLElement* Scale = Collision->FirstChildElement("Scale"); + Scale->QueryFloatAttribute("x", &Desc.vScale.x); + Scale->QueryFloatAttribute("y", &Desc.vScale.y); + Scale->QueryFloatAttribute("z", &Desc.vScale.z); + + /* Rotation */ + tinyxml2::XMLElement* Rotation = Collision->FirstChildElement("Rotation"); + Rotation->QueryFloatAttribute("x", &Desc.vRotation.x); + Rotation->QueryFloatAttribute("y", &Desc.vRotation.y); + Rotation->QueryFloatAttribute("z", &Desc.vRotation.z); + + pContainerObject->Add_Collision(g_iStaticLevel, &Desc); +#pragma endregion + + } +#pragma endregion + + return S_OK; +} + HRESULT CMapInfo::Initialize(ID3D11Device* pDevice, ID3D11DeviceContext* pContex) { m_pGameInstance = CGameInstance::GetInstance(); diff --git a/Jusin154_Team3D/Client/Private/StreetContainer.cpp b/Jusin154_Team3D/Client/Private/StreetContainer.cpp index e8573609c..5a2adf4cc 100644 --- a/Jusin154_Team3D/Client/Private/StreetContainer.cpp +++ b/Jusin154_Team3D/Client/Private/StreetContainer.cpp @@ -24,19 +24,12 @@ void CStreetContainer::Update(_float fTimeDelta) { __super::Update(fTimeDelta); - m_fCamDepth = XMVectorGetX(XMVector3Length(XMLoadFloat4(m_pGameInstance->Get_CamPosition()) - XMLoadFloat3(&m_vExtentPosition))); - for (auto& pCollisiton : m_ColiisonPartObjects) pCollisiton->Update(fTimeDelta); } void CStreetContainer::Late_Update(_float fTimeDelta) { - if (m_pOcclusionQueryCom->isDraw()) - __super::Late_Update(fTimeDelta); - - m_pGameInstance->Add_RenderGroup(RENDER::OCCLUSION, this); - __super::Late_Update(fTimeDelta); for (auto& pCollisiton : m_ColiisonPartObjects) @@ -48,45 +41,6 @@ HRESULT CStreetContainer::Render() return S_OK; } -HRESULT CStreetContainer::Render_BoundingBox() -{ - m_pOcclusionQueryCom->Begin_Query(); - - if (FAILED(m_pShaderCom->Bind_Matrix("g_WorldMatrix", &m_BoundingBoxWorldMatirx))) { - return E_FAIL; - } - - if (FAILED(m_pShaderCom->Bind_Matrix("g_ViewMatrix", m_pGameInstance->Get_Transform_Float4x4(D3DTS::VIEW)))) { - return E_FAIL; - } - if (FAILED(m_pShaderCom->Bind_Matrix("g_ProjMatrix", m_pGameInstance->Get_Transform_Float4x4(D3DTS::PROJ)))) { - return E_FAIL; - } - if (m_pGameInstance->Key_Pressing(DIK_Q)) - { - if (FAILED(m_pShaderCom->Begin(1))) - return E_FAIL; - } - else - { - if (FAILED(m_pShaderCom->Begin(0))) - return E_FAIL; - } - - if (FAILED(m_pShaderCom->Bind_RawValue("g_vRadius", &m_vExtentRadius, sizeof(_float3)))) - return E_FAIL; - - if (FAILED(m_pVIBufferCom->Bind_Resources())) - return E_FAIL; - - if (FAILED(m_pVIBufferCom->Render())) - return E_FAIL; - - m_pOcclusionQueryCom->End_Query(); - - return S_OK; -} - HRESULT CStreetContainer::Initialize_Prototype() { return S_OK; @@ -117,21 +71,6 @@ HRESULT CStreetContainer::Ready_Components(void* pArg) return E_FAIL; } - ///* Com_Shader */ - //if (FAILED(__super::Add_Asset_Component(g_iStaticLevel, FX_VTXPOS, - // reinterpret_cast(&m_pShaderCom)))) - // return E_FAIL; - - /* Com_Shader */ - if (FAILED(__super::Add_Asset_Component(g_iStaticLevel, TEXT("Prototype_Component_VIBuffer_Box"), - reinterpret_cast(&m_pVIBufferCom)))) - return E_FAIL; - - /* Com_OcclusionQuery */ - if (FAILED(__super::Add_Asset_Component(g_iStaticLevel, TEXT("Prototype_Component_OcclusionQuery"), - reinterpret_cast(&m_pOcclusionQueryCom)))) - return E_FAIL; - return S_OK; } @@ -170,10 +109,6 @@ void CStreetContainer::Free() { __super::Free(); - SAFE_RELEASE(m_pShaderCom); - SAFE_RELEASE(m_pVIBufferCom); - SAFE_RELEASE(m_pOcclusionQueryCom); - for (auto& pCollision : m_ColiisonPartObjects) SAFE_RELEASE(pCollision); } diff --git a/Jusin154_Team3D/Client/Public/BuildingContainer.h b/Jusin154_Team3D/Client/Public/BuildingContainer.h index d95386a94..81d97bc6b 100644 --- a/Jusin154_Team3D/Client/Public/BuildingContainer.h +++ b/Jusin154_Team3D/Client/Public/BuildingContainer.h @@ -3,10 +3,23 @@ #include "Client_Define.h" #include "MapContainer.h" +NS_BEGIN(Engine) +class CShader; +class CVIBuffer_Box; +class COcclusionQuery; +NS_END + NS_BEGIN(Client) -class CBuildingContainer final : public CMapContainer +class CBuildingContainer final : public CMapContainer // OCCLUSION CONTAINER { +public: + typedef struct tagMapContainerDesc : public CMapContainer::MAP_CONTAINER_DESC + { + _float3 vContainerMin; + _float3 vContainerMax; + }MAP_CONTAINER_DESC; + private: CBuildingContainer(ID3D11Device* pDevice, ID3D11DeviceContext* pContext); CBuildingContainer(const CBuildingContainer& rhs); @@ -17,25 +30,14 @@ class CBuildingContainer final : public CMapContainer virtual void Update(_float fTimeDelta) override; virtual void Late_Update(_float fTimeDelta) override; virtual HRESULT Render() override; + virtual HRESULT Render_BoundingBox() override; -public: - template - HRESULT Add_Part(const _string& strPartKey, _uint iPrototypeLevelIndex, T** ppOut, void* pArg = nullptr) { - return Add_PartObject(strPartKey, iPrototypeLevelIndex, ppOut, pArg); - } - template - HRESULT Add_Collision(_uint iPrototypeLevelIndex, void* pArg = nullptr) - { - T* pPartObject = m_pGameInstance->Clone_Prototype(iPrototypeLevelIndex, pArg, this); +private: + CShader* m_pShaderCom = { nullptr }; + CVIBuffer_Box* m_pVIBufferCom = { nullptr }; + COcclusionQuery* m_pOcclusionQueryCom = { nullptr }; - if (nullptr == pPartObject) { - return E_FAIL; - } - - m_ColiisonPartObjects.push_back(pPartObject); - - return S_OK; - } + _float3 m_vExtentWorldPosition = {}; private: virtual HRESULT Initialize_Prototype() override; diff --git a/Jusin154_Team3D/Client/Public/Client_Macro.h b/Jusin154_Team3D/Client/Public/Client_Macro.h index b37b639ab..df875b2d5 100644 --- a/Jusin154_Team3D/Client/Public/Client_Macro.h +++ b/Jusin154_Team3D/Client/Public/Client_Macro.h @@ -20,6 +20,7 @@ namespace Client { #define FX_INSTANCE_PROP_MODEL TEXT("FX_INSTANCE_PROP_MODEL") #define FX_UIEDITOR TEXT("FX_UIEDITOR") #define FX_UIINSTANCE TEXT("FX_UIINSTANCE") +#define FX_VTXPOS TEXT("FX_VTXPOS") #pragma endregion #pragma region MACRO_PROTOTYPE diff --git a/Jusin154_Team3D/Client/Public/MapContainer.h b/Jusin154_Team3D/Client/Public/MapContainer.h index fafc5b8d7..8ce40a7ec 100644 --- a/Jusin154_Team3D/Client/Public/MapContainer.h +++ b/Jusin154_Team3D/Client/Public/MapContainer.h @@ -26,6 +26,25 @@ class CMapContainer abstract : public CContainerObject virtual void Late_Update(_float fTimeDelta) override; virtual HRESULT Render() override; +public: + template + HRESULT Add_Part(const _string& strPartKey, _uint iPrototypeLevelIndex, T** ppOut, void* pArg = nullptr) { + return Add_PartObject(strPartKey, iPrototypeLevelIndex, ppOut, pArg); + } + template + HRESULT Add_Collision(_uint iPrototypeLevelIndex, void* pArg = nullptr) + { + T* pPartObject = m_pGameInstance->Clone_Prototype(iPrototypeLevelIndex, pArg, this); + + if (nullptr == pPartObject) { + return E_FAIL; + } + + m_ColiisonPartObjects.push_back(pPartObject); + + return S_OK; + } + protected: virtual HRESULT Initialize_Prototype() override; virtual HRESULT Initialize(void* pArg) override; diff --git a/Jusin154_Team3D/Client/Public/MapInfo.h b/Jusin154_Team3D/Client/Public/MapInfo.h index 0a3e4c98b..e81fc6bb4 100644 --- a/Jusin154_Team3D/Client/Public/MapInfo.h +++ b/Jusin154_Team3D/Client/Public/MapInfo.h @@ -18,7 +18,10 @@ class CMapInfo final : public CBase void Update(_float fTimeDelta); void Change_Level(); HRESULT Load_MapObjects(const _char* pFilePath); - + HRESULT Load_BuildingContainer(tinyxml2::XMLElement* Container, class CMapContainer** ppContainerObject); + HRESULT Load_StreetContainer(tinyxml2::XMLElement* Container, class CMapContainer** ppContainerObject); + HRESULT Load_MapRenderObjects(tinyxml2::XMLElement* Container, class CMapContainer* pContainerObject); + HRESULT Load_MapCollisionObjects(tinyxml2::XMLElement* Container, class CMapContainer* pContainerObject); private: CGameInstance* m_pGameInstance = { nullptr }; diff --git a/Jusin154_Team3D/Client/Public/StreetContainer.h b/Jusin154_Team3D/Client/Public/StreetContainer.h index 988f625ee..5bda61ca5 100644 --- a/Jusin154_Team3D/Client/Public/StreetContainer.h +++ b/Jusin154_Team3D/Client/Public/StreetContainer.h @@ -2,22 +2,11 @@ #include "Client_Define.h" #include "MapContainer.h" -NS_BEGIN(Engine) -class CShader; -class CVIBuffer_Box; -class COcclusionQuery; -NS_END NS_BEGIN(Client) -class CStreetContainer final : public CMapContainer +class CStreetContainer final : public CMapContainer // NON OCCLUSION CONTAINER { - typedef struct tagStreetContainerDesc : public MAP_CONTAINER_DESC - { - _float3 vExtentRadius = {}; - _float3 vExtentPosition = {}; - }STREET_CONTAINER_DESC; - private: CStreetContainer(ID3D11Device* pDevice, ID3D11DeviceContext* pContext); CStreetContainer(const CStreetContainer& rhs); @@ -28,36 +17,6 @@ class CStreetContainer final : public CMapContainer virtual void Update(_float fTimeDelta) override; virtual void Late_Update(_float fTimeDelta) override; virtual HRESULT Render() override; - virtual HRESULT Render_BoundingBox() override; - -public: - template - HRESULT Add_Part(const _string& strPartKey, _uint iPrototypeLevelIndex, T** ppOut, void* pArg = nullptr) { - return Add_PartObject(strPartKey, iPrototypeLevelIndex, ppOut, pArg); - } - template - HRESULT Add_Collision(_uint iPrototypeLevelIndex, void* pArg = nullptr) - { - T* pPartObject = m_pGameInstance->Clone_Prototype(iPrototypeLevelIndex, pArg, this); - - if (nullptr == pPartObject) { - return E_FAIL; - } - - m_ColiisonPartObjects.push_back(pPartObject); - - return S_OK; - } - -private: - CShader* m_pShaderCom = { nullptr }; - CVIBuffer_Box* m_pVIBufferCom = { nullptr }; - COcclusionQuery* m_pOcclusionQueryCom = { nullptr }; - - _float3 m_vExtentRadius = {}; - _float3 m_vExtentPosition = {}; - _float4x4 m_BoundingBoxWorldMatirx; - private: virtual HRESULT Initialize_Prototype() override; diff --git a/Jusin154_Team3D/Editor/Bin/Resources/Data/Map/ClientTest.xml b/Jusin154_Team3D/Editor/Bin/Resources/Data/Map/ClientTest.xml index 662897e10..23ec0d1e9 100644 --- a/Jusin154_Team3D/Editor/Bin/Resources/Data/Map/ClientTest.xml +++ b/Jusin154_Team3D/Editor/Bin/Resources/Data/Map/ClientTest.xml @@ -4,6 +4,9 @@ + + + Prototype_GameObject_SM_HM_Ollivanders_Railing_Post_A Prototype_GameObject_SM_HM_Ollivanders_Railing_Post_A_Lod1 @@ -366,6 +369,9 @@ + + + Prototype_GameObject_SM_HM_LowerHiStreet_Zonkos @@ -520,6 +526,9 @@ + + + Prototype_GameObject_SM_HM_Gatehouse_Bridge Prototype_GameObject_SM_HM_Gatehouse_Bridge_Lod1 @@ -716,6 +725,9 @@ + + + Prototype_GameObject_SM_HM_PlazaMain_A diff --git a/Jusin154_Team3D/Engine/Private/VIBuffer_Box.cpp b/Jusin154_Team3D/Engine/Private/VIBuffer_Box.cpp index a77b053f6..d2445d048 100644 --- a/Jusin154_Team3D/Engine/Private/VIBuffer_Box.cpp +++ b/Jusin154_Team3D/Engine/Private/VIBuffer_Box.cpp @@ -10,7 +10,24 @@ CVIBuffer_Box::CVIBuffer_Box(const CVIBuffer_Box& rhs) : CVIBuffer(rhs) { } -#ifdef EDITOR_PROJECT + +HRESULT CVIBuffer_Box::Update(_float3* pVertexDatas) +{ + D3D11_MAPPED_SUBRESOURCE SubResource{}; + m_pContext->Map(m_pVB, 0, D3D11_MAP_WRITE_DISCARD, 0, &SubResource); + + VTXPOS* pVertices = static_cast(SubResource.pData); + + for (_uint i = 0; i < m_iNumVertices; ++i) + { + memcpy(&pVertices[i].vPosition, &pVertexDatas[i], sizeof(_float3)); + } + + m_pContext->Unmap(m_pVB, 0); + + return S_OK; +} + HRESULT CVIBuffer_Box::Initialize_Prototype() { m_iNumVertexBuffers = 1; @@ -75,59 +92,25 @@ HRESULT CVIBuffer_Box::Initialize_Prototype() HRESULT CVIBuffer_Box::Initialize(void* pArg) { -#pragma region VTX_BUFFER - D3D11_BUFFER_DESC VBDesc{}; - VBDesc.ByteWidth = m_iVertexStride * m_iNumVertices; - VBDesc.Usage = D3D11_USAGE_DYNAMIC; - VBDesc.BindFlags = D3D11_BIND_VERTEX_BUFFER; - VBDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE; - VBDesc.MiscFlags = 0; - VBDesc.StructureByteStride = m_iVertexStride; - - VTXPOS* pVertices = new VTXPOS[m_iNumVertices]; - memset(pVertices, 0, sizeof(VTXPOS) * m_iNumVertices); - - pVertices[0].vPosition = _float3(-0.5f, 0.5f, -0.5f); - pVertices[1].vPosition = _float3(0.5f, 0.5f, -0.5f); - pVertices[2].vPosition = _float3(0.5f, -0.5f, -0.5f); - pVertices[3].vPosition = _float3(-0.5f, -0.5f, -0.5f); - pVertices[4].vPosition = _float3(-0.5f, 0.5f, 0.5f); - pVertices[5].vPosition = _float3(0.5f, 0.5f, 0.5f); - pVertices[6].vPosition = _float3(0.5f, -0.5f, 0.5f); - pVertices[7].vPosition = _float3(-0.5f, -0.5f, 0.5f); - - D3D11_SUBRESOURCE_DATA VBRes{}; - VBRes.pSysMem = pVertices; - - if (FAILED(m_pDevice->CreateBuffer(&VBDesc, &VBRes, &m_pVB))) { - return E_FAIL; - } - Safe_Delete_Array(pVertices); - -#pragma endregion - - return S_OK; -} - -HRESULT CVIBuffer_Box::Update(_float3* pVertexDatas) -{ - D3D11_MAPPED_SUBRESOURCE SubResource{}; - m_pContext->Map(m_pVB, 0, D3D11_MAP_WRITE_DISCARD, 0, &SubResource); - - VTXPOS* pVertices = static_cast(SubResource.pData); - - for (_uint i = 0; i < m_iNumVertices; ++i) + if (nullptr == pArg) { - memcpy(&pVertices[i].vPosition, &pVertexDatas[i], sizeof(_float3)); +#ifdef EDITOR_PROJECT + if(FAILED(Ready_VIBuffer_Editor())) + return E_FAIL; +#else + return E_FAIL; +#endif + } + else + { + if(FAILED(Ready_VIBuffer(pArg))) + return E_FAIL; } - - m_pContext->Unmap(m_pVB, 0); return S_OK; } -#else -HRESULT CVIBuffer_Box::Initialize(void* pArg) +HRESULT CVIBuffer_Box::Ready_VIBuffer(void* pArg) { _float3* pCorners = static_cast<_float3*>(pArg); @@ -165,7 +148,42 @@ HRESULT CVIBuffer_Box::Initialize(void* pArg) return S_OK; } +#ifdef EDITOR_PROJECT +HRESULT CVIBuffer_Box::Ready_VIBuffer_Editor() +{ +#pragma region VTX_BUFFER + D3D11_BUFFER_DESC VBDesc{}; + VBDesc.ByteWidth = m_iVertexStride * m_iNumVertices; + VBDesc.Usage = D3D11_USAGE_DYNAMIC; + VBDesc.BindFlags = D3D11_BIND_VERTEX_BUFFER; + VBDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE; + VBDesc.MiscFlags = 0; + VBDesc.StructureByteStride = m_iVertexStride; + VTXPOS* pVertices = new VTXPOS[m_iNumVertices]; + memset(pVertices, 0, sizeof(VTXPOS) * m_iNumVertices); + + pVertices[0].vPosition = _float3(-0.5f, 0.5f, -0.5f); + pVertices[1].vPosition = _float3(0.5f, 0.5f, -0.5f); + pVertices[2].vPosition = _float3(0.5f, -0.5f, -0.5f); + pVertices[3].vPosition = _float3(-0.5f, -0.5f, -0.5f); + pVertices[4].vPosition = _float3(-0.5f, 0.5f, 0.5f); + pVertices[5].vPosition = _float3(0.5f, 0.5f, 0.5f); + pVertices[6].vPosition = _float3(0.5f, -0.5f, 0.5f); + pVertices[7].vPosition = _float3(-0.5f, -0.5f, 0.5f); + + D3D11_SUBRESOURCE_DATA VBRes{}; + VBRes.pSysMem = pVertices; + + if (FAILED(m_pDevice->CreateBuffer(&VBDesc, &VBRes, &m_pVB))) { + return E_FAIL; + } + Safe_Delete_Array(pVertices); + +#pragma endregion + + return S_OK; +} #endif CVIBuffer_Box* CVIBuffer_Box::Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext) diff --git a/Jusin154_Team3D/Engine/Public/VIBuffer_Box.h b/Jusin154_Team3D/Engine/Public/VIBuffer_Box.h index e5aa9d67e..76003564a 100644 --- a/Jusin154_Team3D/Engine/Public/VIBuffer_Box.h +++ b/Jusin154_Team3D/Engine/Public/VIBuffer_Box.h @@ -11,18 +11,17 @@ class ENGINE_DLL CVIBuffer_Box final : CVIBuffer_Box(const CVIBuffer_Box& rhs); virtual ~CVIBuffer_Box() = default; -private: - virtual HRESULT Initialize_Prototype() override; -#ifdef EDITOR_PROJECT - virtual HRESULT Initialize(void* pArg) override; public: virtual HRESULT Update(_float3* pVertices); -#else private: + virtual HRESULT Initialize_Prototype() override; virtual HRESULT Initialize(void* pArg) override; -#endif // EDITOR_PROJECT - + + HRESULT Ready_VIBuffer(void* pArg); +#ifdef EDITOR_PROJECT + HRESULT Ready_VIBuffer_Editor(); +#endif public: static CVIBuffer_Box* Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext);