Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Random functions for debugging vectors.
- function IsVecEqual(vec1, vec2)
- if vec1.x ~= vec2.x or
- vec1.y ~= vec2.y or
- vec1.z ~= vec2.z then
- return false
- end
- return true
- end
- //opacity - optional parameter
- function SimpleColor(red, green, blue, opacity)
- if opacity then
- Color(red/255, green/255, blue/255, opacity/100)
- end
- return Color(red/255, green/255, blue/255, 1)
- end
- // The vector drawing functions can take an optional color parameter and these make them easier to use.
- red = SimpleColor(255, 0, 0)
- green = SimpleColor(0, 255, 0)
- blue = SimpleColor(0, 0, 255)
- white = SimpleColor(255, 255, 255)
- yellow = SimpleColor(255, 255, 0)
- cyan = SimpleColor(0, 255, 255)
- magenta = SimpleColor(255, 0, 255)
- orange = SimpleColor(255, 165, 0)
- purple = SimpleColor(160, 32, 240)
- lime = SimpleColor(50, 205, 50)
- local lineLifetime = 0.1//0.05 //determines how long the lines linger (if set to small then when running ns2 windowed, the lines will disappear) (if set to large then you see multiple copies of lines if the point moves)
- local xAxisColor = Color(1,0,0,1)
- local yAxisColor = Color(0,1,0,1)
- local zAxisColor = Color(0,0,1,1)
- local xAxisAltColor = Color(0.8, 0.0, 0.5, 1)
- local yAxisAltColor = Color(0.0, 1.0, 0.0, 1)
- local zAxisAltColor = Color(0.0, 0.5, 0.8, 1)
- //color - optional parameter
- function DrawLine(startPoint, endPoint, color)
- if color then
- DebugLine(startPoint, endPoint, lineLifetime, color.r, color.g, color.b, color.a)
- else
- DebugLine(startPoint, endPoint, lineLifetime, xAxisAltColor.r, xAxisAltColor.g, xAxisAltColor.b, xAxisAltColor.a)
- end
- end
- //based on DrawEntityAxis(entity)
- //color - optional parameter to override the axis colors
- function DrawEntityXZAxes(entity, color)
- // Draw x red, y green, z blue (like 3ds Max)
- local lineLength = 1
- local coords = entity:GetAngles():GetCoords()
- local p0 = entity:GetOrigin()
- p0.y = p0.y + 0.1
- if color then
- DebugLine(p0, p0 + coords.xAxis*lineLength, lineLifetime, color.r, color.g, color.b, color.a)
- //DebugLine(p0, p0 + coords.yAxis*lineLength, lineLifetime, color.r, color.g, color.b, color.a)
- DebugLine(p0, p0 + coords.zAxis*lineLength, lineLifetime, color.r, color.g, color.b, color.a)
- else
- DebugLine(p0, p0 + coords.xAxis*lineLength, lineLifetime, xAxisColor.r, xAxisColor.g, xAxisColor.b, xAxisColor.a)
- //DebugLine(p0, p0 + coords.yAxis*lineLength, lineLifetime, yAxisColor.r, yAxisColor.g, yAxisColor.b, yAxisColor.a)
- DebugLine(p0, p0 + coords.zAxis*lineLength, lineLifetime, zAxisColor.r, zAxisColor.g, zAxisColor.b, zAxisColor.a)
- end
- end
- //based on DrawEntityAxis(entity)
- //draws world Axis on player
- //color - optional parameter to override the axis colors
- function DrawWorldXZAxes(entity, color)
- // Draw x red, y green, z blue, but used lighter colors to distinguish from DrawEntityXZAxis and DrawEntityAxis
- local lineLength = 10
- local shortLineLength = 1.25
- local p0 = entity:GetOrigin()
- p0.y = p0.y + 0.1
- if color then
- DebugLine(p0 - Vector.xAxis*shortLineLength , p0 + Vector.xAxis*lineLength, lineLifetime, color.r, color.g, color.b, color.a)
- //DebugLine(p0 - Vector.yAxis*shortLineLength , p0 + Vector.yAxis*lineLength, lineLifetime, color.r, color.g, color.b, color.a)
- DebugLine(p0 - Vector.zAxis*shortLineLength , p0 + Vector.zAxis*lineLength, lineLifetime, color.r, color.g, color.b, color.a)
- else
- DebugLine(p0 - Vector.xAxis*shortLineLength , p0 + Vector.xAxis*lineLength, lineLifetime, xAxisColor.r, xAxisColor.g, xAxisColor.b, xAxisColor.a)
- //DebugLine(p0 - Vector.yAxis*shortLineLength , p0 + Vector.yAxis*lineLength, lineLifetime, yAxisColor.r, yAxisColor.g, yAxisColor.b, yAxisColor.a)
- DebugLine(p0 - Vector.zAxis*shortLineLength , p0 + Vector.zAxis*lineLength, lineLifetime, zAxisColor.r, zAxisColor.g, zAxisColor.b, zAxisColor.a)
- end
- end
- //color - optional parameter to override the axis colors
- function DrawVector(vec, color)
- local vec = Vector(vec)
- // Draw x red, y green, z blue (like 3ds Max)
- local lineLength = 0.25
- if color then
- DebugLine(vec - Vector.xAxis*lineLength, vec + Vector.xAxis*lineLength, lineLifetime, color.r, color.g, color.b, color.a)
- //DebugLine(vec - Vector.yAxis*lineLength, vec + Vector.yAxis*lineLength, lineLifetime, color.r, color.g, color.b, color.a)
- DebugLine(vec - Vector.zAxis*lineLength, vec + Vector.zAxis*lineLength, lineLifetime, color.r, color.g, color.b, color.a)
- else
- DebugLine(vec - Vector.xAxis*lineLength, vec + Vector.xAxis*lineLength, lineLifetime, xAxisColor.r, xAxisColor.g, xAxisColor.b, xAxisColor.a)
- //DebugLine(vec - Vector.yAxis*lineLength, vec + Vector.yAxis*lineLength, lineLifetime, yAxisColor.r, yAxisColor.g, yAxisColor.b, yAxisColor.a)
- DebugLine(vec - Vector.zAxis*lineLength, vec + Vector.zAxis*lineLength, lineLifetime, zAxisColor.r, zAxisColor.g, zAxisColor.b, zAxisColor.a)
- end
- end
- //color - optional parameter to override the axis colors
- //groundHeight - height above ground, for example use player:GetOrigin().y + 0.1
- function DrawVectorOnGround(vec, groundHeight, color)
- local vec = Vector(vec)
- // Draw x red, y green, z blue (like 3ds Max)
- local lineLength = 0.25
- vec.y = groundHeight
- if color then
- DebugLine(vec, vec + Vector.xAxis*lineLength, lineLifetime, color.r, color.g, color.b, color.a)
- //DebugLine(vec, vec + Vector.yAxis*lineLength, lineLifetime, color.r, color.g, color.b, color.a)
- DebugLine(vec, vec + Vector.zAxis*lineLength, lineLifetime, color.r, color.g, color.b, color.a)
- else
- DebugLine(vec, vec + Vector.xAxis*lineLength, lineLifetime, xAxisAltColor.r, xAxisAltColor.g, xAxisAltColor.b, xAxisAltColor.a)
- //DebugLine(vec, vec + Vector.yAxis*lineLength, lineLifetime, yAxisAltColor.r, yAxisAltColor.g, yAxisAltColor.b, yAxisAltColor.a)
- DebugLine(vec, vec + Vector.zAxis*lineLength, lineLifetime, zAxisAltColor.r, zAxisAltColor.g, zAxisAltColor.b, zAxisAltColor.a)
- end
- end
- //color - optional parameter to override the axis colors
- function DrawVectorPoint(vec, color)
- local vec = Vector(vec)
- // Draw x red, y green, z blue (like 3ds Max)
- local lineLength = 0.25
- if color then
- DebugLine(vec - Vector.xAxis*lineLength, vec + Vector.xAxis*lineLength, lineLifetime, color.r, color.g, color.b, color.a)
- DebugLine(vec - Vector.yAxis*lineLength, vec + Vector.yAxis*lineLength, lineLifetime, color.r, color.g, color.b, color.a)
- DebugLine(vec - Vector.zAxis*lineLength, vec + Vector.zAxis*lineLength, lineLifetime, color.r, color.g, color.b, color.a)
- else
- DebugLine(vec - Vector.xAxis*lineLength, vec + Vector.xAxis*lineLength, lineLifetime, xAxisAltColor.r, xAxisAltColor.g, xAxisAltColor.b, xAxisAltColor.a)
- DebugLine(vec - Vector.yAxis*lineLength, vec + Vector.yAxis*lineLength, lineLifetime, yAxisAltColor.r, yAxisAltColor.g, yAxisAltColor.b, yAxisAltColor.a)
- DebugLine(vec - Vector.zAxis*lineLength, vec + Vector.zAxis*lineLength, lineLifetime, zAxisAltColor.r, zAxisAltColor.g, zAxisAltColor.b, zAxisAltColor.a)
- end
- end
- //color - optional parameter to override the axis colors
- function DrawVectorPointBig(vec, color)
- local vec = Vector(vec)
- // Draw x red, y green, z blue (like 3ds Max)
- local lineLength = 0.5
- if color then
- DebugLine(vec - Vector.xAxis*lineLength, vec + Vector.xAxis*lineLength, lineLifetime, color.r, color.g, color.b, color.a)
- DebugLine(vec - Vector.yAxis*lineLength, vec + Vector.yAxis*lineLength, lineLifetime, color.r, color.g, color.b, color.a)
- DebugLine(vec - Vector.zAxis*lineLength, vec + Vector.zAxis*lineLength, lineLifetime, color.r, color.g, color.b, color.a)
- else
- DebugLine(vec - Vector.xAxis*lineLength, vec + Vector.xAxis*lineLength, lineLifetime, xAxisAltColor.r, xAxisAltColor.g, xAxisAltColor.b, xAxisAltColor.a)
- DebugLine(vec - Vector.yAxis*lineLength, vec + Vector.yAxis*lineLength, lineLifetime, yAxisAltColor.r, yAxisAltColor.g, yAxisAltColor.b, yAxisAltColor.a)
- DebugLine(vec - Vector.zAxis*lineLength, vec + Vector.zAxis*lineLength, lineLifetime, zAxisAltColor.r, zAxisAltColor.g, zAxisAltColor.b, zAxisAltColor.a)
- end
- end
- //color - optional parameter to override the axis colors
- function DrawVectorPointLarge(vec, color) //dedicated to the gorge which is so fat that i coudn't see the point!
- local vec = Vector(vec)
- // Draw x red, y green, z blue (like 3ds Max)
- local lineLength = 1
- if color then
- DebugLine(vec - Vector.xAxis*lineLength, vec + Vector.xAxis*lineLength, lineLifetime, color.r, color.g, color.b, color.a)
- DebugLine(vec - Vector.yAxis*lineLength, vec + Vector.yAxis*lineLength, lineLifetime, color.r, color.g, color.b, color.a)
- DebugLine(vec - Vector.zAxis*lineLength, vec + Vector.zAxis*lineLength, lineLifetime, color.r, color.g, color.b, color.a)
- else
- DebugLine(vec - Vector.xAxis*lineLength, vec + Vector.xAxis*lineLength, lineLifetime, xAxisAltColor.r, xAxisAltColor.g, xAxisAltColor.b, xAxisAltColor.a)
- DebugLine(vec - Vector.yAxis*lineLength, vec + Vector.yAxis*lineLength, lineLifetime, yAxisAltColor.r, yAxisAltColor.g, yAxisAltColor.b, yAxisAltColor.a)
- DebugLine(vec - Vector.zAxis*lineLength, vec + Vector.zAxis*lineLength, lineLifetime, zAxisAltColor.r, zAxisAltColor.g, zAxisAltColor.b, zAxisAltColor.a)
- end
- end
- //color - optional parameter to override the axis colors
- function DrawVectorPointHuge(vec, color) //dedicated to the gorge which is so fat that i coudn't see the point!
- local vec = Vector(vec)
- // Draw x red, y green, z blue (like 3ds Max)
- local lineLength = 3
- if color then
- DebugLine(vec - Vector.xAxis*lineLength, vec + Vector.xAxis*lineLength, lineLifetime, color.r, color.g, color.b, color.a)
- DebugLine(vec - Vector.yAxis*lineLength, vec + Vector.yAxis*lineLength, lineLifetime, color.r, color.g, color.b, color.a)
- DebugLine(vec - Vector.zAxis*lineLength, vec + Vector.zAxis*lineLength, lineLifetime, color.r, color.g, color.b, color.a)
- else
- DebugLine(vec - Vector.xAxis*lineLength, vec + Vector.xAxis*lineLength, lineLifetime, xAxisAltColor.r, xAxisAltColor.g, xAxisAltColor.b, xAxisAltColor.a)
- DebugLine(vec - Vector.yAxis*lineLength, vec + Vector.yAxis*lineLength, lineLifetime, yAxisAltColor.r, yAxisAltColor.g, yAxisAltColor.b, yAxisAltColor.a)
- DebugLine(vec - Vector.zAxis*lineLength, vec + Vector.zAxis*lineLength, lineLifetime, zAxisAltColor.r, zAxisAltColor.g, zAxisAltColor.b, zAxisAltColor.a)
- end
- end
- //color - optional parameter to override the axis colors
- //groundHeight - height above ground, for example use player:GetOrigin().y + 0.1
- function DrawVectorPointOnGround(vec, groundHeight, color)
- local vec = Vector(vec)
- // Draw x red, y green, z blue (like 3ds Max)
- local lineLength = 0.25
- vec.y = groundHeight
- if color then
- DebugLine(vec - Vector.xAxis*lineLength, vec + Vector.xAxis*lineLength, lineLifetime, color.r, color.g, color.b, color.a)
- //DebugLine(vec - Vector.yAxis*lineLength, vec + Vector.yAxis*lineLength, lineLifetime, color.r, color.g, color.b, color.a)
- DebugLine(vec - Vector.zAxis*lineLength, vec + Vector.zAxis*lineLength, lineLifetime, color.r, color.g, color.b, color.a)
- else
- DebugLine(vec - Vector.xAxis*lineLength, vec + Vector.xAxis*lineLength, lineLifetime, xAxisAltColor.r, xAxisAltColor.g, xAxisAltColor.b, xAxisAltColor.a)
- //DebugLine(vec - Vector.yAxis*lineLength, vec + Vector.yAxis*lineLength, lineLifetime, yAxisAltColor.r, yAxisAltColor.g, yAxisAltColor.b, yAxisAltColor.a)
- DebugLine(vec - Vector.zAxis*lineLength, vec + Vector.zAxis*lineLength, lineLifetime, zAxisAltColor.r, zAxisAltColor.g, zAxisAltColor.b, zAxisAltColor.a)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement