• Curved HUD box's
    23 replies, posted
  • Avatar of Chessnut
  • [b][url=http://wiki.garrysmod.com/?title=Draw.RoundedBox]Draw.RoundedBox [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b] or [b][url=http://wiki.garrysmod.com/?title=Draw.RoundedBoxEx]Draw.RoundedBoxEx [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]
  • Avatar of JeffDOA
  • [QUOTE=Chessnut;34379892][b][url=http://wiki.garrysmod.com/?title=Draw.RoundedBox]Draw.RoundedBox [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b] or [b][url=http://wiki.garrysmod.com/?title=Draw.RoundedBoxEx]Draw.RoundedBoxEx [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b][/QUOTE] I know how to draw HUD, i specifically want to know how to create a box that bends, curves, or is circular.
  • Avatar of vercas
  • [QUOTE=JeffDOA;34384305]I know how to draw HUD, i specifically want to know how to create a box that bends, curves, or is circular.[/QUOTE] So do you want to bend shapes like this? [IMG]http://dl.dropbox.com/u/1217587/To%20Host/bent%20box.png[/IMG]
  • Avatar of R@Rdeathmatch
  • [QUOTE=vercas;34388131]So do you want to bend shapes like this? [IMG]http://dl.dropbox.com/u/1217587/To%20Host/bent%20box.png[/IMG][/QUOTE] It was realy necesary to upload a image wich say " Bent this motherf*****! ?? And Another Romanian guy :D
  • Avatar of vercas
  • [QUOTE=R@Rdeathmatch;34389146]It was realy necesary to upload a image wich say " Bent this motherf*****! ?? And Another Romanian guy :D[/QUOTE] Yes, it was necessary, because if that is what he really wants, I might be able to present him a solution.
  • Avatar of Bel Irkalli
  • 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.
  • Avatar of vercas
  • [QUOTE=Bel Irkalli;34393419]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.[/QUOTE] 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.
  • Avatar of Bel Irkalli
  • [QUOTE=vercas;34393509]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.[/QUOTE] So you're saying I can draw polygons on the viewport? How? I'm pretty new to HUD scripting. EDIT: Holy shit [b][url=http://wiki.garrysmod.com/?title=Surface.DrawPoly]Surface.DrawPoly [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b] 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.
  • Avatar of JeffDOA
  • [QUOTE=vercas;34388131]So do you want to bend shapes like this? [IMG]http://dl.dropbox.com/u/1217587/To%20Host/bent%20box.png[/IMG][/QUOTE] Yea something like that, explain your solution pls
  • Avatar of wizardsbane
  • [QUOTE=Wizard of Ass;34402868]You cannot use polygons to draw konkav objects. What you all are talking about doesn't work.[/QUOTE] [url]http://mathworld.wolfram.com/ConcavePolygon.html[/url] [IMG]http://cloud.steampowered.com/ugc/594708803549441540/9D2DB4BB54BFFD9EDA24F96FC31DF7530592BE75/[/IMG] Do I win a prize? [lua] -- 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) [/lua]
  • Avatar of Wizard of Ass
  • I always got pretty fucked up rendering errors when doing konvex polys, also: Wiki said something else. [quote] The polygon MUST be convex for it to work properly. [/quote] Have to use a mirrored reference since garry took down the wiki. [url]http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index4287.html?title=Surface.DrawPoly[/url] Maybe valve changed something.
  • Avatar of wizardsbane
  • [QUOTE=Wizard of Ass;34406210]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. [url]http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index4287.html?title=Surface.DrawPoly[/url] Maybe valve changed something.[/QUOTE] The wiki has been wrong/outdated before. I just clearly created a concave polygon successfully using surface.DrawPoly() [editline]hm, what?[/editline] What sorts of rendering errors? The only thing I think would be truly affected is textures being applied to the polygon
  • Avatar of Wizard of Ass
  • [QUOTE=wizardsbane;34406324]The wiki has been wrong/outdated before. I just clearly created a concave polygon successfully using surface.DrawPoly() [editline]hm, what?[/editline] What sorts of rendering errors? The only thing I think would be truly affected is textures being applied to the polygon[/QUOTE] The poly just went plain invisible once it got konvex.
  • Avatar of wizardsbane
  • [QUOTE=Wizard of Ass;34406697]The poly just went plain invisible once it got konvex.[/QUOTE] That is very peculiar. Are you sure it was below the 256 vertices limit? How complex was it? Do you still have the code?
  • Avatar of Wizard of Ass
  • [QUOTE=wizardsbane;34407137]That is very peculiar. Are you sure it was below the 256 vertices limit? How complex was it? Do you still have the code?[/QUOTE] The limit just clamps not makes it invisible, and it the attempt of making more then half of a circle.
  • Avatar of Bel Irkalli
  • [QUOTE=Wizard of Ass;34406697]The poly just went plain invisible once it got konvex.[/QUOTE] 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? [media]http://www.youtube.com/watch?v=08xQLGWTSag[/media]
  • Avatar of wizardsbane
  • [QUOTE=Wizard of Ass;34407251]The limit just clamps not makes it invisible, and it the attempt of making more then half of a circle.[/QUOTE] 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. [editline]aw shit[/editline] Actually, I'm also retarded, because a circle, even a semi-circle, isn't a polygon.
  • Avatar of Wizard of Ass
  • [QUOTE=wizardsbane;34407601]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. [editline]aw shit[/editline] Actually, I'm also retarded, because a circle, even a semi-circle, isn't a polygon.[/QUOTE] 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.
  • Avatar of wizardsbane
  • [QUOTE=Wizard of Ass;34407960]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.[/QUOTE] 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.
  • Avatar of fnox
  • Here's the math I found from an old 3D VGUI thing [lua] 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[/lua]
  • Avatar of vercas
  • 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: [I]lua/postprocess/morph.lua[/I]
  • Avatar of wizardsbane
  • [QUOTE=vercas;34413944]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: [I]lua/postprocess/morph.lua[/I][/QUOTE] 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. [editline]now[/editline] [url]http://mathworld.wolfram.com/Circle.html[/url] [quote] 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 [/quote] We're wrong on one point, though, a circle is a composition of infinite points, not infinite line segments.