blob: 6fbfdd51cb19d96af1bd71225b2dc3f8d0ff9716 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
local glm = honey.glm
local Mat4 = require "honey.mat4"
local module = {}
setmetatable(module, {__index=_G})
setfenv(1, module)
Quaternion = {}
Quaternion.__index = Quaternion
function Quaternion.new(_, tbl)
local tbl = tbl or { 0, 0, 0, 0 }
local self = {}
self.data = glm.quat_create()
glm.quat_init(self.data, unpack(tbl))
setmetatable(self, Quaternion)
return self
end
setmetatable(Quaternion, {__call=Quaternion.new})
function Quaternion.toMat4(self)
local m = Mat4()
glm.quat_mat4(self.data, m.data)
return m
end
return module.Quaternion
|