1. Post #1
    Gold Member
    JeffDOA's Avatar
    July 2011
    120 Posts
    How can I make rounded or circular HUD box's?

  2. Post #2
    "The superior man understands what is right; the inferior man understands what will sell"
    Chessnut's Avatar
    August 2011
    3,488 Posts

  3. Post #3
    Gold Member
    JeffDOA's Avatar
    July 2011
    120 Posts
    I know how to draw HUD, i specifically want to know how to create a box that bends, curves, or is circular.
    Reply With Quote Edit / Delete Reply Windows XP United States Show Events Dumb Dumb x 3Informative Informative x 1 (list)

  4. Post #4
    Always the vGuy.
    vercas's Avatar
    September 2011
    841 Posts
    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?
    Reply With Quote Edit / Delete Reply Windows 7 Romania Show Events Funny Funny x 2Disagree Disagree x 1 (list)

  5. Post #5
    R@Rdeathmatch's Avatar
    November 2010
    859 Posts
    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
    Reply With Quote Edit / Delete Reply Windows XP Romania Show Events Dumb Dumb x 3 (list)

  6. Post #6
    Always the vGuy.
    vercas's Avatar
    September 2011
    841 Posts
    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.

  7. Post #7
    Bel Irkalli's Avatar
    January 2012
    167 Posts
    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.

  8. Post #8
    Always the vGuy.
    vercas's Avatar
    September 2011
    841 Posts
    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.

  9. Post #9
    Bel Irkalli's Avatar
    January 2012
    167 Posts
    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.

  10. Post #10
    Gold Member
    JeffDOA's Avatar
    July 2011
    120 Posts
    So do you want to bend shapes like this?
    Yea something like that, explain your solution pls

  11. Post #11
    Dragon Dildoes
    Dennab
    April 2009
    4,432 Posts
    You cannot use polygons to draw konkav objects.

    What you all are talking about doesn't work.
    Reply With Quote Edit / Delete Reply Windows 7 Germany Show Events Funny Funny x 1Dumb Dumb x 1 (list)

  12. Post #12
    wizardsbane's Avatar
    January 2008
    372 Posts
    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)
    
    Reply With Quote Edit / Delete Reply Windows Vista United States Show Events Winner Winner x 3Disagree Disagree x 1 (list)

  13. Post #13
    Dragon Dildoes
    Dennab
    April 2009
    4,432 Posts
    I always got pretty fucked up rendering errors when doing konvex polys, also:

    Wiki said something else.

    The polygon MUST be convex for it to work properly.
    Have to use a mirrored reference since garry took down the wiki.

    http://maurits.tv/data/garrysmod/wik...rface.DrawPoly

    Maybe valve changed something.
    Reply With Quote Edit / Delete Reply Windows 7 Germany Show Events Disagree Disagree x 1 (list)

  14. Post #14
    wizardsbane's Avatar
    January 2008
    372 Posts
    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

  15. Post #15
    Dragon Dildoes
    Dennab
    April 2009
    4,432 Posts
    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.

  16. Post #16
    wizardsbane's Avatar
    January 2008
    372 Posts
    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?

  17. Post #17
    Dragon Dildoes
    Dennab
    April 2009
    4,432 Posts
    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.

  18. Post #18
    Bel Irkalli's Avatar
    January 2012
    167 Posts
    The poly just went plain invisible once it got konvex.
    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?
    Reply With Quote Edit / Delete Reply Windows Vista United States Show Events Dumb Dumb x 4 (list)

  19. Post #19
    wizardsbane's Avatar
    January 2008
    372 Posts
    The limit just clamps not makes it invisible, and it the attempt of making more then half of a circle.
    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.

  20. Post #20
    Dragon Dildoes
    Dennab
    April 2009
    4,432 Posts
    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.

  21. Post #21
    wizardsbane's Avatar
    January 2008
    372 Posts
    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.

  22. Post #22
    VENEZOLANO
    Big Bang's Avatar
    August 2006
    3,413 Posts
    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
    Reply With Quote Edit / Delete Reply Windows 7 Venezuela Show Events Winner Winner x 1Useful Useful x 1 (list)

  23. Post #23
    Always the vGuy.
    vercas's Avatar
    September 2011
    841 Posts
    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

  24. Post #24
    wizardsbane's Avatar
    January 2008
    372 Posts
    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

    A circle is the set of points in a plane that are equidistant from a given point . The distance from the center is called the radius, and the point is called the center
    We're wrong on one point, though, a circle is a composition of infinite points, not infinite line segments.