-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathReflect Visualizer.txt
67 lines (55 loc) · 2.4 KB
/
Reflect Visualizer.txt
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
@name Reflect Visualizer
@persist Size:vector Reflections [Rangers Directions]:array MaxCPU
@model models/props_lab/tpplug.mdl
if(first()|duped()){
Reflections = 30
MaxCPU = 5000
runOnTick(1)
#get the length of the model we're using for the holo in hammer units
Getlen = propSpawn("models/hunter/plates/plate32x32.mdl", 1)
Size = Getlen:aabbSize()
Getlen:propDelete()
#function i stole most of from vurv
#makes a line with a holo index, and 2 points.
function void line(Index, [Pos1 Pos2 Color]:vector){
local Distance = Pos1:distance(Pos2)
local Direction = Pos2 - Pos1
#check if the holo with the index specified allready exists
if(holoEntity(Index):isValid()){
holoReset(Index, "models/hunter/plates/plate32x32.mdl", vec(1), Color, "models/debug/debugwhite")
holoPos(Index, (Pos1 + Pos2)/2)
holoAng(Index, (Pos1 - Pos2):toAngle() + ang(0, 0, 0))
holoScaleUnits(Index, vec(Distance, 3, 3))
holoVisible(Index, players(), 0)
holoVisible(Index, owner(), 1)
} else {
holoCreate(Index, (Pos1 + Pos2)/2, vec(1), Direction:toAngle(), Color, "models/hunter/plates/plate32x32.mdl")
holoMaterial(Index, "models/debug/debugwhite")
holoScaleUnits(Index, vec(Distance, 3, 3))
holoVisible(Index, players(), 0)
holoVisible(Index, owner(), 1)
}
}
#reflect func I stole from vurv
function vector vector:reflect(HitNormal:vector){
return This - 2 * (This:dot(HitNormal)) * HitNormal
}
Reflections++
}
#keep the chip from using too much cpu
while(cpuUsage()*10^6 < MaxCPU & (opcounter() < softQuota())){
for(I = 1, Reflections){
if(I == 1){
#incidince ray
Directions[I, vector] = entity():forward()
Rangers[I, ranger] = rangerOffset(65535, entity():pos(), Directions[I, vector])
line(I, entity():pos(), Rangers[I, ranger]:pos(), vec(85, 220, 85))
I++
} else {
#reflection ray(s)
Directions[I, vector] = Directions[I-1, vector]:reflect(Rangers[I-1, ranger]:hitNormal())
Rangers[I, ranger] = rangerOffset(65535, Rangers[I-1, ranger]:pos(), Directions[I, vector])
line(I, Rangers[I-1, ranger]:pos(), Rangers[I, ranger]:pos(), vec(85, 85, 220))
}
}
}