Made MeshRenderer able to take a matrix transform for each mesh, and we are now able to draw 100 cubes.
Claude OPus helpes with implementation
This commit is contained in:
@@ -109,7 +109,20 @@ void JulietApplication::Init()
|
||||
Running = false;
|
||||
}
|
||||
|
||||
std::ignore = AddCube();
|
||||
constexpr int kGridSize = 10;
|
||||
constexpr float kSpacing = 2.5f;
|
||||
constexpr float kOffset = (kGridSize - 1) * kSpacing * 0.5f;
|
||||
|
||||
for (int row = 0; row < kGridSize; ++row)
|
||||
{
|
||||
for (int col = 0; col < kGridSize; ++col)
|
||||
{
|
||||
MeshID cube = AddCube();
|
||||
float x = static_cast<float>(col) * kSpacing - kOffset;
|
||||
float y = static_cast<float>(row) * kSpacing - kOffset;
|
||||
SetMeshTransform(cube, MatrixTranslation(x, y, 0.0f));
|
||||
}
|
||||
}
|
||||
|
||||
CommandList* loadCmd = AcquireCommandList(GraphicsDevice);
|
||||
LoadMeshesOnGPU(loadCmd);
|
||||
@@ -275,8 +288,6 @@ void JulietApplication::OnRender(RenderPass* pass, CommandList* cmd)
|
||||
pushData.ViewProjection = Camera_GetViewProjectionMatrix(GetDebugCamera());
|
||||
|
||||
RenderMeshes(pass, cmd, pushData);
|
||||
|
||||
// SetPushConstants(cmd, ShaderStage::Vertex, 0, sizeof(pushData) / 4, &pushData);
|
||||
}
|
||||
|
||||
ColorTargetInfo JulietApplication::GetColorTargetInfo(Texture* swapchainTexture)
|
||||
@@ -308,14 +319,14 @@ Camera JulietApplication::GetDebugCamera()
|
||||
float currentOrbitTime = time * orbitSpeed;
|
||||
|
||||
// --- Adjusted for 1-Meter Scale ---
|
||||
float baseRadius = 2.5f; // Hover 2.5 meters away (down from 15.0f)
|
||||
float baseRadius = 25.0f; // Increased to see 10x10 cube grid
|
||||
|
||||
float radius = baseRadius;
|
||||
/* Uncomment for active zoom
|
||||
float zoomAmplitude = 1.0f; // Oscillate between 1.5m and 3.5m away
|
||||
//* Uncomment for active zoom
|
||||
float zoomAmplitude = 10.0f; // Oscillate between 1.5m and 3.5m away
|
||||
float zoomSpeed = 0.8f;
|
||||
radius = baseRadius + (sinf(time * zoomSpeed) * zoomAmplitude);
|
||||
*/
|
||||
radius = baseRadius + (sinf(time * zoomSpeed) * zoomAmplitude);
|
||||
//*/
|
||||
float zHeight = radius * 0.5f; // Keep a nice downward viewing angle
|
||||
|
||||
Camera cam = {};
|
||||
|
||||
Reference in New Issue
Block a user