Team Spartan Cookies & Milk Forums
  • Issue Tracker
  • Donations
  • Search
  • Member List
  • Help

Register

Team Spartan Cookies & Milk Forums Garry's Mod Starfall v
« Previous 1 … 10 11 12 13 14 … 18 Next »
Polygon Help needed
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Threaded Mode
Polygon Help needed
08-12-2015, 06:21 PM, (This post was last modified: 08-12-2015, 06:23 PM by Destiny's Player.)
#1
Destiny's Player Offline
A passing by member
***
Posts: 237
Threads: 35
Joined: Dec 2013
Polygon Help needed
Basically, I need to somehow make a function which would automatically create a polygon and an outline of lines around it. Here's what I have so far.

function Draw(press,ptable,col,alpha)
local Polygon = render.createPoly(--something)
if press == 1 then
render.setColor(col[1]+20,col[2]+20,col[3]+20,alpha)
else
render.setColor(col[1],col[2],col[3],alpha)
end
render.drawPoly(Polygon)

render.setColor(255,255,255,alpha)
for i=1,#ptable do
--render.drawLine
end
--[[render.drawLine(p1x,p1y,p2x,p2y)
render.drawLine(p2x,p2y,p3x,p3y)
render.drawLine(p3x,p3y,p4x,p4y)
render.drawLine(p4x,p4y,p1x,p1y)]]
end

And I can't figure out, what to do to actually make it work. Mostly, I can't figure out how to make the polygon work... Can you even compose a polygon in multiple steps? ptable can be input in any way possible, right now I'm thinking about having tables within tables with both x and y in each slot.
Find
Reply
08-12-2015, 06:41 PM,
#2
Person8880 Offline
gpj.ecafllorT
*******
Posts: 2,407
Threads: 45
Joined: Sep 2013
RE: Polygon Help needed
Well first of all, render.createPoly is not something you need to or should be using. It's a leftover from old and bad code that was over paranoid with polygons.

All you need for a polygon is a table like this:
{
{ x = 0, y = 0, u = 0, v = 0 },
{ x = 10, y = 0, u = 1, v = 0 },
{ x = 10, y = 10, u = 1, v = 1 },
{ x = 0, y = 10, u = 0, v = 1 }
}

Compose it however you want. If you want lines to go around the outside, then you just have to connect the dots between your polygon vertices.
Find
Reply
08-12-2015, 07:16 PM,
#3
Destiny's Player Offline
A passing by member
***
Posts: 237
Threads: 35
Joined: Dec 2013
RE: Polygon Help needed
Thanks! I was not aware of that. It all works now, just finished replacing all of my previous mess with that lone function.
Find
Reply
« Next Oldest | Next Newest »


  • View a Printable Version
Forum Jump:


Users browsing this thread:
Contact UsTeam Spartan Cookies & MilkReturn to TopLite (Archive) ModeMark all forums readRSS Syndication

Powered By MyBB, © 2002-2026 MyBB Group.