Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SharedPtr<Mesh> MeshMgr::CreatePlane(const std::wstring & id, const UINT width, const UINT height, const float spacing)
- {
- Array<Vertex> verts(width * height);
- Array<UINT> indices;
- const float fWidth = static_cast<float>(width);
- const float fHeight = static_cast<float>(height);
- const float halfWidth = fWidth / 2.f;
- const float halfHeight = fHeight / 2.f;
- for (UINT y = 0; y < height; ++y)
- {
- for (UINT x = 0; x < width; ++x)
- {
- verts[y * width + x] = Vertex((x - halfWidth) * spacing, 0.f, (y - halfHeight) * spacing, 0.f, 1.f, 0.f, x / fWidth, y / fHeight);
- }
- }
- for (UINT y = 1; y < height; ++y)
- {
- for (UINT x = 1; x < width; ++x)
- {
- indices.push_back((y - 1) * width + (x - 1));
- indices.push_back((y - 0) * width + (x - 0));
- indices.push_back((y - 1) * width + (x - 0));
- indices.push_back((y - 1) * width + (x - 1));
- indices.push_back((y - 0) * width + (x - 1));
- indices.push_back((y - 0) * width + (x - 0));
- }
- }
- return CreateMesh(id, verts, indices);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement