Certainly! To add diagonal lines on every face of the bounding box (top, bottom, and all four sides), you need to connect the corners diagonally on each face.
Your bounding box has 8 corners indexed as follows (assuming a standard cube corner indexing):
- Bottom face corners: 0, 1, 2, 3
- Top face corners: 4, 5, 6, 7
You already have edges connecting the corners around each face and vertical edges connecting top and bottom faces.
What to add:
- Diagonal lines on the bottom face: (0 to 2) and (1 to 3)
- Diagonal lines on the top face: (4 to 6) and (5 to 7)
- Diagonal lines on the four vertical faces:
- Face between corners 0,1,5,4: diagonals (0 to 5) and (1 to 4)
- Face between corners 1,2,6,5: diagonals (1 to 6) and (2 to 5)
- Face between corners 2,3,7,6: diagonals (2 to 7) and (3 to 6)
- Face between corners 3,0,4,7: diagonals (3 to 4) and (0 to 7)
Updated code with diagonals:
def draw_bounding_box(view, comp, color)
bounds = comp.bounds
points = (0..7).map { |i| bounds.corner(i) }
view.drawing_color = color
view.line_width = 2
edges = [
# Bottom face edges
[0,1], [1,2], [2,3], [3,0],
# Top face edges
[4,5], [5,6], [6,7], [7,4],
# Vertical edges
[0,4], [1,5], [2,6], [3,7],
# Diagonals on bottom face
[0,2], [1,3],
# Diagonals on top face
[4,6], [5,7],
# Diagonals on vertical faces
[0,5], [1,4], # face 0-1-5-4
[1,6], [2,5], # face 1-2-6-5
[2,7], [3,6], # face 2-3-7-6
[3,4], [0,7] # face 3-0-4-7
]
edges.each do |start_idx, end_idx|
view.draw(GL_LINES, points[start_idx], points[end_idx])
end
end
This will draw all the edges plus the diagonals on every face of the bounding box. Let me know if you want me to help with anything else!