|
@@ -158,6 +158,145 @@ private class TileLayerContent extends h3d.prim.Primitive {
|
|
|
if( y > yMax ) yMax = y;
|
|
|
}
|
|
|
|
|
|
+ public inline function fillArc( x : Float, y : Float, ray : Float, c : Int, start: Float, end: Float) {
|
|
|
+ if (end <= start) return;
|
|
|
+ var arcLength = end - start;
|
|
|
+ var nsegments = Math.ceil(ray * 3.14 * 2 / 4);
|
|
|
+ if ( nsegments < 4 ) nsegments = 4;
|
|
|
+ var angle = arcLength / nsegments;
|
|
|
+ var prevX = Math.NEGATIVE_INFINITY;
|
|
|
+ var prevY = Math.NEGATIVE_INFINITY;
|
|
|
+ var _x = 0.;
|
|
|
+ var _y = 0.;
|
|
|
+ var i = 0;
|
|
|
+ while ( i < nsegments ) {
|
|
|
+ var a = start + i * angle;
|
|
|
+ _x = x + Math.cos(a) * ray;
|
|
|
+ _y = y + Math.sin(a) * ray;
|
|
|
+ if (prevX != Math.NEGATIVE_INFINITY) {
|
|
|
+ addPoint(x, y, c);
|
|
|
+ addPoint(_x, _y, c);
|
|
|
+ addPoint(prevX, prevY, c);
|
|
|
+ addPoint(prevX, prevY, c);
|
|
|
+ }
|
|
|
+ prevX = _x;
|
|
|
+ prevY = _y;
|
|
|
+ i += 1;
|
|
|
+ }
|
|
|
+ var a = end;
|
|
|
+ _x = x + Math.cos(a) * ray;
|
|
|
+ _y = y + Math.sin(a) * ray;
|
|
|
+ addPoint(x, y, c);
|
|
|
+ addPoint(_x, _y, c);
|
|
|
+ addPoint(prevX, prevY, c);
|
|
|
+ addPoint(prevX, prevY, c);
|
|
|
+ }
|
|
|
+
|
|
|
+ public inline function fillCircle( x : Float, y : Float, radius : Float, c : Int) {
|
|
|
+ var nsegments = Math.ceil(radius * 3.14 * 2 / 2);
|
|
|
+ if( nsegments < 3 ) nsegments = 3;
|
|
|
+ var angle = Math.PI * 2 / nsegments;
|
|
|
+ var prevX = Math.NEGATIVE_INFINITY;
|
|
|
+ var prevY = Math.NEGATIVE_INFINITY;
|
|
|
+ var firstX = Math.NEGATIVE_INFINITY;
|
|
|
+ var firstY = Math.NEGATIVE_INFINITY;
|
|
|
+ var curX = 0., curY = 0.;
|
|
|
+ for( i in 0...nsegments) {
|
|
|
+ var a = i * angle;
|
|
|
+ curX = x + Math.cos(a) * radius;
|
|
|
+ curY = y + Math.sin(a) * radius;
|
|
|
+ if (prevX != Math.NEGATIVE_INFINITY) {
|
|
|
+ addPoint(x, y, c);
|
|
|
+ addPoint(curX, curY, c);
|
|
|
+ addPoint(prevX, prevY, c);
|
|
|
+ addPoint(x, y, c);
|
|
|
+ }
|
|
|
+ if (firstX == Math.NEGATIVE_INFINITY) {
|
|
|
+ firstX = curX;
|
|
|
+ firstY = curY;
|
|
|
+ }
|
|
|
+ prevX = curX;
|
|
|
+ prevY = curY;
|
|
|
+ }
|
|
|
+ addPoint(x, y, c);
|
|
|
+ addPoint(curX, curY, c);
|
|
|
+ addPoint(firstX, firstY, c);
|
|
|
+ addPoint(x, y, c);
|
|
|
+ }
|
|
|
+
|
|
|
+ public inline function circle( x : Float, y : Float, ray : Float, size: Float, c : Int) {
|
|
|
+ if (size > ray) return;
|
|
|
+ var nsegments = Math.ceil(ray * 3.14 * 2 / 2);
|
|
|
+ if ( nsegments < 3 ) nsegments = 3;
|
|
|
+ var ray1 = ray - size;
|
|
|
+ var angle = Math.PI * 2 / nsegments;
|
|
|
+ var prevX = Math.NEGATIVE_INFINITY;
|
|
|
+ var prevY = Math.NEGATIVE_INFINITY;
|
|
|
+ var prevX1 = Math.NEGATIVE_INFINITY;
|
|
|
+ var prevY1 = Math.NEGATIVE_INFINITY;
|
|
|
+ for( i in 0...nsegments ) {
|
|
|
+ var a = i * angle;
|
|
|
+ var _x = x + Math.cos(a) * ray;
|
|
|
+ var _y = y + Math.sin(a) * ray;
|
|
|
+ var _x1 = x + Math.cos(a) * ray1;
|
|
|
+ var _y1 = y + Math.sin(a) * ray1;
|
|
|
+ if (prevX != Math.NEGATIVE_INFINITY) {
|
|
|
+ addPoint(_x, _y, c);
|
|
|
+ addPoint(prevX, prevY, c);
|
|
|
+ addPoint(_x1, _y1, c);
|
|
|
+ addPoint(prevX1, prevY1, c);
|
|
|
+ }
|
|
|
+ prevX = _x;
|
|
|
+ prevY = _y;
|
|
|
+ prevX1 = _x1;
|
|
|
+ prevY1 = _y1;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public inline function arc( x : Float, y : Float, ray : Float, size: Float, start: Float, end: Float, c : Int) {
|
|
|
+ if (size > ray) return;
|
|
|
+ if (end <= start) return;
|
|
|
+ var arcLength = end - start;
|
|
|
+ var nsegments = Math.ceil(ray * 3.14 * 2 / 4);
|
|
|
+ if ( nsegments < 3 ) nsegments = 3;
|
|
|
+ var ray1 = ray - size;
|
|
|
+ var angle = arcLength / nsegments;
|
|
|
+ var prevX = Math.NEGATIVE_INFINITY;
|
|
|
+ var prevY = Math.NEGATIVE_INFINITY;
|
|
|
+ var prevX1 = Math.NEGATIVE_INFINITY;
|
|
|
+ var prevY1 = Math.NEGATIVE_INFINITY;
|
|
|
+ var _x = 0.;
|
|
|
+ var _y = 0.;
|
|
|
+ var _x1 = 0.;
|
|
|
+ var _y1 = 0.;
|
|
|
+ for( i in 0...nsegments ) {
|
|
|
+ var a = start + i * angle;
|
|
|
+ _x = x + Math.cos(a) * ray;
|
|
|
+ _y = y + Math.sin(a) * ray;
|
|
|
+ _x1 = x + Math.cos(a) * ray1;
|
|
|
+ _y1 = y + Math.sin(a) * ray1;
|
|
|
+ if (prevX != Math.NEGATIVE_INFINITY) {
|
|
|
+ addPoint(_x, _y, c);
|
|
|
+ addPoint(prevX, prevY, c);
|
|
|
+ addPoint(_x1, _y1, c);
|
|
|
+ addPoint(prevX1, prevY1, c);
|
|
|
+ }
|
|
|
+ prevX = _x;
|
|
|
+ prevY = _y;
|
|
|
+ prevX1 = _x1;
|
|
|
+ prevY1 = _y1;
|
|
|
+ }
|
|
|
+ var a = end;
|
|
|
+ _x = x + Math.cos(a) * ray;
|
|
|
+ _y = y + Math.sin(a) * ray;
|
|
|
+ _x1 = x + Math.cos(a) * ray1;
|
|
|
+ _y1 = y + Math.sin(a) * ray1;
|
|
|
+ addPoint(_x, _y, c);
|
|
|
+ addPoint(prevX, prevY, c);
|
|
|
+ addPoint(_x1, _y1, c);
|
|
|
+ addPoint(prevX1, prevY1, c);
|
|
|
+ }
|
|
|
+
|
|
|
override public function alloc(engine:h3d.Engine) {
|
|
|
if( tmp == null ) reset();
|
|
|
buffer = h3d.Buffer.ofFloats(tmp, 8, [Quads, RawFormat]);
|