diff options
author | sanine <sanine.not@pm.me> | 2023-05-10 23:59:04 -0500 |
---|---|---|
committer | sanine <sanine.not@pm.me> | 2023-05-10 23:59:04 -0500 |
commit | 14195dac1eda9140192ca07003258715b8b0abd3 (patch) | |
tree | bb4e41153363c791d4a9c7948bc85e0d4f77bc98 /main.lua | |
parent | 26bfc10ad0e8a355e9b02946dd31642f49a6ec60 (diff) |
implement basic floating-ray character controller
Diffstat (limited to 'main.lua')
-rw-r--r-- | main.lua | 81 |
1 files changed, 2 insertions, 79 deletions
@@ -81,6 +81,7 @@ function setupEntities() density = 1, radius = 1, }, + surface = true, velocity = Vec3{ 0, 0, 0 }, angularVelocity = Vec3{ 0, 0, 0 }, }, @@ -107,72 +108,10 @@ function setupEntities() }, }) - local capsule = entities:createEntityWithComponents{ - node = { - matrix = Mat4():identity():translate(Vec3{0,10,0}):rotateX(0.5*math.pi) - }, - collision = { - class = "capsule", - radius = 1, - length = 2, - }, - physics = { - mass = { - class = "capsule", - density = 1, - direction = 3, - radius = 1, - length = 2, - }, - maxAngularSpeed = 0, - }, - renderMesh = { - mesh = { filename="assets/capsule.obj", index=1 }, - shader = { vertex="vertex.glsl", fragment="fragment.glsl" }, - }, - script = { script = "scripts.capsuleMove" }, - } - - - local pivotPivot = entities:createEntityWithComponents{ - node = { - name = "p", - parent = capsule, - matrix = Mat4():identity():rotateX(-0.5*math.pi), - }, - } - - - local capcamPivot = entities:createEntityWithComponents{ - node = { - name = "pivot", - parent = pivotPivot, - matrix = Mat4():identity(), - }, - pitchyaw = { - pitch = 0, - yaw = 0, - }, - onCursorPos = { script = "scripts.cameraPivot" }, - } - - - local capcam = entities:createEntityWithComponents{ - camera = { - projection = Mat4():perspective(math.rad(45), 640/480, 0.1, 1000), - render="screen", - }, - node = { - parent = capcamPivot, - matrix = Mat4():identity():translate(Vec3{0,0,20}), - }, - onFramebufferSize = { script = "scripts.cameraHandleResize" }, - } - + require('character')(entities) local skybox = entities:createEntityWithComponents{ node = { - parent = capsule, matrix = Mat4():identity():scale(Vec3{2,2,2}):rotateX(math.rad(90)) }, renderMesh = { @@ -190,22 +129,6 @@ function setupEntities() }, } - - local camera = entities:createEntity() - entities:addComponents(camera, { - ccamera={ - projection=Mat4():perspective(math.rad(90), 640/480, 0.1, 1000), - render="screen", - }, - node={ - matrix=Mat4() - :identity() - :rotateX(math.rad(90)) - :translate(Vec3{0, 10, 0}), - }, - onFramebufferSize = { script = "scripts.cameraHandleResize" }, - }) - local misc = entities:createEntityWithComponents{ onKey = { script = "scripts.loadSaveQuit" }, onFramebufferSize = { script = "scripts.viewportResize" }, |