MCPcopy Create free account
hub / github.com/TheRealMJP/DeferredTexturing / InitPlane

Method InitPlane

SampleFramework12/v1.00/Graphics/Model.cpp:321–355  ·  view source on GitHub ↗

Initializes the mesh as a plane

Source from the content-addressed store, hash-verified

319
320// Initializes the mesh as a plane
321void Mesh::InitPlane(const Float2& dimensions, const Float3& position, const Quaternion& orientation, uint32 materialIdx,
322 MeshVertex* dstVertices, uint16* dstIndices)
323{
324 uint64 vIdx = 0;
325
326 dstVertices[vIdx++] = MeshVertex(Float3(-1.0f, 0.0f, 1.0f), Float3(0.0f, 1.0f, 0.0f), Float2(0.0f, 0.0f), Float3(1.0f, 0.0f, 0.0f), Float3(0.0f, 0.0f, -1.0f));
327 dstVertices[vIdx++] = MeshVertex(Float3(1.0f, 0.0f, 1.0f), Float3(0.0f, 1.0f, 0.0f), Float2(1.0f, 0.0f), Float3(1.0f, 0.0f, 0.0f), Float3(0.0f, 0.0f, -1.0f));
328 dstVertices[vIdx++] = MeshVertex(Float3(1.0f, 0.0f, -1.0f), Float3(0.0f, 1.0f, 0.0f), Float2(1.0f, 1.0f), Float3(1.0f, 0.0f, 0.0f), Float3(0.0f, 0.0f, -1.0f));
329 dstVertices[vIdx++] = MeshVertex(Float3(-1.0f, 0.0f, -1.0f), Float3(0.0f, 1.0f, 0.0f), Float2(0.0f, 1.0f), Float3(1.0f, 0.0f, 0.0f), Float3(0.0f, 0.0f, -1.0f));
330
331 for(uint64 i = 0; i < NumPlaneVerts; ++i)
332 dstVertices[i].Transform(position, Float3(dimensions.x, 1.0f, dimensions.y) * 0.5f, orientation);
333
334 uint64 iIdx = 0;
335 dstIndices[iIdx++] = 0;
336 dstIndices[iIdx++] = 1;
337 dstIndices[iIdx++] = 2;
338 dstIndices[iIdx++] = 2;
339 dstIndices[iIdx++] = 3;
340 dstIndices[iIdx++] = 0;
341
342 const uint32 indexSize = 2;
343 indexType = IndexType::Index16Bit;
344
345 numVertices = uint32(NumPlaneVerts);
346 numIndices = uint32(NumPlaneIndices);
347
348 meshParts.Init(1);
349 MeshPart& part = meshParts[0];
350 part.IndexStart = 0;
351 part.IndexCount = numIndices;
352 part.VertexStart = 0;
353 part.VertexCount = numVertices;
354 part.MaterialIdx = materialIdx;
355}
356
357void Mesh::InitCommon(const MeshVertex* vertices_, const uint16* indices_, uint64 vbAddress, uint64 ibAddress, uint64 vtxOffset_, uint64 idxOffset_)
358{

Callers 1

GeneratePlaneSceneMethod · 0.80

Calls 5

MeshVertexClass · 0.85
Float3Class · 0.85
Float2Class · 0.85
TransformMethod · 0.45
InitMethod · 0.45

Tested by

no test coverage detected