Predefined Polygons
5 posts • Page 1 of 1
Predefined Polygons
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?
I am currently only using Phun 5.28 and not Algodoo. I would annoy the people on the Phun Forum and not here, but the Forum refused new registrations when I looked the last time.
- Papriko
- Posts: 29
- Joined: Tue Nov 17, 2009 8:43 pm
Re: Predefined Polygons
- Code: Select all
Scene.addPolygon({vecs := [[x, y], [x, y], ...]})
Each point on a polygon is a point on the Cartesian Coordinate graph.
-
standardtoaster - Posts: 606
- Joined: Mon Aug 31, 2009 7:57 pm
Re: Predefined Polygons
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
- gradyfitz
- Posts: 174
- Joined: Tue Sep 01, 2009 8:33 am
- Location: Victoria, Australia
Re: Predefined Polygons
It actually doesn't matter whether or not you use vecs or surfaces. I've always preferred vecs.
-
standardtoaster - Posts: 606
- Joined: Mon Aug 31, 2009 7:57 pm
Re: Predefined Polygons
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!
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!
I am currently only using Phun 5.28 and not Algodoo. I would annoy the people on the Phun Forum and not here, but the Forum refused new registrations when I looked the last time.
- Papriko
- Posts: 29
- Joined: Tue Nov 17, 2009 8:43 pm
5 posts • Page 1 of 1
Who is online
Users browsing this forum: No registered users and 10 guests