1+ package com.lambda.graphics.renderer.esp.builders
2+
3+ import com.lambda.graphics.renderer.esp.DirectionMask
4+ import com.lambda.graphics.renderer.esp.DirectionMask.hasDirection
5+ import com.lambda.graphics.renderer.esp.DynamicAABB
6+ import com.lambda.graphics.renderer.esp.impl.DynamicESPRenderer
7+ import com.lambda.util.primitives.extension.max
8+ import com.lambda.util.primitives.extension.min
9+ import java.awt.Color
10+
11+ fun DynamicESPRenderer.build (
12+ box : DynamicAABB ,
13+ filledColor : Color ,
14+ outlineColor : Color ,
15+ sides : Int = DirectionMask .ALL ,
16+ outlineMode : DirectionMask .OutlineMode = DirectionMask .OutlineMode .OR
17+ ) {
18+ buildFilled(box, filledColor, sides)
19+ buildOutline(box, outlineColor, sides, outlineMode)
20+ }
21+
22+ fun DynamicESPRenderer.buildFilled (
23+ box : DynamicAABB ,
24+ color : Color ,
25+ sides : Int = DirectionMask .ALL
26+ ) = faces.use {
27+ val boxes = box.getBoxPair() ? : return @use
28+
29+ val pos11 = boxes.first.min
30+ val pos12 = boxes.first.max
31+ val pos21 = boxes.second.min
32+ val pos22 = boxes.second.max
33+
34+ grow(8 )
35+
36+ val blb by lazy { vec3(pos11.x, pos11.y, pos11.z).vec3(pos21.x, pos21.y, pos21.z).color(color).end() }
37+ val blf by lazy { vec3(pos11.x, pos11.y, pos12.z).vec3(pos21.x, pos21.y, pos22.z).color(color).end() }
38+ val brb by lazy { vec3(pos12.x, pos11.y, pos11.z).vec3(pos22.x, pos21.y, pos21.z).color(color).end() }
39+ val brf by lazy { vec3(pos12.x, pos11.y, pos12.z).vec3(pos22.x, pos21.y, pos22.z).color(color).end() }
40+ val tlb by lazy { vec3(pos11.x, pos12.y, pos11.z).vec3(pos21.x, pos22.y, pos21.z).color(color).end() }
41+ val tlf by lazy { vec3(pos11.x, pos12.y, pos12.z).vec3(pos21.x, pos22.y, pos22.z).color(color).end() }
42+ val trb by lazy { vec3(pos12.x, pos12.y, pos11.z).vec3(pos22.x, pos22.y, pos21.z).color(color).end() }
43+ val trf by lazy { vec3(pos12.x, pos12.y, pos12.z).vec3(pos22.x, pos22.y, pos22.z).color(color).end() }
44+
45+ if (sides.hasDirection(DirectionMask .EAST )) putQuad(brb, trb, trf, brf)
46+ if (sides.hasDirection(DirectionMask .WEST )) putQuad(blb, blf, tlf, tlb)
47+ if (sides.hasDirection(DirectionMask .UP )) putQuad(tlb, tlf, trf, trb)
48+ if (sides.hasDirection(DirectionMask .DOWN )) putQuad(blb, brb, brf, blf)
49+ if (sides.hasDirection(DirectionMask .SOUTH )) putQuad(blf, brf, trf, tlf)
50+ if (sides.hasDirection(DirectionMask .NORTH )) putQuad(blb, tlb, trb, brb)
51+ }
52+
53+ fun DynamicESPRenderer.buildOutline (
54+ box : DynamicAABB ,
55+ color : Color ,
56+ sides : Int = DirectionMask .ALL ,
57+ outlineMode : DirectionMask .OutlineMode = DirectionMask .OutlineMode .OR
58+ ) = outlines.use {
59+ val boxes = box.getBoxPair() ? : return @use
60+
61+ val pos11 = boxes.first.min
62+ val pos12 = boxes.first.max
63+ val pos21 = boxes.second.min
64+ val pos22 = boxes.second.max
65+
66+ grow(8 )
67+
68+ val blb by lazy { vec3(pos11.x, pos11.y, pos11.z).vec3(pos21.x, pos21.y, pos21.z).color(color).end() }
69+ val blf by lazy { vec3(pos11.x, pos11.y, pos12.z).vec3(pos21.x, pos21.y, pos22.z).color(color).end() }
70+ val brb by lazy { vec3(pos12.x, pos11.y, pos11.z).vec3(pos22.x, pos21.y, pos21.z).color(color).end() }
71+ val brf by lazy { vec3(pos12.x, pos11.y, pos12.z).vec3(pos22.x, pos21.y, pos22.z).color(color).end() }
72+ val tlb by lazy { vec3(pos11.x, pos12.y, pos11.z).vec3(pos21.x, pos22.y, pos21.z).color(color).end() }
73+ val tlf by lazy { vec3(pos11.x, pos12.y, pos12.z).vec3(pos21.x, pos22.y, pos22.z).color(color).end() }
74+ val trb by lazy { vec3(pos12.x, pos12.y, pos11.z).vec3(pos22.x, pos22.y, pos21.z).color(color).end() }
75+ val trf by lazy { vec3(pos12.x, pos12.y, pos12.z).vec3(pos22.x, pos22.y, pos22.z).color(color).end() }
76+
77+ val hasEast = sides.hasDirection(DirectionMask .EAST )
78+ val hasWest = sides.hasDirection(DirectionMask .WEST )
79+ val hasUp = sides.hasDirection(DirectionMask .UP )
80+ val hasDown = sides.hasDirection(DirectionMask .DOWN )
81+ val hasSouth = sides.hasDirection(DirectionMask .SOUTH )
82+ val hasNorth = sides.hasDirection(DirectionMask .NORTH )
83+
84+ if (outlineMode.check(hasUp, hasNorth)) putLine(tlb, trb)
85+ if (outlineMode.check(hasUp, hasSouth)) putLine(tlf, trf)
86+ if (outlineMode.check(hasUp, hasWest)) putLine(tlb, tlf)
87+ if (outlineMode.check(hasUp, hasEast)) putLine(trf, trb)
88+
89+ if (outlineMode.check(hasDown, hasNorth)) putLine(blb, brb)
90+ if (outlineMode.check(hasDown, hasSouth)) putLine(blf, brf)
91+ if (outlineMode.check(hasDown, hasWest)) putLine(blb, blf)
92+ if (outlineMode.check(hasDown, hasEast)) putLine(brb, brf)
93+
94+ if (outlineMode.check(hasWest, hasNorth)) putLine(tlb, blb)
95+ if (outlineMode.check(hasNorth, hasEast)) putLine(trb, brb)
96+ if (outlineMode.check(hasEast, hasSouth)) putLine(trf, brf)
97+ if (outlineMode.check(hasSouth, hasWest)) putLine(tlf, blf)
98+ }
0 commit comments