aabb drawing for debug
This commit is contained in:
parent
e3f195cf71
commit
1433aa8e40
@ -2,12 +2,12 @@ util = require "util"
|
|||||||
local player = require "classes.player"
|
local player = require "classes.player"
|
||||||
local Vector3 = require "types.vector3"
|
local Vector3 = require "types.vector3"
|
||||||
local List = require "types.list"
|
local List = require "types.list"
|
||||||
-- local AABB = require "types.aabb"
|
local AABB = require "types.aabb"
|
||||||
|
|
||||||
-- local test_aabb = AABB.new(
|
local test_aabb = AABB.new(
|
||||||
-- Vector3(-1, -1, -1),
|
Vector3(-1, -1, -1),
|
||||||
-- Vector3(1, 1, 1)
|
Vector3(1, 2, 1)
|
||||||
-- )
|
)
|
||||||
|
|
||||||
local Obj = require "classes.obj"
|
local Obj = require "classes.obj"
|
||||||
|
|
||||||
@ -91,12 +91,12 @@ function game_tick()
|
|||||||
texture = "images/measure001a.png",
|
texture = "images/measure001a.png",
|
||||||
texture_region = { x = 0, y = 0, w = 512, h = 512 },
|
texture_region = { x = 0, y = 0, w = 512, h = 512 },
|
||||||
}
|
}
|
||||||
draw_quad(util.merge(q, params))
|
-- draw_quad(util.merge(q, params))
|
||||||
cube.position.y = math.sin(ctx.frame_number * 0.05)
|
cube.position.y = math.sin(ctx.frame_number * 0.05)
|
||||||
-- cube.position.z = math.cos(ctx.frame_number * 0.01)
|
-- cube.position.z = math.cos(ctx.frame_number * 0.01)
|
||||||
cube.rotation.x = cube.rotation.x + 0.01
|
cube.rotation.x = cube.rotation.x + 0.01
|
||||||
cube.rotation.z = cube.rotation.z + 0.01
|
cube.rotation.z = cube.rotation.z + 0.01
|
||||||
cube:draw()
|
cube:draw()
|
||||||
|
|
||||||
-- test_aabb:draw()
|
test_aabb:draw()
|
||||||
end
|
end
|
||||||
|
@ -6,6 +6,13 @@ local AABB = {
|
|||||||
max = Vector3(),
|
max = Vector3(),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
local RED = {
|
||||||
|
r = 255,
|
||||||
|
g = 0,
|
||||||
|
b = 0,
|
||||||
|
a = 255,
|
||||||
|
}
|
||||||
|
|
||||||
setmetatable(AABB, AABB)
|
setmetatable(AABB, AABB)
|
||||||
|
|
||||||
AABB.__index = AABB
|
AABB.__index = AABB
|
||||||
@ -29,10 +36,29 @@ function AABB:draw()
|
|||||||
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.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 = 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 = 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 = Vector3(self.max.x, self.min.y, self.max.z), finish = Vector3(self.max.x, self.min.y, self.min.z)}
|
||||||
|
-- bottom rectangle diagonal
|
||||||
|
draw_line_3d{start = self.min, finish = Vector3(self.max.x, self.min.y, self.max.z), color = RED}
|
||||||
|
-- top rectangle
|
||||||
|
draw_line_3d{start = Vector3(self.min.x, self.max.y, self.min.z), finish = Vector3(self.max.x, self.max.y, self.min.z)}
|
||||||
|
draw_line_3d{start = Vector3(self.min.x, self.max.y, self.min.z), finish = Vector3(self.min.x, self.max.y, self.max.z)}
|
||||||
|
draw_line_3d{start = Vector3(self.max.x, self.max.y, self.max.z), finish = Vector3(self.min.x, self.max.y, self.max.z)}
|
||||||
|
draw_line_3d{start = Vector3(self.max.x, self.max.y, self.max.z), finish = Vector3(self.max.x, self.max.y, self.min.z)}
|
||||||
|
-- top rectangle diagonal
|
||||||
|
draw_line_3d{start = Vector3(self.max.x, self.max.y, self.max.z), finish = Vector3(self.min.x, self.max.y, self.min.z), color = RED}
|
||||||
|
-- hull
|
||||||
|
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.max.x, self.max.y, self.min.z), color = RED}
|
||||||
|
|
||||||
|
draw_line_3d{start = Vector3(self.max.x, self.min.y, self.min.z), finish = Vector3(self.max.x, self.max.y, self.min.z)}
|
||||||
|
draw_line_3d{start = Vector3(self.max.x, self.min.y, self.min.z), finish = Vector3(self.max.x, self.max.y, self.max.z), color = RED}
|
||||||
|
|
||||||
|
draw_line_3d{start = Vector3(self.max.x, self.min.y, self.max.z), finish = Vector3(self.max.x, self.max.y, self.max.z)}
|
||||||
|
draw_line_3d{start = Vector3(self.max.x, self.min.y, self.max.z), finish = Vector3(self.min.x, self.max.y, self.max.z), color = RED}
|
||||||
|
|
||||||
|
draw_line_3d{start = Vector3(self.min.x, self.min.y, self.max.z), finish = Vector3(self.min.x, self.max.y, self.max.z)}
|
||||||
|
draw_line_3d{start = Vector3(self.min.x, self.min.y, self.max.z), finish = Vector3(self.min.x, self.max.y, self.min.z), color = RED}
|
||||||
|
|
||||||
-- 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
|
end
|
||||||
|
|
||||||
return AABB
|
return AABB
|
||||||
|
Loading…
Reference in New Issue
Block a user