-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathCuboid.lua
More file actions
40 lines (39 loc) · 816 Bytes
/
Cuboid.lua
File metadata and controls
40 lines (39 loc) · 816 Bytes
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
31
32
33
34
35
36
37
38
39
40
fysiks.Cuboid = fysiks.FullPolyhedron:new(nil, {}, {}, {})
fysiks.Cuboid.__index = fysiks.Cuboid
function fysiks.Cuboid:new(obj, min, max)
local verts = {
{x = min.x, y = min.y, z = min.z},
{x = min.x, y = min.y, z = max.z},
{x = min.x, y = max.y, z = min.z},
{x = min.x, y = max.y, z = max.z},
{x = max.x, y = min.y, z = min.z},
{x = max.x, y = min.y, z = max.z},
{x = max.x, y = max.y, z = min.z},
{x = max.x, y = max.y, z = max.z},
}
local edges = {
{1, 2},
{2, 4},
{4, 3},
{3, 1},
{5, 6},
{6, 8},
{8, 7},
{7, 5},
{1, 5},
{2, 6},
{3, 7},
{4, 8},
}
local faces = {
{1, 2, 3, 4},
{1, 2, 5, 6},
{1, 3, 5, 7},
{2, 4, 6, 8},
{3, 4, 7, 8},
{5, 6, 7, 8},
}
local c = fysiks.FullPolyhedron:new(obj, verts, edges, faces)
c = setmetatable(c, self)
return c
end