Java 类com.badlogic.gdx.math.Plane 实例源码

项目:nhglib    文件:LightGrid.java   
public LightGrid(int x, int y) {
    planePoints = new Vector3[8];
    for (int i = 0; i < 8; i++) {
        planePoints[i] = new Vector3();
    }
    sizex = x;
    sizey = y;
    verticalPlanes = new Plane[2][10];
    horizontalPlanes = new Plane[2][10];
    for (int i = 0; i < 10; i++) {
        for (int j = 0; j < 2; j++) {
            verticalPlanes[j][i] = new Plane(new Vector3(), 0);
            horizontalPlanes[j][i] = new Plane(new Vector3(), 0);
        }
    }
    nearBotLeft = new Vector3();
    nearBotRight = new Vector3();
    nearTopRight = new Vector3();
    nearTopLeft = new Vector3();
    farBotLeft = new Vector3();
    farBotRight = new Vector3();
    farTopRight = new Vector3();
    farTopLeft = new Vector3();
}
项目:ForgE    文件:FrustrumOctreeQuery.java   
@Override
public boolean checkObject(OctreeObject object) {
  object.getBoundingBox(tempBox);
  for (int i = 0, len2 = frustum.planes.length; i < len2; i++) {
    if (frustum.planes[i].testPoint(tempBox.getCorner000(tmpV)) != Plane.PlaneSide.Back) continue;
    if (frustum.planes[i].testPoint(tempBox.getCorner001(tmpV)) != Plane.PlaneSide.Back) continue;
    if (frustum.planes[i].testPoint(tempBox.getCorner010(tmpV)) != Plane.PlaneSide.Back) continue;
    if (frustum.planes[i].testPoint(tempBox.getCorner011(tmpV)) != Plane.PlaneSide.Back) continue;
    if (frustum.planes[i].testPoint(tempBox.getCorner100(tmpV)) != Plane.PlaneSide.Back) continue;
    if (frustum.planes[i].testPoint(tempBox.getCorner101(tmpV)) != Plane.PlaneSide.Back) continue;
    if (frustum.planes[i].testPoint(tempBox.getCorner110(tmpV)) != Plane.PlaneSide.Back) continue;
    if (frustum.planes[i].testPoint(tempBox.getCorner111(tmpV)) != Plane.PlaneSide.Back) continue;
    return false;
  }

  return true;
}
项目:gdx-cclibs    文件:PlaneSerializer.java   
@Override
public void write(Kryo kryo, Output output, Plane plane) {
    Vector3 normal = plane.normal;
    output.writeFloat(normal.x);
    output.writeFloat(normal.y);
    output.writeFloat(normal.z);
    output.writeFloat(plane.d);
}
项目:gdx-cclibs    文件:PlaneSerializer.java   
@Override
public Plane read(Kryo kryo, Input input, Class<Plane> type) {
    Plane plane = new Plane();
    Vector3 normal = plane.normal;
    normal.x = input.readFloat();
    normal.y = input.readFloat();
    normal.z = input.readFloat();
    plane.d = input.readFloat();
    return plane;
}
项目:ForgE    文件:DebugFrustrum.java   
public DebugFrustrum(Frustum copy, Matrix4 invProjectionView) {
  super();
  for (int i = 0; i < copy.planes.length; i++) {
    planes[i] = new Plane(copy.planes[i].getNormal(), copy.planes[i].getD());
  }

  for (int i = 0; i < copy.planePoints.length; i++) {
    planePoints[i] = new Vector3(copy.planePoints[i].x, copy.planePoints[i].y, copy.planePoints[i].z);
  }

  update(invProjectionView);
}
项目:gdx-toolbox    文件:IntersectionTester.java   
public static boolean test(Sphere sphere, Plane plane) {
    float distance = sphere.center.dot(plane.normal) - plane.d;
    if (Math.abs(distance) <= sphere.radius)
        return true;
    else
        return false;
}
项目:gdx-toolbox    文件:IntersectionTester.java   
public static boolean test(BoundingBox box, Plane plane) {
    tmp1.set(box.max).add(box.min).scl(0.5f);   // (box.max + box.min) / 2.0f
    tmp2.set(box.max).sub(tmp1);

    float radius = (tmp2.x * Math.abs(plane.normal.x)) +
                   (tmp2.y * Math.abs(plane.normal.y)) +
                   (tmp2.z * Math.abs(plane.normal.z));

    float distance = plane.normal.dot(tmp1) - plane.d;

    if (Math.abs(distance) <= radius)
        return true;
    else
        return false;
}
项目:gdx-toolbox    文件:IntersectionTester.java   
public static boolean test(Ray ray, Plane plane, Vector3 outIntersection) {
    float denominator = ray.direction.dot(plane.normal);
    if (denominator == 0.0f)
        return false;

    float t = ((-plane.d - ray.origin.dot(plane.normal)) / denominator);
    if (t < 0.0f)
        return false;

    if (outIntersection != null)
        ray.getEndPoint(outIntersection, t);

    return true;
}
项目:GdxDemo3D    文件:NavMeshPointPath.java   
public Plane.PlaneSide sideLeftPlane(Vector3 point) {
    return leftPlane.testPoint(point);
}
项目:GdxDemo3D    文件:NavMeshPointPath.java   
public Plane.PlaneSide sideRightPlane(Vector3 point) {
    return rightPlane.testPoint(point);
}
项目:GdxDemo3D    文件:NavMeshPointPath.java   
/**
 * Calculate the shortest point path through the path triangles, using the Simple Stupid Funnel Algorithm.
 *
 * @return
 */
