From 704614fde1a9062fa613b3b8646ee8108ccfb219 Mon Sep 17 00:00:00 2001 From: sanine-a Date: Fri, 14 Apr 2023 15:55:34 -0500 Subject: add physics linear/angular velocity tracking --- honey/ecs-systems.lua | 5 +++++ save | 3 +++ 2 files changed, 8 insertions(+) create mode 100644 save diff --git a/honey/ecs-systems.lua b/honey/ecs-systems.lua index 969b6fe..418f312 100644 --- a/honey/ecs-systems.lua +++ b/honey/ecs-systems.lua @@ -271,6 +271,11 @@ physics = function(params) :identity() :translate(Vec3{x,y,z}) :mul(Quaternion{a,b,c,d}:toMat4()) + + local vel = physics.velocity + vel[1], vel[2], vel[3] = ode.BodyGetLinearVel(physics._body) + local avel = physics.angularVelocity + avel[1], avel[2], avel[3] = ode.BodyGetAngularVel(physics._body) end end end, diff --git a/save b/save new file mode 100644 index 0000000..2cd1c2c --- /dev/null +++ b/save @@ -0,0 +1,3 @@ +Entity("84c91244-b225-4757-9ae2-501e4b933e12", {script={script="cameraRotationScript"},z={value=-60},onKey={script="cameraKeyHandler"},transform={matrix=Mat4{1.0000, 0.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 0.0000, 1.0000, -59.2666, 0.0000, 0.0000, 0.0000, 1.0000}},camera={projection=Mat4{1.8107, 0.0000, 0.0000, 0.0000, 0.0000, 2.4142, 0.0000, 0.0000, 0.0000, 0.0000, -1.0020, -0.2002, 0.0000, 0.0000, -1.0000, 0.0000}},onWindowResize={script="cameraHandleResize"}}) +Entity("2a902813-02b8-49d6-9602-76ec6394cc86", {transform={matrix=Mat4{0.5222, -0.5222, 0.6743, 0.0000, 0.7071, 0.7071, -0.0000, 4.6250, -0.4768, 0.4768, 0.7385, 0.0000, 0.0000, 0.0000, 0.0000, 1.0000}},renderMesh={textures={ourTexture={filename="77155.png"}},mesh={filename="assets/icosahedron.obj",index=1},shader={fragment="fragment.glsl",vertex="vertex.glsl"}},physics={velocity=Vec3{0.0000, 2.6000, 0.0000},angularVelocity=Vec3{0.0000, 1.0000, 0.0000},mass={radius=1,class="sphere",density=1}}}) +Entity("1dd0a59e-83ed-4358-a493-4a3c604f10bf", {transform={parent="2a902813-02b8-49d6-9602-76ec6394cc86",matrix=Mat4{1.0000, 0.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 2.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 0.0000, 1.0000}},renderMesh={shader={fragment="fragment.glsl",vertex="vertex.glsl"},mesh={filename="assets/tetrahedron.obj",index=1}}}) -- cgit v1.2.1