update
This commit is contained in:
parent
cb848e7109
commit
fe5404f6e7
3 changed files with 54 additions and 9 deletions
|
|
@ -7,6 +7,7 @@ module;
|
||||||
|
|
||||||
export module Crafter.Graphics:Mesh;
|
export module Crafter.Graphics:Mesh;
|
||||||
import Crafter.Component;
|
import Crafter.Component;
|
||||||
|
import Crafter.Math;
|
||||||
import :VulkanBuffer;
|
import :VulkanBuffer;
|
||||||
|
|
||||||
namespace Crafter {
|
namespace Crafter {
|
||||||
|
|
@ -62,5 +63,49 @@ namespace Crafter {
|
||||||
}
|
}
|
||||||
return mesh;
|
return mesh;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static Mesh* FromHeightMapUV(float* heights, uint32_t sizeX, uint32_t sizeZ, float spacing) {
|
||||||
|
Mesh* mesh = new Mesh(sizeX*sizeZ, ((sizeX-1)*(sizeZ-1))*6);
|
||||||
|
for (float x = 0; x < sizeX; x++)
|
||||||
|
{
|
||||||
|
for (float z = 0; z < sizeZ; z++)
|
||||||
|
{
|
||||||
|
uint32_t xInt = static_cast<uint32_t>(x);
|
||||||
|
uint32_t zInt = static_cast<uint32_t>(z);
|
||||||
|
Vector<float, 3> pos((x * spacing) - ((sizeX*spacing) / 2.0f), heights[xInt * sizeX + zInt], (z * spacing) - ((sizeZ*spacing) / 2.0f));
|
||||||
|
Vector<float, 2> uv(x / sizeX, z / sizeZ);
|
||||||
|
VertexType vertex;
|
||||||
|
vertex.x = pos.x;
|
||||||
|
vertex.y = pos.y;
|
||||||
|
vertex.z = pos.z;
|
||||||
|
vertex.w = 1.0f;
|
||||||
|
vertex.u = uv.x;
|
||||||
|
vertex.v = uv.y;
|
||||||
|
mesh->verticies.value[xInt * sizeX + zInt] = vertex;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (uint32_t x = 0; x < sizeX - 1; x++)
|
||||||
|
{
|
||||||
|
for (uint32_t z = 0; z < sizeZ - 1; z++)
|
||||||
|
{
|
||||||
|
uint32_t topLeftIndex = x * sizeZ + z;
|
||||||
|
uint32_t topRightIndex = topLeftIndex + 1;
|
||||||
|
uint32_t bottomLeftIndex = topLeftIndex + sizeZ;
|
||||||
|
uint32_t bottomRightIndex = bottomLeftIndex + 1;
|
||||||
|
|
||||||
|
uint32_t index = (x * sizeX + z)*6;
|
||||||
|
|
||||||
|
mesh->indicies.value[index] = topRightIndex;
|
||||||
|
mesh->indicies.value[index + 1] = bottomLeftIndex;
|
||||||
|
mesh->indicies.value[index + 2] = topLeftIndex;
|
||||||
|
|
||||||
|
mesh->indicies.value[index + 3] = bottomRightIndex;
|
||||||
|
mesh->indicies.value[index + 4] = bottomLeftIndex;
|
||||||
|
mesh->indicies.value[index + 5] = topRightIndex;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return mesh;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@ namespace Crafter {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export template <typename MeshShader, typename FragmentShader>
|
export template <typename MeshShader, typename FragmentShader, typename bruh>
|
||||||
class VulkanPipeline {
|
class VulkanPipeline {
|
||||||
private:
|
private:
|
||||||
consteval static std::uint32_t GetUniqueDiscriptorCount() {
|
consteval static std::uint32_t GetUniqueDiscriptorCount() {
|
||||||
|
|
|
||||||
16
project.json
16
project.json
|
|
@ -42,20 +42,20 @@
|
||||||
"debug": true,
|
"debug": true,
|
||||||
"dependencies": [
|
"dependencies": [
|
||||||
{
|
{
|
||||||
"path":"/home/jorijn/repos/Crafter/Crafter.Event/project.json",
|
"path":"https://forgejo.catcrafts.net/Catcrafts/Crafter.Event.git",
|
||||||
"configuration":"debug"
|
"configuration":"debug"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"path":"/home/jorijn/repos/Crafter/Crafter.Asset/project.json",
|
"path":"https://forgejo.catcrafts.net/Catcrafts/Crafter.Asset.git",
|
||||||
"configuration":"lib-debug"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"path":"/home/jorijn/repos/Crafter/Crafter.Component/project.json",
|
|
||||||
"configuration":"debug"
|
"configuration":"debug"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"path":"/home/jorijn/repos/Crafter/Crafter.Math/project.json",
|
"path":"https://forgejo.catcrafts.net/Catcrafts/Crafter.Component.git",
|
||||||
"configuration":"debug-lib"
|
"configuration":"debug"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path":"https://forgejo.catcrafts.net/Catcrafts/Crafter.Math.git",
|
||||||
|
"configuration":"debug"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue