From b19671ad8e45e91b87dc8b6a0dddb3b47e0a423e Mon Sep 17 00:00:00 2001 From: JinhoBa <127280695+JinhoBa@users.noreply.github.com> Date: Tue, 11 Nov 2025 22:15:11 +0900 Subject: [PATCH] [add] MapTool Level [add] MapObject [add] MapObject Manager --- Jusin154_Team3D/Editor/Default/Editor.vcxproj | 8 + .../Editor/Default/Editor.vcxproj.filters | 61 ++- .../Editor/Private/Level_MapViewer.cpp | 12 +- Jusin154_Team3D/Editor/Private/Loader.cpp | 20 +- Jusin154_Team3D/Editor/Private/MapObject.cpp | 214 +++------- .../Editor/Private/MapObject_Manager.cpp | 374 +++++++++++++----- .../Editor/Public/Level_MapViewer.h | 2 +- Jusin154_Team3D/Editor/Public/MapObject.h | 37 +- .../Editor/Public/MapObject_Manager.h | 19 +- 9 files changed, 430 insertions(+), 317 deletions(-) diff --git a/Jusin154_Team3D/Editor/Default/Editor.vcxproj b/Jusin154_Team3D/Editor/Default/Editor.vcxproj index ab2d009b2..2fa1ba95d 100644 --- a/Jusin154_Team3D/Editor/Default/Editor.vcxproj +++ b/Jusin154_Team3D/Editor/Default/Editor.vcxproj @@ -153,6 +153,7 @@ + @@ -163,8 +164,11 @@ + + + @@ -210,6 +214,7 @@ + @@ -220,8 +225,11 @@ + + + diff --git a/Jusin154_Team3D/Editor/Default/Editor.vcxproj.filters b/Jusin154_Team3D/Editor/Default/Editor.vcxproj.filters index 5d5cb53ea..9239be701 100644 --- a/Jusin154_Team3D/Editor/Default/Editor.vcxproj.filters +++ b/Jusin154_Team3D/Editor/Default/Editor.vcxproj.filters @@ -145,9 +145,6 @@ {44a3ddc2-3993-48d6-840c-3da09daeab70} - - {584466e9-fe1a-4a7d-a4ba-54d62ee1a7c1} - {943a760b-2861-45b7-87b8-462e1309c172} @@ -166,6 +163,24 @@ {15a9dfe7-f3f7-4906-8bd4-91734f4ddc92} + + {584466e9-fe1a-4a7d-a4ba-54d62ee1a7c1} + + + {d925c13c-6d66-4632-8bef-172baa566920} + + + {9643531b-3b64-4a3b-9ba7-e372b4e4ddba} + + + {702dfe26-f6b0-4aa0-b8d5-79385c0191d1} + + + {bc80fcba-1ebd-497c-a40d-973e44ad3ef8} + + + {34fa4d78-8091-44cf-b4b4-59db9fd56d98} + @@ -303,14 +318,11 @@ 01.Level\30.MapViewer - - 02.GameObjects\Env - 02.GameObjects\Terrain - 02.GameObjects\Env\Manger + 02.GameObjects\Env\00.Manger 01.Level\60.PhysXLab @@ -327,6 +339,21 @@ 02.GameObjects\Dummys\DummyObject + + 02.GameObjects\Env\01.MapContainer + + + 02.GameObjects\Env\01.MapContainer\BuildingContainer + + + 02.GameObjects\Env\02.MapObject + + + 02.GameObjects\Env\02.MapObject\Static + + + 02.GameObjects\Env\02.MapObject\LOD + @@ -445,14 +472,11 @@ 01.Level\30.MapViewer - - 02.GameObjects\Env - 02.GameObjects\Terrain - 02.GameObjects\Env\Manger + 02.GameObjects\Env\00.Manger 01.Level\60.PhysXLab @@ -484,6 +508,21 @@ 02.GameObjects\Dummys\DummyObject + + 02.GameObjects\Env\01.MapContainer + + + 02.GameObjects\Env\01.MapContainer\BuildingContainer + + + 02.GameObjects\Env\02.MapObject + + + 02.GameObjects\Env\02.MapObject\Static + + + 02.GameObjects\Env\02.MapObject\LOD + diff --git a/Jusin154_Team3D/Editor/Private/Level_MapViewer.cpp b/Jusin154_Team3D/Editor/Private/Level_MapViewer.cpp index 6b69a4dbc..6b52cdbb3 100644 --- a/Jusin154_Team3D/Editor/Private/Level_MapViewer.cpp +++ b/Jusin154_Team3D/Editor/Private/Level_MapViewer.cpp @@ -6,6 +6,7 @@ #include "DebugCamera.h" #include "Terrain.h" #include "MapObject_Manager.h" +#include "BuildingContainer.h" CLevel_MapViewer::CLevel_MapViewer(ID3D11Device* pDevice, ID3D11DeviceContext* pContext, LEVEL eLevelID) : CLevel{ pDevice, pContext, ENUM_CLASS(eLevelID) } @@ -38,7 +39,7 @@ HRESULT CLevel_MapViewer::Initialize() return E_FAIL; } - if (FAILED(Ready_Layer_MapObjects(TEXT("Layer_MapObject")))) { + if (FAILED(Ready_Layer_BuildingContainer(TEXT("Layer_Building")))) { return E_FAIL; } @@ -92,13 +93,10 @@ HRESULT CLevel_MapViewer::Ready_Layer_Terrain(const _wstring& strLayerTag) return S_OK; } -HRESULT CLevel_MapViewer::Ready_Layer_MapObjects(const _wstring& strLayerTag) +HRESULT CLevel_MapViewer::Ready_Layer_BuildingContainer(const _wstring& strLayerTag) { - //CMapObject::MAPOBJECT_DESC Desc = {}; - //Desc.pModelPrototypeTag = TEXT("Prototype_GameObject_SM_HW_ClockTower_Courtyard_BaseWall_A"); - - //if (FAILED(m_pGameInstance->Add_GameObject_ToLayer(g_iStaticLevel, NEXT_LEVEL,strLayerTag, &Desc))) - // return E_FAIL; + if (FAILED(m_pGameInstance->Add_GameObject_ToLayer(g_iStaticLevel, NEXT_LEVEL, strLayerTag))) + return E_FAIL; return S_OK; } diff --git a/Jusin154_Team3D/Editor/Private/Loader.cpp b/Jusin154_Team3D/Editor/Private/Loader.cpp index dee279c41..dbf95ca29 100644 --- a/Jusin154_Team3D/Editor/Private/Loader.cpp +++ b/Jusin154_Team3D/Editor/Private/Loader.cpp @@ -47,7 +47,9 @@ #pragma region MAP_HEADER #include "VIBuffer_Terrain.h" #include "Terrain.h" -#include "MapObject.h" +#include "BuildingContainer.h" +#include "MapObject_Static.h" +#include "MapObject_LOD.h" #include "MapObject_Manager.h" #pragma endregion @@ -676,9 +678,9 @@ HRESULT CLoader::Loading_For_MapViewer() _wstring strFileName = L"Prototype_GameObject_" + file.path().stem().wstring(); - /*For Prototype_Component_Model_Auro*/ + /*For Prototype_Component_Model_*/ if (FAILED(m_pGameInstance->Add_Asset_Prototype(g_iStaticLevel, strFileName, - CModel::Create(m_pDevice, m_pContext, szFilePath, MODEL::ENVIROMENT, XMMatrixIdentity(), 0)))) + CModel::Create(m_pDevice, m_pContext,szFilePath, MODEL::ENVIROMENT, XMMatrixIdentity(), 0)))) return E_FAIL; ModelPrototypeTags.push_back(strFileName); @@ -694,8 +696,16 @@ HRESULT CLoader::Loading_For_MapViewer() CVIBuffer_Terrain::Create(m_pDevice, m_pContext, nullptr, 100, 100)))) return E_FAIL; - /* For.Prototype_GameObject_MapObject */ - if (FAILED(m_pGameInstance->Add_Prototype(g_iStaticLevel, CMapObject::Create(m_pDevice, m_pContext)))) + /* For.Prototype_GameObject_BuildingContainer */ + if (FAILED(m_pGameInstance->Add_Prototype(g_iStaticLevel, CBuildingContainer::Create(m_pDevice, m_pContext)))) + return E_FAIL; + + /* For.Prototype_GameObject_MapObject_Static */ + if (FAILED(m_pGameInstance->Add_Prototype(g_iStaticLevel, CMapObject_Static::Create(m_pDevice, m_pContext)))) + return E_FAIL; + + /* For.Prototype_GameObject_MapObject_LOD */ + if (FAILED(m_pGameInstance->Add_Prototype(g_iStaticLevel, CMapObject_LOD::Create(m_pDevice, m_pContext)))) return E_FAIL; /* For.Prototype_GameObject_Terrain */ diff --git a/Jusin154_Team3D/Editor/Private/MapObject.cpp b/Jusin154_Team3D/Editor/Private/MapObject.cpp index ace0588d0..1385f0f6c 100644 --- a/Jusin154_Team3D/Editor/Private/MapObject.cpp +++ b/Jusin154_Team3D/Editor/Private/MapObject.cpp @@ -4,45 +4,20 @@ #include "GameInstance.h" #include "DebugCamera.h" #include "Layer.h" -//#include "Terrain.h" +#include "Terrain.h" +#include "VIBuffer_Terrain.h" CMapObject::CMapObject(ID3D11Device * pDevice, ID3D11DeviceContext * pContext) - : CGameObject(pDevice, pContext) + : CPartObject(pDevice, pContext) { } CMapObject::CMapObject(const CMapObject& Prototype) - : CGameObject(Prototype) + : CPartObject(Prototype) { } -HRESULT CMapObject::Initialize_Prototype() -{ - return S_OK; -} -HRESULT CMapObject::Initialize(void* pArg) -{ - MAPOBJECT_DESC* pDesc = static_cast(pArg); - - m_strModelPrototypeTag = pDesc->pModelPrototypeTag; - - if (FAILED(__super::Initialize(pArg))) - return E_FAIL; - - if (FAILED(Ready_Components())) - return E_FAIL; - - -#ifdef _DEBUG - m_bSelected = false; - m_vPosition = _float3(0.f, 0.f, 0.f); - m_vRotation = _float3(0.f, 0.f, 0.f); - m_vScale = _float3(1.f, 1.f, 1.f); -#endif // _DEBUG - - return S_OK; -} void CMapObject::Priority_Update(_float fTimeDelta) { @@ -53,15 +28,20 @@ void CMapObject::Priority_Update(_float fTimeDelta) void CMapObject::Update(_float fTimeDelta) { -#ifdef _DEBUG - m_pTransformCom->Set_State(STATE::POSITION, XMVectorSetW(XMLoadFloat3(&m_vPosition), 1.f)); - m_pTransformCom->Set_Scale(m_vScale); - m_pTransformCom->Rotation(XMConvertToRadians(m_vRotation.x), XMConvertToRadians(m_vRotation.y), XMConvertToRadians(m_vRotation.z)); -#endif + } void CMapObject::Late_Update(_float fTimeDelta) { +#ifdef _DEBUG + if(m_bSelected) + { + m_pTransformCom->Set_State(STATE::POSITION, XMVectorSetW(XMLoadFloat3(&m_vPosition), 1.f)); + m_pTransformCom->Set_Scale(m_vScale); + m_pTransformCom->Rotation(XMConvertToRadians(m_vRotation.x), XMConvertToRadians(m_vRotation.y), XMConvertToRadians(m_vRotation.z)); + } +#endif + _float4 vPos; XMStoreFloat4(&vPos, Get_WorldPostion()); m_pGameInstance->Add_RenderGroup(RENDER::NONBLEND, this, vPos, 20.f); @@ -73,25 +53,53 @@ HRESULT CMapObject::Render() return E_FAIL; } - _uint iNumMeshes = m_pModelCom->Get_NumMeshes(); + //_uint iNumMeshes = m_pModelCom->Get_NumMeshes(); - for (_uint i = 0; i < iNumMeshes; i++) - { - if (FAILED(m_pModelCom->Bind_Material(i, m_pShaderCom, "g_DiffuseTexture", aiTextureType_DIFFUSE, 0))) { - return E_FAIL; - } - if (FAILED(m_pModelCom->Bind_Material(i, m_pShaderCom, "g_NormalTexture", aiTextureType_NORMALS, 0))) { - return E_FAIL; - } + //for (_uint i = 0; i < iNumMeshes; i++) + //{ + // if (FAILED(m_pModelCom->Bind_Material(i, m_pShaderCom, "g_DiffuseTexture", aiTextureType_DIFFUSE, 0))) { + // return E_FAIL; + // } + // if (FAILED(m_pModelCom->Bind_Material(i, m_pShaderCom, "g_NormalTexture", aiTextureType_NORMALS, 0))) { + // return E_FAIL; + // } - if (FAILED(m_pShaderCom->Begin(ENUM_CLASS(SHADER_PASS_MESH::DEFAULT)))) { - return E_FAIL; - } + // if (FAILED(m_pShaderCom->Begin(ENUM_CLASS(SHADER_PASS_MESH::DEFAULT)))) { + // return E_FAIL; + // } - if (FAILED(m_pModelCom->Render(i))) { - return E_FAIL; - } - } + // if (FAILED(m_pModelCom->Render(i))) { + // return E_FAIL; + // } + //} + + return S_OK; +} + +_wstring CMapObject::Get_PrototypeTag(_uint iLodIndex) +{ + return _wstring(); +} + +HRESULT CMapObject::Initialize_Prototype() +{ + return S_OK; +} + +HRESULT CMapObject::Initialize(void* pArg) +{ + if (FAILED(__super::Initialize(pArg))) + return E_FAIL; + + if (FAILED(Ready_Components())) + return E_FAIL; + +#ifdef _DEBUG + m_bSelected = false; + m_vPosition = _float3(0.f, 0.f, 0.f); + m_vRotation = _float3(0.f, 0.f, 0.f); + m_vScale = _float3(1.f, 1.f, 1.f); +#endif // _DEBUG return S_OK; } @@ -100,126 +108,20 @@ HRESULT CMapObject::Ready_Components() { __super::Ready_Components(nullptr); - /* Com_Model */ - if (FAILED(__super::Add_Asset_Component(g_iStaticLevel, m_strModelPrototypeTag, - reinterpret_cast(&m_pModelCom)))) - return E_FAIL; - - /* Com_Shader */ - if (FAILED(__super::Add_Asset_Component(g_iStaticLevel, FX_MESH, - reinterpret_cast(&m_pShaderCom)))) - return E_FAIL; - return S_OK; } HRESULT CMapObject::Bind_ShaderResources() { - if (FAILED(m_pTransformCom->Bind_ShaderResource(m_pShaderCom, "g_WorldMatrix"))) { - 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->Bind_RawValue("g_fFar", m_pGameInstance->Get_CurrentCameraFar(), sizeof(_float)))) { - return E_FAIL; - } - //if (FAILED(m_pShaderCom->Bind_RawValue("g_vCamPosition", m_pGameInstance->Get_CamPosition(), sizeof(_float4)))) { - // return E_FAIL; - //} - //if (FAILED(m_pShaderCom->Bind_RawValue("g_bRimLight", &m_bRimLight, sizeof(_bool)))) { - // return E_FAIL; - //} - //if (FAILED(m_pShaderCom->Bind_RawValue("g_fRimStrength", &m_fRimLightStrength, sizeof(_float)))) { - // return E_FAIL; - //} - //if (FAILED(m_pShaderCom->Bind_RawValue("g_fRimPower", &m_fRimLightPower, sizeof(_float)))) { - // return E_FAIL; - //} - //if (FAILED(m_pShaderCom->Bind_RawValue("g_vRimColor", &m_vRimLightColor, sizeof(_float3)))) { - // return E_FAIL; - //} return S_OK; } -CMapObject* CMapObject::Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext) -{ - CMapObject* pInstance = new CMapObject(pDevice, pContext); - - if (FAILED(pInstance->Initialize_Prototype())) - { - MSG_BOX("Failed to Created : CMapObject"); - Safe_Release(pInstance); - } - - return pInstance; -} - -CGameObject* CMapObject::Clone(void* pArg, CGameObject* pOwner) -{ - CMapObject* pInstance = new CMapObject(*this); - - if (FAILED(pInstance->Initialize(pArg))) - { - MSG_BOX("Failed to Cloned : CMapObject"); - Safe_Release(pInstance); - } - - return pInstance; -} void CMapObject::Free() { __super::Free(); - - Safe_Release(m_pShaderCom); - Safe_Release(m_pModelCom); } void CMapObject::Describe_Entity() { - if (m_bDead) - return; - if (nullptr == m_pGameInstance) - return; - - ImGui::Text(CMyTools::ToString(m_strModelPrototypeTag).c_str()); - ImGui::Text("----- Transfrom ----"); - ImGui::InputFloat("X##Position", &m_vPosition.x, 1.f, 10.f); - ImGui::InputFloat("Y##Position", &m_vPosition.y, 0.1f, 1.f); - ImGui::InputFloat("Z##Position", &m_vPosition.z, 1.f, 10.f); - - if (m_pGameInstance->Mouse_Down(DIM_4)) - { - /*CTerrain* pTerrain = m_pGameInstance->Get_Layer(ENUM_CLASS(LEVEL::MAP), TEXT("Layer_Terrain"))->Get_Object(); - if (nullptr != pTerrain) - { - pTerrain->Get_Component()->Picking(pTerrain->Get_Component(), m_vPosition); - }*/ - - } - - ImGui::Text("----- Rotation ----"); - ImGui::InputFloat("X##Rotation", &m_vRotation.x, 10.f, 45.f); - ImGui::InputFloat("Y##Rotation", &m_vRotation.y, 10.f, 45.f); - ImGui::InputFloat("Z##Rotation", &m_vRotation.z, 10.f, 45.f); - - ImGui::Text("----- Scale ----"); - ImGui::InputFloat("X##Scale", &m_vScale.x, 0.1f, 1.f); - ImGui::InputFloat("Y##Scale", &m_vScale.y, 0.1f, 1.f); - ImGui::InputFloat("Z##Scale", &m_vScale.z, 0.1f, 1.f); - - m_vScale.x = max(0.01f, m_vScale.x); - m_vScale.y = max(0.01f, m_vScale.y); - m_vScale.z = max(0.01f, m_vScale.z); - - - if (ImGui::Button("Delete")) - m_bDead = true; - - m_bSelected = true; } \ No newline at end of file diff --git a/Jusin154_Team3D/Editor/Private/MapObject_Manager.cpp b/Jusin154_Team3D/Editor/Private/MapObject_Manager.cpp index 65acf60aa..19ac803a6 100644 --- a/Jusin154_Team3D/Editor/Private/MapObject_Manager.cpp +++ b/Jusin154_Team3D/Editor/Private/MapObject_Manager.cpp @@ -5,6 +5,9 @@ #include "DebugCamera.h" #include "Layer.h" #include "MapObject.h" +#include "MapObject_LOD.h" +#include "MapObject_Static.h" +#include "BuildingContainer.h" CMapObject_Manager::CMapObject_Manager(ID3D11Device * pDevice, ID3D11DeviceContext * pContext) @@ -12,15 +15,25 @@ CMapObject_Manager::CMapObject_Manager(ID3D11Device * pDevice, ID3D11DeviceConte { } -CMapObject_Manager::CMapObject_Manager(const CMapObject_Manager& Prototype) - : CGameObject(Prototype) - , m_ModelPrototypeTags{ Prototype.m_ModelPrototypeTags } +CMapObject_Manager::CMapObject_Manager(const CMapObject_Manager& rhs) + : CGameObject(rhs) + , m_ModelPrototypeTags{ rhs.m_ModelPrototypeTags } + , m_LODModelPrototypeTags{ rhs.m_LODModelPrototypeTags } { } HRESULT CMapObject_Manager::Initialize_Prototype(vector<_wstring>& ModelPrototypeTags) { - m_ModelPrototypeTags = ModelPrototypeTags; + for (auto& Tag : ModelPrototypeTags) + { + if (_wstring::npos != Tag.find(L"Lod")) + { + m_LODModelPrototypeTags.push_back(Tag); + } + + m_ModelPrototypeTags.push_back(Tag); + + } return S_OK; } @@ -30,7 +43,9 @@ HRESULT CMapObject_Manager::Initialize(void* pArg) if (FAILED(__super::Initialize(pArg))) return E_FAIL; + m_pContainer = m_pGameInstance->Get_Layer(ENUM_CLASS(LEVEL::MAP), TEXT("Layer_Building"))->Get_Object(); + SAFE_ADDREF(m_pContainer); return S_OK; } @@ -42,68 +57,20 @@ void CMapObject_Manager::Priority_Update(_float fTimeDelta) void CMapObject_Manager::Update(_float fTimeDelta) { - GUI::Begin("Model Prototype List"); + GUI::Begin("File"); - for (auto& Tag : m_ModelPrototypeTags) + if (GUI::Button("Save_XML")) { - if (ImGui::Button(CMyTools::ToString(Tag).c_str())) - { - CMapObject::MAPOBJECT_DESC Desc = {}; - Desc.pModelPrototypeTag = Tag.c_str(); - - if (FAILED(m_pGameInstance->Add_GameObject_ToLayer(g_iStaticLevel, ENUM_CLASS(LEVEL::MAP), TEXT("Layer_MapObject"), &Desc))) - { - }; - - } + Save_MapData("Test"); } GUI::End(); - CLayer* pLayer = m_pGameInstance->Get_Layer(ENUM_CLASS(LEVEL::MAP), TEXT("Layer_MapObject")); + Update_PrototypeList(); - if (nullptr == pLayer) - return; + Update_ObjectList(); - m_pMapObjects = pLayer->Get_Objects(); - - GUI::Begin("MapObject List"); - - _uint iObjectIndex = {}; - string strSrc; - - if (nullptr != m_pMapObjects) - { - for (auto pMapObject : (*m_pMapObjects)) - { - CMapObject* pCurrentMapObject = static_cast(pMapObject); - - if (nullptr == pCurrentMapObject) - continue; - - wstring strPrototypeTag = pCurrentMapObject->Get_PrototypeTag(); - - strSrc = CMyTools::ToString(strPrototypeTag) + to_string(iObjectIndex) + "##" + to_string(iObjectIndex++); - - if (ImGui::Button(strSrc.c_str())) - { - m_pSelectObject = pCurrentMapObject; - } - } - } - - GUI::End(); - - GUI::Begin("Edit"); - - if (nullptr != m_pSelectObject) - { - m_pSelectObject->Describe_Entity(); - if (m_pSelectObject->isDead()) - m_pSelectObject = nullptr; - } - - GUI::End(); + Update_Edit(); } @@ -129,77 +96,265 @@ HRESULT CMapObject_Manager::Bind_ShaderResources() HRESULT CMapObject_Manager::Save_MapData(const _char* pFileName) { - const list* pObjectList = m_pGameInstance->Get_Layer(ENUM_CLASS(LEVEL::MAP), TEXT("Layer_MapObject"))->Get_Objects(); + //const list* pObjectList = m_pGameInstance->Get_Layer(ENUM_CLASS(LEVEL::MAP), TEXT("Layer_MapObject"))->Get_Objects(); - if (nullptr == pObjectList) - return E_FAIL; + //if (nullptr == pObjectList) + // return E_FAIL; - tinyxml2::XMLDocument doc; + //tinyxml2::XMLDocument doc; - doc.InsertFirstChild(doc.NewDeclaration()); + //doc.InsertFirstChild(doc.NewDeclaration()); - tinyxml2::XMLElement* land = doc.NewElement("Land"); - doc.InsertEndChild(land); + //tinyxml2::XMLElement* land = doc.NewElement("Land"); + //doc.InsertEndChild(land); - for (auto& pObjcet : *pObjectList) - { - CMapObject* pMapObject = dynamic_cast(pObjcet); + //for (auto& pObjcet : *pObjectList) + //{ + // CMapObject* pMapObject = dynamic_cast(pObjcet); - if (nullptr == pMapObject) - continue; + // if (nullptr == pMapObject) + // continue; - // - tinyxml2::XMLElement* model = doc.NewElement("Model"); - land->InsertEndChild(model); + // // + // tinyxml2::XMLElement* model = doc.NewElement("Model"); + // land->InsertEndChild(model); - // 텍스트 - tinyxml2::XMLElement* proto = doc.NewElement("PrototypeTag"); - proto->SetText(CMyTools::ToString(pMapObject->Get_PrototypeTag()).c_str()); - model->InsertEndChild(proto); + // // 텍스트 + // tinyxml2::XMLElement* proto = doc.NewElement("PrototypeTag"); + // proto->SetText(CMyTools::ToString(pMapObject->Get_PrototypeTag()).c_str()); + // model->InsertEndChild(proto); - // - tinyxml2::XMLElement* PositionElem = doc.NewElement("Position"); + // // + // tinyxml2::XMLElement* PositionElem = doc.NewElement("Position"); - _float3 vPosition = {}; - XMStoreFloat3(&vPosition, pMapObject->Get_WorldPostion()); - - PositionElem->SetAttribute("x", vPosition.x); - PositionElem->SetAttribute("y", vPosition.y); - PositionElem->SetAttribute("z", vPosition.z); - model->InsertEndChild(PositionElem); + // _float3 vPosition = {}; + // XMStoreFloat3(&vPosition, pMapObject->Get_WorldPostion()); + // + // PositionElem->SetAttribute("x", vPosition.x); + // PositionElem->SetAttribute("y", vPosition.y); + // PositionElem->SetAttribute("z", vPosition.z); + // model->InsertEndChild(PositionElem); - // - tinyxml2::XMLElement* ScaleElem = doc.NewElement("Scale"); + // // + // tinyxml2::XMLElement* ScaleElem = doc.NewElement("Scale"); - _float3 pScale = pMapObject->Get_Component()->Get_Scale(); - ScaleElem->SetAttribute("x", pScale.x); - ScaleElem->SetAttribute("y", pScale.y); - ScaleElem->SetAttribute("z", pScale.z); - model->InsertEndChild(ScaleElem); + // _float3 pScale = pMapObject->Get_Component()->Get_Scale(); + // ScaleElem->SetAttribute("x", pScale.x); + // ScaleElem->SetAttribute("y", pScale.y); + // ScaleElem->SetAttribute("z", pScale.z); + // model->InsertEndChild(ScaleElem); - // - tinyxml2::XMLElement* RotationElem = doc.NewElement("Rotation"); + // // + // tinyxml2::XMLElement* RotationElem = doc.NewElement("Rotation"); - _float3 vRotation = {}; - XMStoreFloat3(&vRotation, pMapObject->Get_Component()->Get_RollPitchYawVector()); - - RotationElem->SetAttribute("x", vRotation.x); - RotationElem->SetAttribute("y", vRotation.y); - RotationElem->SetAttribute("z", vRotation.z); - model->InsertEndChild(RotationElem); + // _float3 vRotation = {}; + // XMStoreFloat3(&vRotation, pMapObject->Get_Component()->Get_RollPitchYawVector()); + // + // RotationElem->SetAttribute("x", vRotation.x); + // RotationElem->SetAttribute("y", vRotation.y); + // RotationElem->SetAttribute("z", vRotation.z); + // model->InsertEndChild(RotationElem); - } - string strPath = "../Bin/Resources/Data/" + string(pFileName) + ".xml"; + //} + //string strPath = "../Bin/Resources/Data/Map/" + string(pFileName) + ".xml"; - // 저장 - if (doc.SaveFile(strPath.c_str()) != tinyxml2::XML_SUCCESS) { - - return E_FAIL; - } + //// 저장 + //if (doc.SaveFile(strPath.c_str()) != tinyxml2::XML_SUCCESS) { + // return E_FAIL; + //} return S_OK; } +HRESULT CMapObject_Manager::Load_MapData(const _char* pFileName) +{ + tinyxml2::XMLDocument xmlDoc; + + string strPath = "../Bin/Resources/Data/Map/" + string(pFileName) + ".xml"; + + if ((tinyxml2::XML_SUCCESS != xmlDoc.LoadFile(strPath.c_str()))) + return E_FAIL; + + tinyxml2::XMLElement* root = xmlDoc.FirstChildElement("Land"); + + if (nullptr == root) + { + MSG_BOX("Failed to Find root"); + return E_FAIL; + } + + ///* Map */ + //MAP_DATA Map_Data = {}; + + //for (auto* land = root->FirstChildElement("Model"); land; land = land->NextSiblingElement("Model")) + //{ + // tinyxml2::XMLElement* protoElem = land->FirstChildElement("PrototypeTag"); + + // const _char* pPrototypeTag = protoElem->GetText(); + + // if (nullptr != pPrototypeTag) + // { + // string strPtotoypeTag = pPrototypeTag; + // Map_Data.strPrototypeTag = CMyTools::ToWstring(strPtotoypeTag); + // } + // else + // { + // Map_Data.strPrototypeTag = L""; + // } + + // protoElem = land->FirstChildElement("Position"); + // if (nullptr == protoElem) + // return E_FAIL; + // protoElem->QueryFloatAttribute("x", &Map_Data.vPosition.x); + // protoElem->QueryFloatAttribute("y", &Map_Data.vPosition.y); + // protoElem->QueryFloatAttribute("z", &Map_Data.vPosition.z); + + // protoElem = land->FirstChildElement("Scale"); + // if (nullptr == protoElem) + // return E_FAIL; + // protoElem->QueryFloatAttribute("x", &Map_Data.vScale.x); + // protoElem->QueryFloatAttribute("y", &Map_Data.vScale.y); + // protoElem->QueryFloatAttribute("z", &Map_Data.vScale.z); + + // protoElem = land->FirstChildElement("Rotation"); + // if (nullptr == protoElem) + // return E_FAIL; + // protoElem->QueryFloatAttribute("x", &Map_Data.vRotation.x); + // protoElem->QueryFloatAttribute("y", &Map_Data.vRotation.y); + // protoElem->QueryFloatAttribute("z", &Map_Data.vRotation.z); + + // m_MapDatas.push_back(Map_Data); + //} + + return S_OK; +} + +void CMapObject_Manager::Update_PrototypeList() +{ + GUI::Begin("Model Prototype List"); + GUI::Checkbox("bLOD", &m_bLOD); + for (auto& Tag : m_ModelPrototypeTags) + { + if (_wstring::npos != Tag.find(L"Lod")) + continue; + + if (ImGui::Button(CMyTools::ToString(Tag).c_str())) + { + if(false == m_bLOD) + { + CMapObject_Static::MAPOBJECT_STATIC_DESC Desc = {}; + + Desc.pModelPrototypeTag = Tag.c_str(); + Desc.pParentTransform = m_pContainer->Get_Component(); + + CMapObject_Static* pMapObject = { nullptr }; + const string strKey = CMyTools::ToString(Tag); + m_pContainer->Add_Part(strKey, 0, &pMapObject, &Desc); + + m_MapObjects.push_back(pMapObject); + } + else + { + CMapObject_LOD::MAPOBJECT_LOD_DESC Desc = {}; + + vector PrototypeTags; + + PrototypeTags.push_back(Tag.c_str()); + Desc.iMaxLodLevel = 0; + Desc.ModelPrototypeTags = PrototypeTags; + Desc.pParentTransform = m_pContainer->Get_Component(); + + CMapObject_Static* pMapObject = { nullptr }; + const string strKey = CMyTools::ToString(Tag); + m_pContainer->Add_Part(strKey, 0, nullptr, &Desc); + + m_MapObjects.push_back(pMapObject); + } + } + } + GUI::End(); + + + GUI::Begin("LOD Model Prototype List"); + for (auto& Tag : m_LODModelPrototypeTags) + { + if (ImGui::Button(CMyTools::ToString(Tag).c_str())) + { + if (nullptr != m_pSelectObject) + { + CMapObject_LOD* pLodObject = dynamic_cast(m_pSelectObject); + + if (nullptr != pLodObject) + { + pLodObject->Add_LodModel(Tag.c_str()); + } + else + { + MSG_BOX("Failed to Add Lod Model"); + } + + if (m_pSelectObject->isDead()) + m_pSelectObject = nullptr; + + } + } + } + GUI::End(); + +} + +void CMapObject_Manager::Update_ObjectList() +{ + //CLayer* pLayer = m_pGameInstance->Get_Layer(ENUM_CLASS(LEVEL::MAP), TEXT("Layer_MapObject")); + + //if (nullptr == pLayer) + // return; + + //m_pMapObjects = pLayer->Get_Objects(); + + GUI::Begin("MapObject List"); + + _uint iObjectIndex = {}; + string strSrc; + + if (false == m_MapObjects.empty()) + { + for (auto pMapObject : m_MapObjects) + { + CMapObject* pCurrentMapObject = static_cast(pMapObject); + + if (nullptr == pCurrentMapObject) + continue; + + wstring strPrototypeTag = pCurrentMapObject->Get_PrototypeTag(); + + strSrc = CMyTools::ToString(strPrototypeTag) + to_string(iObjectIndex) + "##" + to_string(iObjectIndex++); + + if (ImGui::Button(strSrc.c_str())) + { + m_pSelectObject = pCurrentMapObject; + } + } + } + + GUI::End(); +} + +void CMapObject_Manager::Update_Edit() +{ + GUI::Begin("Edit"); + + if (nullptr != m_pSelectObject) + { + m_pSelectObject->Describe_Entity(); + if (m_pSelectObject->isDead()) + m_pSelectObject = nullptr; + + } + + GUI::End(); +} + CMapObject_Manager* CMapObject_Manager::Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext, vector<_wstring>& ModelPrototypeTags) { @@ -231,6 +386,7 @@ void CMapObject_Manager::Free() { __super::Free(); + SAFE_RELEASE(m_pContainer); } void CMapObject_Manager::Describe_Entity() diff --git a/Jusin154_Team3D/Editor/Public/Level_MapViewer.h b/Jusin154_Team3D/Editor/Public/Level_MapViewer.h index 84319b5fe..94a6dfeae 100644 --- a/Jusin154_Team3D/Editor/Public/Level_MapViewer.h +++ b/Jusin154_Team3D/Editor/Public/Level_MapViewer.h @@ -20,7 +20,7 @@ class CLevel_MapViewer final : public CLevel HRESULT Ready_Layer_Light(); HRESULT Ready_Layer_Camera(const _wstring& strLayerTag); HRESULT Ready_Layer_Terrain(const _wstring& strLayerTag); - HRESULT Ready_Layer_MapObjects(const _wstring& strLayerTag); + HRESULT Ready_Layer_BuildingContainer(const _wstring& strLayerTag); HRESULT Ready_Layer_MapObjectManager(const _wstring& strLayerTag); diff --git a/Jusin154_Team3D/Editor/Public/MapObject.h b/Jusin154_Team3D/Editor/Public/MapObject.h index b830e36ff..cb9af64cf 100644 --- a/Jusin154_Team3D/Editor/Public/MapObject.h +++ b/Jusin154_Team3D/Editor/Public/MapObject.h @@ -1,7 +1,7 @@ #pragma once #include "Editor_Define.h" -#include "GameObject.h" +#include "PartObject.h" NS_BEGIN(Engine) class CShader; @@ -10,50 +10,41 @@ NS_END NS_BEGIN(Editor) -class CMapObject final : public CGameObject +class CMapObject abstract : public CPartObject { -public: - typedef struct tagMapObjectDesc - { - const _tchar* pModelPrototypeTag; - }MAPOBJECT_DESC; - -private: +protected: CMapObject(ID3D11Device* pDevice, ID3D11DeviceContext* pContext); CMapObject(const CMapObject& Prototype); virtual ~CMapObject() = default; public: - virtual HRESULT Initialize_Prototype() override; - virtual HRESULT Initialize(void* pArg) override; virtual void Priority_Update(_float fTimeDelta) override; virtual void Update(_float fTimeDelta) override; virtual void Late_Update(_float fTimeDelta) override; virtual HRESULT Render() override; public: - _wstring& Get_PrototypeTag() { return m_strModelPrototypeTag; } + virtual _wstring Get_PrototypeTag(_uint iLodIndex = 0); -private: - CShader* m_pShaderCom = { nullptr }; - CModel* m_pModelCom = { nullptr }; +protected: - _wstring m_strModelPrototypeTag; + +protected: + virtual HRESULT Initialize_Prototype() override; + virtual HRESULT Initialize(void* pArg) override; + HRESULT Ready_Components(); #ifdef _DEBUG - _bool m_bSelected = {}; - _float3 m_vPosition = {}; - _float3 m_vRotation = {}; - _float3 m_vScale = {}; + _bool m_bSelected = {}; + _float3 m_vPosition = {}; + _float3 m_vRotation = {}; + _float3 m_vScale = {}; #endif // _DEBUG private: - HRESULT Ready_Components(); HRESULT Bind_ShaderResources(); public: - static CMapObject* Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext); - virtual CGameObject* Clone(void* pArg, CGameObject* pOwner = nullptr) override; virtual void Free() override; virtual void Describe_Entity() override; }; diff --git a/Jusin154_Team3D/Editor/Public/MapObject_Manager.h b/Jusin154_Team3D/Editor/Public/MapObject_Manager.h index c38516be3..7f2be7252 100644 --- a/Jusin154_Team3D/Editor/Public/MapObject_Manager.h +++ b/Jusin154_Team3D/Editor/Public/MapObject_Manager.h @@ -26,14 +26,23 @@ class CMapObject_Manager final : public CGameObject virtual HRESULT Render() override; private: - class CMapObject* m_pSelectObject = { nullptr }; - const list* m_pMapObjects = { nullptr }; + class CMapObject* m_pSelectObject = { nullptr }; + list m_MapObjects = { nullptr }; vector<_wstring> m_ModelPrototypeTags; + vector<_wstring> m_LODModelPrototypeTags; + + _bool m_bLOD = { false }; + class CBuildingContainer* m_pContainer = { nullptr }; private: - HRESULT Ready_Components(); - HRESULT Bind_ShaderResources(); - HRESULT Save_MapData(const _char* pFileName); + HRESULT Ready_Components(); + HRESULT Bind_ShaderResources(); + HRESULT Save_MapData(const _char* pFileName); + HRESULT Load_MapData(const _char* pFileName); + + void Update_PrototypeList(); + void Update_ObjectList(); + void Update_Edit(); public: static CMapObject_Manager* Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext, vector<_wstring>& ModelPrototypeTags);