Package toxi.geom

Examples of toxi.geom.Triangle3D


    public void testBarycentric() {
        Vec3D a = new Vec3D(-100, -100, 0);
        Vec3D c = new Vec3D(100, 0, 0);
        Vec3D b = new Vec3D(-100, 100, 0);
        Triangle3D t = new Triangle3D(a, b, c);
        assertTrue(a.equalsWithTolerance(t.fromBarycentric(t.toBarycentric(a)),
                0.01f));
        assertTrue(b.equalsWithTolerance(t.fromBarycentric(t.toBarycentric(b)),
                0.01f));
        assertTrue(c.equalsWithTolerance(t.fromBarycentric(t.toBarycentric(c)),
                0.01f));
    }
View Full Code Here


        ScaleMap wz = new ScaleMap(bmin.z, bmax.z, 1, volume.resZ - 2);
        ScaleMap gx = new ScaleMap(1, volume.resX - 2, bmin.x, bmax.x);
        ScaleMap gy = new ScaleMap(1, volume.resY - 2, bmin.y, bmax.y);
        ScaleMap gz = new ScaleMap(1, volume.resZ - 2, bmin.z, bmax.z);
        volume.setScale(box.getExtent().scale(2f));
        Triangle3D tri = new Triangle3D();
        AABB voxel = new AABB(new Vec3D(), volume.voxelSize.scale(0.5f));
        for (Face f : mesh.getFaces()) {
            tri.a = f.a;
            tri.b = f.b;
            tri.c = f.c;
            AABB bounds = tri.getBoundingBox();
            Vec3D min = bounds.getMin();
            Vec3D max = bounds.getMax();
            min = new Vec3D((int) wx.getClippedValueFor(min.x),
                    (int) wy.getClippedValueFor(min.y),
                    (int) wz.getClippedValueFor(min.z));
View Full Code Here

            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());
            points2d.add(new Vec2D());
            points2d.add(new Vec2D());
            points2d.add(new Vec2D());
View Full Code Here

        return vedges;
    }

    public Triangle3D getFaceAsTriangle(AttributedFace f) {
        Vec3D[] verts = getFaceVertices(f, null);
        return new Triangle3D(verts[0], verts[1], verts[2]);
    }
View Full Code Here

        }
    }

    public IsectData3D intersectsRay(Ray3D ray) {
        TriangleIntersector intersector = new TriangleIntersector();
        Triangle3D tri = intersector.getTriangle();
        Vec3D[] v = null;
        for (AttributedFace f : faces) {
            v = getFaceVertices(f, v);
            tri.set(v[0], v[1], v[2]);
            if (intersector.intersectsRay(ray)) {
                return intersector.getIntersectionData();
            }
        }
        return null;
View Full Code Here

TOP

Related Classes of toxi.geom.Triangle3D

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.