Usages of

model.Ray.getDirection()

@Override public IntersectionContext trace(Ray ray) { double ox = ray.getOrigin().x; double oy = ray.getOrigin().y; double oz = ray.getOrigin().z; double dx = ray.getDirection().x; double dy = ray.getDirection().y; double dz = ray.getDirection().z; double tx_min, ty_min, tz_min; double tx_max, ty_max, tz_max; double a = 1.0f / dx; if(a >= 0){ tx_min = (x0 - ox) * a; tx_max = (x1 - ox) * a; }else{ tx_min = (x1 - ox) * a; tx_max = (x0 - ox) * a; } double b = 1.0f / dy; if(b >= 0){ ty_min = (y0 - oy) * b; ty_max = (y1 - oy) * b; }else{ ty_min = (y1 - oy) * b; ty_max = (y0 - oy) * b; } double c = 1.0f / dz; if(c >= 0){ tz_min = (z0 - oz) * c; tz_max = (z1 - oz) * c; }else{ tz_min = (z1 - oz) * c; tz_max = (z0 - oz) * c; } double t0, t1; int face_in, face_out; if(tx_min > ty_min){ t0 = tx_min; face_in = (a >= 0.0d ) ? 0 : 3 ; }else{ t0 = ty_min; face_in = (b >= 0.0d ) ? 1 : 4 ; } if( tz_min > t0){ t0 = tz_min; face_in = (c >= 0.0d ) ? 2 : 5 ; } if(tx_max < ty_max){ t1 = tx_max; face_out = (a >= 0.0d ) ? 3 : 0 ; }else{ t1 = ty_max; face_out = (b >= 0.0d ) ? 4 : 1 ; } if( tz_max < t1){ t1 = tz_max; face_out = (c >= 0.0d ) ? 5 : 2 ; } double tmin = 0.0d; Vector3d normal = null; if(t0 < t1 && t1 > EPS){ if(t0 > EPS){ tmin = t0; normal = getNormal(face_in); }else{ tmin = t1; normal = getNormal(face_out); } Vector3d dir = new Vector3d(ray.getDirection()); dir.scale(tmin); Point3d ori = new Point3d(ray.getOrigin()); ori.add(dir); Point3d localHitPoint = ori; Point2d uv = getUVCoordinates(localHitPoint); return new IntersectionContext(tmin,normal,ray,true,uv.x,uv.y); } return IntersectionContext.noHit(); }
Back to Search Results
Usage snippet has been bookmarked! Review your bookmarks
Thank you! Review your likes