From eafff1e04eb7f6a63818db035d2c6a277c5c364c Mon Sep 17 00:00:00 2001 From: sanine Date: Thu, 18 May 2023 22:23:42 -0500 Subject: visualize collisions --- main.lua | 34 ++++++++++++++++++++++++++++++---- 1 file changed, 30 insertions(+), 4 deletions(-) (limited to 'main.lua') diff --git a/main.lua b/main.lua index 2542910..f5237a5 100644 --- a/main.lua +++ b/main.lua @@ -48,11 +48,23 @@ db:createEntityWithComponents{ }, } + +local parent = db:createEntityWithComponents{ + node = { + matrix = Mat4() + :identity() + }, + script = { script = "scripts.update" }, +} + -- mesh db:createEntityWithComponents{ node = { + parent = parent, matrix = Mat4() - :identity(), + :identity() + :rotateX(0.5*math.pi) + :rotateZ(0.5*math.pi) }, renderMesh = { mesh = { @@ -67,14 +79,28 @@ db:createEntityWithComponents{ shader = { vertex="vertex.glsl", fragment="fragment.glsl" }, }, collision = { - class = "capsule", + class = "ray", radius = 1, - length = 2, + length = 4, lx = 2, ly = 2, lz = 2, }, - script = { script = "scripts.rotate" }, + onCollision = { script = "scripts.collide" }, +} + + +-- box? +db:createEntityWithComponents{ + node = { + matrix = Mat4() + :identity() + :translate(Vec3{0,-3,0}) + }, + collision = { + class = "box", + lx = 1, ly=1, lz=1, + }, } honey.loop(function(dt) -- cgit v1.2.1