Examples of Ray3D


Examples of toxi.geom.Ray3D

    mouseRayPos.y -= (GLOBAL.windowHeight / 2);
    mouseRayPos.scaleSelf((float) (1 / GLOBAL.getZOOM()));

    mouseRayPos.addSelf(focusCentre);

    Ray3D ray;

    Vec3D mousePos = null;
    Vec3D intersect;
    mouseRayDir = new Vec3D(0, 0, -1);

    plane.z = 0;
    //we need to rotate the plane so that it matches the one on the draw view
    plane.normal.rotateY(GLOBAL.rotateModelsY);
    plane.normal.rotateX(GLOBAL.rotateModelsX);

    plane.addSelf(plane.normal.scale(planeIn.z));
    //mouseRayDir.rotateY(GLOBAL.rotateModelsY);
    //mouseRayDir.rotateX(GLOBAL.rotateModelsX);

    mouseRayPos.subSelf(focusCentre);
    ray = new Ray3D(mouseRayPos, mouseRayDir); // this should be the world position of the mouse poiner on the 0,0,-1 plane

    intersect = plane.getIntersectionWithRay(ray);

    if (intersect == null) {
      ray = new Ray3D(mouseRayPos, mouseRayDir.invert());
      intersect = plane.getIntersectionWithRay(ray);
    }

    ray = new Ray3D(mouseRayPos, mouseRayDir);
    ray.addSelf(focusCentre);

    //if(this.mouseDown)
    //  GLOBAL.debugRay = ray;

    if (intersect != null) {
View Full Code Here

Examples of toxi.geom.Ray3D

    mouseRayDir.z = mouseRayDir.z - mouseRayPos.z;

    mouseRayDir.rotateX((GLOBAL.rotateModelsX));
    mouseRayDir.rotateY((GLOBAL.rotateModelsY));

    Ray3D ray = new Ray3D(mouseRayPos, mouseRayDir);

    Vec3D mousePos = null;

    if (GLOBAL.rotateModelsX == 0 && GLOBAL.rotateModelsY == 0
        && plane.normal.x == 0 && plane.normal.y == 0)
      mousePos = new Vec3D(ray.x, ray.y, ray.z);

    //put these back in for 3d
    //  if(mousePos == null) 
    //    mousePos = plane.getIntersectionWithRay(ray);

    if (mousePos == null) {

      mouseRayDir = new Vec3D(0, 0, 1);
      mouseRayDir.x = mouseRayDir.x - mouseRayPos.x;
      mouseRayDir.y = mouseRayDir.y - mouseRayPos.y;
      mouseRayDir.z = mouseRayDir.z - mouseRayPos.z;

      mouseRayDir.rotateX((GLOBAL.rotateModelsX));
      mouseRayDir.rotateY((GLOBAL.rotateModelsY));

      ray = new Ray3D(mouseRayPos, mouseRayDir);
      plane.normal.z *= -1;
      //put these back in for 3d
      //  mousePos = plane.getIntersectionWithRay(ray);
    }

View Full Code Here

Examples of toxi.geom.Ray3D

                  .getPlane().classifyPoint(p2b)) {

                Vec3D intersect = null;
                intersect = (Vec3D) slicePlane.getPlane()
                    .getIntersectionWithRay(
                        new Ray3D(p2b, p1b.sub(p2b)));
                if (intersect == null)
                  intersect = (Vec3D) slicePlane
                      .getPlane()
                      .getIntersectionWithRay(
                          new Ray3D(p1b, p2b.sub(p1b)));

                Vec2D intexsecX = new Vec2D(intersect.x,
                    intersect.y);

                if (intersect != null) {

                  intersect.subSelf(slicePlane.getPlane());

                  intersect
                      .rotateY((float) (functions.angleOf(new Vec2D(
                          slicePlane.getPlane().normal.x,
                          slicePlane.getPlane().normal.z)) - (Math.PI / 2)));

                  float rotateAn = (functions
                      .angleOf(new Vec2D(
                          slicePlane.getPlane().normal.x,
                          slicePlane.getPlane().normal.y)));

                  if (rotateAn < Math.PI / 2
                      || rotateAn > (Math.PI / 2) * 3)
                    rotateAn = (float) ((Math.PI * 2) - Math
                        .abs(rotateAn));

                  intersect.rotateX(rotateAn);

                  List<Vec2D> listItem = new ArrayList<Vec2D>();
                  listItem.add(new Vec2D(intersect.x,
                      intersect.y));
                  listItem.add(intexsecX);
                  returnList.add(listItem);
                  //t = 2;
                }
              }

            }

          } else {

            Vec3D intersect = null;
            intersect = (Vec3D) slicePlane.getPlane()
                .getIntersectionWithRay(
                    new Ray3D(p2, p1.sub(p2)));
            if (intersect == null)
              intersect = (Vec3D) slicePlane.getPlane()
                  .getIntersectionWithRay(
                      new Ray3D(p1, p2.sub(p1)));

            if (intersect != null) {
              Vec2D intexsecX = new Vec2D(intersect.x,
                  intersect.y);

View Full Code Here

Examples of toxi.geom.Ray3D

            Vec3D intersect = null;

            //try intersecting  ray in one direction
            intersect = (Vec3D) slicePlane.getPlane()
                .getIntersectionWithRay(
                    new Ray3D(p1, p2.sub(p1)));

            //if we do not find a point try the other direction
            if (intersect == null)
              intersect = (Vec3D) slicePlane.getPlane()
                  .getIntersectionWithRay(
                      new Ray3D(p2, p1.sub(p2)));

            //if we do not find a point try the other direction
            if (intersect == null)
              intersect = (Vec3D) slicePlane.getPlane()
                  .getIntersectionWithRay(
                      new Ray3D(p2.sub(p1.sub(p2)), p1
                          .sub(p2)));

            //if we do not find a point try the other direction
            if (intersect == null)
              intersect = (Vec3D) slicePlane.getPlane()
                  .getIntersectionWithRay(
                      new Ray3D(p2.add(p1.sub(p2)), p1
                          .sub(p2)));

            collisionsFound++;
            //we found a intersection with the plane
            if (intersect != null) {
View Full Code Here

Examples of toxi.geom.Ray3D

    protected Ray3D intersectRay;
    private float restitution = 1;

    public BoxConstraint(AABB box) {
        this.box = box.copy();
        this.intersectRay = new Ray3D(box, new Vec3D());
    }
View Full Code Here

Examples of toxi.geom.Ray3D

        assertEquals(Vec3D.Z_AXIS.getInverted(), box.getNormalForPoint(p));
    }

    public void testAABBRayIntersect() {
        AABB box = AABB.fromMinMax(new Vec3D(), new Vec3D(100, 100, 100));
        Ray3D r = new Ray3D(new Vec3D(50, 10, 10), new Vec3D(0, 1, 0));
        System.out.println(box.intersectsRay(r, -1000, 1000));
    }
View Full Code Here

Examples of toxi.geom.Ray3D

    }

    public void testReflectRay() {
        SphereIntersectorReflector si = new SphereIntersectorReflector(
                new Vec3D(0, 0, 0), 10);
        Ray3D r = si.reflectRay(new Ray3D(new Vec3D(100, 100, 0), new Vec3D(-1,
                -1, 0)));
        float absDiff = r.getDirection().angleBetween(new Vec3D(1, 1, 0), true);
        System.out.println(r + " diff: " + absDiff);
        assertEquals(absDiff < 0.002, true);
    }
View Full Code Here

Examples of toxi.geom.Ray3D

            int z2 = (int) MathUtils.min(zz + 1, depth - 1);
            Vec3D a = getVertexAtCell((int) xx, (int) zz);
            Vec3D b = getVertexAtCell(x2, (int) zz);
            Vec3D c = getVertexAtCell(x2, z2);
            Vec3D d = getVertexAtCell((int) xx, z2);
            Ray3D r = new Ray3D(new Vec3D(x, 10000, z), new Vec3D(0, -1, 0));
            TriangleIntersector i = new TriangleIntersector(new Triangle3D(a,
                    b, d));
            if (i.intersectsRay(r)) {
                isec = i.getIntersectionData();
            } else {
View Full Code Here

Examples of toxi.geom.Ray3D

    }

    public void setup() {
        size(400, 400);
        gfx = new ToxiclibsSupport(this);
        Ray3D r = new Ray3D(new Vec3D(), new Vec3D(1, 0, 0));
        Ray3D r2 = new Ray3D(new Vec3D(10, 10, 0), new Vec3D(1, -1, 0));
        Ray3DIntersector ri = new Ray3DIntersector(r);
        ri.intersectsRay(r2);
        println(ri.getIntersectionData());
    }
View Full Code Here

Examples of toxi.geom.Ray3D

        try {
            JAXBGeomTest test = new JAXBGeomTest();
            test.box = new AABB();
            test.plane = new Plane();
            test.quat = new Quaternion(0, Vec3D.X_AXIS);
            test.ray = new Ray3D();
            test.rect = new Rect(0, 0, 100, 200);
            test.sphere = new Sphere();
            test.tri = new Triangle3D(new Vec3D(), new Vec3D(), new Vec3D());
            List<Vec2D> points2d = new ArrayList<Vec2D>();
            points2d.add(new Vec2D());
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.