Hi here is a 3d box that rotates based on player yaw, its glitchy on two quadrants and idk why have fun!
MY PITCH YAW ROLL TO PITCH YAW THING WAS USEFUL FOR SOMETHING OMGGGGGGGGGGGGGGGGGGGGGGGGG
Code:
hook.Add( "HUDPaint", "3D-Box", function()
for k,v in pairs(player.GetAll()) do
if v != LocalPlayer() and v:IsValid() and v:Alive() and v:Health() >= 0 then
eye = v:EyeAngles();
local min, max = v:WorldSpaceAABB();
mid = (min + max)/2
diff = max-min;
cam.Start3D()
--[[Bottom Horizontal Lines]]--
render.DrawLine( Rotate(min) , Rotate(min+Vector(diff.x,0,0)) , Color(255,100,0) )
render.DrawLine( Rotate(min), Rotate(min+Vector(0,diff.y,0)) , Color(255,100,0) )
render.DrawLine( Rotate(min+Vector(diff.x, diff.y,0)), Rotate(min+Vector(diff.x,0,0)) , Color(255,100,0) )
render.DrawLine( Rotate(min+Vector(diff.x, diff.y,0)), Rotate(min+Vector(0,diff.y,0)) , Color(255,100,0) )
--[[Vertical Lines]]--
render.DrawLine( Rotate(min), Rotate(min+Vector(0,0,diff.z)), Color(255,100,0) )
render.DrawLine( Rotate(min+Vector(diff.x,0,0)), Rotate(min+Vector(diff.x,0,diff.z)), Color(255,100,0) )
render.DrawLine( Rotate(min+Vector(0,diff.y,0)), Rotate(min+Vector(0,diff.y,diff.z)), Color(255,100,0) )
render.DrawLine( Rotate(min+Vector(diff.x,diff.y,0)), Rotate(min+Vector(diff.x,diff.y,diff.z)), Color(255,100,0) )
--[[Top Horizontal Lines]]--
render.DrawLine( Rotate(max), Rotate(max-Vector(diff.x,0,0)) , Color(255,100,0) )
render.DrawLine( Rotate(max), Rotate(max-Vector(0,diff.y,0)) , Color(255,100,0) )
render.DrawLine( Rotate(max-Vector(diff.x, diff.y,0)), Rotate(max-Vector(diff.x,0,0)) , Color(255,100,0) )
render.DrawLine( Rotate(max-Vector(diff.x, diff.y,0)), Rotate(max-Vector(0,diff.y,0)) , Color(255,100,0) )
cam.End3D()
end
end
end)
function Rotate(V)
R = eye.y;
origin = Vector(mid.x, mid.y, V.z);
x = V.x - origin.x;
y = V.y - origin.y;
_x = math.abs(x); -- Absolute X (Made Positive)
_y = math.abs(y); -- Absolute Y (Made Positive)
ang = nil; -- Angle Before Roll
tang = nil; -- Total Angle
_rad = nil; -- Radius
q = nil; -- Quadrant # Before Roll
_q = nil; -- Quadrant # After Roll
rang = nil; -- Total Angle + Roll
_rang = nil; -- (Total Angle + Roll) Modulus 90
__x = nil; -- X After Rotate (Supposed)
__y = nil; -- Y After Rotate (Supposed)
fx = nil; -- Final X
fy = nil; -- Final Y
if (x > 0) then
if (y > 0) then
q = 1;
else
q = 4;
end
else
if (y > 0) then
q = 2;
else
q = 3;
end
end
_rad = math.sqrt(_x^2 + _y^2);
if (q == 1 or q == 3) then
ang = math.deg(math.acos((_x^2+_rad^2-_y^2)/(2*_x*_rad)));
else
ang = math.deg(math.acos((_y^2+_rad^2-_x^2)/(2*_y*_rad)));
end
tang = ang + ((q - 1) * 90);
if ((tang + R) >= 0) then
rang = (tang + R)%360;
else
rang = 360 + (tang + R)%360;
end
_rang = rang%90;
_q = math.ceil(rang/90);
__x = _rad*math.sin(math.rad(90-_rang));
__y = _rad*math.sin(math.rad(_rang));
if (_q == 1) then
fx = __x + origin.x;
fy = __y + origin.y;
elseif (_q == 2) then
fx = __y * -1 + origin.x;
fy = __x + origin.y;
elseif (_q == 3) then
fx = __x * -1 + origin.x;
fy = __y * -1 + origin.y;
elseif (_q == 4) then
fx = __y + origin.x;
fy = __x * -1 + origin.y;
end
return Vector(fx,fy,V.z)
end
TURNS OUT THERES A CODE THAT ALLOWS YOU TO DRAW A 3D BOX!!!
THAT WOULD HAVE BEEN NICE TO KNOW EARLIER
btw this code is in no way supposed to be good the whole 3dbox is pasted from dhack and i just added the rotate thing as a poc i guess.
After Playing around for a while I figured out the 10*easier less retarded method but whatever fuck it. the 1st method would be more useful if you were coding in C++ ;w;
Code:
hook.Add( "HUDPaint", "3D-Box", function()
for k,v in pairs(player.GetAll()) do
if v != LocalPlayer() and v:IsValid() and v:Alive() and v:Health() >= 0 then
eye = v:EyeAngles();
local min, max = v:WorldSpaceAABB();
origin = v:GetPos();
cam.Start3D()
render.DrawWireframeBox( origin, Angle(0, eye.y, 0), min-origin, max-origin, Color(255,100,0))
render.DrawWireframeBox( origin, Angle(0, eye.y, 0), min-origin, Vector(max.x-origin.x,max.y-origin.y,(max.z-origin.z)/100*v:Health(), Color(255,100,0)))
cam.End3D()
end
end
end)
Cool new 3D-Health-Box™ i made ;3
[IMG]http://images.akamai.steamuserconten*****m/ugc/433820153444586282/CDBFBA52AA5678B302DD7FA27367E21937B694DA/[/IMG]