Good morning. I've been trying to find information on this for a pretty long time (A few hours... Yeah, not as long as it could be, but still). So, here's a question. How on earth do you use drawPoly? I know that you need to use render.createPoly({render.Vertex(x,y,u,v)...}), but... I can't understand what do the u and v parameters mean. And also, if they aren't important for basic use, then I can't get the poly to show up non-black, or even at all.
if CLIENT then
local function Hexagon(posx,posy,col)
local top = posy-30
local bot = posy+30
local tbleft = posx-20
local tbright = posx+20
local midleft = posx-35
local midright = posx+35
render.setColor(255,255,255,150)
local Test = render.createPoly({
render.vertex(top,tbleft),
render.vertex(top,tbright),
render.vertex(posy,midright),
render.vertex(bot,tbright),
render.vertex(bot,tbleft),
render.vertex(posy,midleft)
})
render.drawPoly(Test)
Yep, looking at it, it's definately clockwise. But still, it's interesting that it requires starting from bottom-right, and when I try top-left it doesn't work...
local function MakeHexagon( X, Y, W, H )
return {
render.vertex( X, Y - H * 0.5 ),
render.vertex( X + W * 0.5, Y - H * 0.25 ),
render.vertex( X + W * 0.5, Y + H * 0.25 ),
render.vertex( X, Y + H * 0.5 ),
render.vertex( X - W * 0.5, Y + H * 0.25 ),
render.vertex( X - W * 0.5, Y - H * 0.25 )
}
end
draws a hexagon happily in the centre of a screen. The vertices are in clockwise order starting from the top left (in this case, more top-centre, but the general rule is upper-leftmost), so it definitely does work.
I'm not 100% sure about top-left being an absolute requirement, but I do know that clockwise is. I go with what's always worked, and top-left clockwise has never failed me.
17-04-2015, 09:53 PM, (This post was last modified: 17-04-2015, 10:00 PM by Destiny's Player.)
Thanks for the help! On the first sleepy glance, your code is cleaner and has an easy to change scale feature. I'll look into it more tomorrow, but still, thanks a lot.
Also, a small question. What's the purpose of the second render hook in the second-to-last row?