Entity now can be linked to a mesh.

Only support cube generated from code no light no nothing
This commit is contained in:
2026-08-09 17:20:38 -04:00
parent 30ea435b87
commit 73aa4a846b
11 changed files with 177 additions and 89 deletions
+15
View File
@@ -15,6 +15,7 @@
#include <Entity/Entity.h>
#include <Entity/EntityManager.h>
#include <Graphics/Camera.h>
#include <Graphics/MeshRenderer.h>
#include <imgui.h>
GameState* gGameState = nullptr;
@@ -92,6 +93,10 @@ extern "C" JULIET_API void __cdecl GameUpdate(Juliet::GameData* params, [[maybe_
rock->Health = 100;
Assert(door->Base != rock->Base);
MeshAssetID cubeAsset = GetCubePrimitiveMeshAssetID();
MeshInstanceID meshInst = CreateMeshInstance(cubeAsset, 0, MatrixIdentity());
rock->Base->MeshInstance = meshInst;
printf("Door is %s\n", door->IsOpened ? "Opened" : "Closed");
printf("Rock has %d health points\n", rock->Health);
}
@@ -106,6 +111,16 @@ extern "C" JULIET_API void __cdecl GameUpdate(Juliet::GameData* params, [[maybe_
{
// update game
}
// Sync entity transforms to meshes
auto& manager = GetEntityManager();
for (Entity& ent : manager.Entities)
{
if (ent.MeshInstance != static_cast<index_t>(-1))
{
SetMeshInstanceTransform(ent.MeshInstance, MatrixTranslation(ent.X, ent.Y, 0.0f));
}
}
if (gGameState->Mode == GameMode::Debug)
{