Package se.llbit.math

Examples of se.llbit.math.Triangle


    int c0 = (0xF & (data >> 16)) % 8;
    int c1 = (0xF & (data >> 20)) % 8;
    int c2 = (0xF & (data >> 24)) % 8;
    int c3 = (0xF & (data >> 28)) % 8;
    Triangle triangle = t012[c0][c1][c2];
    if (triangle.intersect(ray)) {
      ray.n.set(triangle.n);
      ray.n.scale(QuickMath.signum(-ray.d.dot(triangle.n)));
      ray.t = ray.tNear;
      hit = true;
    }
    triangle = t230[c2][c3][c0];
    if (triangle.intersect(ray)) {
      ray.n.set(triangle.n);
      ray.n.scale(QuickMath.signum(-ray.d.dot(triangle.n)));
      ray.t = ray.tNear;
      ray.u = 1-ray.u;
      ray.v = 1-ray.v;
      hit = true;
    }
    triangle = westt[c0][c3];
    if (triangle.intersect(ray)) {
      ray.n.set(triangle.n);
      ray.n.scale(QuickMath.signum(-ray.d.dot(triangle.n)));
      ray.t = ray.tNear;
      hit = true;
    }
    triangle = westb[c0];
    if (triangle.intersect(ray)) {
      ray.n.set(triangle.n);
      ray.n.scale(QuickMath.signum(-ray.d.dot(triangle.n)));
      ray.t = ray.tNear;
      ray.u = 1-ray.u;
      ray.v = 1-ray.v;
      hit = true;
    }
    triangle = eastt[c1][c2];
    if (triangle.intersect(ray)) {
      ray.n.set(triangle.n);
      ray.n.scale(QuickMath.signum(-ray.d.dot(triangle.n)));
      ray.t = ray.tNear;
      hit = true;
    }
    triangle = eastb[c1];
    if (triangle.intersect(ray)) {
      ray.n.set(triangle.n);
      ray.n.scale(QuickMath.signum(-ray.d.dot(triangle.n)));
      ray.t = ray.tNear;
      ray.u = 1-ray.u;
      ray.v = 1-ray.v;
      hit = true;
    }
    triangle = southt[c0][c1];
    if (triangle.intersect(ray)) {
      ray.n.set(triangle.n);
      ray.n.scale(QuickMath.signum(-ray.d.dot(triangle.n)));
      ray.t = ray.tNear;
      hit = true;
    }
    triangle = southb[c1];
    if (triangle.intersect(ray)) {
      ray.n.set(triangle.n);
      ray.n.scale(QuickMath.signum(-ray.d.dot(triangle.n)));
      ray.t = ray.tNear;
      ray.u = 1-ray.u;
      ray.v = 1-ray.v;
      hit = true;
    }
    triangle = northt[c2][c3];
    if (triangle.intersect(ray)) {
      ray.n.set(triangle.n);
      ray.n.scale(QuickMath.signum(-ray.d.dot(triangle.n)));
      ray.t = ray.tNear;
      hit = true;
    }
    triangle = northb[c2];
    if (triangle.intersect(ray)) {
      ray.n.set(triangle.n);
      ray.n.scale(QuickMath.signum(-ray.d.dot(triangle.n)));
      ray.t = ray.tNear;
      ray.u = 1-ray.u;
      ray.v = 1-ray.v;
View Full Code Here


    int c0 = (0xF & (data >> 16)) % 8;
    int c1 = (0xF & (data >> 20)) % 8;
    int c2 = (0xF & (data >> 24)) % 8;
    int c3 = (0xF & (data >> 28)) % 8;
    Triangle triangle = WaterModel.t012[c0][c1][c2];
    boolean hit = false;
    if (triangle.intersect(ray)) {
      ray.n.set(triangle.n);
      ray.n.scale(QuickMath.signum(-ray.d.dot(triangle.n)));
      ray.t = ray.tNear;
      hit = true;
    }
    triangle = WaterModel.t230[c2][c3][c0];
    if (triangle.intersect(ray)) {
      ray.n.set(triangle.n);
      ray.n.scale(QuickMath.signum(-ray.d.dot(triangle.n)));
      ray.t = ray.tNear;
      ray.u = 1-ray.u;
      ray.v = 1-ray.v;
      hit = true;
    }
    triangle = WaterModel.westt[c0][c3];
    if (triangle.intersect(ray)) {
      ray.n.set(triangle.n);
      ray.n.scale(QuickMath.signum(-ray.d.dot(triangle.n)));
      ray.t = ray.tNear;
      double y = ray.t * ray.d.y + ray.x.y;
      double z = ray.t * ray.d.z + ray.x.z;
      y -= QuickMath.floor(y);
      z -= QuickMath.floor(z);
      ray.u = z;
      ray.v = y;
      hit = true;
    }
    triangle = WaterModel.westb[c0];
    if (triangle.intersect(ray)) {
      ray.n.set(triangle.n);
      ray.n.scale(QuickMath.signum(-ray.d.dot(triangle.n)));
      ray.t = ray.tNear;
      double y = ray.t * ray.d.y + ray.x.y;
      double z = ray.t * ray.d.z + ray.x.z;
      y -= QuickMath.floor(y);
      z -= QuickMath.floor(z);
      ray.u = z;
      ray.v = y;
      hit = true;
    }
    triangle = WaterModel.eastt[c1][c2];
    if (triangle.intersect(ray)) {
      ray.n.set(triangle.n);
      ray.n.scale(QuickMath.signum(-ray.d.dot(triangle.n)));
      ray.t = ray.tNear;
      double y = ray.t * ray.d.y + ray.x.y;
      double z = ray.t * ray.d.z + ray.x.z;
      y -= QuickMath.floor(y);
      z -= QuickMath.floor(z);
      ray.u = z;
      ray.v = y;
      hit = true;
    }
    triangle = WaterModel.eastb[c1];
    if (triangle.intersect(ray)) {
      ray.n.set(triangle.n);
      ray.n.scale(QuickMath.signum(-ray.d.dot(triangle.n)));
      ray.t = ray.tNear;
      double y = ray.t * ray.d.y + ray.x.y;
      double z = ray.t * ray.d.z + ray.x.z;
      y -= QuickMath.floor(y);
      z -= QuickMath.floor(z);
      ray.u = z;
      ray.v = y;
      hit = true;
    }
    triangle = WaterModel.southt[c0][c1];
    if (triangle.intersect(ray)) {
      ray.n.set(triangle.n);
      ray.n.scale(QuickMath.signum(-ray.d.dot(triangle.n)));
      ray.t = ray.tNear;
      double x = ray.t * ray.d.x + ray.x.x;
      double y = ray.t * ray.d.y + ray.x.y;
      x -= QuickMath.floor(x);
      y -= QuickMath.floor(y);
      ray.u = x;
      ray.v = y;
      hit = true;
    }
    triangle = WaterModel.southb[c1];
    if (triangle.intersect(ray)) {
      ray.n.set(triangle.n);
      ray.n.scale(QuickMath.signum(-ray.d.dot(triangle.n)));
      ray.t = ray.tNear;
      double x = ray.t * ray.d.x + ray.x.x;
      double y = ray.t * ray.d.y + ray.x.y;
      x -= QuickMath.floor(x);
      y -= QuickMath.floor(y);
      ray.u = x;
      ray.v = y;
      hit = true;
    }
    triangle = WaterModel.northt[c2][c3];
    if (triangle.intersect(ray)) {
      ray.n.set(triangle.n);
      ray.n.scale(QuickMath.signum(-ray.d.dot(triangle.n)));
      ray.t = ray.tNear;
      double x = ray.t * ray.d.x + ray.x.x;
      double y = ray.t * ray.d.y + ray.x.y;
      x -= QuickMath.floor(x);
      y -= QuickMath.floor(y);
      ray.u = 1-x;
      ray.v = y;
      hit = true;
    }
    triangle = WaterModel.northb[c2];
    if (triangle.intersect(ray)) {
      ray.n.set(triangle.n);
      ray.n.scale(QuickMath.signum(-ray.d.dot(triangle.n)));
      ray.t = ray.tNear;
      double x = ray.t * ray.d.x + ray.x.x;
      double y = ray.t * ray.d.y + ray.x.y;
View Full Code Here

TOP

Related Classes of se.llbit.math.Triangle

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.