Merge branch 'Develope' into Camera
This commit is contained in:
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -112,7 +112,7 @@ void CAlphaMap::Load_ToFile(const _char* pFilePath)
|
||||
if (FAILED(m_pContext->Map(m_pTexture2D, 0, D3D11_MAP_WRITE_DISCARD, 0, &SubResource)))
|
||||
return;
|
||||
|
||||
MSG_BOX("Success to Load Binanry File");
|
||||
//MSG_BOX("Success to Load Binanry File");
|
||||
|
||||
memcpy(SubResource.pData, m_pPixels, sizeof(_float4) * m_iNumPixels);
|
||||
|
||||
|
||||
@@ -36,12 +36,15 @@ void CBuildingContainer::Update(_float fTimeDelta)
|
||||
|
||||
void CBuildingContainer::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 // _DEBUG
|
||||
|
||||
__super::Late_Update(fTimeDelta);
|
||||
|
||||
@@ -147,10 +150,8 @@ void CBuildingContainer::Describe_Entity()
|
||||
|
||||
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<CTerrain>();
|
||||
if (nullptr != pTerrain)
|
||||
if (m_pGameInstance->isPicking(&m_vPosition))
|
||||
{
|
||||
pTerrain->Get_Component<CVIBuffer_Terrain>()->Picking(pTerrain->Get_Component<CTransform>()->Get_XMWorldMatrix(), &m_vPosition);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -57,9 +57,18 @@ HRESULT CMapObject_LOD::Initialize(void* pArg)
|
||||
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));
|
||||
|
||||
XMStoreFloat4x4(&m_CombinedWorldMatrix, m_pTransformCom->Get_XMWorldMatrix() * m_pParentTransformCom->Get_XMWorldMatrix());
|
||||
|
||||
_float3 vOffset = m_pModelComs[0]->Get_RadiusOffset();
|
||||
_matrix ColliderMatrix = XMMatrixTranslation(vOffset.x, vOffset.y, vOffset.z) * XMLoadFloat4x4(&m_CombinedWorldMatrix);
|
||||
XMStoreFloat4(&m_vExtentPosition, ColliderMatrix.r[3]);
|
||||
|
||||
|
||||
|
||||
|
||||
//m_pGameInstance->Add_RenderGroup(RENDER::NONBLEND, this);
|
||||
|
||||
|
||||
@@ -78,18 +87,12 @@ void CMapObject_LOD::Priority_Update(_float fTimeDelta)
|
||||
|
||||
void CMapObject_LOD::Update(_float fTimeDelta)
|
||||
{
|
||||
//if (0 == m_iLodIndex)
|
||||
// m_bSelected = true;
|
||||
/*if (0 == m_iLodIndex)
|
||||
m_bSelected = true;*/
|
||||
|
||||
//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));
|
||||
|
||||
XMStoreFloat4x4(&m_CombinedWorldMatrix, m_pTransformCom->Get_XMWorldMatrix() * m_pParentTransformCom->Get_XMWorldMatrix());
|
||||
|
||||
_float3 vOffset = m_pModelComs[0]->Get_RadiusOffset();
|
||||
_matrix ColliderMatrix = XMMatrixTranslation(vOffset.x, vOffset.y, vOffset.z) * XMLoadFloat4x4(&m_CombinedWorldMatrix);
|
||||
XMStoreFloat4(&m_vExtentPosition, ColliderMatrix.r[3]);
|
||||
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));
|
||||
}
|
||||
|
||||
void CMapObject_LOD::Late_Update(_float fTimeDelta)
|
||||
@@ -102,6 +105,12 @@ void CMapObject_LOD::Late_Update(_float fTimeDelta)
|
||||
m_pTransformCom->Rotation(XMConvertToRadians(m_vRotation.x), XMConvertToRadians(m_vRotation.y), XMConvertToRadians(m_vRotation.z));
|
||||
}
|
||||
#endif
|
||||
XMStoreFloat4x4(&m_CombinedWorldMatrix, m_pTransformCom->Get_XMWorldMatrix() * m_pParentTransformCom->Get_XMWorldMatrix());
|
||||
|
||||
_float3 vOffset = m_pModelComs[0]->Get_RadiusOffset();
|
||||
_matrix ColliderMatrix = XMMatrixTranslation(vOffset.x, vOffset.y, vOffset.z) * XMLoadFloat4x4(&m_CombinedWorldMatrix);
|
||||
XMStoreFloat4(&m_vExtentPosition, ColliderMatrix.r[3]);
|
||||
|
||||
_float fRaius = m_pModelComs[0]->Get_Radius();
|
||||
if (m_pGameInstance->isIn_WorldFrustum(XMLoadFloat4(&m_vExtentPosition), fRaius)) {
|
||||
|
||||
|
||||
@@ -1348,7 +1348,7 @@ void CMapObject_Manager::Update_ContainerObject()
|
||||
|
||||
for (auto& pObject : (*pList))
|
||||
{
|
||||
if (GUI::Button((dynamic_cast<CMapContainer*>(pObject)->Get_Name().c_str())))
|
||||
if (GUI::Button((dynamic_cast<CMapContainer*>(pObject)->Get_Name() + to_string(iIndex)).c_str()))
|
||||
{
|
||||
m_iContainerObjectIndex = iIndex;
|
||||
}
|
||||
|
||||
@@ -40,6 +40,9 @@ HRESULT CTerrain::Initialize(void* pArg)
|
||||
|
||||
m_pAlphaMap->Load_ToFile("Hogsmeade_AlphaMap.bin");
|
||||
|
||||
if (FAILED(m_pVIBufferCom->Load_HeightMap("Hogsmeade_HeightMap.bin")))
|
||||
return E_FAIL;
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
@@ -63,7 +66,7 @@ void CTerrain::Priority_Update(_float fTimeDelta)
|
||||
//}
|
||||
|
||||
|
||||
GUI::DragFloat("Up", &m_fUpValue, 0.01f, -1.0f, 1.f);
|
||||
//GUI::DragFloat("Up", &m_fUpValue, 0.01f, -1.0f, 1.f);
|
||||
if (m_pGameInstance->Mouse_Pressing(DIM_LBUTTON))
|
||||
{
|
||||
if (m_pGameInstance->isPicking(&m_vPickingPosition))
|
||||
@@ -82,23 +85,24 @@ void CTerrain::Priority_Update(_float fTimeDelta)
|
||||
}
|
||||
#pragma endregion
|
||||
|
||||
#pragma region HEIGHT MAP
|
||||
//HRESULT hr = {};
|
||||
//if(GUI::Button("Save HeightMap"))
|
||||
// hr = m_pVIBufferCom->Save_HeightMap("Hogsmeade_HeightMap.bin");
|
||||
//if(GUI::Button("Load HeightMap"))
|
||||
// hr = m_pVIBufferCom->Load_HeightMap("Hogsmeade_HeightMap.bin");
|
||||
#pragma endregion
|
||||
|
||||
|
||||
/*GUI::InputFloat("Height Ratio", &m_fHeightRatio);
|
||||
max(0.01f, m_fHeightRatio);
|
||||
*/
|
||||
//m_pVIBufferCom->Change_HeigthRatio(m_fHeightRatio);
|
||||
//GUI::DragFloat3("Picking", (_float*)(&m_vPickingPosition));
|
||||
_float4 vPos = {};
|
||||
_float3 vRotation = {};
|
||||
XMStoreFloat4(&vPos, m_pTransformCom->Get_State(STATE::POSITION));
|
||||
GUI::DragFloat3("Pos", (_float*)(&vPos));
|
||||
GUI::DragFloat3("Rota", (_float*)(&m_vRotation));
|
||||
//_float4 vPos = {};
|
||||
//_float3 vRotation = {};
|
||||
//XMStoreFloat4(&vPos, m_pTransformCom->Get_State(STATE::POSITION));
|
||||
//GUI::DragFloat3("Pos", (_float*)(&vPos));
|
||||
//GUI::DragFloat3("Rota", (_float*)(&m_vRotation));
|
||||
|
||||
//m_pTransformCom->Rotation(XMConvertToRadians(m_vRotation.x), XMConvertToRadians(m_vRotation.y), XMConvertToRadians(m_vRotation.z));
|
||||
m_pTransformCom->Set_State(STATE::POSITION, XMLoadFloat4(&vPos));
|
||||
//m_pTransformCom->Set_State(STATE::POSITION, XMLoadFloat4(&vPos));
|
||||
|
||||
GUI::DragFloat("Culling Radius", &m_fCullingRadius, 0.01f, 0.01f, 2.f);
|
||||
//GUI::DragFloat("Culling Radius", &m_fCullingRadius, 0.01f, 0.01f, 2.f);
|
||||
|
||||
GUI::End();
|
||||
}
|
||||
@@ -107,7 +111,10 @@ void CTerrain::Update(_float fTimeDelta)
|
||||
{
|
||||
//m_pVIBufferCom->Culling(XMMatrixIdentity());
|
||||
|
||||
|
||||
if(m_pGameInstance->Key_Down(DIK_LSHIFT) && m_pGameInstance->Key_Down(DIK_W))
|
||||
{
|
||||
m_bWasWireFrame = !m_bWasWireFrame;
|
||||
}
|
||||
}
|
||||
|
||||
void CTerrain::Late_Update(_float fTimeDelta)
|
||||
@@ -122,9 +129,18 @@ HRESULT CTerrain::Render()
|
||||
if (FAILED(Bind_ShaderResources())) {
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
if (FAILED(m_pShaderCom->Begin(ENUM_CLASS(SHADER_PASS_NORTEX::DEFAULT)))) {
|
||||
return E_FAIL;
|
||||
|
||||
if(m_bWasWireFrame)
|
||||
{
|
||||
if (FAILED(m_pShaderCom->Begin(ENUM_CLASS(SHADER_PASS_NORTEX::TERRAIN)))) {
|
||||
return E_FAIL;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (FAILED(m_pShaderCom->Begin(ENUM_CLASS(SHADER_PASS_NORTEX::DEFAULT)))) {
|
||||
return E_FAIL;
|
||||
}
|
||||
}
|
||||
|
||||
if (FAILED(m_pVIBufferCom->Bind_Resources())) {
|
||||
|
||||
@@ -49,6 +49,7 @@ class CTerrain final : public CGameObject
|
||||
_float m_fMaskValue = {0.1f};
|
||||
|
||||
_float m_fUpValue = { 0.01f };
|
||||
_bool m_bWasWireFrame = { false };
|
||||
|
||||
private:
|
||||
HRESULT Ready_Components();
|
||||
|
||||
@@ -277,9 +277,7 @@ _bool CQuadTree::Set_Y(CGameInstance* pGameInstance, const _float3* pVertexPosit
|
||||
{
|
||||
if (nullptr == m_pChildren[CORNER_LT])
|
||||
{
|
||||
pVertices[m_iCorners[CORNER_LT]].vPosition.y += fY;
|
||||
pVertices[m_iCorners[CORNER_RT]].vPosition.y += fY;
|
||||
pVertices[m_iCorners[CORNER_RB]].vPosition.y += fY;
|
||||
Add_Y(pVertices, fY);
|
||||
|
||||
XMStoreFloat3(&Out, XMVector3TransformCoord(XMLoadFloat3(&Out), WorldMatrix));
|
||||
return true;
|
||||
@@ -291,9 +289,7 @@ _bool CQuadTree::Set_Y(CGameInstance* pGameInstance, const _float3* pVertexPosit
|
||||
{
|
||||
if (nullptr == m_pChildren[CORNER_LT])
|
||||
{
|
||||
pVertices[m_iCorners[CORNER_LT]].vPosition.y += fY;
|
||||
pVertices[m_iCorners[CORNER_RB]].vPosition.y += fY;
|
||||
pVertices[m_iCorners[CORNER_LB]].vPosition.y += fY;
|
||||
Add_Y(pVertices, fY);
|
||||
|
||||
XMStoreFloat3(&Out, XMVector3TransformCoord(XMLoadFloat3(&Out), WorldMatrix));
|
||||
return true;
|
||||
@@ -313,6 +309,24 @@ _bool CQuadTree::Set_Y(CGameInstance* pGameInstance, const _float3* pVertexPosit
|
||||
return false;
|
||||
}
|
||||
|
||||
void CQuadTree::Add_Y(VTXNORTEX* pVertices, _float fY)
|
||||
{
|
||||
_float fValue = {};
|
||||
|
||||
fValue += pVertices[m_iCorners[CORNER_LT]].vPosition.y;
|
||||
fValue += pVertices[m_iCorners[CORNER_RB]].vPosition.y;
|
||||
fValue += pVertices[m_iCorners[CORNER_RT]].vPosition.y;
|
||||
fValue += pVertices[m_iCorners[CORNER_LB]].vPosition.y;
|
||||
|
||||
fValue /= 4.0f;
|
||||
fValue += fY;
|
||||
|
||||
pVertices[m_iCorners[CORNER_LT]].vPosition.y = fValue;
|
||||
pVertices[m_iCorners[CORNER_RB]].vPosition.y = fValue;
|
||||
pVertices[m_iCorners[CORNER_RT]].vPosition.y = fValue;
|
||||
pVertices[m_iCorners[CORNER_LB]].vPosition.y = fValue;
|
||||
}
|
||||
|
||||
_bool CQuadTree::isDraw(CGameInstance* pGameInstance, const _float3* pVertexPositions)
|
||||
{
|
||||
_vector vCamPos = XMLoadFloat4(pGameInstance->Get_CamPosition());
|
||||
|
||||
@@ -106,7 +106,7 @@ HRESULT CTexture::Load_SRV(const _char* szPath, ID3D11ShaderResourceView** ppSRV
|
||||
|
||||
HRESULT hr = {};
|
||||
|
||||
hr = CreateDDSTextureFromFile(m_pDevice, CMyTools::ToWstring(szTextureFilePath).c_str(), nullptr, ppSRV); // 일단 dds로 시도하고
|
||||
hr = CreateDDSTextureFromFile(m_pDevice, CMyTools::ToWstring(szTextureFilePath).c_str(), nullptr, ppSRV, 1024); // 일단 dds로 시도하고
|
||||
if (FAILED(hr)) {
|
||||
memset(szTextureFilePath, 0, sizeof(_char) * MAX_PATH); // 실패하면 원래 확장자로 다시 시도
|
||||
strcat_s(szTextureFilePath, szTextureFileName);
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include "QuadTree.h"
|
||||
|
||||
#define STB_IMAGE_IMPLEMENTATION
|
||||
#define STB_IMAGE_WRITE_IMPLEMENTATION
|
||||
#include "stb_image.h"
|
||||
|
||||
CVIBuffer_Terrain::CVIBuffer_Terrain(ID3D11Device* pDevice, ID3D11DeviceContext* pContext)
|
||||
@@ -26,6 +27,7 @@ HRESULT CVIBuffer_Terrain::Initialize_Prototype(const _char* pFilePath, _uint iS
|
||||
_int iWidth = {};
|
||||
_int iHeight = {};
|
||||
_int iComp = {};
|
||||
|
||||
unsigned char* pTexture = {};
|
||||
pTexture = stbi_load(pFilePath, &iWidth, &iHeight, &iComp, 0);
|
||||
|
||||
@@ -252,7 +254,7 @@ void CVIBuffer_Terrain::FitY(_fmatrix WorldMatrix, _float fY)
|
||||
|
||||
D3D11_MAPPED_SUBRESOURCE SubResource{};
|
||||
|
||||
m_pContext->Map(m_pVB, 0, D3D11_MAP_WRITE, 0, &SubResource);
|
||||
m_pContext->Map(m_pVB, 0, D3D11_MAP_READ_WRITE, 0, &SubResource);
|
||||
|
||||
VTXNORTEX* pVertices = static_cast<VTXNORTEX*>(SubResource.pData);
|
||||
|
||||
@@ -262,6 +264,12 @@ void CVIBuffer_Terrain::FitY(_fmatrix WorldMatrix, _float fY)
|
||||
|
||||
m_pQuadTree->Set_Y(m_pGameInstance, m_pVertexPositions, pVertices, WorldMatrix, fY);
|
||||
|
||||
for (_uint i = 0; i < m_iNumVertices; ++i)
|
||||
{
|
||||
memcpy(&m_pVertexPositions[i], &pVertices[i].vPosition, sizeof(_float3));
|
||||
}
|
||||
|
||||
|
||||
m_pContext->Unmap(m_pVB, 0);
|
||||
}
|
||||
|
||||
@@ -289,6 +297,74 @@ void CVIBuffer_Terrain::Set_CullingRadius(_float fRaduis)
|
||||
#endif // _DEBUG
|
||||
|
||||
|
||||
HRESULT CVIBuffer_Terrain::Save_HeightMap(const _char* pFilePath)
|
||||
{
|
||||
string strFilePath = "../Bin/Resources/Data/Map/" + string(pFilePath);
|
||||
|
||||
ofstream out(strFilePath, ios::binary);
|
||||
|
||||
if (false == out.is_open())
|
||||
{
|
||||
MSG_BOX("Failed to Save Binanry File");
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
D3D11_MAPPED_SUBRESOURCE SubResource{};
|
||||
|
||||
m_pContext->Map(m_pVB, 0, D3D11_MAP_READ, 0, &SubResource);
|
||||
|
||||
VTXNORTEX* pVertices = static_cast<VTXNORTEX*>(SubResource.pData);
|
||||
|
||||
for (_uint i = 0; i < m_iNumVerticesZ; ++i)
|
||||
{
|
||||
for (_uint j = 0; j < m_iNumVerticesX; ++j)
|
||||
{
|
||||
_uint iIndex = i * m_iNumVerticesX + j;
|
||||
out.write(reinterpret_cast<const _char*>(&pVertices[iIndex].vPosition.y), sizeof(_float));
|
||||
}
|
||||
}
|
||||
m_pContext->Unmap(m_pVB, 0);
|
||||
|
||||
out.close();
|
||||
|
||||
MSG_BOX("Success to Load Binanry File");
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT CVIBuffer_Terrain::Load_HeightMap(const _char* pFilePath)
|
||||
{
|
||||
string strFilePath = "../Bin/Resources/Data/Map/" + string(pFilePath);
|
||||
|
||||
ifstream in(strFilePath, ios::binary);
|
||||
|
||||
if (false == in.is_open())
|
||||
{
|
||||
MSG_BOX("Failed to Load Model Binanry File");
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
D3D11_MAPPED_SUBRESOURCE SubResource{};
|
||||
m_pContext->Map(m_pVB, 0, D3D11_MAP_WRITE, 0, &SubResource);
|
||||
|
||||
VTXNORTEX* pVertices = static_cast<VTXNORTEX*>(SubResource.pData);
|
||||
|
||||
for (_uint i = 0; i < m_iNumVerticesZ; ++i)
|
||||
{
|
||||
for (_uint j = 0; j < m_iNumVerticesX; ++j)
|
||||
{
|
||||
_uint iIndex = i * m_iNumVerticesX + j;
|
||||
in.read(reinterpret_cast<_char*>(&pVertices[iIndex].vPosition.y), sizeof(_float));
|
||||
}
|
||||
}
|
||||
|
||||
in.close();
|
||||
|
||||
m_pContext->Unmap(m_pVB, 0);
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
CVIBuffer_Terrain* CVIBuffer_Terrain::Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext, const _char* pFilePath, _uint iSizeX, _uint iSizeZ)
|
||||
{
|
||||
CVIBuffer_Terrain* pInstance = new CVIBuffer_Terrain(pDevice, pContext);
|
||||
|
||||
@@ -19,10 +19,11 @@ class CQuadTree final : public CBase
|
||||
#endif // _DEBUG
|
||||
|
||||
|
||||
void Culling(class CGameInstance* pGameInstance, const _float3* pVertexPositions, _uint* pIndices, _uint* pNumIndices);
|
||||
void SetUp_Neighbors();
|
||||
_bool Picking(class CGameInstance* pGameInstance, const _float3* pVertexPositions, _float3& Out, _fmatrix WorldMatrix);
|
||||
_bool Set_Y(class CGameInstance* pGameInstance, const _float3* pVertexPositions, VTXNORTEX* pVertices, _fmatrix WorldMatrix, _float fY);
|
||||
void Culling(class CGameInstance* pGameInstance, const _float3* pVertexPositions, _uint* pIndices, _uint* pNumIndices);
|
||||
void SetUp_Neighbors();
|
||||
_bool Picking(class CGameInstance* pGameInstance, const _float3* pVertexPositions, _float3& Out, _fmatrix WorldMatrix);
|
||||
_bool Set_Y(class CGameInstance* pGameInstance, const _float3* pVertexPositions, VTXNORTEX* pVertices, _fmatrix WorldMatrix, _float fY);
|
||||
void Add_Y(VTXNORTEX* pVertices, _float fY);
|
||||
|
||||
private:
|
||||
_uint m_iCorners[CORNER_END] = { };
|
||||
|
||||
@@ -28,7 +28,9 @@ class ENGINE_DLL CVIBuffer_Terrain final : public CVIBuffer
|
||||
void Change_HeigthRatio(_float fRatio);
|
||||
|
||||
#ifdef _DEBUG
|
||||
void Set_CullingRadius(_float fRaduis);
|
||||
void Set_CullingRadius(_float fRaduis);
|
||||
HRESULT Save_HeightMap(const _char* pFilePath);
|
||||
HRESULT Load_HeightMap(const _char* pFilePath);
|
||||
#endif // _DEBUG
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user