private void calculateEdgePoints() {
    Edge edge = getEdge(0);
    addPoint(start, edge.fromNode);
    lastPointAdded.fromNode = edge.fromNode;

    Funnel funnel = new Funnel();
    funnel.pivot.set(start);
    funnel.setPlanes(funnel.pivot, edge);

    int leftIndex = 0;
    int rightIndex = 0;
    int lastRestart = 0;

    for (int i = 1; i < numEdges(); ++i) {
        edge = getEdge(i);

        Plane.PlaneSide leftPlaneLeftDP = funnel.sideLeftPlane(edge.leftVertex);
        Plane.PlaneSide leftPlaneRightDP = funnel.sideLeftPlane(edge.rightVertex);
        Plane.PlaneSide rightPlaneLeftDP = funnel.sideRightPlane(edge.leftVertex);
        Plane.PlaneSide rightPlaneRightDP = funnel.sideRightPlane(edge.rightVertex);

        if (rightPlaneRightDP != Plane.PlaneSide.Front) {
            if (leftPlaneRightDP != Plane.PlaneSide.Front) {
                // Tighten the funnel.
                funnel.setRightPlane(funnel.pivot, edge.rightVertex);
                rightIndex = i;
            } else {
                // Right over left, insert left to path and restart scan from portal left point.
                calculateEdgeCrossings(lastRestart, leftIndex, funnel.pivot, funnel.leftPortal);
                funnel.pivot.set(funnel.leftPortal);
                i = leftIndex;
                rightIndex = i;
                if (i < numEdges() - 1) {
                    lastRestart = i;
                    funnel.setPlanes(funnel.pivot, getEdge(i + 1));
                    continue;
                }
                break;
            }
        }
        if (leftPlaneLeftDP != Plane.PlaneSide.Front) {
            if (rightPlaneLeftDP != Plane.PlaneSide.Front) {
                // Tighten the funnel.
                funnel.setLeftPlane(funnel.pivot, edge.leftVertex);
                leftIndex = i;
            } else {
                // Left over right, insert right to path and restart scan from portal right point.
                calculateEdgeCrossings(lastRestart, rightIndex, funnel.pivot, funnel.rightPortal);
                funnel.pivot.set(funnel.rightPortal);
                i = rightIndex;
                leftIndex = i;
                if (i < numEdges() - 1) {
                    lastRestart = i;
                    funnel.setPlanes(funnel.pivot, getEdge(i + 1));
                    continue;
                }
                break;
            }
        }
    }
    calculateEdgeCrossings(lastRestart, numEdges() - 1, funnel.pivot, end);

    for (int i = 1; i < pathPoints.size; i++) {
        EdgePoint p = pathPoints.get(i);
        p.fromNode = pathPoints.get(i - 1).toNode;
    }
    return;
}
项目:gdx-vr    文件:Stage3D.java   
public Stage3D() {
    super();
    this.plane = new Plane(new Vector3(0, 0, 1), Vector3.Zero);
}
项目:gdx-vr    文件:Stage3D.java   
public Stage3D(Viewport viewport) {
    super(viewport);
    this.plane = new Plane(new Vector3(0, 0, 1), Vector3.Zero);
}
项目:gdx-vr    文件:Stage3D.java   
public Stage3D(Viewport viewport, SpriteBatch batch) {
    super(viewport, batch);
    this.plane = new Plane(new Vector3(0, 0, 1), Vector3.Zero);
}
项目:gdx-vr    文件:Stage3D.java   
public Stage3D(Plane plane, Viewport viewport, SpriteBatch batch) {
    super(viewport, batch);
    this.plane = plane;
}