wip
This commit is contained in:
@@ -5,6 +5,23 @@
|
||||
#include <bx/math.h>
|
||||
#include <bgfx/bgfx.h>
|
||||
|
||||
namespace
|
||||
{
|
||||
void CreateTransform(float* out, Vec3 pos, Quat rot = {}, Vec3 scale = {1.0f, 1.0f, 1.0f})
|
||||
{
|
||||
if (out == nullptr) return;
|
||||
float rMat[16]{0};
|
||||
float tMat[16]{0};
|
||||
float sMat[16]{0};
|
||||
bx::mtxFromQuaternion(rMat, bx::Quaternion{rot.X, rot.Y, rot.Z, rot.W});
|
||||
bx::mtxTranslate(tMat, pos.X, pos.Y, pos.Z);
|
||||
bx::mtxScale(sMat, scale.X, scale.Y, scale.Z);
|
||||
float buf[16]{0};
|
||||
bx::mtxMul(buf, rMat, sMat);
|
||||
bx::mtxMul(out, buf, tMat);
|
||||
}
|
||||
}
|
||||
|
||||
namespace Game
|
||||
{
|
||||
void Level::Setup(GameData& data)
|
||||
@@ -25,6 +42,8 @@ namespace Game
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Cube* floor = Cubes.New();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,23 +59,28 @@ namespace Game
|
||||
|
||||
void Cube::Update()
|
||||
{
|
||||
double globalTime = GetInstance().Now;
|
||||
double time = TestY <= 5 ? globalTime * 0.1f : 0.0f;
|
||||
if (TestX == 4 && TestY == 4)
|
||||
if (TestX >= 0 && TestY >= 0)
|
||||
{
|
||||
bx::mtxTranslate(Transform.M, 0, 0, bx::lerp(-20.0f, -32.0f, bx::sin(globalTime* 0.5f) * 0.5 + 0.5));
|
||||
double globalTime = GetInstance().Now;
|
||||
double time = TestY <= 5 ? globalTime * 1.0f : 0.0f;
|
||||
if (TestX == 4 && TestY == 4)
|
||||
{
|
||||
bx::mtxTranslate(Transform.M, 0, 0, bx::lerp(-20.0f, -32.0f, bx::sin(globalTime* 0.5f) * 0.5 + 0.5));
|
||||
}
|
||||
else
|
||||
{
|
||||
float scale = 1.0f + TestX * 0.4f;
|
||||
CreateTransform(Transform.M,
|
||||
Vec3{TestX * 10.0f - 40.0f, TestY * 10.0f - 40.0f, (float)TestX},
|
||||
Quat::FromEuler(time * 10.0f + TestX, time * 5.0f * TestY, 0.0f),
|
||||
{scale, scale, scale}
|
||||
);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
float rot[16]{0};
|
||||
bx::mtxRotateXY(rot, time + TestX * 0.1f, time * 2 + TestY * .37f);
|
||||
float scale[16]{0};
|
||||
bx::mtxScale(scale, 1.0f + TestX * 0.4f);
|
||||
float pos[16]{0};
|
||||
bx::mtxTranslate(pos, TestX * 10.0f - 40.0f, TestY * 10.0f - 40.0f, TestX);
|
||||
float buf[16]{0};
|
||||
bx::mtxMul(buf, scale, rot);
|
||||
bx::mtxMul(Transform.M, buf, pos);
|
||||
CreateTransform(Transform.M, {0.0f, -30.0f, 100.0f}, {}, {100.0f, 10.0f, 100.0f});
|
||||
// Nothing for now
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user