I am trying to create a useful / general class of two-dimensional polygons for rendering OpenGL ES. When I create a polygon, I give it a few parameters:
Polygon(Vector3 centerpoint, int numVertices, float inPolySize)
Then I try to generate vertices. This is where I have a hard time. I need to determine the number of vertices, get the angle, find the x / y position of this angle, someone takes into account the size, And moves by position.
OpenGL works with large amounts of data. Nothing is more beautiful than Vector3's Lists. Instead, it floats [] arrays, with the first index being X1, the second being Y1, the third being Z1, the fourth being X2, etc.
final int XPOS = 0; final int YPOS = 1; final int ZPOS = 2; int mvSize = 3;
Sure, my triangle is never right. He distorted a lot, the size does not seem right ...
I suppose I throw the size into the wrong formula, can anyone help?
EDIT: Here are some examples of data Polygon test = new polygon (new vector3 (0, 1, 0), 3, .5f);
vertices [0] = -0.25
tops [1] = 1.4330127
peaks [2] = 0.0
vertices [3] = -0.25
peaks [4] = 0.5669873
peaks [5] = 0.0
peaks [6] = 0.5
tops [7] = 1.0
peaks [8] = 0.0
vertices [9] = -0.25
tops [10] = 1.4330127
peaks [11] = 0.0