From 3275ae4948fd2c1bb8da780214cbb741dc3178be Mon Sep 17 00:00:00 2001 From: sanine Date: Fri, 12 May 2023 01:16:46 -0500 Subject: begin refactor --- main.lua | 67 +++++++++++++++++++++++++++++++++++++++++++++------------------- 1 file changed, 47 insertions(+), 20 deletions(-) (limited to 'main.lua') diff --git a/main.lua b/main.lua index ebd4cd1..10ffebe 100644 --- a/main.lua +++ b/main.lua @@ -31,37 +31,64 @@ systems:addSystem(honey.ecs.collision.system, {space=space}) systems:addSystem(honey.ecs.physics.system, {space=space, world=world}) function setupEntities() - - local plane = entities:createEntity() - entities:addComponents(plane, { - node = { - matrix = Mat4() - :identity() - :rotateZ(math.rad(5)) - }, - collision = { - class = "plane", - }, - }) - - local planeMesh = entities:createEntityWithComponents{ + local terrain = entities:createEntityWithComponents{ node = { - parent = plane, - matrix = Mat4():identity():rotateX(0.5*math.pi):scale(Vec3{20,20,20}), + matrix = Mat4():identity():translate(Vec3{4,0,0}), }, renderMesh = { - textures = { ourTexture={ filename="assets/green+grass-1024x1024.jpg" } }, - shader = { vertex="vertex.glsl", fragment="fragment.glsl" }, - mesh = { filename="builtin.quad", index=1 }, + textures = { + ourTexture = { + filename = "assets/green+grass-1024x1024.jpg", + }, + }, + shader = { + vertex = "vertex.glsl", + fragment = "fragment.glsl", + }, + mesh = { filename = "assets/terrain.obj", index=1 }, + }, + collision = { + class = "trimesh", + filename = "assets/terrain.obj", }, } + +-- local plane = entities:createEntity() +-- entities:addComponents(plane, { +-- node = { +-- matrix = Mat4() +-- :identity() +-- :rotateZ(math.rad(5)) +-- }, +-- collision = { +-- class = "plane", +-- }, +-- }) +-- +-- local planeMesh = entities:createEntityWithComponents{ +-- node = { +-- parent = plane, +-- matrix = Mat4():identity():rotateX(0.5*math.pi):scale(Vec3{20,20,20}), +-- }, +-- renderMesh = { +-- textures = { +-- ourTexture={ +-- filename="assets/green+grass-1024x1024.jpg" +-- } +-- }, +-- shader = { vertex="vertex.glsl", fragment="fragment.glsl" }, +-- mesh = { filename="builtin.quad", index=1 }, +-- }, +-- } local id = entities:createEntity() entities:addComponents(id, { renderMesh = { - textures = { ourTexture={ filename="77155.png" } }, + textures = { + ourTexture={ filename="77155.png" } + }, shader = { vertex="vertex.glsl", fragment="fragment.glsl" }, mesh = { filename="assets/icosahedron.obj", index=1 }, }, -- cgit v1.2.1