Entity now can be linked to a mesh.
Only support cube generated from code no light no nothing
This commit is contained in:
@@ -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)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user