Examples of Ray


Examples of it.marteEngine.test.zombieEscape.Ray

  public void update(GameContainer container, int delta) {
    radarCircle = new Circle(e.x + e.width / 2, e.y + e.height / 2, radar);

    Entity p = ME.world.find(Player.PLAYER);
    if (ray == null) {
      ray = new Ray(e, p);
    }

    if (ray != null) {
      Entity pl = ME.world.find(Player.PLAYER);
      ray.update(e, pl);
View Full Code Here

Examples of jpbrt.core.Ray

   
    @Override
    public Intersection intersect(Ray r)
    {
        Intersection result = new Intersection();
        Ray ray = worldToObject.transform(r);
       
        // compute quadratic sphere coefficients
        double a = ray.d.x*ray.d.x +ray.d.y*ray.d.y + ray.d.z*ray.d.z;
        double b = 2 * (ray.d.x*ray.o.x + ray.d.y*ray.o.y + ray.d.z* ray.o.z);
        double c = ray.o.x*ray.o.x + ray.o.y*ray.o.y + ray.o.z*ray.o.z - radius*radius;
       
        // solve quadratic equation for t values
        double[] t = Global.quadratic(a, b, c);
        if (t == null)
            return result;
       
        // compute intersection distance along ray
        if (t[0] > ray.maxt || t[1] < ray.mint)
            return result;
        double thit = t[0];
        if (t[0] < ray.mint)
        {
            thit = t[1];
            if (thit > ray.maxt)
                return result;
        }
       
        // compute sphere hit position and phi
        Point phit = ray.eval(thit);
        if (phit.x == 0.0 && phit.y == 0.0)
            phit.x = 1e-5 * radius;
        double phi = Math.atan2(phit.y, phit.x);
        if (phi < 0.0)
            phi += 2 * Math.PI;
       
        // test sphere intersection against clipping parameters
        if ( (zmin > -radius && phit.z < zmin) ||
             (zmax > radius && phit.z > zmax) || phi > phiMax )
        {
            if (thit == t[1] || t[1] > ray.maxt)
                return result;
            thit = t[1];
           
            // compute sphere hit position and phi
            phit = ray.eval(thit);
            if (phit.x == 0.0 && phit.y == 0.0)
                phit.x = 1e-5 * radius;
            phi = Math.atan2(phit.y, phit.x);
            if (phi < 0.0)
                phi += 2 * Math.PI;
 
View Full Code Here

Examples of jpbrt.core.Ray

   
    @Override
    public boolean intersectP(Ray r)
    {
        // transform ray to object space
        Ray ray = worldToObject.transform(r);
       
        // compute quadratic sphere coefficients
        double a = ray.d.x*ray.d.x +ray.d.y*ray.d.y + ray.d.z*ray.d.z;
        double b = 2 * (ray.d.x*ray.o.x + ray.d.y*ray.o.y + ray.d.z* ray.o.z);
        double c = ray.o.x*ray.o.x + ray.o.y*ray.o.y + ray.o.z*ray.o.z - radius*radius;
       
        // solve quadratic equation for t values
        double[] t = Global.quadratic(a, b, c);
        if (t == null)
            return false;
       
        // compute intersection distance along ray
        if (t[0] > ray.maxt || t[1] < ray.mint)
            return false;
        double thit = t[0];
        if (t[0] < ray.mint)
        {
            thit = t[1];
            if (thit > ray.maxt)
                return false;
        }
       
        // compute sphere hit position and phi
        Point phit = ray.eval(thit);
        if (phit.x == 0.0 && phit.y == 0.0)
            phit.x = 1e-5 * radius;
        double phi = Math.atan2(phit.y, phit.x);
        if (phi < 0.0)
            phi += 2 * Math.PI;
       
        // test sphere intersection against clipping parameters
        if ( (zmin > -radius && phit.z < zmin) ||
                (zmax > radius && phit.z > zmax) || phi > phiMax )
       {
           if (thit == t[1] || t[1] > ray.maxt)
               return false;
           thit = t[1];
          
           // compute sphere hit position and phi
           phit = ray.eval(thit);
           if (phit.x == 0.0 && phit.y == 0.0)
               phit.x = 1e-5 * radius;
           phi = Math.atan2(phit.y, phit.x);
           if (phi < 0.0)
               phi += 2 * Math.PI;
 
View Full Code Here

Examples of jray.common.Ray

  }

  @Override
  public double getHitPointDistance(Ray r) {
    double dist;
    Ray subRay;
    Vect3 tmp = new Vect3();
    Vect.add(position, model.getBoundingSphere().getPosition(), tmp);
   
    if(RaySphere.isRayOriginatingInSphere(r.getOrigin(), r.getDirection(), tmp, model.getBoundingSphere().getRadius())){
      Vect.subtract(r.getOrigin(), position, tmp);
      subRay = new Ray(tmp, r.getDirection());
     
      dist = 0;
    }else{
      dist=RaySphere.getHitPointRaySphereDistance(r.getOrigin(), r.getDirection(), tmp, model.getBoundingSphere().getRadius());
     
      if(Double.isInfinite(dist))
        return dist;
     
      Vect.addMultiple(r.getOrigin(), r.getDirection(), dist, tmp);
      Vect.subtract(tmp, position, tmp);
      subRay = new Ray(tmp, r.getDirection());
    }
   
    CollisionData d = new CollisionData();
    lastCollision.put(Thread.currentThread(), d);
    d.d = RayPath.getFirstCollision(model.getTree(), subRay);
    if(!Double.isInfinite(d.d.d)){
      Vect3 hitPointLocal = new Vect3();
      Vect.addMultiple(subRay.getOrigin(), subRay.getDirection(), d.d.d, hitPointLocal);
      d.hitPointLocal = hitPointLocal;
      Vect3 hitPointGlobal = new Vect3();
      Vect.add(hitPointLocal, position, hitPointGlobal);
      d.hitPointGlobal = hitPointGlobal;
      return d.d.d + dist;
View Full Code Here

Examples of jray.common.Ray

        BackwardRayTracer logic = getLogic();
        Vect3 rayDirection = new Vect3();
        Camera camera = scene.getCamera();

        Ray ray = new Ray(new Vect3(camera.getPosition()), rayDirection);

        Vect3 vertAdd = new Vect3(camera.getViewPaneHeightVector());
        Vect.scale(vertAdd, 1.0 / (heightPx - 1), vertAdd);
        Vect3 horzAdd = new Vect3(camera.getViewPaneWidthVector());
        Vect.scale(horzAdd, 1.0 / (widthPx - 1), horzAdd);

        for (int i = from; i < to; i++) {
            for (int j = 0; j < widthPx; j++) {
             
              Vect.subtract(camera.getViewPaneEdge(), ray.getOrigin(), rayDirection);
              Vect.addMultiple(rayDirection, vertAdd, i, rayDirection);
              Vect.addMultiple(rayDirection, horzAdd, j, rayDirection);
               
                rayDirection.normalize();
View Full Code Here

Examples of jray.common.Ray

        c.o.getNormalAt(hitPoint, normal);
       
        //Check if anything is blocking direct sunlight (go where the sunlight comes from)
        Vect3 lrDir = new Vect3();
        Vect.scale(LIGHT_DIRECTION, -1, lrDir);
        Ray lightRay = new Ray(hitPoint, lrDir);
        CollisionDetails lc = findNearestHit(lightRay);
       
        //if nothing blocks the sun's light, add ambient and diffuse light, otherwise ambient only 
        double lightScale = 0;
        if(lc.o==null)
View Full Code Here

Examples of org.kalimullin.fsraytracer.ray.Ray

    @Test
    public void testRayTraceHit() {
        // test data has only one object
        SceneObject pyramid = (SceneObject) scene.getSceneObjects().toArray()[0];
        HitData expectedHitData = new HitData(new HitPoint(new Point(-0.5, -0.5, 0), Math.sqrt(9 * 3)), pyramid);
        assertEquals(expectedHitData, scene.traceRay(new Ray(new Point(-3.5, -3.5, -3), new Point(1, 1, 1))));
    }
View Full Code Here

Examples of org.kalimullin.fsraytracer.ray.Ray

        assertEquals(expectedHitData, scene.traceRay(new Ray(new Point(-3.5, -3.5, -3), new Point(1, 1, 1))));
    }

    @Test
    public void testRayMiss() {
        assertEquals(HitData.MISS, scene.traceRay(new Ray(new Point(10,10,10), new Point(1,1,1))));
    }
View Full Code Here

Examples of org.kalimullin.fsraytracer.ray.Ray

        assertEquals(GeometryTestData.PYRAMID, pyramid);
    }

    @Test
    public void testHitPoints() {
        Ray xyRay = new Ray(new Point(3, 3, -5), new Point(0, 0, 2));
        assertEquals(new HitPoint(new Point(3,3,0), 5), GeometryTestData.PYRAMID.getHitPoint(xyRay));
        Ray yzRay = new Ray(new Point(-10, 3, 3), new Point(2, 0, 0));
        assertEquals(new HitPoint(new Point(0, 3, 3), 10), GeometryTestData.PYRAMID.getHitPoint(yzRay));
        Ray xzRay = new Ray(new Point(3, -5, 3), new Point(0, 2, 0));
        assertEquals(new HitPoint(new Point(3, 0, 3), 5), GeometryTestData.PYRAMID.getHitPoint(xzRay));
    }
View Full Code Here

Examples of org.kalimullin.fsraytracer.ray.Ray

        assertEquals(new HitPoint(new Point(3, 0, 3), 5), GeometryTestData.PYRAMID.getHitPoint(xzRay));
    }

    @Test
    public void testMiss() {
        Ray missRay = new Ray(new Point(20,20,20), new Point(1,1,1));
        assertEquals(HitPoint.MISSED, GeometryTestData.PYRAMID.getHitPoint(missRay));
    }
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.