本文整理汇总了C++中MeshData::SetBoundingBox方法的典型用法代码示例。如果您正苦于以下问题:C++ MeshData::SetBoundingBox方法的具体用法?C++ MeshData::SetBoundingBox怎么用?C++ MeshData::SetBoundingBox使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MeshData
的用法示例。
在下文中一共展示了MeshData::SetBoundingBox方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CreateGameObject
//.........这里部分代码省略.........
texture_coordinate[index_ul].x,
(texture_coordinate[index_ul].y == 1.0f ? 0.0f : texture_coordinate[index_ul].y)
);
const float2 ur_uv(
(texture_coordinate[index_ur].x == 0.0f ? 1.0f : texture_coordinate[index_ur].x),
(texture_coordinate[index_ur].y == 1.0f ? 0.0f : texture_coordinate[index_ur].y)
);
Vector3 bl(i * m_initInfo.CellSpacing, m_HeightMap[index_bl] * m_initInfo.CellSpacing, j* m_initInfo.CellSpacing);
Vector3 br((i + 8)* m_initInfo.CellSpacing, m_HeightMap[index_br] * m_initInfo.CellSpacing, j* m_initInfo.CellSpacing);
Vector3 ul(i* m_initInfo.CellSpacing, m_HeightMap[index_ul] * m_initInfo.CellSpacing, (j + 8)* m_initInfo.CellSpacing);
Vector3 ur((i + 8)* m_initInfo.CellSpacing, m_HeightMap[index_ur] * m_initInfo.CellSpacing, (j + 8)* m_initInfo.CellSpacing);
const int patch_id = j + (i / m_initInfo.CellsPerPatch);
// bottom left
{
vertices[indexCounter].m_pos = bl;
vertices[indexCounter].m_UV[0] = bl_uv.x;
vertices[indexCounter].m_UV[1] = bl_uv.y;
vertices[indexCounter].m_boundsY[0] = boundsY[patch_id].x;
vertices[indexCounter].m_boundsY[1] = boundsY[patch_id].y;
indices[indexCounter] = indexCounter;
indexCounter++;
}
// bottom right
{
vertices[indexCounter].m_pos = br;
vertices[indexCounter].m_UV[0] = br_uv.x;
vertices[indexCounter].m_UV[1] = br_uv.y;
vertices[indexCounter].m_boundsY[0] = boundsY[patch_id].x;
vertices[indexCounter].m_boundsY[1] = boundsY[patch_id].y;
indices[indexCounter] = indexCounter;
indexCounter++;
}
// upper left
{
vertices[indexCounter].m_pos = ul;
vertices[indexCounter].m_UV[0] = ul_uv.x;
vertices[indexCounter].m_UV[1] = ul_uv.y;
vertices[indexCounter].m_boundsY[0] = boundsY[patch_id].x;
vertices[indexCounter].m_boundsY[1] = boundsY[patch_id].y;
indices[indexCounter] = indexCounter;
indexCounter++;
}
// upper right
{
vertices[indexCounter].m_pos = ur;
vertices[indexCounter].m_UV[0] = ur_uv.x;
vertices[indexCounter].m_UV[1] = ur_uv.y;
vertices[indexCounter].m_boundsY[0] = boundsY[patch_id].x;
vertices[indexCounter].m_boundsY[1] = boundsY[patch_id].y;
indices[indexCounter] = indexCounter;
indexCounter++;
}
}
}
std::string diffuseTxt_filepath = std::string("../Assets/") + diffuseTxt_filename;
std::string normalTxt_filepath = std::string("../Assets/") + normalTxt_filename;
std::string heightTxt_filepath = std::string("../Assets/") + heightTxt_filemane;
MeshData* meshData = new MeshData(vertices, iNumVertices, indices, iNumIndices, sizeof(VertexTerrain));
meshData->SetBoundingBox(AABB(Vector3(0, 0, 0), Vector3(m_initInfo.HeightmapHeight, 0, m_initInfo.HeightmapWidth)));
Handle hMeshComp(sizeof(MeshComponent));
new (hMeshComp) MeshComponent(meshData);
SceneGraph::GetInstance()->AddComponent((MeshComponent*) hMeshComp.Raw());
RenderPass* renderPass = new RenderPass;
renderPass->SetVertexShader("../DEngine/Shaders/VS_terrain.hlsl");
renderPass->SetHullShader("../DEngine/Shaders/HS_terrain.hlsl");
renderPass->SetDomainShader("../DEngine/Shaders/DS_terrain.hlsl");
renderPass->SetPixelShader("../DEngine/Shaders/PS_terrain.hlsl");
Handle hTexture1(sizeof(Texture));
new (hTexture1) Texture(Texture::SHADER_RESOURCES, 1, diffuseTxt_filepath.c_str());
Handle hTexture2(sizeof(Texture));
new (hTexture2) Texture(Texture::SHADER_RESOURCES, 1, normalTxt_filepath.c_str());
Handle hTexture3(sizeof(Texture));
new (hTexture3) Texture(Texture::SHADER_RESOURCES, 1, heightTxt_filepath.c_str());
renderPass->AddTexture(hTexture1);
renderPass->AddTexture(hTexture2);
renderPass->AddTexture(hTexture3);
renderPass->SetTopology(D3D_PRIMITIVE_TOPOLOGY_4_CONTROL_POINT_PATCHLIST);
renderPass->SetBlendState(State::NULL_STATE);
renderPass->SetRenderTargets(D3D11Renderer::GetInstance()->m_pRTVArray, 2);
renderPass->SetDepthStencilView(D3D11Renderer::GetInstance()->m_depth->GetDSV());
renderPass->SetDepthStencilState(State::DEFAULT_DEPTH_STENCIL_DSS);
renderPass->SetRasterizerState(State::CULL_BACK_RS);
((MeshComponent*) hMeshComp.Raw())->m_pMeshData->m_Material.AddPassToTechnique(renderPass);
GameObject* terrain = new GameObject;
terrain->AddComponent((Component*) hMeshComp.Raw());
delete[] vertices;
delete[] indices;
return terrain;
}