Package jray.struct

Examples of jray.struct.CollisionDetails


        if (level == MAX_RECURSION_DEPTH) {
            return 0xFFFF00FF00000000L;
        }

        //Find nearest Hit
        CollisionDetails c = findNearestHit(ray);

        //No hit
        if (c.o == null) {
            return 0xFFFF00FF00FF00FFL;
        }
View Full Code Here


        return IntColors.toLong(c.o.getColorAt(hitPoint));
    }

    protected CollisionDetails findNearestHit(Ray ray) {
      if(!USE_OCTREE || tree==null){
        CollisionDetails c = new CollisionDetails(ray);
       
          //Find nearest Hit
          for (Object3D objectCandidate : objects) {
              double distanceCandidate = objectCandidate.getHitPointDistance(ray);
              if (distanceCandidate > 0 && distanceCandidate < c.d) {
View Full Code Here

        if (level == MAX_RECURSION_DEPTH) {
            return 0xFFFF00FF00000000L;
        }

        //Find nearest Hit
        CollisionDetails c = findNearestHit(ray);

        //No hit
        if (c.o == null) {
            return 0xFFFF00FF00FF00FFL;
        }
       
        //Calculate hit position
        Vect3 hitPoint = new Vect3();
        Vect.addMultiple(ray.getOrigin(), ray.getDirection(), c.d, hitPoint);
       
        //Get color and normal at hitpoint
        long color = IntColors.toLong(c.o.getColorAt(hitPoint));
        Vect3 normal = new Vect3();
        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)
          lightScale = Vect.dotProduct(normal, LIGHT_DIRECTION);
View Full Code Here

TOP

Related Classes of jray.struct.CollisionDetails

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.