summaryrefslogtreecommitdiff
path: root/demo/MeshInstance.lua
diff options
context:
space:
mode:
Diffstat (limited to 'demo/MeshInstance.lua')
-rw-r--r--demo/MeshInstance.lua30
1 files changed, 30 insertions, 0 deletions
diff --git a/demo/MeshInstance.lua b/demo/MeshInstance.lua
new file mode 100644
index 0000000..6e176fd
--- /dev/null
+++ b/demo/MeshInstance.lua
@@ -0,0 +1,30 @@
+local Node = require('Node')
+
+local MeshInstance = {}
+
+MeshInstance.prototype = {}
+setmetatable(MeshInstance.prototype, { __index = Node.prototype})
+
+MeshInstance.prototype.draw = function(self, shader, camera)
+ honey.texture.use(self.texture, 0)
+ honey.shader.set_mat4(shader, 'model', self.transform.array)
+ honey.shader.set_mat4(shader, 'view', camera.view.array)
+ honey.shader.set_mat4(shader, 'projection', camera.view.array)
+ honey.mesh.draw(self.mesh, shader)
+end
+
+-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+MeshInstance.mt = {}
+MeshInstance.mt.__index = MeshInstance.prototype
+
+-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+MeshInstance.new = function(parent, position, rotation, scale, mesh)
+ local meshinstance = Node.new(parent, postion, rotation, scale)
+ setmetatable(meshinstance, MeshInstance.mt)
+
+ meshinstance.mesh = mesh
+
+ return meshinstance
+end