[add] MapTool Level

[add] MapObject
[add] MapObject Manager
This commit is contained in:
JinhoBa
2025-11-11 22:15:11 +09:00
parent 237c9e8d53
commit b19671ad8e
9 changed files with 430 additions and 317 deletions
@@ -153,6 +153,7 @@
<ClInclude Include="..\public\Active_Icon.h" />
<ClInclude Include="..\Public\DummyObject.h" />
<ClInclude Include="..\public\GamePlay_Canvas.h" />
<ClInclude Include="..\public\BuildingContainer.h" />
<ClInclude Include="..\Public\DebugCamera.h" />
<ClInclude Include="..\Public\Dummy_PhysXBox.h" />
<ClInclude Include="..\Public\Dummy_PhysXMesh.h">
@@ -163,8 +164,11 @@
<ClInclude Include="..\Public\EditEffect.h" />
<ClInclude Include="..\public\Level_MapViewer.h" />
<ClInclude Include="..\Public\LoadingWidget.h" />
<ClInclude Include="..\public\MapContainer.h" />
<ClInclude Include="..\public\MapObject.h" />
<ClInclude Include="..\public\MapObject_LOD.h" />
<ClInclude Include="..\public\MapObject_Manager.h" />
<ClInclude Include="..\public\MapObject_Static.h" />
<ClInclude Include="..\public\Terrain.h" />
<ClInclude Include="..\Public\Level_PhysXLab.h" />
<ClInclude Include="..\Public\TestEffect.h" />
@@ -210,6 +214,7 @@
<ClCompile Include="..\private\Active_Icon.cpp" />
<ClCompile Include="..\Private\DummyObject.cpp" />
<ClCompile Include="..\private\GamePlay_Canvas.cpp" />
<ClCompile Include="..\private\BuildingContainer.cpp" />
<ClCompile Include="..\Private\DebugCamera.cpp" />
<ClCompile Include="..\Private\Dummy_PhysXBox.cpp" />
<ClCompile Include="..\Private\Dummy_PhysXMesh.cpp">
@@ -220,8 +225,11 @@
<ClCompile Include="..\Private\EditEffect.cpp" />
<ClCompile Include="..\private\Level_MapViewer.cpp" />
<ClCompile Include="..\Private\LoadingWidget.cpp" />
<ClCompile Include="..\private\MapContainer.cpp" />
<ClCompile Include="..\private\MapObject.cpp" />
<ClCompile Include="..\private\MapObject_LOD.cpp" />
<ClCompile Include="..\private\MapObject_Manager.cpp" />
<ClCompile Include="..\private\MapObject_Static.cpp" />
<ClCompile Include="..\private\Terrain.cpp" />
<ClCompile Include="..\Private\Level_PhysXLab.cpp" />
<ClCompile Include="..\Private\TestEffect.cpp" />
@@ -145,9 +145,6 @@
<Filter Include="02.GameObjects\Terrain">
<UniqueIdentifier>{44a3ddc2-3993-48d6-840c-3da09daeab70}</UniqueIdentifier>
</Filter>
<Filter Include="02.GameObjects\Env\Manger">
<UniqueIdentifier>{584466e9-fe1a-4a7d-a4ba-54d62ee1a7c1}</UniqueIdentifier>
</Filter>
<Filter Include="01.Level\60.PhysXLab">
<UniqueIdentifier>{943a760b-2861-45b7-87b8-462e1309c172}</UniqueIdentifier>
</Filter>
@@ -166,6 +163,24 @@
<Filter Include="02.GameObjects\Dummys\PhysXMesh">
<UniqueIdentifier>{15a9dfe7-f3f7-4906-8bd4-91734f4ddc92}</UniqueIdentifier>
</Filter>
<Filter Include="02.GameObjects\Env\00.Manger">
<UniqueIdentifier>{584466e9-fe1a-4a7d-a4ba-54d62ee1a7c1}</UniqueIdentifier>
</Filter>
<Filter Include="02.GameObjects\Env\01.MapContainer">
<UniqueIdentifier>{d925c13c-6d66-4632-8bef-172baa566920}</UniqueIdentifier>
</Filter>
<Filter Include="02.GameObjects\Env\01.MapContainer\BuildingContainer">
<UniqueIdentifier>{9643531b-3b64-4a3b-9ba7-e372b4e4ddba}</UniqueIdentifier>
</Filter>
<Filter Include="02.GameObjects\Env\02.MapObject">
<UniqueIdentifier>{702dfe26-f6b0-4aa0-b8d5-79385c0191d1}</UniqueIdentifier>
</Filter>
<Filter Include="02.GameObjects\Env\02.MapObject\Static">
<UniqueIdentifier>{bc80fcba-1ebd-497c-a40d-973e44ad3ef8}</UniqueIdentifier>
</Filter>
<Filter Include="02.GameObjects\Env\02.MapObject\LOD">
<UniqueIdentifier>{34fa4d78-8091-44cf-b4b4-59db9fd56d98}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="Editor.h">
@@ -303,14 +318,11 @@
<ClInclude Include="..\public\Level_MapViewer.h">
<Filter>01.Level\30.MapViewer</Filter>
</ClInclude>
<ClInclude Include="..\public\MapObject.h">
<Filter>02.GameObjects\Env</Filter>
</ClInclude>
<ClInclude Include="..\public\Terrain.h">
<Filter>02.GameObjects\Terrain</Filter>
</ClInclude>
<ClInclude Include="..\public\MapObject_Manager.h">
<Filter>02.GameObjects\Env\Manger</Filter>
<Filter>02.GameObjects\Env\00.Manger</Filter>
</ClInclude>
<ClInclude Include="..\Public\Level_PhysXLab.h">
<Filter>01.Level\60.PhysXLab</Filter>
@@ -327,6 +339,21 @@
<ClInclude Include="..\Public\DummyObject.h">
<Filter>02.GameObjects\Dummys\DummyObject</Filter>
</ClInclude>
<ClInclude Include="..\public\MapContainer.h">
<Filter>02.GameObjects\Env\01.MapContainer</Filter>
</ClInclude>
<ClInclude Include="..\public\BuildingContainer.h">
<Filter>02.GameObjects\Env\01.MapContainer\BuildingContainer</Filter>
</ClInclude>
<ClInclude Include="..\public\MapObject.h">
<Filter>02.GameObjects\Env\02.MapObject</Filter>
</ClInclude>
<ClInclude Include="..\public\MapObject_Static.h">
<Filter>02.GameObjects\Env\02.MapObject\Static</Filter>
</ClInclude>
<ClInclude Include="..\public\MapObject_LOD.h">
<Filter>02.GameObjects\Env\02.MapObject\LOD</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<Image Include="Editor.ico">
@@ -445,14 +472,11 @@
<ClCompile Include="..\private\Level_MapViewer.cpp">
<Filter>01.Level\30.MapViewer</Filter>
</ClCompile>
<ClCompile Include="..\private\MapObject.cpp">
<Filter>02.GameObjects\Env</Filter>
</ClCompile>
<ClCompile Include="..\private\Terrain.cpp">
<Filter>02.GameObjects\Terrain</Filter>
</ClCompile>
<ClCompile Include="..\private\MapObject_Manager.cpp">
<Filter>02.GameObjects\Env\Manger</Filter>
<Filter>02.GameObjects\Env\00.Manger</Filter>
</ClCompile>
<ClCompile Include="..\Private\Level_PhysXLab.cpp">
<Filter>01.Level\60.PhysXLab</Filter>
@@ -484,6 +508,21 @@
<ClCompile Include="..\Private\DummyObject.cpp">
<Filter>02.GameObjects\Dummys\DummyObject</Filter>
</ClCompile>
<ClCompile Include="..\private\MapContainer.cpp">
<Filter>02.GameObjects\Env\01.MapContainer</Filter>
</ClCompile>
<ClCompile Include="..\private\BuildingContainer.cpp">
<Filter>02.GameObjects\Env\01.MapContainer\BuildingContainer</Filter>
</ClCompile>
<ClCompile Include="..\private\MapObject.cpp">
<Filter>02.GameObjects\Env\02.MapObject</Filter>
</ClCompile>
<ClCompile Include="..\private\MapObject_Static.cpp">
<Filter>02.GameObjects\Env\02.MapObject\Static</Filter>
</ClCompile>
<ClCompile Include="..\private\MapObject_LOD.cpp">
<Filter>02.GameObjects\Env\02.MapObject\LOD</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="Editor.rc">
@@ -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<CMapObject>(g_iStaticLevel, NEXT_LEVEL,strLayerTag, &Desc)))
// return E_FAIL;
if (FAILED(m_pGameInstance->Add_GameObject_ToLayer<CBuildingContainer>(g_iStaticLevel, NEXT_LEVEL, strLayerTag)))
return E_FAIL;
return S_OK;
}
+15 -5
View File
@@ -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<CMapObject>(g_iStaticLevel, CMapObject::Create(m_pDevice, m_pContext))))
/* For.Prototype_GameObject_BuildingContainer */
if (FAILED(m_pGameInstance->Add_Prototype<CBuildingContainer>(g_iStaticLevel, CBuildingContainer::Create(m_pDevice, m_pContext))))
return E_FAIL;
/* For.Prototype_GameObject_MapObject_Static */
if (FAILED(m_pGameInstance->Add_Prototype<CMapObject_Static>(g_iStaticLevel, CMapObject_Static::Create(m_pDevice, m_pContext))))
return E_FAIL;
/* For.Prototype_GameObject_MapObject_LOD */
if (FAILED(m_pGameInstance->Add_Prototype<CMapObject_LOD>(g_iStaticLevel, CMapObject_LOD::Create(m_pDevice, m_pContext))))
return E_FAIL;
/* For.Prototype_GameObject_Terrain */
+58 -156
View File
@@ -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<MAPOBJECT_DESC*>(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<CComponent**>(&m_pModelCom))))
return E_FAIL;
/* Com_Shader */
if (FAILED(__super::Add_Asset_Component(g_iStaticLevel, FX_MESH,
reinterpret_cast<CComponent**>(&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<CTerrain>();
if (nullptr != pTerrain)
{
pTerrain->Get_Component<CVIBuffer_Terrain>()->Picking(pTerrain->Get_Component<CTransform>(), 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;
}
@@ -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<CBuildingContainer>();
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<CMapObject>(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<CMapObject*>(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<CGameObject*>* pObjectList = m_pGameInstance->Get_Layer(ENUM_CLASS(LEVEL::MAP), TEXT("Layer_MapObject"))->Get_Objects();
//const list<CGameObject*>* 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<CMapObject*>(pObjcet);
//for (auto& pObjcet : *pObjectList)
//{
// CMapObject* pMapObject = dynamic_cast<CMapObject*>(pObjcet);
if (nullptr == pMapObject)
continue;
// if (nullptr == pMapObject)
// continue;
// <Model>
tinyxml2::XMLElement* model = doc.NewElement("Model");
land->InsertEndChild(model);
// // <Model>
// tinyxml2::XMLElement* model = doc.NewElement("Model");
// land->InsertEndChild(model);
// <PrototypeTag>ÅØ½ºÆ®</PrototypeTag>
tinyxml2::XMLElement* proto = doc.NewElement("PrototypeTag");
proto->SetText(CMyTools::ToString(pMapObject->Get_PrototypeTag()).c_str());
model->InsertEndChild(proto);
// // <PrototypeTag>ÅØ½ºÆ®</PrototypeTag>
// tinyxml2::XMLElement* proto = doc.NewElement("PrototypeTag");
// proto->SetText(CMyTools::ToString(pMapObject->Get_PrototypeTag()).c_str());
// model->InsertEndChild(proto);
// <Position x="0.0" y="0.0" z="0.0"/>
tinyxml2::XMLElement* PositionElem = doc.NewElement("Position");
// // <Position x="0.0" y="0.0" z="0.0"/>
// 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);
// <Scale x="0.0" y="0.0" z="0.0"/>
tinyxml2::XMLElement* ScaleElem = doc.NewElement("Scale");
// // <Scale x="0.0" y="0.0" z="0.0"/>
// tinyxml2::XMLElement* ScaleElem = doc.NewElement("Scale");
_float3 pScale = pMapObject->Get_Component<CTransform>()->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<CTransform>()->Get_Scale();
// ScaleElem->SetAttribute("x", pScale.x);
// ScaleElem->SetAttribute("y", pScale.y);
// ScaleElem->SetAttribute("z", pScale.z);
// model->InsertEndChild(ScaleElem);
// <Rotation x="0.0" y="0.0" z="0.0"/>
tinyxml2::XMLElement* RotationElem = doc.NewElement("Rotation");
// // <Rotation x="0.0" y="0.0" z="0.0"/>
// tinyxml2::XMLElement* RotationElem = doc.NewElement("Rotation");
_float3 vRotation = {};
XMStoreFloat3(&vRotation, pMapObject->Get_Component<CTransform>()->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<CTransform>()->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<CTransform>();
CMapObject_Static* pMapObject = { nullptr };
const string strKey = CMyTools::ToString(Tag);
m_pContainer->Add_Part<CMapObject_Static>(strKey, 0, &pMapObject, &Desc);
m_MapObjects.push_back(pMapObject);
}
else
{
CMapObject_LOD::MAPOBJECT_LOD_DESC Desc = {};
vector<const _tchar*> PrototypeTags;
PrototypeTags.push_back(Tag.c_str());
Desc.iMaxLodLevel = 0;
Desc.ModelPrototypeTags = PrototypeTags;
Desc.pParentTransform = m_pContainer->Get_Component<CTransform>();
CMapObject_Static* pMapObject = { nullptr };
const string strKey = CMyTools::ToString(Tag);
m_pContainer->Add_Part<CMapObject_LOD>(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<CMapObject_LOD*>(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<CMapObject*>(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()
@@ -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);
+14 -23
View File
@@ -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;
};
@@ -26,14 +26,23 @@ class CMapObject_Manager final : public CGameObject
virtual HRESULT Render() override;
private:
class CMapObject* m_pSelectObject = { nullptr };
const list<class CGameObject*>* m_pMapObjects = { nullptr };
class CMapObject* m_pSelectObject = { nullptr };
list<class CMapObject*> 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);