diff options
Diffstat (limited to 'main.lua')
-rw-r--r-- | main.lua | 34 |
1 files changed, 17 insertions, 17 deletions
@@ -36,19 +36,19 @@ end) local entities = ecs.EntityDb() local systems = ecs.SystemDb(entities) -systems:addSystem(sys.transform) +systems:addSystem(sys.node) systems:addSystem(sys.renderCamera) systems:addSystem(sys.script) systems:addSystem(sys.collision, {space=space}) systems:addSystem(sys.physics, {space=space, world=world}) package.loaded['baseRotationScript'] = function(entities, id, dt) - local transform = entities:getComponent(id, "transform") - transform.matrix:rotateZ(math.pi * dt) + local node = entities:getComponent(id, "node") + node.matrix:rotateZ(math.pi * dt) end package.loaded['cameraRotationScript'] = function(entities, id, dt) - local transform = entities:getComponent(id, "transform") + local node = entities:getComponent(id, "node") local z = entities:getComponent(id, "z") - transform.matrix + node.matrix :identity() :translate(Vec3{0, 0, z.value + math.sin(math.pi * glfw.GetTime())}) end @@ -65,7 +65,7 @@ function setupEntities() local plane = entities:createEntity() entities:addComponents(plane, { - transform = { + node = { matrix = Mat4() :identity() :rotateZ(math.rad(5)) @@ -76,7 +76,7 @@ function setupEntities() }) local planeMesh = entities:createEntityWithComponents{ - transform = { + node = { parent = plane, matrix = Mat4():identity():rotateX(0.5*math.pi):scale(Vec3{20,20,20}), }, @@ -96,7 +96,7 @@ function setupEntities() shader = { vertex="vertex.glsl", fragment="fragment.glsl" }, mesh = { filename="assets/icosahedron.obj", index=1 }, }, - transform = { + node = { matrix = Mat4() :identity() :translate(Vec3{0,1,0}) @@ -124,7 +124,7 @@ function setupEntities() --mesh = { filename="assets/tetrahedron.obj", index=1 }, mesh = { filename="builtin.quad", index=1 }, }, - transform = { + node = { parent=id, matrix=Mat4():identity():translate(Vec3{0, 2, 0}), }, @@ -139,7 +139,7 @@ function setupEntities() }) local capsule = entities:createEntityWithComponents{ - transform = { + node = { matrix = Mat4():identity():translate(Vec3{0,10,0}):rotateX(0.5*math.pi) }, collision = { @@ -165,7 +165,7 @@ function setupEntities() local pivotPivot = entities:createEntityWithComponents{ - transform = { + node = { parent = capsule, matrix = Mat4():identity():rotateX(-0.5*math.pi), }, @@ -173,7 +173,7 @@ function setupEntities() local capcamPivot = entities:createEntityWithComponents{ - transform = { + node = { parent = pivotPivot, matrix = Mat4():identity(), }, @@ -195,14 +195,14 @@ function setupEntities() print(dx,dy) prevx, prevy = data.xpos, data.ypos - local transform = entities:getComponent(id, "transform") + local node = entities:getComponent(id, "node") local py = entities:getComponent(id, "pitchyaw") py.pitch = py.pitch - dy py.yaw = py.yaw - dx if py.pitch > 89.9 then py.pitch = 89.9 end if py.pitch < -89.9 then py.pitch = -89.9 end - transform.matrix + node.matrix :identity() :rotateY(math.rad(py.yaw)) :rotateX(math.rad(py.pitch)) @@ -252,7 +252,7 @@ function setupEntities() projection = Mat4():perspective(math.rad(45), 640/480, 0.1, 1000), render="screen", }, - transform = { + node = { parent = capcamPivot, matrix = Mat4():identity():translate(Vec3{0,0,10}), }, @@ -261,7 +261,7 @@ function setupEntities() local skybox = entities:createEntityWithComponents{ - transform = { + node = { parent = capsule, matrix = Mat4():identity():scale(Vec3{2,2,2}), }, @@ -283,7 +283,7 @@ function setupEntities() projection=Mat4():perspective(math.rad(45), 640/480, 0.1, 1000), render="screen", }, - transform={ + node={ matrix=Mat4():identity():rotateX(math.rad(-20)):translate(Vec3{0, 5, 30}), }, z = {value=-60}, |