Page 1 of 1

### Predefined Polygons Posted: Sat Dec 19, 2009 1:01 am
Just a very little and quick question: I want to create Polygons via scene.addPolygon with predefined size and shape. How do I put them correct into the { } brackets?

### Re: Predefined Polygons Posted: Sat Dec 19, 2009 1:51 am
Code: Select all
`Scene.addPolygon({vecs := [[x, y], [x, y], ...]})`

Each point on a polygon is a point on the Cartesian Coordinate graph.

### Re: Predefined Polygons Posted: Sat Dec 19, 2009 6:53 am
standardtoaster wrote:
Code: Select all
`Scene.addPolygon({vecs := [[x, y], [x, y], ...]})`

Each point on a polygon is a point on the Cartesian Coordinate graph.

Not quite,
Code: Select all
`Scene.addPolygon{surfaces := [[[x - Start surface one,y - Start surface one]~[x - End surface one, y - End surface one] ],[[x - Start surface two,y - Start surface two]~[x - End surface two, y - End surface two] ]]] }`

It can be thought of as: surfaces(surface)(point)(x or y co-ord). So surfaces(2)(1)(0) would give the x co-ordinate of the second point on the third surface, surfaces(2)(1) would give the [x,y] array of co-ordinates of the second point on the third surface, surfaces(2) would give the array of all the points (which each have arrays of co-ordinates) on the third surface, surfaces would give the array of all the surfaces in the polygon (which each have arrays of points (which each have arrays of co-ordinates)).

Vecs was for 4.22 (no self intersecting polygons), and water.

Hopefully this helps ### Re: Predefined Polygons Posted: Sat Dec 19, 2009 7:01 am
It actually doesn't matter whether or not you use vecs or surfaces. I've always preferred vecs.

### Re: Predefined Polygons Posted: Sat Dec 19, 2009 12:30 pm
I am quite lazy about writing and almost everything else too, so I first tried standardtoaster's suggestion. That worked great to me. I was really able to create a Triangle! Now I just have to find out how I can directly rotate things while creating, but I already know where I could look that up...

Thanks you both for the quick and good answers!