diff --git a/Jusin154_Team3D/Editor/Bin/Resources/Data/Map/ContainerTest.xml b/Jusin154_Team3D/Editor/Bin/Resources/Data/Map/ContainerTest.xml index ec0e10dae..210855c23 100644 --- a/Jusin154_Team3D/Editor/Bin/Resources/Data/Map/ContainerTest.xml +++ b/Jusin154_Team3D/Editor/Bin/Resources/Data/Map/ContainerTest.xml @@ -1,500 +1,24 @@ - + - - Prototype_GameObject_SM_HM_3Broom_Ext_Awning_Trim - Prototype_GameObject_SM_HM_3Broom_Ext_Awning_Trim_Lod1 - Prototype_GameObject_SM_HM_3Broom_Ext_Awning_Trim_Lod2 - Prototype_GameObject_SM_HM_3Broom_Ext_Awning_Trim_Lod3 + + Prototype_GameObject_SM_HW_GH_ArchSmall + Prototype_GameObject_SM_HW_GH_ArchSmall_Lod1 + Prototype_GameObject_SM_HW_GH_ArchSmall_Lod2 + + + + + + Prototype_GameObject_SM_HW_GH_ArchSmall + Prototype_GameObject_SM_HW_GH_ArchSmall_Lod1 + Prototype_GameObject_SM_HW_GH_ArchSmall_Lod2 - - Prototype_GameObject_SM_HM_3Broom_ext_barrels - Prototype_GameObject_SM_HM_3Broom_ext_barrels_Lod1 - Prototype_GameObject_SM_HM_3Broom_ext_barrels_Lod2 - Prototype_GameObject_SM_HM_3Broom_ext_barrels_Lod3 - - - - - - Prototype_GameObject_SM_HM_3Broom_ext_barrels_sign - Prototype_GameObject_SM_HM_3Broom_ext_barrels_sign_Lod1 - - - - - - Prototype_GameObject_SM_HM_3Broom_ext_barrel_stands - Prototype_GameObject_SM_HM_3Broom_ext_barrel_stands_Lod1 - Prototype_GameObject_SM_HM_3Broom_ext_barrel_stands_Lod2 - - - - - - Prototype_GameObject_SM_HM_3Broom_ext_chimneys_B - Prototype_GameObject_SM_HM_3Broom_ext_chimneys_B_Lod1 - Prototype_GameObject_SM_HM_3Broom_ext_chimneys_B_Lod2 - Prototype_GameObject_SM_HM_3Broom_ext_chimneys_B_Lod3 - - - - - - Prototype_GameObject_SM_HM_3Broom_ext_decals - Prototype_GameObject_SM_HM_3Broom_ext_decals_Lod1 - Prototype_GameObject_SM_HM_3Broom_ext_decals_Lod2 - - - - - - Prototype_GameObject_SM_HM_3Broom_ext_Decals_A - Prototype_GameObject_SM_HM_3Broom_ext_Decals_A_Lod1 - - - - - - Prototype_GameObject_SM_HM_3Broom_Ext_DoorFrameSide - Prototype_GameObject_SM_HM_3Broom_Ext_DoorFrameSide_Lod1 - Prototype_GameObject_SM_HM_3Broom_Ext_DoorFrameSide_Lod2 - - - - - - Prototype_GameObject_SM_HM_3Broom_ext_Dormer_Wood_Slats - - - - - - Prototype_GameObject_SM_HM_3Broom_ext_roof - Prototype_GameObject_SM_HM_3Broom_ext_roof_Lod1 - Prototype_GameObject_SM_HM_3Broom_ext_roof_Lod2 - - - - - - Prototype_GameObject_SM_HM_3Broom_ext_roof_copper_tops - Prototype_GameObject_SM_HM_3Broom_ext_roof_copper_tops_Lod1 - Prototype_GameObject_SM_HM_3Broom_ext_roof_copper_tops_Lod2 - - - - - - Prototype_GameObject_SM_HM_3Broom_ext_roof_decals - Prototype_GameObject_SM_HM_3Broom_ext_roof_decals_Lod1 - - - - - - Prototype_GameObject_SM_HM_3Broom_ext_side_garden_box - Prototype_GameObject_SM_HM_3Broom_ext_side_garden_box_Lod1 - Prototype_GameObject_SM_HM_3Broom_ext_side_garden_box_Lod2 - - - - - - Prototype_GameObject_SM_HM_3Broom_ext_trim - Prototype_GameObject_SM_HM_3Broom_ext_trim_Lod1 - Prototype_GameObject_SM_HM_3Broom_ext_trim_Lod2 - Prototype_GameObject_SM_HM_3Broom_ext_trim_Lod3 - - - - - - Prototype_GameObject_SM_HM_3Broom_ext_trim_stone - Prototype_GameObject_SM_HM_3Broom_ext_trim_stone_Lod1 - Prototype_GameObject_SM_HM_3Broom_ext_trim_stone_Lod2 - Prototype_GameObject_SM_HM_3Broom_ext_trim_stone_Lod3 - - - - - - Prototype_GameObject_SM_HM_3Broom_ext_walls - Prototype_GameObject_SM_HM_3Broom_ext_walls_Lod1 - Prototype_GameObject_SM_HM_3Broom_ext_walls_Lod2 - - - - - - Prototype_GameObject_SM_HM_3Broom_ext_wood_Corbels - Prototype_GameObject_SM_HM_3Broom_ext_wood_Corbels_Lod1 - - - - - - Prototype_GameObject_SM_HM_3Broom_fireplace - Prototype_GameObject_SM_HM_3Broom_fireplace_Lod1 - Prototype_GameObject_SM_HM_3Broom_fireplace_Lod2 - Prototype_GameObject_SM_HM_3Broom_fireplace_Lod3 - - - - - - Prototype_GameObject_SM_HM_3Broom_Door_L - Prototype_GameObject_SM_HM_3Broom_Door_L_Lod1 - Prototype_GameObject_SM_HM_3Broom_Door_L_Lod2 - - - - - - Prototype_GameObject_SM_HM_3Broom_Door_R - Prototype_GameObject_SM_HM_3Broom_Door_R_Lod1 - Prototype_GameObject_SM_HM_3Broom_Door_R_Lod2 - - - - - - Prototype_GameObject_SM_HM_3Broom_DoorFrame - Prototype_GameObject_SM_HM_3Broom_DoorFrame_Lod1 - Prototype_GameObject_SM_HM_3Broom_DoorFrame_Lod2 - - - - - - Prototype_GameObject_SM_HM_3Broom_Window_Glass - Prototype_GameObject_SM_HM_3Broom_Window_Glass_Lod1 - - - - - - Prototype_GameObject_SM_HM_3Broom_Roof_Debris_A - Prototype_GameObject_SM_HM_3Broom_Roof_Debris_A_Lod1 - Prototype_GameObject_SM_HM_3Broom_Roof_Debris_A_Lod2 - Prototype_GameObject_SM_HM_3Broom_Roof_Debris_A_Lod3 - - - - - - Prototype_GameObject_SM_HM_3Broom_Roof_Debris_B - Prototype_GameObject_SM_HM_3Broom_Roof_Debris_B_Lod1 - Prototype_GameObject_SM_HM_3Broom_Roof_Debris_B_Lod2 - Prototype_GameObject_SM_HM_3Broom_Roof_Debris_B_Lod3 - - - - - - - - - - - Prototype_GameObject_SM_HM_3Broom_int_Bar - Prototype_GameObject_SM_HM_3Broom_int_Bar_Lod1 - Prototype_GameObject_SM_HM_3Broom_int_Bar_Lod2 - - - - - - Prototype_GameObject_SM_HM_3Broom_int_floors - Prototype_GameObject_SM_HM_3Broom_int_floors_Lod1 - Prototype_GameObject_SM_HM_3Broom_int_floors_Lod2 - - - - - - Prototype_GameObject_SM_HM_3Broom_int_stairs_A - Prototype_GameObject_SM_HM_3Broom_int_stairs_A_Lod1 - - - - - - Prototype_GameObject_SM_HM_3Broom_int_stairs_B - Prototype_GameObject_SM_HM_3Broom_int_stairs_B_Lod1 - Prototype_GameObject_SM_HM_3Broom_int_stairs_B_Lod2 - - - - - - Prototype_GameObject_SM_HM_3Broom_int_stairs_D - Prototype_GameObject_SM_HM_3Broom_int_stairs_D_Lod1 - - - - - - Prototype_GameObject_SM_HM_3Broom_int_Stairs_Upper_Floors - Prototype_GameObject_SM_HM_3Broom_int_Stairs_Upper_Floors_Lod1 - Prototype_GameObject_SM_HM_3Broom_int_Stairs_Upper_Floors_Lod2 - - - - - - Prototype_GameObject_SM_HM_3Broom_int_walls - Prototype_GameObject_SM_HM_3Broom_int_walls_Lod1 - Prototype_GameObject_SM_HM_3Broom_int_walls_Lod2 - Prototype_GameObject_SM_HM_3Broom_int_walls_Lod3 - - - - - - Prototype_GameObject_SM_HM_3Broom_int_windows - Prototype_GameObject_SM_HM_3Broom_int_windows_Lod1 - - - - - - Prototype_GameObject_SM_HM_3Broom_int_wood_A - Prototype_GameObject_SM_HM_3Broom_int_wood_A_Lod1 - Prototype_GameObject_SM_HM_3Broom_int_wood_A_Lod2 - Prototype_GameObject_SM_HM_3Broom_int_wood_A_Lod3 - - - - - - Prototype_GameObject_SM_HM_3Broom_int_wood_B - Prototype_GameObject_SM_HM_3Broom_int_wood_B_Lod1 - Prototype_GameObject_SM_HM_3Broom_int_wood_B_Lod2 - Prototype_GameObject_SM_HM_3Broom_int_wood_B_Lod3 - - - - - - Prototype_GameObject_SM_HM_3Broom_int_wood_C - Prototype_GameObject_SM_HM_3Broom_int_wood_C_Lod1 - Prototype_GameObject_SM_HM_3Broom_int_wood_C_Lod2 - Prototype_GameObject_SM_HM_3Broom_int_wood_C_Lod3 - - - - - - Prototype_GameObject_SM_HM_3Broom_int_wood_Stairs - Prototype_GameObject_SM_HM_3Broom_int_wood_Stairs_Lod1 - Prototype_GameObject_SM_HM_3Broom_int_wood_Stairs_Lod2 - - - - - - Prototype_GameObject_SM_Broom_01 - Prototype_GameObject_SM_Broom_01_Lod1 - Prototype_GameObject_SM_Broom_01_Lod2 - - - - - - - - - - - Prototype_GameObject_SM_HM_3Broom_ext_barrel_stands - - - - - - Prototype_GameObject_SM_HM_3Broom_ext_barrel_stands - - - - - - Prototype_GameObject_SM_HM_3Broom_ext_barrels - - - - - - Prototype_GameObject_SM_HM_3Broom_Door_R - - - - - - - - - - - Prototype_GameObject_SM_HM_3Broom_Door_L - - - - - - Prototype_GameObject_SM_HM_3Broom_ext_Decals_A - - - - - - - - - - - Prototype_GameObject_SM_HW_GH_FloorMain - - - - - - Prototype_GameObject_SM_HW_GH_FloorEnd - - - - - - Prototype_GameObject_SM_HW_GH_Sconce_Gryffindor - - - - - - Prototype_GameObject_SM_HW_GH_WallIntWindowB - - - - - - Prototype_GameObject_SM_HW_GH_WallIntWindowB - - - - - - Prototype_GameObject_SM_HW_GH_WallIntWindowC - - - - - - Prototype_GameObject_SM_HW_GH_WallPaneling - - - - - - Prototype_GameObject_SM_HW_GH_WallInt_FlatCeilingB - - - - - - Prototype_GameObject_SM_HW_GH_Sconce_Gryffindor - - - - - - Prototype_GameObject_SM_HW_GH_Sconce_HufflePuff - - - - - - Prototype_GameObject_SM_HW_GH_Sconce_Slytherin - - - - - - Prototype_GameObject_SM_HW_GH_ShadowCaster - - - - - - Prototype_GameObject_SM_HW_GH_Table - - - - - - Prototype_GameObject_SM_HW_GH_Table - - - - - - Prototype_GameObject_SM_HW_GH_Table - - - - - - Prototype_GameObject_SM_HW_GH_TableRunnerGryff - - - - - - Prototype_GameObject_SM_HW_GH_TableRunnerHufflePuff - - - - - - Prototype_GameObject_SM_HW_GH_TableRunnerRaven - - - - - - Prototype_GameObject_SM_HW_GH_WallColumnAB - - - - - - Prototype_GameObject_SM_HW_GH_WallColumnAC - - - - - - Prototype_GameObject_SM_HW_GH_WallColumnC - - - - - - Prototype_GameObject_SM_HW_GH_WallDoor - - - - - - Prototype_GameObject_SM_HW_GH_WallDoorB - - - - diff --git a/Jusin154_Team3D/Editor/Bin/Resources/Data/Map/MapTest.xml b/Jusin154_Team3D/Editor/Bin/Resources/Data/Map/MapTest.xml index 98d8b1513..6aeafba8b 100644 --- a/Jusin154_Team3D/Editor/Bin/Resources/Data/Map/MapTest.xml +++ b/Jusin154_Team3D/Editor/Bin/Resources/Data/Map/MapTest.xml @@ -1,123 +1,56 @@ - - Prototype_GameObject_SM_HM_3Broom_Ext_Awning_Trim.mo - + + - - - Prototype_GameObject_SM_HM_3Broom_Ext_DoorFrameSide.mo - + + Prototype_GameObject_SM_HW_GH_ArchSmall + Prototype_GameObject_SM_HW_GH_ArchSmall_Lod1 + Prototype_GameObject_SM_HW_GH_ArchSmall_Lod2 + + + + + + Prototype_GameObject_SM_HW_GH_ArchSmall + Prototype_GameObject_SM_HW_GH_ArchSmall_Lod1 + Prototype_GameObject_SM_HW_GH_ArchSmall_Lod2 + + + + + + + Prototype_GameObject_SM_HW_GH_FloorMain + Prototype_GameObject_SM_HW_GH_FloorMain_Lod1 + - - - Prototype_GameObject_SM_HM_3Broom_MERGED_Entry_Base_Stones.mo - + + + Prototype_GameObject_SM_HW_GH_WallWindow + - - - Prototype_GameObject_SM_HM_3Broom_MERGED_Side_Stone_Steps.mo - + + + Prototype_GameObject_SM_HW_GH_WallTimbers + Prototype_GameObject_SM_HW_GH_WallTimbers_Lod1 + - - - Prototype_GameObject_SM_HM_3Broom_MERGED_Winter_Kit_Icicles.mo - + + + Prototype_GameObject_SM_HW_GH_Table + + + + + + Prototype_GameObject_SM_HW_GH_ShadowCaster + - - - Prototype_GameObject_SM_HM_3Broom_MERGED_Winter_Kit_Snow.mo - - - - - - Prototype_GameObject_SM_HM_3Broom_Roof_Debris_A.mo - - - - - - Prototype_GameObject_SM_HM_3Broom_Roof_Debris_A_Decal.mo - - - - - - Prototype_GameObject_SM_HM_3Broom_Roof_Debris_B_Decal.mo - - - - - - Prototype_GameObject_SM_HM_3Broom_Roof_Snow_Winter.mo - - - - - - Prototype_GameObject_SM_HM_3Broom_Window_Glass.mo - - - - - - Prototype_GameObject_SM_HM_3Broom_Wood_Steps_B.mo - - - - - - Prototype_GameObject_SM_HM_3Broom_Wood_Steps_C.mo - - - - - - Prototype_GameObject_SM_HM_3Broom_int_walls.mo - - - - - - Prototype_GameObject_SM_HM_3Broom_int_wood_A.mo - - - - - - Prototype_GameObject_SM_HM_3Broom_int_wood_B.mo - - - - - - Prototype_GameObject_SM_HM_3Broom_int_wood_Stairs.mo - - - - - - Prototype_GameObject_SM_HM_3Broom_int_windows.mo - - - - - - Prototype_GameObject_SM_HM_3Broom_int_walls.mo - - - - - - Prototype_GameObject_SM_HM_3Broom_int_Stairs_Upper_Floors.mo - - - - + diff --git a/Jusin154_Team3D/Editor/Private/BuildingContainer.cpp b/Jusin154_Team3D/Editor/Private/BuildingContainer.cpp index 08a091a3e..30dd371fc 100644 --- a/Jusin154_Team3D/Editor/Private/BuildingContainer.cpp +++ b/Jusin154_Team3D/Editor/Private/BuildingContainer.cpp @@ -4,6 +4,7 @@ #include "Terrain.h" #include "Layer.h" #include "VIBuffer_Terrain.h" +#include "PartObject.h" CBuildingContainer::CBuildingContainer(ID3D11Device* pDevice, ID3D11DeviceContext* pContext) :CMapContainer(pDevice, pContext) @@ -139,7 +140,6 @@ void CBuildingContainer::Describe_Entity() { pTerrain->Get_Component()->Picking(pTerrain->Get_Component(), m_vPosition); } - } GUI::Text("----- Rotation ----"); diff --git a/Jusin154_Team3D/Editor/Private/Loader.cpp b/Jusin154_Team3D/Editor/Private/Loader.cpp index 98f059290..50b664c1f 100644 --- a/Jusin154_Team3D/Editor/Private/Loader.cpp +++ b/Jusin154_Team3D/Editor/Private/Loader.cpp @@ -50,6 +50,8 @@ #include "MapObject_Static.h" #include "MapObject_LOD.h" #include "MapObject_Manager.h" +#include "MapElement_Interactable.h" +#include "MapElement_Static.h" #pragma endregion @@ -862,6 +864,14 @@ HRESULT CLoader::Loading_For_MapViewer() if (FAILED(m_pGameInstance->Add_Prototype(g_iStaticLevel, CMapObject_LOD::Create(m_pDevice, m_pContext)))) return E_FAIL; + /* For.Prototype_GameObject_MapElement_Interactable */ + if (FAILED(m_pGameInstance->Add_Prototype(g_iStaticLevel, CMapElement_Interactable::Create(m_pDevice, m_pContext)))) + return E_FAIL; + + /* For.Prototype_GameObject_MapElement_Static */ + if (FAILED(m_pGameInstance->Add_Prototype(g_iStaticLevel, CMapElement_Static::Create(m_pDevice, m_pContext)))) + return E_FAIL; + /* For.Prototype_GameObject_Terrain */ if (FAILED(m_pGameInstance->Add_Prototype(g_iStaticLevel, CTerrain::Create(m_pDevice, m_pContext)))) return E_FAIL; diff --git a/Jusin154_Team3D/Editor/Private/MapContainer.cpp b/Jusin154_Team3D/Editor/Private/MapContainer.cpp index 484d616cb..b4520a259 100644 --- a/Jusin154_Team3D/Editor/Private/MapContainer.cpp +++ b/Jusin154_Team3D/Editor/Private/MapContainer.cpp @@ -70,6 +70,7 @@ HRESULT CMapContainer::Save_PartObjects(tinyxml2::XMLDocument& Doc, tinyxml2::XM // tinyxml2::XMLElement* PartObject = Doc.NewElement("PartObject"); PartObject->SetAttribute("Lod_Level", pMapObject->Get_LodLevel()); + PartObject->SetAttribute("Key_Index", pMapObject->Get_iKeyIndex()); Container->InsertEndChild(PartObject); for (_uint i = 0; i < pMapObject->Get_LodLevel() + 1; ++i) @@ -110,7 +111,6 @@ HRESULT CMapContainer::Save_PartObjects(tinyxml2::XMLDocument& Doc, tinyxml2::XM RotationElem->SetAttribute("y", vRotation.y); RotationElem->SetAttribute("z", vRotation.z); PartObject->InsertEndChild(RotationElem); - } return S_OK; diff --git a/Jusin154_Team3D/Editor/Private/MapElement.cpp b/Jusin154_Team3D/Editor/Private/MapElement.cpp index 499097f8a..1ed1d51e1 100644 --- a/Jusin154_Team3D/Editor/Private/MapElement.cpp +++ b/Jusin154_Team3D/Editor/Private/MapElement.cpp @@ -13,6 +13,14 @@ CMapElement::CMapElement(const CMapElement& rhs) { } +const _wstring& CMapElement::Get_PrototypeTag(_uint iIndex) +{ + if (m_iMaxLodLevel < iIndex) + return m_ModelPrototypeTags[0]; + + return m_ModelPrototypeTags[iIndex]; +} + void CMapElement::Priority_Update(_float fTimeDelta) { } diff --git a/Jusin154_Team3D/Editor/Private/MapElement_Interactable.cpp b/Jusin154_Team3D/Editor/Private/MapElement_Interactable.cpp index 1b44bfded..bd8a892ab 100644 --- a/Jusin154_Team3D/Editor/Private/MapElement_Interactable.cpp +++ b/Jusin154_Team3D/Editor/Private/MapElement_Interactable.cpp @@ -2,6 +2,9 @@ #include "MapElement_Interactable.h" #include "GameInstance.h" +#include "Terrain.h" +#include "Layer.h" +#include "VIBuffer_Terrain.h" CMapElement_Interactable::CMapElement_Interactable(ID3D11Device* pDevice, ID3D11DeviceContext* pContext) : CMapElement{ pDevice, pContext } @@ -20,12 +23,33 @@ HRESULT CMapElement_Interactable::Initialize_Prototype() HRESULT CMapElement_Interactable::Initialize(void* pArg) { + MAPOBJECT_LOD_DESC* pDesc = static_cast(pArg); + + m_iMaxLodLevel = pDesc->iMaxLodLevel; + + for (_uint i = 0; i < m_iMaxLodLevel + 1; i++) + { + m_ModelPrototypeTags.push_back(pDesc->ModelPrototypeTags[i]); + //m_ModelPathIndices.push_back((*pDesc->pModelPathIndices)[i]); + } + if (FAILED(__super::Initialize(pArg))) return E_FAIL; if (FAILED(Ready_Components(pArg))) return E_FAIL; +#ifdef _DEBUG + m_bSelected = false; + m_vPosition = pDesc->vPosition; + m_vScale = pDesc->vScale; + m_vRotation = pDesc->vRotation; + + 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 // _DEBUG + return S_OK; } @@ -58,6 +82,9 @@ void CMapElement_Interactable::Late_Update(_float fTimeDelta) HRESULT CMapElement_Interactable::Render() { + if (FAILED(Bind_ShaderResources())) + return E_FAIL; + _uint iNumMeshes = m_pModelComs[m_iLodIndex]->Get_NumMeshes(); for (_uint i = 0; i < iNumMeshes; i++) @@ -96,6 +123,23 @@ HRESULT CMapElement_Interactable::Ready_Components(void* pArg) return E_FAIL; } + for (_uint i = 0; i < m_iMaxLodLevel + 1; ++i) + { + CModel* pModel = { nullptr }; + + /* Com_Model */ + if (FAILED(__super::Add_Asset_Component(g_iStaticLevel, m_ModelPrototypeTags[i], + reinterpret_cast(&pModel)))) + return E_FAIL; + + m_pModelComs.push_back(pModel); + } + + /* Com_Shader */ + if (FAILED(__super::Add_Asset_Component(g_iStaticLevel, FX_MESH, + reinterpret_cast(&m_pShaderCom)))) + return E_FAIL; + return S_OK; } @@ -147,6 +191,10 @@ CGameObject* CMapElement_Interactable::Clone(void* pArg, CGameObject* pOwner) void CMapElement_Interactable::Free() { __super::Free(); + + SAFE_RELEASE(m_pShaderCom); + for (auto& pModel : m_pModelComs) + SAFE_RELEASE(pModel); } void CMapElement_Interactable::Describe_Entity() @@ -165,7 +213,7 @@ void CMapElement_Interactable::Describe_Entity() GUI::InputFloat("Y##Position", &m_vPosition.y, 0.1f, 1.f); GUI::InputFloat("Z##Position", &m_vPosition.z, 0.1f, 1.f); - /*if (m_pGameInstance->Mouse_Down(DIM_LBUTTON) && m_pGameInstance->Key_Pressing(DIK_LSHIFT)) + if (m_pGameInstance->Mouse_Down(DIM_LBUTTON) && m_pGameInstance->Key_Pressing(DIK_LSHIFT)) { CTerrain* pTerrain = m_pGameInstance->Get_Layer(ENUM_CLASS(LEVEL::MAP), TEXT("Layer_Terrain"))->Get_Object(); if (nullptr != pTerrain) @@ -173,7 +221,7 @@ void CMapElement_Interactable::Describe_Entity() pTerrain->Get_Component()->Picking(pTerrain->Get_Component(), m_vPosition); } - }*/ + } GUI::Text("----- Rotation ----"); GUI::InputFloat("X##Rotation", &m_vRotation.x, 10.f, 45.f); diff --git a/Jusin154_Team3D/Editor/Private/MapElement_Static.cpp b/Jusin154_Team3D/Editor/Private/MapElement_Static.cpp index 26d7d3b37..256ccd3f3 100644 --- a/Jusin154_Team3D/Editor/Private/MapElement_Static.cpp +++ b/Jusin154_Team3D/Editor/Private/MapElement_Static.cpp @@ -3,6 +3,10 @@ #include "GameInstance.h" +#include "Terrain.h" +#include "Layer.h" +#include "VIBuffer_Terrain.h" + CMapElement_Static::CMapElement_Static(ID3D11Device* pDevice, ID3D11DeviceContext* pContext) : CMapElement{ pDevice, pContext } { @@ -20,12 +24,33 @@ HRESULT CMapElement_Static::Initialize_Prototype() HRESULT CMapElement_Static::Initialize(void* pArg) { + MAPOBJECT_LOD_DESC* pDesc = static_cast(pArg); + + m_iMaxLodLevel = pDesc->iMaxLodLevel; + + for (_uint i = 0; i < m_iMaxLodLevel + 1; i++) + { + m_ModelPrototypeTags.push_back(pDesc->ModelPrototypeTags[i]); + //m_ModelPathIndices.push_back((*pDesc->pModelPathIndices)[i]); + } + if (FAILED(__super::Initialize(pArg))) return E_FAIL; if (FAILED(Ready_Components(pArg))) return E_FAIL; +#ifdef _DEBUG + m_bSelected = false; + m_vPosition = pDesc->vPosition; + m_vScale = pDesc->vScale; + m_vRotation = pDesc->vRotation; + + 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 // _DEBUG + return S_OK; } @@ -58,6 +83,9 @@ void CMapElement_Static::Late_Update(_float fTimeDelta) HRESULT CMapElement_Static::Render() { + if (FAILED(Bind_ShaderResources())) + return E_FAIL; + _uint iNumMeshes = m_pModelComs[m_iLodIndex]->Get_NumMeshes(); for (_uint i = 0; i < iNumMeshes; i++) @@ -95,6 +123,23 @@ HRESULT CMapElement_Static::Ready_Components(void* pArg) return E_FAIL; } + for (_uint i = 0; i < m_iMaxLodLevel + 1; ++i) + { + CModel* pModel = { nullptr }; + + /* Com_Model */ + if (FAILED(__super::Add_Asset_Component(g_iStaticLevel, m_ModelPrototypeTags[i], + reinterpret_cast(&pModel)))) + return E_FAIL; + + m_pModelComs.push_back(pModel); + } + + /* Com_Shader */ + if (FAILED(__super::Add_Asset_Component(g_iStaticLevel, FX_MESH, + reinterpret_cast(&m_pShaderCom)))) + return E_FAIL; + return S_OK; } @@ -146,6 +191,10 @@ CGameObject* CMapElement_Static::Clone(void* pArg, CGameObject* pOwner) void CMapElement_Static::Free() { __super::Free(); + + SAFE_RELEASE(m_pShaderCom); + for (auto& pModel : m_pModelComs) + SAFE_RELEASE(pModel); } void CMapElement_Static::Describe_Entity() @@ -164,7 +213,7 @@ void CMapElement_Static::Describe_Entity() GUI::InputFloat("Y##Position", &m_vPosition.y, 0.1f, 1.f); GUI::InputFloat("Z##Position", &m_vPosition.z, 0.1f, 1.f); - /*if (m_pGameInstance->Mouse_Down(DIM_LBUTTON) && m_pGameInstance->Key_Pressing(DIK_LSHIFT)) + if (m_pGameInstance->Mouse_Down(DIM_LBUTTON) && m_pGameInstance->Key_Pressing(DIK_LSHIFT)) { CTerrain* pTerrain = m_pGameInstance->Get_Layer(ENUM_CLASS(LEVEL::MAP), TEXT("Layer_Terrain"))->Get_Object(); if (nullptr != pTerrain) @@ -172,7 +221,7 @@ void CMapElement_Static::Describe_Entity() pTerrain->Get_Component()->Picking(pTerrain->Get_Component(), m_vPosition); } - }*/ + } GUI::Text("----- Rotation ----"); GUI::InputFloat("X##Rotation", &m_vRotation.x, 10.f, 45.f); diff --git a/Jusin154_Team3D/Editor/Private/MapObject.cpp b/Jusin154_Team3D/Editor/Private/MapObject.cpp index 183b29636..2bcb7908e 100644 --- a/Jusin154_Team3D/Editor/Private/MapObject.cpp +++ b/Jusin154_Team3D/Editor/Private/MapObject.cpp @@ -57,6 +57,11 @@ _wstring CMapObject::Get_PrototypeTag(_uint iLodIndex) return _wstring(); } +_uint CMapObject::Get_LodLevel() +{ + return m_iMaxLodLevel; +} + HRESULT CMapObject::Initialize_Prototype() { return S_OK; diff --git a/Jusin154_Team3D/Editor/Private/MapObject_LOD.cpp b/Jusin154_Team3D/Editor/Private/MapObject_LOD.cpp index cae66ff29..def354f62 100644 --- a/Jusin154_Team3D/Editor/Private/MapObject_LOD.cpp +++ b/Jusin154_Team3D/Editor/Private/MapObject_LOD.cpp @@ -32,7 +32,7 @@ HRESULT CMapObject_LOD::Initialize(void* pArg) for (_uint i = 0; i < m_iMaxLodLevel + 1; i++) { m_ModelPrototypeTags.push_back(pDesc->ModelPrototypeTags[i]); - m_ModelPathIndices.push_back((*pDesc->pModelPathIndices)[i]); + //m_ModelPathIndices.push_back((*pDesc->pModelPathIndices)[i]); } if (FAILED(__super::Initialize(pArg))) diff --git a/Jusin154_Team3D/Editor/Private/MapObject_Manager.cpp b/Jusin154_Team3D/Editor/Private/MapObject_Manager.cpp index 5437ff436..cd092cb15 100644 --- a/Jusin154_Team3D/Editor/Private/MapObject_Manager.cpp +++ b/Jusin154_Team3D/Editor/Private/MapObject_Manager.cpp @@ -8,6 +8,8 @@ #include "MapObject_LOD.h" #include "MapObject_Static.h" #include "BuildingContainer.h" +#include "MapElement_Static.h" +#include "MapElement_Interactable.h" CMapObject_Manager::CMapObject_Manager(ID3D11Device * pDevice, ID3D11DeviceContext * pContext) @@ -20,6 +22,7 @@ CMapObject_Manager::CMapObject_Manager(const CMapObject_Manager& rhs) , m_ModelPrototypeTags{ rhs.m_ModelPrototypeTags } , m_LODModelPrototypeTags{ rhs.m_LODModelPrototypeTags } , m_ModelPrototypePaths{ rhs.m_ModelPrototypePaths } + , m_PartObjectKeyCount{ rhs.m_PartObjectKeyCount } { } @@ -32,6 +35,10 @@ HRESULT CMapObject_Manager::Initialize_Prototype(vector<_wstring>& ModelPrototyp { m_LODModelPrototypeTags.push_back(ModelPrototypeTags[i]); } + else + { + m_PartObjectKeyCount.emplace(ModelPrototypeTags[i], 0); + } m_ModelPrototypeTags.push_back(ModelPrototypeTags[i]); m_ModelPrototypePaths.push_back(ModelPrototypePaths[i]); @@ -65,20 +72,34 @@ void CMapObject_Manager::Priority_Update(_float fTimeDelta) void CMapObject_Manager::Update(_float fTimeDelta) { GUI::Begin("File"); + const char* ModeNames[3] = + { + "CONTAINER", + "ELEMENT_STATIC", + "ELEMENT_INTERACT" + }; + GUI::Combo("MODE", (_int*)(&m_eType), ModeNames, IM_ARRAYSIZE(ModeNames)); + + GUI::InputText("MapFileName", m_szSaveFileName, MAX_PATH); if (GUI::Button("Save_Map")) { - Save_MapData("Test"); + Save_MapData(m_szSaveFileName); } if (GUI::Button("Load_Map")) { - Load_MapData("Test"); + Load_MapData(m_szSaveFileName); } + GUI::InputText("Containter Name", m_szSaveContainerName, MAX_PATH); - if (GUI::Button("Save_Container")) + + if (ADD_TYPE::CONTAINER == m_eType) { - Save_ContainerData("ContainerTest", m_szSaveContainerName); + if (GUI::Button("Save_Container")) + { + Save_ContainerData("ContainerTest", m_szSaveContainerName); + } } if (GUI::Button("Load_Container")) { @@ -90,9 +111,15 @@ void CMapObject_Manager::Update(_float fTimeDelta) Update_ObjectList(); - Update_Edit(); + if (ADD_TYPE::CONTAINER != m_eType) + { + Update_Edit(); + } - Update_ContainerObject(); + if (ADD_TYPE::CONTAINER == m_eType) + { + Update_ContainerObject(); + } for (auto* pObject : m_MapObjects) { @@ -148,22 +175,13 @@ HRESULT CMapObject_Manager::Save_MapData(const _char* pFileName) tinyxml2::XMLError loadResult = doc.LoadFile(strPath.c_str()); - tinyxml2::XMLElement* land = {}; - tinyxml2::XMLElement* container = {}; + doc.Clear(); + doc.InsertFirstChild(doc.NewDeclaration()); - if (loadResult != tinyxml2::XML_SUCCESS) - { - doc.InsertFirstChild(doc.NewDeclaration()); - - land = doc.NewElement("Land"); - doc.InsertEndChild(land); - - } - else - { - land = doc.FirstChildElement("Land"); - } + tinyxml2::XMLElement* land = doc.NewElement("Land"); + doc.InsertEndChild(land); +#pragma region SAVE_BUILDING CLayer* pLayer = m_pGameInstance->Get_Layer(ENUM_CLASS(LEVEL::MAP), TEXT("Layer_Building")); if (nullptr == pLayer) @@ -171,7 +189,6 @@ HRESULT CMapObject_Manager::Save_MapData(const _char* pFileName) const list* pList = pLayer->Get_Objects(); - for (auto pGamObject : *pList) { CBuildingContainer* pContainerObject = dynamic_cast(pGamObject); @@ -196,7 +213,6 @@ HRESULT CMapObject_Manager::Save_MapData(const _char* pFileName) vRotation.y = XMConvertToDegrees(vRotation.y); vRotation.z = XMConvertToDegrees(vRotation.z); - #pragma region CONTAINER_TRANSFORM tinyxml2::XMLElement* Position = doc.NewElement("Position"); Position->SetAttribute("x", vPosition.x); @@ -217,15 +233,147 @@ HRESULT CMapObject_Manager::Save_MapData(const _char* pFileName) container->InsertEndChild(Rotation); #pragma endregion - - #pragma region SAVE_PARTOBJECT if (FAILED(pContainerObject->Save_PartObjects(doc, container))) return E_FAIL; +#pragma endregion } #pragma endregion +#pragma region ELEMENT_STATIC + pLayer = m_pGameInstance->Get_Layer(ENUM_CLASS(LEVEL::MAP), TEXT("Layer_Element_Static")); + + if (nullptr != pLayer) + { + const list* pList = pLayer->Get_Objects(); + + for (auto pGamObject : *pList) + { + CMapElement* pElement = dynamic_cast(pGamObject); + + if (nullptr == pElement) + return E_FAIL; + + _uint iLodLevel = pElement->Get_LodLevel(); + + tinyxml2::XMLElement* object = doc.NewElement("Object"); + object->SetAttribute("Type", ENUM_CLASS(MAPOBJECT_TYPE::ELEMENT_STATIC)); + object->SetAttribute("Lod_Level", iLodLevel); + land->InsertEndChild(object); + +#pragma region PROTOTYPETAG + for (_uint i = 0; i < iLodLevel + 1; ++i) + { + tinyxml2::XMLElement* prototype = doc.NewElement("PrototypeTag"); + prototype->SetText(CMyTools::ToString(pElement->Get_PrototypeTag(i)).c_str()); + object->InsertEndChild(prototype); + } +#pragma endregion + + +#pragma region TRANSFORM + _float3 vPosition = {}; + XMStoreFloat3(&vPosition, pGamObject->Get_Component()->Get_State(STATE::POSITION)); + + _float3 vScale = pGamObject->Get_Component()->Get_Scale(); + + _float3 vRotation = {}; + XMStoreFloat3(&vRotation, pGamObject->Get_Component()->Get_RollPitchYawVector()); + vRotation.x = XMConvertToDegrees(vRotation.x); + vRotation.y = XMConvertToDegrees(vRotation.y); + vRotation.z = XMConvertToDegrees(vRotation.z); + + tinyxml2::XMLElement* Position = doc.NewElement("Position"); + Position->SetAttribute("x", vPosition.x); + Position->SetAttribute("y", vPosition.y); + Position->SetAttribute("z", vPosition.z); + object->InsertEndChild(Position); + + tinyxml2::XMLElement* Scale = doc.NewElement("Scale"); + Scale->SetAttribute("x", vScale.x); + Scale->SetAttribute("y", vScale.y); + Scale->SetAttribute("z", vScale.z); + object->InsertEndChild(Scale); + + tinyxml2::XMLElement* Rotation = doc.NewElement("Rotation"); + Rotation->SetAttribute("x", vRotation.x); + Rotation->SetAttribute("y", vRotation.y); + Rotation->SetAttribute("z", vRotation.z); + object->InsertEndChild(Rotation); +#pragma endregion + + + } + } +#pragma endregion + +#pragma region ELEMENT_INTERACTABEL + pLayer = m_pGameInstance->Get_Layer(ENUM_CLASS(LEVEL::MAP), TEXT("Layer_Element_Interactable")); + + if (nullptr != pLayer) + { + const list* pList = pLayer->Get_Objects(); + + for (auto pGamObject : *pList) + { + CMapElement* pElement = dynamic_cast(pGamObject); + + if (nullptr == pElement) + return E_FAIL; + + _uint iLodLevel = pElement->Get_LodLevel(); + + tinyxml2::XMLElement* object = doc.NewElement("Object"); + object->SetAttribute("Type", ENUM_CLASS(MAPOBJECT_TYPE::ELEMENT_INTERACT)); + object->SetAttribute("Lod_Level", iLodLevel); + land->InsertEndChild(object); + +#pragma region PROTOTYPETAG + for (_uint i = 0; i < iLodLevel + 1; ++i) + { + tinyxml2::XMLElement* prototype = doc.NewElement("PrototypeTag"); + prototype->SetText(CMyTools::ToString(pElement->Get_PrototypeTag(i)).c_str()); + object->InsertEndChild(prototype); + } +#pragma endregion + +#pragma region TRANSFORM + _float3 vPosition = {}; + XMStoreFloat3(&vPosition, pGamObject->Get_Component()->Get_State(STATE::POSITION)); + + _float3 vScale = pGamObject->Get_Component()->Get_Scale(); + + _float3 vRotation = {}; + XMStoreFloat3(&vRotation, pGamObject->Get_Component()->Get_RollPitchYawVector()); + vRotation.x = XMConvertToDegrees(vRotation.x); + vRotation.y = XMConvertToDegrees(vRotation.y); + vRotation.z = XMConvertToDegrees(vRotation.z); + + tinyxml2::XMLElement* Position = doc.NewElement("Position"); + Position->SetAttribute("x", vPosition.x); + Position->SetAttribute("y", vPosition.y); + Position->SetAttribute("z", vPosition.z); + object->InsertEndChild(Position); + + tinyxml2::XMLElement* Scale = doc.NewElement("Scale"); + Scale->SetAttribute("x", vScale.x); + Scale->SetAttribute("y", vScale.y); + Scale->SetAttribute("z", vScale.z); + object->InsertEndChild(Scale); + + tinyxml2::XMLElement* Rotation = doc.NewElement("Rotation"); + Rotation->SetAttribute("x", vRotation.x); + Rotation->SetAttribute("y", vRotation.y); + Rotation->SetAttribute("z", vRotation.z); + object->InsertEndChild(Rotation); +#pragma endregion + + } + } +#pragma endregion + + // ÀúÀå if (doc.SaveFile(strPath.c_str()) != tinyxml2::XML_SUCCESS) { MSG_BOX("Failed to Save File"); @@ -235,11 +383,6 @@ HRESULT CMapObject_Manager::Save_MapData(const _char* pFileName) MSG_BOX("Succeed to Save File"); } - return S_OK; - - - - return S_OK; } @@ -300,7 +443,10 @@ HRESULT CMapObject_Manager::Save_ContainerData(const _char* pFileName, const _ch { // tinyxml2::XMLElement* PartObject = doc.NewElement("PartObject"); - PartObject->SetAttribute("Lod_Level", pMapObject->Get_LodLevel()); + _uint iLodLvel = pMapObject->Get_LodLevel(); + + PartObject->SetAttribute("Lod_Level", iLodLvel); + PartObject->SetAttribute("Key_Index", pMapObject->Get_iKeyIndex()); container->InsertEndChild(PartObject); for (_uint i = 0; i < pMapObject->Get_LodLevel() + 1; ++i) @@ -417,86 +563,96 @@ HRESULT CMapObject_Manager::Load_MapData(const _char* pFileName) for (auto* PartObject = Container->FirstChildElement("PartObject"); PartObject; PartObject = PartObject->NextSiblingElement("PartObject")) { _uint iLodLevel = {}; + _uint iKeyIndex = {}; PartObject->QueryUnsignedAttribute("Lod_Level", &iLodLevel); - -#pragma region MAPOBJECT_STATIC - if (0 == iLodLevel) /* MapObject_Static */ - { - MAPOBJECT_STATIC_DESC Desc = {}; - string strTag = {}; - auto* PrototypeTag = PartObject->FirstChildElement("PrototypeTag"); - - strTag = PrototypeTag->GetText(); - - Desc.strModelPrototypeTag = CMyTools::ToWstring(strTag); - - Desc.pParentTransform = pContainerObject->Get_Component(); - const string strKey = strTag; - - /* 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); - - pContainerObject->Add_Part(strKey, g_iStaticLevel, nullptr, &Desc); - } -#pragma endregion + PartObject->QueryUnsignedAttribute("Key_Index", &iKeyIndex); #pragma region MAPOBJECT_LOD - else + MAPOBJECT_LOD_DESC Desc = {}; + string strTag = {}; + for (auto* PrototypeTag = PartObject->FirstChildElement("PrototypeTag"); PrototypeTag; PrototypeTag = PrototypeTag->NextSiblingElement("PrototypeTag")) { - MAPOBJECT_LOD_DESC Desc = {}; - string strTag = {}; - for (auto* PrototypeTag = PartObject->FirstChildElement("PrototypeTag"); PrototypeTag; PrototypeTag = PrototypeTag->NextSiblingElement("PrototypeTag")) - { - strTag = PrototypeTag->GetText(); + strTag = PrototypeTag->GetText(); - Desc.ModelPrototypeTags.push_back(CMyTools::ToWstring(strTag)); - } - - Desc.pParentTransform = pContainerObject->Get_Component(); - const string strKey = strTag; - - /* 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); - - pContainerObject->Add_Part(strKey, g_iStaticLevel, nullptr, &Desc); + 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); + + CMapObject_LOD* pMapObject; + + if (FAILED(pContainerObject->Add_Part(strKey, g_iStaticLevel, &pMapObject, &Desc))) + return E_FAIL; + + pMapObject->Set_KeyIndex(iKeyIndex); + + SAFE_RELEASE(pMapObject); #pragma endregion } #pragma endregion } + for (auto* Object = root->FirstChildElement("Object"); Object; Object = Object->NextSiblingElement("Object")) + { + MAPOBJECT_LOD_DESC Desc = {}; + + MAPOBJECT_TYPE eType = {}; + + Object->QueryUnsignedAttribute("Type", (_uint*)(&eType)); + Object->QueryUnsignedAttribute("Lod_Level", &Desc.iMaxLodLevel); + + auto* Position = Object->FirstChildElement("Position"); + Position->QueryFloatAttribute("x", &Desc.vPosition.x); + Position->QueryFloatAttribute("y", &Desc.vPosition.y); + Position->QueryFloatAttribute("z", &Desc.vPosition.z); + + auto* Scale = Object->FirstChildElement("Scale"); + Scale->QueryFloatAttribute("x", &Desc.vScale.x); + Scale->QueryFloatAttribute("y", &Desc.vScale.y); + Scale->QueryFloatAttribute("z", &Desc.vScale.z); + + auto* Rotation = Object->FirstChildElement("Rotation"); + Rotation->QueryFloatAttribute("x", &Desc.vRotation.x); + Rotation->QueryFloatAttribute("y", &Desc.vRotation.y); + Rotation->QueryFloatAttribute("z", &Desc.vRotation.z); + + string strTag = {}; + + for (auto* PrototypeTag = Object->FirstChildElement("PrototypeTag"); PrototypeTag; PrototypeTag = PrototypeTag->NextSiblingElement("PrototypeTag")) + { + strTag = PrototypeTag->GetText(); + + Desc.ModelPrototypeTags.push_back(CMyTools::ToWstring(strTag)); + } + + if(MAPOBJECT_TYPE::ELEMENT_STATIC == eType) + m_pGameInstance->Add_GameObject_ToLayer(g_iStaticLevel, NEXT_LEVEL, TEXT("Layer_Element_Static"), &Desc); + else if(MAPOBJECT_TYPE::ELEMENT_INTERACT == eType) + m_pGameInstance->Add_GameObject_ToLayer(g_iStaticLevel, NEXT_LEVEL, TEXT("Layer_Element_Interact"), &Desc); + } + return S_OK; } @@ -568,48 +724,12 @@ HRESULT CMapObject_Manager::Load_ContainerData(const _char* pFileName, const _ch for (auto* PartObject = TargetContainer->FirstChildElement("PartObject"); PartObject; PartObject = PartObject->NextSiblingElement("PartObject")) { _uint iLodLevel = {}; + _uint iKeyIndex = {}; PartObject->QueryUnsignedAttribute("Lod_Level", &iLodLevel); - -#pragma region MAPOBJECT_STATIC - if (0 == iLodLevel) /* MapObject_Static */ - { - MAPOBJECT_STATIC_DESC Desc = {}; - string strTag = {}; - auto* PrototypeTag = PartObject->FirstChildElement("PrototypeTag"); - - strTag = PrototypeTag->GetText(); - - Desc.strModelPrototypeTag = CMyTools::ToWstring(strTag); - Desc.iMaxLodLevel = iLodLevel; - Desc.pParentTransform = pContainerObject->Get_Component(); - const string strKey = strTag; - - /* 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); - - pContainerObject->Add_Part(strKey, g_iStaticLevel, nullptr, &Desc); - } -#pragma endregion + PartObject->QueryUnsignedAttribute("Key_Index", &iKeyIndex); #pragma region MAPOBJECT_LOD - else - { MAPOBJECT_LOD_DESC Desc = {}; string strTag = {}; for (auto* PrototypeTag = PartObject->FirstChildElement("PrototypeTag"); PrototypeTag; PrototypeTag = PrototypeTag->NextSiblingElement("PrototypeTag")) @@ -620,7 +740,7 @@ HRESULT CMapObject_Manager::Load_ContainerData(const _char* pFileName, const _ch } Desc.iMaxLodLevel = iLodLevel; Desc.pParentTransform = pContainerObject->Get_Component(); - const string strKey = strTag; + const string strKey = CMyTools::ToString(Desc.ModelPrototypeTags.front()) + to_string(iKeyIndex); /* Position */ tinyxml2::XMLElement* Position = PartObject->FirstChildElement("Position"); @@ -641,7 +761,6 @@ HRESULT CMapObject_Manager::Load_ContainerData(const _char* pFileName, const _ch Rotation->QueryFloatAttribute("z", &Desc.vRotation.z); pContainerObject->Add_Part(strKey, g_iStaticLevel, nullptr, &Desc); - } #pragma endregion } @@ -661,69 +780,29 @@ void CMapObject_Manager::Update_PrototypeList() { auto& Tag = m_ModelPrototypeTags[i]; - if (_wstring::npos != Tag.find(L"Lod")){ + if (_wstring::npos != Tag.find(L"Lod")) { continue; } if (ImGui::Button(CMyTools::ToString(Tag).c_str())) { - vector<_uint> LodModelIndices; - - if(false == Find_Lod_Prototype(Tag, LodModelIndices)) + switch (m_eType) { - MAPOBJECT_STATIC_DESC Desc = {}; + case Editor::CMapObject_Manager::ADD_TYPE::CONTAINER: + Create_PartObject(Tag); + break; - Desc.strModelPrototypeTag = Tag; - Desc.pParentTransform = m_pTransformCom; - Desc.vPosition = _float3(0.f, 0.f, 0.f); - Desc.vRotation = _float3(0.f, 0.f, 0.f); - Desc.vScale = _float3(1.f, 1.f, 1.f); - Desc.iModelPathIndex = i; + case Editor::CMapObject_Manager::ADD_TYPE::ELEMENT_STATIC: + Create_Elemnt_Static(Tag); + break; - CMapObject_Static* pMapObject = { nullptr }; - const string strKey = CMyTools::ToString(Tag); - - pMapObject = m_pGameInstance->Clone_Prototype(g_iStaticLevel, &Desc); - - /* if(FAILED(m_pContainer->Add_Part(strKey, 0, &pMapObject, &Desc))) - break;*/ - - m_MapObjects.push_back(pMapObject); - } - else - { - MAPOBJECT_LOD_DESC Desc = {}; - - vector<_wstring> PrototypeTags; - - PrototypeTags.push_back(Tag); - Desc.iMaxLodLevel = 0; - Desc.ModelPrototypeTags = PrototypeTags; - Desc.pParentTransform = m_pTransformCom; - Desc.vPosition = _float3(0.f, 0.f, 0.f); - Desc.vRotation = _float3(0.f, 0.f, 0.f); - Desc.vScale = _float3(1.f, 1.f, 1.f); - Desc.pModelPathIndices = &LodModelIndices; - - CMapObject_LOD* pMapObject = { nullptr }; - const string strKey = CMyTools::ToString(Tag); - - pMapObject = m_pGameInstance->Clone_Prototype(g_iStaticLevel, &Desc); - - //if (FAILED(m_pContainer->Add_Part(strKey, 0, &pMapObject, &Desc))) - // break; - - m_MapObjects.push_back(pMapObject); - - for (_uint i = 0; i < LodModelIndices.size(); ++i) - { - _wstring strLodTag = Tag + L"_Lod" + to_wstring(i + 1); - - pMapObject->Add_LodModel(strLodTag.c_str()); - } - - + case Editor::CMapObject_Manager::ADD_TYPE::ELEMENT_INTERACT: + Create_Elemnt_Interact(Tag); + break; + default: + break; } + } } GUI::End(); @@ -732,10 +811,7 @@ void CMapObject_Manager::Update_PrototypeList() void CMapObject_Manager::Update_ObjectList() { - //CLayer* pLayer = m_pGameInstance->Get_Layer(ENUM_CLASS(LEVEL::MAP), TEXT("Layer_MapObject")); - - //if (nullptr == pLayer) - // return; + CLayer* pLayer = { nullptr }; //m_pMapObjects = pLayer->Get_Objects(); @@ -744,41 +820,93 @@ void CMapObject_Manager::Update_ObjectList() _uint iObjectIndex = {}; string strSrc; - if (false == m_MapObjects.empty()) + if(ADD_TYPE::CONTAINER == m_eType) { - for (auto pMapObject : m_MapObjects) + if (false == m_MapObjects.empty()) { - CMapObject* pCurrentMapObject = static_cast(pMapObject); + 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; + } + } + } + } + else + { + if (ADD_TYPE::ELEMENT_STATIC == m_eType) + pLayer = m_pGameInstance->Get_Layer(ENUM_CLASS(LEVEL::MAP), TEXT("Layer_Element_Static")); + else if (ADD_TYPE::ELEMENT_INTERACT == m_eType) + pLayer = m_pGameInstance->Get_Layer(ENUM_CLASS(LEVEL::MAP), TEXT("Layer_Element_Interact")); + + if (nullptr == pLayer) + { + GUI::End(); + return; + } + + const list* pObjectList = pLayer->Get_Objects(); + + for (auto pObject : *pObjectList) + { + CMapElement* pCurrentMapObject = static_cast(pObject); if (nullptr == pCurrentMapObject) continue; - wstring strPrototypeTag = pCurrentMapObject->Get_PrototypeTag(); + wstring strPrototypeTag = pCurrentMapObject->Get_PrototypeTag(0); strSrc = CMyTools::ToString(strPrototypeTag) + to_string(iObjectIndex) + "##" + to_string(iObjectIndex++); if (ImGui::Button(strSrc.c_str())) { - m_pSelectObject = pCurrentMapObject; + m_pSelectElemnt = pCurrentMapObject; } } } + GUI::End(); } void CMapObject_Manager::Update_Edit() { GUI::Begin("Edit"); - if (m_pGameInstance->Mouse_Down(DIM_4)) - m_pSelectObject = nullptr; - if (nullptr != m_pSelectObject) + if (ADD_TYPE::CONTAINER == m_eType) { - m_pSelectObject->Describe_Entity(); - if (m_pSelectObject->isDead()) + if (m_pGameInstance->Mouse_Down(DIM_4)) m_pSelectObject = nullptr; + if (nullptr != m_pSelectObject) + { + m_pSelectObject->Describe_Entity(); + if (m_pSelectObject->isDead()) + m_pSelectObject = nullptr; + + } + } + else + { + if (m_pGameInstance->Mouse_Down(DIM_4)) + m_pSelectElemnt = nullptr; + + if (nullptr != m_pSelectElemnt) + { + m_pSelectElemnt->Describe_Entity(); + if (m_pSelectElemnt->isDead()) + m_pSelectElemnt = nullptr; + } } GUI::End(); @@ -823,12 +951,111 @@ void CMapObject_Manager::Update_ContainerObject() GUI::End(); } +void CMapObject_Manager::Create_PartObject(_wstring& strPrototypeTag) +{ + vector<_uint> LodModelIndices; + + MAPOBJECT_LOD_DESC Desc = {}; + + vector<_wstring> PrototypeTags; + + Find_Lod_Prototype(strPrototypeTag, LodModelIndices); + + PrototypeTags.push_back(strPrototypeTag); + + for (_uint i = 0; i < LodModelIndices.size(); ++i) + { + _wstring strLodTag = strPrototypeTag + L"_Lod" + to_wstring(i + 1); + PrototypeTags.push_back(strLodTag); + } + + Desc.iMaxLodLevel = (_uint)LodModelIndices.size() - 1; + Desc.ModelPrototypeTags = PrototypeTags; + Desc.pParentTransform = m_pTransformCom; + Desc.vPosition = _float3(0.f, 0.f, 0.f); + Desc.vRotation = _float3(0.f, 0.f, 0.f); + Desc.vScale = _float3(1.f, 1.f, 1.f); + Desc.pModelPathIndices = &LodModelIndices; + + CMapObject_LOD* pMapObject = { nullptr }; + const string strKey = CMyTools::ToString(strPrototypeTag); + + pMapObject = m_pGameInstance->Clone_Prototype(g_iStaticLevel, &Desc); + pMapObject->Set_KeyIndex(Get_KeyCount(strPrototypeTag)); + + m_MapObjects.push_back(pMapObject); +} + +void CMapObject_Manager::Create_Elemnt_Static(_wstring& strPrototypeTag) +{ + vector<_uint> LodModelIndices; + + MAPOBJECT_LOD_DESC Desc = {}; + + vector<_wstring> PrototypeTags; + + Find_Lod_Prototype(strPrototypeTag, LodModelIndices); + + PrototypeTags.push_back(strPrototypeTag); + + for (_uint i = 0; i < LodModelIndices.size(); ++i) + { + _wstring strLodTag = strPrototypeTag + L"_Lod" + to_wstring(i + 1); + PrototypeTags.push_back(strLodTag); + } + + Desc.iMaxLodLevel = (_uint)LodModelIndices.size() - 1; + Desc.ModelPrototypeTags = PrototypeTags; + Desc.pParentTransform = m_pTransformCom; + Desc.vPosition = _float3(0.f, 0.f, 0.f); + Desc.vRotation = _float3(0.f, 0.f, 0.f); + Desc.vScale = _float3(1.f, 1.f, 1.f); + Desc.pModelPathIndices = &LodModelIndices; + + CMapElement_Static* pMapObject = { nullptr }; + const string strKey = CMyTools::ToString(strPrototypeTag); + + m_pGameInstance->Add_GameObject_ToLayer(g_iStaticLevel, NEXT_LEVEL, TEXT("Layer_Element_Static"), &Desc); +} + +void CMapObject_Manager::Create_Elemnt_Interact(_wstring& strPrototypeTag) +{ + vector<_uint> LodModelIndices; + + MAPOBJECT_LOD_DESC Desc = {}; + + vector<_wstring> PrototypeTags; + + Find_Lod_Prototype(strPrototypeTag, LodModelIndices); + + PrototypeTags.push_back(strPrototypeTag); + + for (_uint i = 0; i < LodModelIndices.size(); ++i) + { + _wstring strLodTag = strPrototypeTag + L"_Lod" + to_wstring(i + 1); + PrototypeTags.push_back(strLodTag); + } + + Desc.iMaxLodLevel = (_uint)LodModelIndices.size() - 1; + Desc.ModelPrototypeTags = PrototypeTags; + Desc.pParentTransform = m_pTransformCom; + Desc.vPosition = _float3(0.f, 0.f, 0.f); + Desc.vRotation = _float3(0.f, 0.f, 0.f); + Desc.vScale = _float3(1.f, 1.f, 1.f); + Desc.pModelPathIndices = &LodModelIndices; + + CMapElement_Interactable* pMapObject = { nullptr }; + const string strKey = CMyTools::ToString(strPrototypeTag); + + m_pGameInstance->Add_GameObject_ToLayer(g_iStaticLevel, NEXT_LEVEL, TEXT("Layer_Element_Interact"), &Desc); +} + _bool CMapObject_Manager::Find_Lod_Prototype(_wstring strPrototypeTag, vector<_uint>& LodModelIndices) { // for (auto& Tag : m_LODModelPrototypeTags) for(_uint i = 0 ; i < m_ModelPrototypeTags.size(); ++i) { - if (_wstring::npos != m_ModelPrototypeTags[i].find(strPrototypeTag)) + if (_wstring::npos != m_ModelPrototypeTags[i].find(strPrototypeTag) && 5 > (m_ModelPrototypeTags[i].size() - strPrototypeTag.size())) LodModelIndices.push_back(i); } if (0 < LodModelIndices.size()) { @@ -839,6 +1066,16 @@ _bool CMapObject_Manager::Find_Lod_Prototype(_wstring strPrototypeTag, vector<_u // return true; } +_uint CMapObject_Manager::Get_KeyCount(_wstring strPrototypeTag) +{ + auto iter = m_PartObjectKeyCount.find(strPrototypeTag); + + if (iter == m_PartObjectKeyCount.end()) + return 0; + + return iter->second++; +} + CMapObject_Manager* CMapObject_Manager::Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext, vector<_wstring>& ModelPrototypeTags, vector& ModelPrototypePaths) { diff --git a/Jusin154_Team3D/Editor/Public/BuildingContainer.h b/Jusin154_Team3D/Editor/Public/BuildingContainer.h index 3dcd25980..bf4694f2d 100644 --- a/Jusin154_Team3D/Editor/Public/BuildingContainer.h +++ b/Jusin154_Team3D/Editor/Public/BuildingContainer.h @@ -7,8 +7,6 @@ NS_BEGIN(Editor) class CBuildingContainer final : public CMapContainer { - - public: CBuildingContainer(ID3D11Device* pDevice, ID3D11DeviceContext* pContext); CBuildingContainer(const CBuildingContainer& rhs); diff --git a/Jusin154_Team3D/Editor/Public/MapElement.h b/Jusin154_Team3D/Editor/Public/MapElement.h index f4ff533ae..d88aa7df9 100644 --- a/Jusin154_Team3D/Editor/Public/MapElement.h +++ b/Jusin154_Team3D/Editor/Public/MapElement.h @@ -17,6 +17,10 @@ class CMapElement abstract : public CGameObject CMapElement(const CMapElement& rhs); virtual ~CMapElement() = default; +public: + _uint Get_LodLevel() const{ return m_iMaxLodLevel; } + const _wstring& Get_PrototypeTag(_uint iIndex); + public: virtual void Priority_Update(_float fTimeDelta) override; virtual void Update(_float fTimeDelta) override; diff --git a/Jusin154_Team3D/Editor/Public/MapObject.h b/Jusin154_Team3D/Editor/Public/MapObject.h index cd10f0da4..157f5a3e2 100644 --- a/Jusin154_Team3D/Editor/Public/MapObject.h +++ b/Jusin154_Team3D/Editor/Public/MapObject.h @@ -25,7 +25,8 @@ class CMapObject abstract : public CPartObject public: virtual _wstring Get_PrototypeTag(_uint iLodIndex = 0); - virtual _uint Get_LodLevel() { return m_iMaxLodLevel; } + _uint Get_LodLevel(); + _uint Get_iKeyIndex() const { return m_iKeyIndex; } protected: @@ -39,6 +40,7 @@ class CMapObject abstract : public CPartObject protected: _bool m_bSelected = {}; + _uint m_iKeyIndex = {}; _uint m_iMaxLodLevel = {}; _float3 m_vPosition = {}; diff --git a/Jusin154_Team3D/Editor/Public/MapObject_LOD.h b/Jusin154_Team3D/Editor/Public/MapObject_LOD.h index 194fbb031..b936eacdd 100644 --- a/Jusin154_Team3D/Editor/Public/MapObject_LOD.h +++ b/Jusin154_Team3D/Editor/Public/MapObject_LOD.h @@ -23,12 +23,14 @@ class CMapObject_LOD final : public CMapObject // LOD public: virtual _wstring Get_PrototypeTag(_uint iLodIndex = 0); HRESULT Add_LodModel(const _tchar* pModelPrototypeTag); + void Set_KeyIndex(_uint iIndex) { + m_iKeyIndex = iIndex; + } private: CShader* m_pShaderCom = { nullptr }; vector m_pModelComs; - _uint m_iMaxLodLevel = {}; _uint m_iLodIndex = {}; vector<_wstring> m_ModelPrototypeTags; diff --git a/Jusin154_Team3D/Editor/Public/MapObject_Manager.h b/Jusin154_Team3D/Editor/Public/MapObject_Manager.h index 5ca6933d7..6d717337c 100644 --- a/Jusin154_Team3D/Editor/Public/MapObject_Manager.h +++ b/Jusin154_Team3D/Editor/Public/MapObject_Manager.h @@ -12,6 +12,8 @@ NS_BEGIN(Editor) class CMapObject_Manager final : public CGameObject { + enum class ADD_TYPE {CONTAINER, ELEMENT_STATIC, ELEMENT_INTERACT}; + private: CMapObject_Manager(ID3D11Device* pDevice, ID3D11DeviceContext* pContext); CMapObject_Manager(const CMapObject_Manager& Prototype); @@ -28,15 +30,20 @@ class CMapObject_Manager final : public CGameObject const filesystem::path Get_PrototypePath(_uint iModelIndex); private: + ADD_TYPE m_eType = {}; + class CMapObject* m_pSelectObject = { nullptr }; + class CMapElement* m_pSelectElemnt = { nullptr }; list m_MapObjects = {}; vector<_wstring> m_ModelPrototypeTags; + map<_wstring, _uint> m_PartObjectKeyCount; vector<_wstring> m_LODModelPrototypeTags; vector m_ModelPrototypePaths; _uint m_iContainerObjectIndex = {}; class CBuildingContainer* m_pContainer = { nullptr }; + _char m_szSaveFileName[MAX_PATH] = {}; _char m_szSaveContainerName[MAX_PATH] = {}; private: HRESULT Ready_Components(); @@ -44,8 +51,9 @@ class CMapObject_Manager final : public CGameObject #pragma region SAVE_LOAD HRESULT Save_MapData(const _char* pFileName); - HRESULT Save_ContainerData(const _char* pFileName, const _char* pContainerName); HRESULT Load_MapData(const _char* pFileName); + + HRESULT Save_ContainerData(const _char* pFileName, const _char* pContainerName); HRESULT Load_ContainerData(const _char* pFileName, const _char* pContainerName); #pragma endregion @@ -54,8 +62,12 @@ class CMapObject_Manager final : public CGameObject void Update_Edit(); void Update_ContainerObject(); - _bool Find_Lod_Prototype(_wstring strPrototypeTag, vector<_uint>& LodModelIndices); + void Create_PartObject(_wstring& strPrototypeTag); + void Create_Elemnt_Static(_wstring& strPrototypeTag); + void Create_Elemnt_Interact(_wstring& strPrototypeTag); + _bool Find_Lod_Prototype(_wstring strPrototypeTag, vector<_uint>& LodModelIndices); + _uint Get_KeyCount(_wstring strPrototypeTag); public: static CMapObject_Manager* Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext, vector<_wstring>& ModelPrototypeTags, vector& ModelPrototypePaths); virtual CGameObject* Clone(void* pArg, CGameObject* pOwner = nullptr) override;