summaryrefslogtreecommitdiff
path: root/honey
diff options
context:
space:
mode:
Diffstat (limited to 'honey')
-rw-r--r--honey/asset/mesh.lua202
-rw-r--r--honey/asset/shader.lua13
-rw-r--r--honey/ecs/collision.lua2
-rw-r--r--honey/ecs/ecs.lua2
-rw-r--r--honey/ecs/render.lua118
5 files changed, 265 insertions, 72 deletions
diff --git a/honey/asset/mesh.lua b/honey/asset/mesh.lua
index f912577..8f02a88 100644
--- a/honey/asset/mesh.lua
+++ b/honey/asset/mesh.lua
@@ -41,7 +41,7 @@ local function loadShape(shape, attrib, debug)
end
end
- if false then
+ if true then
-- helpful block for creating the builtin meshes
io.write("{")
for i, vertex in ipairs(vertices) do
@@ -1787,102 +1787,198 @@ init = function()
builtin(
"builtin.tube",
{
- 0.000000, -1.000000, -1.000000, 0.098000, 0.000000, -0.995200, 1.000000, 0.000000,
0.000000, 1.000000, -1.000000, 0.098000, 0.000000, -0.995200, 1.000000, 1.000000,
- 0.195090, 1.000000, -0.980785, 0.098000, 0.000000, -0.995200, 0.968750, 1.000000,
+ 0.195090, -1.000000, -0.980785, 0.098000, 0.000000, -0.995200, 0.968750, 0.000000,
0.000000, -1.000000, -1.000000, 0.098000, 0.000000, -0.995200, 1.000000, 0.000000,
+ 0.195090, 1.000000, -0.980785, 0.290300, 0.000000, -0.956900, 0.968750, 1.000000,
+ 0.382683, -1.000000, -0.923880, 0.290300, 0.000000, -0.956900, 0.937500, 0.000000,
+ 0.195090, -1.000000, -0.980785, 0.290300, 0.000000, -0.956900, 0.968750, 0.000000,
+ 0.382683, 1.000000, -0.923880, 0.471400, 0.000000, -0.881900, 0.937500, 1.000000,
+ 0.555570, -1.000000, -0.831470, 0.471400, 0.000000, -0.881900, 0.906250, 0.000000,
+ 0.382683, -1.000000, -0.923880, 0.471400, 0.000000, -0.881900, 0.937500, 0.000000,
+ 0.555570, 1.000000, -0.831470, 0.634400, 0.000000, -0.773000, 0.906250, 1.000000,
+ 0.707107, -1.000000, -0.707107, 0.634400, 0.000000, -0.773000, 0.875000, 0.000000,
+ 0.555570, -1.000000, -0.831470, 0.634400, 0.000000, -0.773000, 0.906250, 0.000000,
+ 0.707107, 1.000000, -0.707107, 0.773000, 0.000000, -0.634400, 0.875000, 1.000000,
+ 0.831470, -1.000000, -0.555570, 0.773000, 0.000000, -0.634400, 0.843750, 0.000000,
+ 0.707107, -1.000000, -0.707107, 0.773000, 0.000000, -0.634400, 0.875000, 0.000000,
+ 0.831470, 1.000000, -0.555570, 0.881900, 0.000000, -0.471400, 0.843750, 1.000000,
+ 0.923880, -1.000000, -0.382683, 0.881900, 0.000000, -0.471400, 0.812500, 0.000000,
+ 0.831470, -1.000000, -0.555570, 0.881900, 0.000000, -0.471400, 0.843750, 0.000000,
+ 0.923880, 1.000000, -0.382683, 0.956900, 0.000000, -0.290300, 0.812500, 1.000000,
+ 0.980785, -1.000000, -0.195090, 0.956900, 0.000000, -0.290300, 0.781250, 0.000000,
+ 0.923880, -1.000000, -0.382683, 0.956900, 0.000000, -0.290300, 0.812500, 0.000000,
+ 0.980785, 1.000000, -0.195090, 0.995200, 0.000000, -0.098000, 0.781250, 1.000000,
+ 1.000000, -1.000000, 0.000000, 0.995200, 0.000000, -0.098000, 0.750000, 0.000000,
+ 0.980785, -1.000000, -0.195090, 0.995200, 0.000000, -0.098000, 0.781250, 0.000000,
+ 1.000000, 1.000000, 0.000000, 0.995200, 0.000000, 0.098000, 0.750000, 1.000000,
+ 0.980785, -1.000000, 0.195090, 0.995200, 0.000000, 0.098000, 0.718750, 0.000000,
+ 1.000000, -1.000000, 0.000000, 0.995200, 0.000000, 0.098000, 0.750000, 0.000000,
+ 0.980785, 1.000000, 0.195090, 0.956900, 0.000000, 0.290300, 0.718750, 1.000000,
+ 0.923880, -1.000000, 0.382683, 0.956900, 0.000000, 0.290300, 0.687500, 0.000000,
+ 0.980785, -1.000000, 0.195090, 0.956900, 0.000000, 0.290300, 0.718750, 0.000000,
+ 0.923880, 1.000000, 0.382683, 0.881900, 0.000000, 0.471400, 0.687500, 1.000000,
+ 0.831470, -1.000000, 0.555570, 0.881900, 0.000000, 0.471400, 0.656250, 0.000000,
+ 0.923880, -1.000000, 0.382683, 0.881900, 0.000000, 0.471400, 0.687500, 0.000000,
+ 0.831470, 1.000000, 0.555570, 0.773000, 0.000000, 0.634400, 0.656250, 1.000000,
+ 0.707107, -1.000000, 0.707107, 0.773000, 0.000000, 0.634400, 0.625000, 0.000000,
+ 0.831470, -1.000000, 0.555570, 0.773000, 0.000000, 0.634400, 0.656250, 0.000000,
+ 0.707107, 1.000000, 0.707107, 0.634400, 0.000000, 0.773000, 0.625000, 1.000000,
+ 0.555570, -1.000000, 0.831470, 0.634400, 0.000000, 0.773000, 0.593750, 0.000000,
+ 0.707107, -1.000000, 0.707107, 0.634400, 0.000000, 0.773000, 0.625000, 0.000000,
+ 0.555570, 1.000000, 0.831470, 0.471400, 0.000000, 0.881900, 0.593750, 1.000000,
+ 0.382683, -1.000000, 0.923880, 0.471400, 0.000000, 0.881900, 0.562500, 0.000000,
+ 0.555570, -1.000000, 0.831470, 0.471400, 0.000000, 0.881900, 0.593750, 0.000000,
+ 0.382683, 1.000000, 0.923880, 0.290300, 0.000000, 0.956900, 0.562500, 1.000000,
+ 0.195090, -1.000000, 0.980785, 0.290300, 0.000000, 0.956900, 0.531250, 0.000000,
+ 0.382683, -1.000000, 0.923880, 0.290300, 0.000000, 0.956900, 0.562500, 0.000000,
+ 0.195090, 1.000000, 0.980785, 0.098000, 0.000000, 0.995200, 0.531250, 1.000000,
+ 0.000000, -1.000000, 1.000000, 0.098000, 0.000000, 0.995200, 0.500000, 0.000000,
+ 0.195090, -1.000000, 0.980785, 0.098000, 0.000000, 0.995200, 0.531250, 0.000000,
+ 0.000000, 1.000000, 1.000000, -0.098000, 0.000000, 0.995200, 0.500000, 1.000000,
+ -0.195090, -1.000000, 0.980785, -0.098000, 0.000000, 0.995200, 0.468750, 0.000000,
+ 0.000000, -1.000000, 1.000000, -0.098000, 0.000000, 0.995200, 0.500000, 0.000000,
+ -0.195090, 1.000000, 0.980785, -0.290300, 0.000000, 0.956900, 0.468750, 1.000000,
+ -0.382683, -1.000000, 0.923880, -0.290300, 0.000000, 0.956900, 0.437500, 0.000000,
+ -0.195090, -1.000000, 0.980785, -0.290300, 0.000000, 0.956900, 0.468750, 0.000000,
+ -0.382683, 1.000000, 0.923880, -0.471400, 0.000000, 0.881900, 0.437500, 1.000000,
+ -0.555570, -1.000000, 0.831470, -0.471400, 0.000000, 0.881900, 0.406250, 0.000000,
+ -0.382683, -1.000000, 0.923880, -0.471400, 0.000000, 0.881900, 0.437500, 0.000000,
+ -0.555570, 1.000000, 0.831470, -0.634400, 0.000000, 0.773000, 0.406250, 1.000000,
+ -0.707107, -1.000000, 0.707107, -0.634400, 0.000000, 0.773000, 0.375000, 0.000000,
+ -0.555570, -1.000000, 0.831470, -0.634400, 0.000000, 0.773000, 0.406250, 0.000000,
+ -0.707107, 1.000000, 0.707107, -0.773000, 0.000000, 0.634400, 0.375000, 1.000000,
+ -0.831470, -1.000000, 0.555570, -0.773000, 0.000000, 0.634400, 0.343750, 0.000000,
+ -0.707107, -1.000000, 0.707107, -0.773000, 0.000000, 0.634400, 0.375000, 0.000000,
+ -0.831470, 1.000000, 0.555570, -0.881900, 0.000000, 0.471400, 0.343750, 1.000000,
+ -0.923880, -1.000000, 0.382683, -0.881900, 0.000000, 0.471400, 0.312500, 0.000000,
+ -0.831470, -1.000000, 0.555570, -0.881900, 0.000000, 0.471400, 0.343750, 0.000000,
+ -0.923880, 1.000000, 0.382683, -0.956900, 0.000000, 0.290300, 0.312500, 1.000000,
+ -0.980785, -1.000000, 0.195090, -0.956900, 0.000000, 0.290300, 0.281250, 0.000000,
+ -0.923880, -1.000000, 0.382683, -0.956900, 0.000000, 0.290300, 0.312500, 0.000000,
+ -0.980785, 1.000000, 0.195090, -0.995200, 0.000000, 0.098000, 0.281250, 1.000000,
+ -1.000000, -1.000000, 0.000000, -0.995200, 0.000000, 0.098000, 0.250000, 0.000000,
+ -0.980785, -1.000000, 0.195090, -0.995200, 0.000000, 0.098000, 0.281250, 0.000000,
+ -1.000000, 1.000000, 0.000000, -0.995200, 0.000000, -0.098000, 0.250000, 1.000000,
+ -0.980785, -1.000000, -0.195090, -0.995200, 0.000000, -0.098000, 0.218750, 0.000000,
+ -1.000000, -1.000000, 0.000000, -0.995200, 0.000000, -0.098000, 0.250000, 0.000000,
+ -0.980785, 1.000000, -0.195090, -0.956900, 0.000000, -0.290300, 0.218750, 1.000000,
+ -0.923880, -1.000000, -0.382683, -0.956900, 0.000000, -0.290300, 0.187500, 0.000000,
+ -0.980785, -1.000000, -0.195090, -0.956900, 0.000000, -0.290300, 0.218750, 0.000000,
+ -0.923880, 1.000000, -0.382683, -0.881900, 0.000000, -0.471400, 0.187500, 1.000000,
+ -0.831470, -1.000000, -0.555570, -0.881900, 0.000000, -0.471400, 0.156250, 0.000000,
+ -0.923880, -1.000000, -0.382683, -0.881900, 0.000000, -0.471400, 0.187500, 0.000000,
+ -0.831470, 1.000000, -0.555570, -0.773000, 0.000000, -0.634400, 0.156250, 1.000000,
+ -0.707107, -1.000000, -0.707107, -0.773000, 0.000000, -0.634400, 0.125000, 0.000000,
+ -0.831470, -1.000000, -0.555570, -0.773000, 0.000000, -0.634400, 0.156250, 0.000000,
+ -0.707107, 1.000000, -0.707107, -0.634400, 0.000000, -0.773000, 0.125000, 1.000000,
+ -0.555570, -1.000000, -0.831470, -0.634400, 0.000000, -0.773000, 0.093750, 0.000000,
+ -0.707107, -1.000000, -0.707107, -0.634400, 0.000000, -0.773000, 0.125000, 0.000000,
+ -0.555570, 1.000000, -0.831470, -0.471400, 0.000000, -0.881900, 0.093750, 1.000000,
+ -0.382683, -1.000000, -0.923880, -0.471400, 0.000000, -0.881900, 0.062500, 0.000000,
+ -0.555570, -1.000000, -0.831470, -0.471400, 0.000000, -0.881900, 0.093750, 0.000000,
+ -0.382683, 1.000000, -0.923880, -0.290300, 0.000000, -0.956900, 0.062500, 1.000000,
+ -0.195090, -1.000000, -0.980785, -0.290300, 0.000000, -0.956900, 0.031250, 0.000000,
+ -0.382683, -1.000000, -0.923880, -0.290300, 0.000000, -0.956900, 0.062500, 0.000000,
+ -0.195090, 1.000000, -0.980785, -0.098000, 0.000000, -0.995200, 0.031250, 1.000000,
+ 0.000000, -1.000000, -1.000000, -0.098000, 0.000000, -0.995200, 0.000000, 0.000000,
+ -0.195090, -1.000000, -0.980785, -0.098000, 0.000000, -0.995200, 0.031250, 0.000000,
+ 0.000000, 1.000000, -1.000000, 0.098000, 0.000000, -0.995200, 1.000000, 1.000000,
0.195090, 1.000000, -0.980785, 0.098000, 0.000000, -0.995200, 0.968750, 1.000000,
0.195090, -1.000000, -0.980785, 0.098000, 0.000000, -0.995200, 0.968750, 0.000000,
- 0.195090, -1.000000, -0.980785, 0.290300, 0.000000, -0.956900, 0.968750, 0.000000,
0.195090, 1.000000, -0.980785, 0.290300, 0.000000, -0.956900, 0.968750, 1.000000,
0.382683, 1.000000, -0.923880, 0.290300, 0.000000, -0.956900, 0.937500, 1.000000,
- 0.195090, -1.000000, -0.980785, 0.290300, 0.000000, -0.956900, 0.968750, 0.000000,
- 0.382683, 1.000000, -0.923880, 0.290300, 0.000000, -0.956900, 0.937500, 1.000000,
0.382683, -1.000000, -0.923880, 0.290300, 0.000000, -0.956900, 0.937500, 0.000000,
- 0.382683, -1.000000, -0.923880, 0.471400, 0.000000, -0.881900, 0.937500, 0.000000,
0.382683, 1.000000, -0.923880, 0.471400, 0.000000, -0.881900, 0.937500, 1.000000,
0.555570, 1.000000, -0.831470, 0.471400, 0.000000, -0.881900, 0.906250, 1.000000,
- 0.382683, -1.000000, -0.923880, 0.471400, 0.000000, -0.881900, 0.937500, 0.000000,
- 0.555570, 1.000000, -0.831470, 0.471400, 0.000000, -0.881900, 0.906250, 1.000000,
0.555570, -1.000000, -0.831470, 0.471400, 0.000000, -0.881900, 0.906250, 0.000000,
- 0.555570, -1.000000, -0.831470, 0.634400, 0.000000, -0.773000, 0.906250, 0.000000,
0.555570, 1.000000, -0.831470, 0.634400, 0.000000, -0.773000, 0.906250, 1.000000,
0.707107, 1.000000, -0.707107, 0.634400, 0.000000, -0.773000, 0.875000, 1.000000,
- 0.555570, -1.000000, -0.831470, 0.634400, 0.000000, -0.773000, 0.906250, 0.000000,
- 0.707107, 1.000000, -0.707107, 0.634400, 0.000000, -0.773000, 0.875000, 1.000000,
0.707107, -1.000000, -0.707107, 0.634400, 0.000000, -0.773000, 0.875000, 0.000000,
- 0.707107, -1.000000, -0.707107, 0.773000, 0.000000, -0.634400, 0.875000, 0.000000,
0.707107, 1.000000, -0.707107, 0.773000, 0.000000, -0.634400, 0.875000, 1.000000,
0.831470, 1.000000, -0.555570, 0.773000, 0.000000, -0.634400, 0.843750, 1.000000,
- 0.707107, -1.000000, -0.707107, 0.773000, 0.000000, -0.634400, 0.875000, 0.000000,
- 0.831470, 1.000000, -0.555570, 0.773000, 0.000000, -0.634400, 0.843750, 1.000000,
0.831470, -1.000000, -0.555570, 0.773000, 0.000000, -0.634400, 0.843750, 0.000000,
- 0.831470, -1.000000, -0.555570, 0.881900, 0.000000, -0.471400, 0.843750, 0.000000,
0.831470, 1.000000, -0.555570, 0.881900, 0.000000, -0.471400, 0.843750, 1.000000,
0.923880, 1.000000, -0.382683, 0.881900, 0.000000, -0.471400, 0.812500, 1.000000,
- 0.831470, -1.000000, -0.555570, 0.881900, 0.000000, -0.471400, 0.843750, 0.000000,
- 0.923880, 1.000000, -0.382683, 0.881900, 0.000000, -0.471400, 0.812500, 1.000000,
0.923880, -1.000000, -0.382683, 0.881900, 0.000000, -0.471400, 0.812500, 0.000000,
- 0.923880, -1.000000, -0.382683, 0.956900, 0.000000, -0.290300, 0.812500, 0.000000,
0.923880, 1.000000, -0.382683, 0.956900, 0.000000, -0.290300, 0.812500, 1.000000,
0.980785, 1.000000, -0.195090, 0.956900, 0.000000, -0.290300, 0.781250, 1.000000,
- 0.923880, -1.000000, -0.382683, 0.956900, 0.000000, -0.290300, 0.812500, 0.000000,
- 0.980785, 1.000000, -0.195090, 0.956900, 0.000000, -0.290300, 0.781250, 1.000000,
0.980785, -1.000000, -0.195090, 0.956900, 0.000000, -0.290300, 0.781250, 0.000000,
- 0.980785, -1.000000, -0.195090, 0.995200, 0.000000, -0.098000, 0.781250, 0.000000,
0.980785, 1.000000, -0.195090, 0.995200, 0.000000, -0.098000, 0.781250, 1.000000,
1.000000, 1.000000, 0.000000, 0.995200, 0.000000, -0.098000, 0.750000, 1.000000,
- 0.980785, -1.000000, -0.195090, 0.995200, 0.000000, -0.098000, 0.781250, 0.000000,
- 1.000000, 1.000000, 0.000000, 0.995200, 0.000000, -0.098000, 0.750000, 1.000000,
1.000000, -1.000000, 0.000000, 0.995200, 0.000000, -0.098000, 0.750000, 0.000000,
- 1.000000, -1.000000, 0.000000, 0.995200, 0.000000, 0.098000, 0.750000, 0.000000,
1.000000, 1.000000, 0.000000, 0.995200, 0.000000, 0.098000, 0.750000, 1.000000,
0.980785, 1.000000, 0.195090, 0.995200, 0.000000, 0.098000, 0.718750, 1.000000,
- 1.000000, -1.000000, 0.000000, 0.995200, 0.000000, 0.098000, 0.750000, 0.000000,
- 0.980785, 1.000000, 0.195090, 0.995200, 0.000000, 0.098000, 0.718750, 1.000000,
0.980785, -1.000000, 0.195090, 0.995200, 0.000000, 0.098000, 0.718750, 0.000000,
- 0.980785, -1.000000, 0.195090, 0.956900, 0.000000, 0.290300, 0.718750, 0.000000,
0.980785, 1.000000, 0.195090, 0.956900, 0.000000, 0.290300, 0.718750, 1.000000,
0.923880, 1.000000, 0.382683, 0.956900, 0.000000, 0.290300, 0.687500, 1.000000,
- 0.980785, -1.000000, 0.195090, 0.956900, 0.000000, 0.290300, 0.718750, 0.000000,
- 0.923880, 1.000000, 0.382683, 0.956900, 0.000000, 0.290300, 0.687500, 1.000000,
0.923880, -1.000000, 0.382683, 0.956900, 0.000000, 0.290300, 0.687500, 0.000000,
- 0.923880, -1.000000, 0.382683, 0.881900, 0.000000, 0.471400, 0.687500, 0.000000,
0.923880, 1.000000, 0.382683, 0.881900, 0.000000, 0.471400, 0.687500, 1.000000,
0.831470, 1.000000, 0.555570, 0.881900, 0.000000, 0.471400, 0.656250, 1.000000,
- 0.923880, -1.000000, 0.382683, 0.881900, 0.000000, 0.471400, 0.687500, 0.000000,
- 0.831470, 1.000000, 0.555570, 0.881900, 0.000000, 0.471400, 0.656250, 1.000000,
0.831470, -1.000000, 0.555570, 0.881900, 0.000000, 0.471400, 0.656250, 0.000000,
- 0.831470, -1.000000, 0.555570, 0.773000, 0.000000, 0.634400, 0.656250, 0.000000,
0.831470, 1.000000, 0.555570, 0.773000, 0.000000, 0.634400, 0.656250, 1.000000,
0.707107, 1.000000, 0.707107, 0.773000, 0.000000, 0.634400, 0.625000, 1.000000,
- 0.831470, -1.000000, 0.555570, 0.773000, 0.000000, 0.634400, 0.656250, 0.000000,
- 0.707107, 1.000000, 0.707107, 0.773000, 0.000000, 0.634400, 0.625000, 1.000000,
0.707107, -1.000000, 0.707107, 0.773000, 0.000000, 0.634400, 0.625000, 0.000000,
- 0.707107, -1.000000, 0.707107, 0.634400, 0.000000, 0.773000, 0.625000, 0.000000,
0.707107, 1.000000, 0.707107, 0.634400, 0.000000, 0.773000, 0.625000, 1.000000,
0.555570, 1.000000, 0.831470, 0.634400, 0.000000, 0.773000, 0.593750, 1.000000,
- 0.707107, -1.000000, 0.707107, 0.634400, 0.000000, 0.773000, 0.625000, 0.000000,
- 0.555570, 1.000000, 0.831470, 0.634400, 0.000000, 0.773000, 0.593750, 1.000000,
0.555570, -1.000000, 0.831470, 0.634400, 0.000000, 0.773000, 0.593750, 0.000000,
- 0.555570, -1.000000, 0.831470, 0.471400, 0.000000, 0.881900, 0.593750, 0.000000,
0.555570, 1.000000, 0.831470, 0.471400, 0.000000, 0.881900, 0.593750, 1.000000,
0.382683, 1.000000, 0.923880, 0.471400, 0.000000, 0.881900, 0.562500, 1.000000,
- 0.555570, -1.000000, 0.831470, 0.471400, 0.000000, 0.881900, 0.593750, 0.000000,
- 0.382683, 1.000000, 0.923880, 0.471400, 0.000000, 0.881900, 0.562500, 1.000000,
0.382683, -1.000000, 0.923880, 0.471400, 0.000000, 0.881900, 0.562500, 0.000000,
- 0.382683, -1.000000, 0.923880, 0.290300, 0.000000, 0.956900, 0.562500, 0.000000,
0.382683, 1.000000, 0.923880, 0.290300, 0.000000, 0.956900, 0.562500, 1.000000,
0.195090, 1.000000, 0.980785, 0.290300, 0.000000, 0.956900, 0.531250, 1.000000,
- 0.382683, -1.000000, 0.923880, 0.290300, 0.000000, 0.956900, 0.562500, 0.000000,
- 0.195090, 1.000000, 0.980785, 0.290300, 0.000000, 0.956900, 0.531250, 1.000000,
0.195090, -1.000000, 0.980785, 0.290300, 0.000000, 0.956900, 0.531250, 0.000000,
- 0.195090, -1.000000, 0.980785, 0.098000, 0.000000, 0.995200, 0.531250, 0.000000,
0.195090, 1.000000, 0.980785, 0.098000, 0.000000, 0.995200, 0.531250, 1.000000,
0.000000, 1.000000, 1.000000, 0.098000, 0.000000, 0.995200, 0.500000, 1.000000,
- 0.195090, -1.000000, 0.980785, 0.098000, 0.000000, 0.995200, 0.531250, 0.000000,
- 0.000000, 1.000000, 1.000000, 0.098000, 0.000000, 0.995200, 0.500000, 1.000000,
0.000000, -1.000000, 1.000000, 0.098000, 0.000000, 0.995200, 0.500000, 0.000000,
+ 0.000000, 1.000000, 1.000000, -0.098000, 0.000000, 0.995200, 0.500000, 1.000000,
+ -0.195090, 1.000000, 0.980785, -0.098000, 0.000000, 0.995200, 0.468750, 1.000000,
+ -0.195090, -1.000000, 0.980785, -0.098000, 0.000000, 0.995200, 0.468750, 0.000000,
+ -0.195090, 1.000000, 0.980785, -0.290300, 0.000000, 0.956900, 0.468750, 1.000000,
+ -0.382683, 1.000000, 0.923880, -0.290300, 0.000000, 0.956900, 0.437500, 1.000000,
+ -0.382683, -1.000000, 0.923880, -0.290300, 0.000000, 0.956900, 0.437500, 0.000000,
+ -0.382683, 1.000000, 0.923880, -0.471400, 0.000000, 0.881900, 0.437500, 1.000000,
+ -0.555570, 1.000000, 0.831470, -0.471400, 0.000000, 0.881900, 0.406250, 1.000000,
+ -0.555570, -1.000000, 0.831470, -0.471400, 0.000000, 0.881900, 0.406250, 0.000000,
+ -0.555570, 1.000000, 0.831470, -0.634400, 0.000000, 0.773000, 0.406250, 1.000000,
+ -0.707107, 1.000000, 0.707107, -0.634400, 0.000000, 0.773000, 0.375000, 1.000000,
+ -0.707107, -1.000000, 0.707107, -0.634400, 0.000000, 0.773000, 0.375000, 0.000000,
+ -0.707107, 1.000000, 0.707107, -0.773000, 0.000000, 0.634400, 0.375000, 1.000000,
+ -0.831470, 1.000000, 0.555570, -0.773000, 0.000000, 0.634400, 0.343750, 1.000000,
+ -0.831470, -1.000000, 0.555570, -0.773000, 0.000000, 0.634400, 0.343750, 0.000000,
+ -0.831470, 1.000000, 0.555570, -0.881900, 0.000000, 0.471400, 0.343750, 1.000000,
+ -0.923880, 1.000000, 0.382683, -0.881900, 0.000000, 0.471400, 0.312500, 1.000000,
+ -0.923880, -1.000000, 0.382683, -0.881900, 0.000000, 0.471400, 0.312500, 0.000000,
+ -0.923880, 1.000000, 0.382683, -0.956900, 0.000000, 0.290300, 0.312500, 1.000000,
+ -0.980785, 1.000000, 0.195090, -0.956900, 0.000000, 0.290300, 0.281250, 1.000000,
+ -0.980785, -1.000000, 0.195090, -0.956900, 0.000000, 0.290300, 0.281250, 0.000000,
+ -0.980785, 1.000000, 0.195090, -0.995200, 0.000000, 0.098000, 0.281250, 1.000000,
+ -1.000000, 1.000000, 0.000000, -0.995200, 0.000000, 0.098000, 0.250000, 1.000000,
+ -1.000000, -1.000000, 0.000000, -0.995200, 0.000000, 0.098000, 0.250000, 0.000000,
+ -1.000000, 1.000000, 0.000000, -0.995200, 0.000000, -0.098000, 0.250000, 1.000000,
+ -0.980785, 1.000000, -0.195090, -0.995200, 0.000000, -0.098000, 0.218750, 1.000000,
+ -0.980785, -1.000000, -0.195090, -0.995200, 0.000000, -0.098000, 0.218750, 0.000000,
+ -0.980785, 1.000000, -0.195090, -0.956900, 0.000000, -0.290300, 0.218750, 1.000000,
+ -0.923880, 1.000000, -0.382683, -0.956900, 0.000000, -0.290300, 0.187500, 1.000000,
+ -0.923880, -1.000000, -0.382683, -0.956900, 0.000000, -0.290300, 0.187500, 0.000000,
+ -0.923880, 1.000000, -0.382683, -0.881900, 0.000000, -0.471400, 0.187500, 1.000000,
+ -0.831470, 1.000000, -0.555570, -0.881900, 0.000000, -0.471400, 0.156250, 1.000000,
+ -0.831470, -1.000000, -0.555570, -0.881900, 0.000000, -0.471400, 0.156250, 0.000000,
+ -0.831470, 1.000000, -0.555570, -0.773000, 0.000000, -0.634400, 0.156250, 1.000000,
+ -0.707107, 1.000000, -0.707107, -0.773000, 0.000000, -0.634400, 0.125000, 1.000000,
+ -0.707107, -1.000000, -0.707107, -0.773000, 0.000000, -0.634400, 0.125000, 0.000000,
+ -0.707107, 1.000000, -0.707107, -0.634400, 0.000000, -0.773000, 0.125000, 1.000000,
+ -0.555570, 1.000000, -0.831470, -0.634400, 0.000000, -0.773000, 0.093750, 1.000000,
+ -0.555570, -1.000000, -0.831470, -0.634400, 0.000000, -0.773000, 0.093750, 0.000000,
+ -0.555570, 1.000000, -0.831470, -0.471400, 0.000000, -0.881900, 0.093750, 1.000000,
+ -0.382683, 1.000000, -0.923880, -0.471400, 0.000000, -0.881900, 0.062500, 1.000000,
+ -0.382683, -1.000000, -0.923880, -0.471400, 0.000000, -0.881900, 0.062500, 0.000000,
+ -0.382683, 1.000000, -0.923880, -0.290300, 0.000000, -0.956900, 0.062500, 1.000000,
+ -0.195090, 1.000000, -0.980785, -0.290300, 0.000000, -0.956900, 0.031250, 1.000000,
+ -0.195090, -1.000000, -0.980785, -0.290300, 0.000000, -0.956900, 0.031250, 0.000000,
+ -0.195090, 1.000000, -0.980785, -0.098000, 0.000000, -0.995200, 0.031250, 1.000000,
+ 0.000000, 1.000000, -1.000000, -0.098000, 0.000000, -0.995200, 0.000000, 1.000000,
+ 0.000000, -1.000000, -1.000000, -0.098000, 0.000000, -0.995200, 0.000000, 0.000000,
},
{
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
@@ -1892,7 +1988,15 @@ init = function()
48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59,
60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71,
72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83,
- 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95
+ 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95,
+ 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107,
+ 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119,
+ 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131,
+ 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143,
+ 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155,
+ 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167,
+ 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179,
+ 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191,
}
)
end
diff --git a/honey/asset/shader.lua b/honey/asset/shader.lua
index d1fecc4..8094a0c 100644
--- a/honey/asset/shader.lua
+++ b/honey/asset/shader.lua
@@ -183,4 +183,17 @@ builtin["builtin.flat.frag"] = [[
}
]]
+
+builtin["builtin.color.frag"] = [[
+ #version 410 core
+
+ out vec4 frag_color;
+ uniform vec3 color;
+
+ void main()
+ {
+ frag_color = vec4(color, 1.0);
+ }
+]]
+
return module
diff --git a/honey/ecs/collision.lua b/honey/ecs/collision.lua
index f34c320..b385e76 100644
--- a/honey/ecs/collision.lua
+++ b/honey/ecs/collision.lua
@@ -67,7 +67,7 @@ end
local updateGeom = ecs.System("collisionGeoms", function(db, dt, p)
for id, collision in pairs(db:queryComponent("collision")) do
if not collision._geom then
- createGeom(p.space, collision)
+ createGeom(p.space, id, collision)
end
updateGeom(collision)
end
diff --git a/honey/ecs/ecs.lua b/honey/ecs/ecs.lua
index 0c84041..dc096be 100644
--- a/honey/ecs/ecs.lua
+++ b/honey/ecs/ecs.lua
@@ -307,7 +307,7 @@ end
function SystemDb.addSystems(self, systems, params)
for _, system in ipairs(systems) do
self.systems[system.name] = system
- self.params[system.name] = params
+ self.params[system.name] = params or {}
end
self.sort, self.dangling = tsort(self.systems)
return self
diff --git a/honey/ecs/render.lua b/honey/ecs/render.lua
index 8cca6cf..1c38692 100644
--- a/honey/ecs/render.lua
+++ b/honey/ecs/render.lua
@@ -1,4 +1,10 @@
-local ecs = require 'honey.ecs.ecs'
+local gl = honey.gl
+local glfw = honey.glfw
+local ode = honey.ode
+
+local ecs = require 'honey.ecs.ecs'
+local collision = require 'honey.ecs.collision'
+local node = require 'honey.ecs.node'
local image = require 'honey.asset.image'
local shader = require 'honey.asset.shader'
@@ -8,16 +14,12 @@ local glm = require 'honey.glm'
local Vec3 = glm.Vec3
local Mat4 = glm.Mat4
-local gl = honey.gl
-local glfw = honey.glfw
-
-local node = require 'honey.ecs.node'
local module = {}
setmetatable(module, {__index=_G})
setfenv(1, module)
---===== rendering =====--
+
local function drawMesh(program, uniforms, matrices, vao, count)
gl.UseProgram(program)
@@ -49,6 +51,88 @@ local function drawMesh(program, uniforms, matrices, vao, count)
end
+local function drawMeshes(db, view, projection)
+ local meshes = db:queryComponent("renderMesh")
+ for id, tbl in pairs(meshes) do
+ -- get model matrix
+ local node = db:getComponent(id, "node")
+ local model = (node and node._matrix) or Mat4():identity()
+
+ -- get shader program
+ local program = shader.get(tbl.shader)
+
+ -- get mesh
+ local vao, count = mesh.get(tbl.mesh.filename, tbl.mesh.index)
+
+ -- draw c:
+ drawMesh(program, tbl.uniforms or {}, {view=view, model=model, projection=projection}, vao, count)
+ end
+end
+
+
+local function drawGeoms(db, view, projection)
+ -- draw wireframes
+ gl.Enable(gl.CULL_FACE)
+ gl.PolygonMode(gl.FRONT_AND_BACK, gl.LINE)
+ gl.LineWidth(1)
+
+ -- shader program for all geoms
+ local program = shader.get{ vertex="builtin.basic3d.vert", fragment="builtin.color.frag" }
+ local uniforms = {
+ vec3 = {
+ color = Vec3{ 1, 0, 1 },
+ },
+ }
+
+ local query = db:queryComponent("collision")
+ for id, tbl in pairs(query) do
+ -- compute model matrix
+ local m = Mat4():identity()
+ m[1][4], m[2][4], m[3][4] = ode.GeomGetPosition(tbl._geom)
+ m[1][1], m[1][2], m[1][3],
+ m[2][1], m[2][2], m[2][3],
+ m[3][1], m[3][2], m[3][3] = ode.GeomGetRotation(tbl._geom)
+
+ local matrices = {
+ view=view,
+ projection=projection,
+ model=m,
+ }
+
+ -- get the mesh
+ if tbl.class == "sphere" then
+ m:scale(Vec3{tbl.radius, tbl.radius, tbl.radius})
+ local vao, count = mesh.get("builtin.hemisphere", 1)
+ drawMesh(program, uniforms, matrices, vao, count)
+ m:rotateX(math.pi)
+ drawMesh(program, uniforms, matrices, vao, count)
+ elseif tbl.class == "box" then
+ m:scale(Vec3{tbl.lx, tbl.ly, tbl.lz})
+ local vao, count = mesh.get("builtin.cube", 1)
+ drawMesh(program, uniforms, matrices, vao, count)
+ elseif tbl.class == "capsule" then
+ m:scale(Vec3{tbl.radius, tbl.length/2, tbl.radius})
+ local vao, count = mesh.get("builtin.tube", 1)
+ drawMesh(program, uniforms, matrices, vao, count)
+ m:scale(Vec3{1, 2*tbl.radius/tbl.length, 1})
+ :translate(Vec3{0, tbl.length/2, 0})
+ vao, count = mesh.get("builtin.hemisphere", 1)
+ drawMesh(program, uniforms, matrices, vao, count)
+ m:translate(Vec3{0, -tbl.length, 0})
+ :rotateX(math.pi)
+ drawMesh(program, uniforms, matrices, vao, count)
+ elseif tbl.class == "ray" then
+ m:scale(Vec3{0.001, 0.001, tbl.length})
+ local vao, count = mesh.get("builtin.cube", 1)
+ drawMesh(program, uniforms, matrices, vao, count)
+ end
+ end
+
+ -- switch out of wireframe mode
+ gl.PolygonMode(gl.FRONT_AND_BACK, gl.FILL)
+end
+
+
local render = ecs.System("render", function(db, dt, p)
for id, camera in pairs(db:queryComponent("camera")) do
-- get camera's view and projection matrices
@@ -60,26 +144,18 @@ local render = ecs.System("render", function(db, dt, p)
else
view:identity()
end
-
- -- iterate over all scene meshes
- local meshes = db:queryComponent("renderMesh")
- for id, tbl in pairs(meshes) do
- -- get model matrix
- local node = db:getComponent(id, "node")
- local model = (node and node._matrix) or Mat4():identity()
- -- get shader program
- local program = shader.get(tbl.shader)
-
- -- get mesh
- local vao, count = mesh.get(tbl.mesh.filename, tbl.mesh.index)
-
- -- draw c:
- drawMesh(program, tbl.uniforms or {}, {view=view, model=model, projection=projection}, vao, count)
+ -- optionally draw collision geoms
+ if p.drawGeoms then
+ drawGeoms(db, view, projection)
end
+
+ -- render all scene meshes
+ drawMeshes(db, view, projection)
end
end)
render:addDependencies(node.system)
+render:addDependencies(collision.system)
system = {render}