Package jray.common

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


        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

        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

TOP

Related Classes of jray.common.Ray

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.