本文整理汇总了C++中GeometryGenerator::CreateSquare方法的典型用法代码示例。如果您正苦于以下问题:C++ GeometryGenerator::CreateSquare方法的具体用法?C++ GeometryGenerator::CreateSquare怎么用?C++ GeometryGenerator::CreateSquare使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GeometryGenerator
的用法示例。
在下文中一共展示了GeometryGenerator::CreateSquare方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GeoBuffer
void Map::GeoBuffer()
{
for (int y = 0; y < Md_.height; y++)
{
for (int x = 0; x < Md_.width; x++)
{
float ID = (float)Md_.grid[x][y][0] - 1;
float col = floor(ID / 52.0f);
float row = ID - (col * 52.0f);
float sx = 1.0f / 52.0f;
float sy = 1.0f / 52.0f;
XMMATRIX trans = XMMatrixTranslation(row, col, 0.0f);
XMMATRIX scale = XMMatrixScaling(sx, sy, 1.0f);
XMStoreFloat4x4(&mTexTransform[x + (y * Md_.width)], trans * scale);
GeometryGenerator::MeshData box;
GeometryGenerator geoGen;
//geoGen.CreateBox(1.0f, 1.0f, 1.0f, box);
//geoGen.CreateFullscreenQuad(box); //Works
//geoGen.CreateGrid(2.0f, 2.0f, 10, 10, box);
//geoGen.CreateGeosphere(0.75f, 100, box);
geoGen.CreateSquare(x, y, box);
// Cache the vertex offsets to each object in the concatenated vertex buffer.
mBoxVertexOffset = 0;
// Cache the index count of each object.
mBoxIndexCount = box.Indices.size();
// Cache the starting index for each object in the concatenated index buffer.
mBoxIndexOffset = 0;
//UINT totalVertexCount = box.Vertices.size();
UINT totalVertexCount = box.Vertices.size();
UINT totalIndexCount = mBoxIndexCount;
//
// Extract the vertex elements we are interested in and pack the
// vertices of all the meshes into one vertex buffer.
//
std::vector<GeometryGenerator::Vertex> vertices(totalVertexCount);
UINT k = 0;
for (size_t i = 0; i < box.Vertices.size(); ++i, ++k)
{
vertices[k].Position = box.Vertices[i].Position;
vertices[k].Normal = box.Vertices[i].Normal;
vertices[k].TexC = box.Vertices[i].TexC;
}
D3D11_BUFFER_DESC vbd;
vbd.Usage = D3D11_USAGE_IMMUTABLE;
vbd.ByteWidth = sizeof(GeometryGenerator::Vertex) * totalVertexCount;
vbd.BindFlags = D3D11_BIND_VERTEX_BUFFER;
vbd.CPUAccessFlags = 0;
vbd.MiscFlags = 0;
D3D11_SUBRESOURCE_DATA vinitData;
vinitData.pSysMem = &vertices[0];
pDev_->CreateBuffer(&vbd, &vinitData, &mBoxVB[x + (y * Md_.width)]);
//
// Pack the indices of all the meshes into one index buffer.
//
std::vector<UINT> indices;
indices.insert(indices.end(), box.Indices.begin(), box.Indices.end());
D3D11_BUFFER_DESC ibd;
ibd.Usage = D3D11_USAGE_IMMUTABLE;
ibd.ByteWidth = sizeof(UINT) * totalIndexCount;
ibd.BindFlags = D3D11_BIND_INDEX_BUFFER;
ibd.CPUAccessFlags = 0;
ibd.MiscFlags = 0;
D3D11_SUBRESOURCE_DATA iinitData;
iinitData.pSysMem = &indices[0];
pDev_->CreateBuffer(&ibd, &iinitData, &mBoxIB[x + (y * Md_.width)]);
}
}
}