How can I make rounded or circular HUD box's?
How can I make rounded or circular HUD box's?
I know how to draw HUD, i specifically want to know how to create a box that bends, curves, or is circular.
So do you want to bend shapes like this?
It was realy necesary to upload a image wich say " Bent this motherf*****! ??
And Another Romanian guy :D
Yes, it was necessary, because if that is what he really wants, I might be able to present him a solution.
I smell the involvement of complex math. I'll be watching, as I'm wondering how this would be possible too.
Also: Sup deathmatch.
Also can I possibly add to this? I'm wondering how to make angled boxes. Pretty sure it's unpossible, but you never know. I'd really like to draw my own stuff instead of using roundedbox. Roundedbox's corners are rasters and they pixelate if you make the corners too round.
For everything, there are polygons.
With some 6th grade math, you can get almost any shape into a polygon and scale it up.
Also, to bend things, I suspect that morphing could be used.
So you're saying I can draw polygons on the viewport? How? I'm pretty new to HUD scripting.
EDIT: Holy shit Surface.DrawPoly
With enough vertices, JeffDOA, I'm sure you could make curved objects like that. Or you could probably use some complex math to generate vertices along the desired curve FOR you. Work smart, not hard.
Yea something like that, explain your solution pls
You cannot use polygons to draw konkav objects.
What you all are talking about doesn't work.
http://mathworld.wolfram.com/ConcavePolygon.html
Do I win a prize?
-- Simple concave polygon vertices local concave = {} concave[1] = { x = (ScrW() / 2) - 200, y = (ScrH() / 2) } concave[2] = { x = (ScrW() / 2) + 200, y = (ScrH() / 2) } concave[3] = { x = (ScrW() / 2) + 200, y = (ScrH() / 2) - 150 } concave[4] = { x = (ScrW() / 2), y = (ScrH() / 2) - 100 } concave[5] = { x = (ScrW() / 2) - 200, y = (ScrH() / 2) - 150 } hook.Add("HUDPaint", "nope", function() surface.SetDrawColor(255, 0, 0, 255) surface.DrawPoly(concave) end)
I always got pretty fucked up rendering errors when doing konvex polys, also:
Wiki said something else.
Have to use a mirrored reference since garry took down the wiki.
http://maurits.tv/data/garrysmod/wik...rface.DrawPoly
Maybe valve changed something.
The wiki has been wrong/outdated before. I just clearly created a concave polygon successfully using surface.DrawPoly()
Edited:
What sorts of rendering errors? The only thing I think would be truly affected is textures being applied to the polygon
The poly just went plain invisible once it got konvex.
That is very peculiar. Are you sure it was below the 256 vertices limit? How complex was it? Do you still have the code?
The limit just clamps not makes it invisible, and it the attempt of making more then half of a circle.
My bet is that you're doing it wrong. Don't worry, you aren't alone. I have to ask you though, to make your shit invisible... Was zum Teufel machen sie?
This kind of shit happens every day, but apply it to GLua. Summary of Lua question forums, right?
A half-circle isn't a concave polygon (it's convex), and it only says the surface.DrawPoly() may not work properly with concave polygons. Your example should've worked. Not trying to be an ass, but I think you just did it wrong.
Edited:
Actually, I'm also retarded, because a circle, even a semi-circle, isn't a polygon.
I was talking about more than half a circle, as in 3/4 of a circle. which is convex-concav.
Also, Bel Irkalli, that was pretty dumb.
Nope, even then it's not a polygon (strictly-speaking). When created on a computer, you're right.
The circle creation really should have worked, concave or not. I guess I'll look into it. It could be that the concave that I drew was just a stroke of luck.
Here's the math I found from an old 3D VGUI thing
function surface.Easy3DRect(x,y,w,h) --ARGUMENTS --Arguments are the same than standard DrawRect, x y origins, width and height surface.Draw3DRect(x,y,w,h,16,1,nil,ScrH()/2 - 64) end function surface.Draw3DRect(x,y,w,h,uix,uiy,ow,oh) --ARGUMENTS --First 4 arguments are the same than standard DrawRect, x y origins, width and height --The next two argument seem to control the quality of the finished polygon, keep this under 30 preferibably. --The last two arguments define the point which the rectangle is oriented to --NOTE I DID NOT WRITE THIS, NIGHT EAGLE DID FOR HIS EP-HUD MOD ix = uix - 1 iy = uiy - 1 ixt = ix iyt = iy local dx = w/uix local dy = h/uiy for ix = 0,ix do for iy = 0,iy do surface.Draw3DPoly(x+ix*dx,y+iy*dy,dx,dy,ow,oh,ix/math.max(ixt,1),iy/math.max(iyt,1)) end end end function surface.Draw3DPoly(x,y,w,h,orx,ory,u1,v1,u2,v2) --NOTE I DID NOT WRITE THIS, NIGHT EAGLE DID FOR HIS EP-HUD MOD local ox = orx or ScrW()*.5 local oy = ory or ScrH()*.5 u1 = u1 or 0 u2 = u2 or 1 v1 = v1 or 0 v2 = v2 or 1 //surface.SetTexture(tex) //surface.SetDrawColor(0,0,255,150*hf.a) local points = { { x=x, y=y, u=u1, v=v1, }, { x=x+w, y=y, u=u2, v=v1, }, { x=x+w, y=y+h, u=u2, v=v2, }, { x=x, y=y+h, u=u1, v=v2, }, } for k,v in ipairs(points) do v.x = (v.x-ox) v.y = (v.y-oy) v.x = v.x*(1+math.sin(v.y/(ScrW()))^2) v.y = v.y*(1+math.sin(v.x/(ScrH()))^2) v.x = v.x+ox v.y = v.y+oy end surface.DrawPoly(points) end
I just wish to state that circles are, in fact, polygons with infinite sides.
A circle would be the least convex polygon, as it's almost concave.
A semicircle would be a big line, and 180 degrees of small, straight lines.
Anyway, for a slightly different way of bending shapes, look at this file in the gcf: lua/postprocess/morph.lua
Nope. I'm totally serious. Circles are not polygons in mathematics. They have infinite sides, which means that each side has a length of 0, which breaks the rules for polygon classification. Even if it has one straight line (semi-circle), the actual circle part still breaks the classification.
You are right when the circle is generated on a computer, as the way that's done in 2D graphics is the use of straight, defined sides.
Edited:
http://mathworld.wolfram.com/Circle.html
We're wrong on one point, though, a circle is a composition of infinite points, not infinite line segments.