dang
This commit is contained in:
parent
342c98e915
commit
e3f195cf71
@ -2,6 +2,12 @@ util = require "util"
|
||||
local player = require "classes.player"
|
||||
local Vector3 = require "types.vector3"
|
||||
local List = require "types.list"
|
||||
-- local AABB = require "types.aabb"
|
||||
|
||||
-- local test_aabb = AABB.new(
|
||||
-- Vector3(-1, -1, -1),
|
||||
-- Vector3(1, 1, 1)
|
||||
-- )
|
||||
|
||||
local Obj = require "classes.obj"
|
||||
|
||||
@ -91,4 +97,6 @@ function game_tick()
|
||||
cube.rotation.x = cube.rotation.x + 0.01
|
||||
cube.rotation.z = cube.rotation.z + 0.01
|
||||
cube:draw()
|
||||
|
||||
-- test_aabb:draw()
|
||||
end
|
||||
|
38
data/scripts/types/aabb.lua
Normal file
38
data/scripts/types/aabb.lua
Normal file
@ -0,0 +1,38 @@
|
||||
local Vector3 = require "types.vector3"
|
||||
|
||||
---@class AABB
|
||||
local AABB = {
|
||||
min = Vector3(),
|
||||
max = Vector3(),
|
||||
}
|
||||
|
||||
setmetatable(AABB, AABB)
|
||||
|
||||
AABB.__index = AABB
|
||||
|
||||
---@param min vectorlike
|
||||
---@param max vectorlike
|
||||
---@return AABB
|
||||
function AABB.new(min, max)
|
||||
min = min or Vector3()
|
||||
max = max or Vector3()
|
||||
local aabb = {
|
||||
min = min,
|
||||
max = max,
|
||||
}
|
||||
|
||||
return setmetatable(aabb, AABB)
|
||||
end
|
||||
|
||||
function AABB:draw()
|
||||
-- bottom rectangle
|
||||
draw_line_3d{start = self.min, finish = Vector3(self.max.x, self.min.y, self.min.z)}
|
||||
draw_line_3d{start = self.min, finish = Vector3(self.min.x, self.min.y, self.max.z)}
|
||||
draw_line_3d{start = Vector3(self.max.x, self.min.y, self.max.z), finish = Vector3(self.min.x, self.min.y, self.max.z)}
|
||||
|
||||
-- draw_line_3d{start = self.min, finish = Vector3(self.max.x, self.min.y, self.min.z)}
|
||||
-- draw_line_3d{start = self.min, finish = Vector3(self.min.x, self.max.y, self.min.z)}
|
||||
-- draw_line_3d{start = self.min, finish = Vector3(self.min.x, self.min.y, self.max.z)}
|
||||
end
|
||||
|
||||
return AABB
|
Loading…
Reference in New Issue
Block a user