Package com.badlogic.gdx.utils

Examples of com.badlogic.gdx.utils.FloatArray


      offset = 0;
      sort(points, count);
    }

    // Lower hull.
    FloatArray hull = this.hull;
    hull.clear();
    for (int i = offset; i < end; i += 2) {
      float x = points[i];
      float y = points[i + 1];
      while (hull.size >= 4 && ccw(x, y) <= 0)
        hull.size -= 2;
      hull.add(x);
      hull.add(y);
    }

    // Upper hull.
    for (int i = end - 4, t = hull.size + 2; i >= offset; i -= 2) {
      float x = points[i];
      float y = points[i + 1];
      while (hull.size >= t && ccw(x, y) <= 0)
        hull.size -= 2;
      hull.add(x);
      hull.add(y);
    }

    return hull;
  }
View Full Code Here


    return hull;
  }

  /** Returns > 0 if the points are a counterclockwise turn, < 0 if clockwise, and 0 if colinear. */
  private float ccw (float p3x, float p3y) {
    FloatArray hull = this.hull;
    int size = hull.size;
    float p1x = hull.get(size - 4);
    float p1y = hull.get(size - 3);
    float p2x = hull.get(size - 2);
    float p2y = hull.peek();
    return (p2x - p1x) * (p3y - p1y) - (p2y - p1y) * (p3x - p1x);
  }
View Full Code Here

    endX = new float[rays];
    endY = new float[rays];
    startX = new float[rays];
    startY = new float[rays];
    this.chain = (chain != null) ?
           new FloatArray(chain) : new FloatArray();
   
    lightMesh = new Mesh(
        VertexDataType.VertexArray, false, vertexNum, 0,
        new VertexAttribute(Usage.Position, 2, "vertex_positions"),
        new VertexAttribute(Usage.ColorPacked, 4, "quad_colors"),
View Full Code Here

  /**
   * Draws a polygon, using ray start and end points as vertices
   */
  public void debugRender(ShapeRenderer shapeRenderer) {
    shapeRenderer.setColor(Color.YELLOW);
    FloatArray vertices = Pools.obtain(FloatArray.class);
    vertices.clear();
    for (int i = 0; i < rayNum; i++) {
      vertices.addAll(mx[i], my[i]);
    }
    for (int i = rayNum - 1; i > -1; i--) {
      vertices.addAll(startX[i], startY[i]);
    }
    shapeRenderer.polygon(vertices.shrink());
    Pools.free(vertices);
  }
View Full Code Here

  public boolean contains(float x, float y) {
    // fast fail
    if (!this.chainLightBounds.contains(x, y))
      return false;
    // actual check
    FloatArray vertices = Pools.obtain(FloatArray.class);
    vertices.clear();
   
    for (int i = 0; i < rayNum; i++) {
      vertices.addAll(mx[i], my[i]);
    }
    for (int i = rayNum - 1; i > -1; i--) {
      vertices.addAll(startX[i], startY[i]);
    }
   
    int intersects = 0;
    for (int i = 0; i < vertices.size; i += 2) {
      float x1 = vertices.items[i];
View Full Code Here

      if (time < frames[0]) return; // Time is before first frame.

      float[][] frameVertices = this.frameVertices;
      int vertexCount = frameVertices[0].length;

      FloatArray verticesArray = slot.getAttachmentVertices();
      if (verticesArray.size != vertexCount) alpha = 1; // Don't mix from uninitialized slot vertices.
      verticesArray.size = 0;
      verticesArray.ensureCapacity(vertexCount);
      verticesArray.size = vertexCount;
      float[] vertices = verticesArray.items;

      if (time >= frames[frames.length - 1]) { // Time is after last frame.
        float[] lastVertices = frameVertices[frames.length - 1];
View Full Code Here

      mesh.setPath(path);
      float[] uvs = readFloatArray(input, 1);
      short[] triangles = readShortArray(input);

      int vertexCount = input.readInt(true);
      FloatArray weights = new FloatArray(uvs.length * 3 * 3);
      IntArray bones = new IntArray(uvs.length * 3);
      for (int i = 0; i < vertexCount; i++) {
        int boneCount = (int)input.readFloat();
        bones.add(boneCount);
        for (int nn = i + boneCount * 4; i < nn; i += 4) {
          bones.add((int)input.readFloat());
          weights.add(input.readFloat() * scale);
          weights.add(input.readFloat() * scale);
          weights.add(input.readFloat());
        }
      }
      mesh.setBones(bones.toArray());
      mesh.setWeights(weights.toArray());
      mesh.setTriangles(triangles);
      mesh.setRegionUVs(uvs);
      mesh.updateUVs();
      Color.rgba8888ToColor(mesh.getColor(), input.readInt());
      mesh.setHullLength(input.readInt(true) * 2);
 
View Full Code Here

      Attachment attachment = slot.attachment;
      if (attachment instanceof BoundingBoxAttachment) {
        BoundingBoxAttachment boundingBox = (BoundingBoxAttachment)attachment;
        boundingBoxes.add(boundingBox);

        FloatArray polygon = polygonPool.obtain();
        polygons.add(polygon);
        int vertexCount = boundingBox.getVertices().length;
        polygon.ensureCapacity(vertexCount);
        polygon.size = vertexCount;

        boundingBox.computeWorldVertices(slot.bone, polygon.items);
      }
    }
View Full Code Here

  private void aabbCompute () {
    float minX = Integer.MAX_VALUE, minY = Integer.MAX_VALUE, maxX = Integer.MIN_VALUE, maxY = Integer.MIN_VALUE;
    Array<FloatArray> polygons = this.polygons;
    for (int i = 0, n = polygons.size; i < n; i++) {
      FloatArray polygon = polygons.get(i);
      float[] vertices = polygon.items;
      for (int ii = 0, nn = polygon.size; ii < nn; ii += 2) {
        float x = vertices[ii];
        float y = vertices[ii + 1];
        minX = Math.min(minX, x);
View Full Code Here

      SkinnedMeshAttachment mesh = attachmentLoader.newSkinnedMeshAttachment(skin, name, path);
      if (mesh == null) return null;
      mesh.setPath(path);
      float[] uvs = map.require("uvs").asFloatArray();
      float[] vertices = map.require("vertices").asFloatArray();
      FloatArray weights = new FloatArray(uvs.length * 3 * 3);
      IntArray bones = new IntArray(uvs.length * 3);
      for (int i = 0, n = vertices.length; i < n;) {
        int boneCount = (int)vertices[i++];
        bones.add(boneCount);
        for (int nn = i + boneCount * 4; i < nn;) {
          bones.add((int)vertices[i]);
          weights.add(vertices[i + 1] * scale);
          weights.add(vertices[i + 2] * scale);
          weights.add(vertices[i + 3]);
          i += 4;
        }
      }
      mesh.setBones(bones.toArray());
      mesh.setWeights(weights.toArray());
      mesh.setTriangles(map.require("triangles").asShortArray());
      mesh.setRegionUVs(uvs);
      mesh.updateUVs();

      String color = map.getString("color", null);
View Full Code Here

TOP

Related Classes of com.badlogic.gdx.utils.FloatArray

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.