Beispiel #1
0
 private Color getReflectionColor(Thing thing, Vector pos, Vector normal, Vector rd, Scene scene, double depth) 
 {
     return Color.scale(thing.surface.reflect(pos), this.traceRay(new Ray (pos, rd), scene, depth + 1));
 }
Beispiel #2
0
 public static Vector plus(Vector v1, Vector v2) 
 {
     return new Vector(v1.x + v2.x, v1.y + v2.y, v1.z + v2.z);
 }
Beispiel #3
0
 public static double dot(Vector v1, Vector v2) 
 {
     return v1.x * v2.x + v1.y * v2.y + v1.z * v2.z;
 }
Beispiel #4
0
 public Plane(Vector norm, double offset, Surface surface) 
 {
     this.norm = norm;
     this.offset = offset;
     this.surface = surface;
 }
Beispiel #5
0
 public static Vector minus(Vector v1, Vector v2) 
 {
     return new Vector(v1.x - v2.x, v1.y - v2.y, v1.z - v2.z);
 }
Beispiel #6
0
 public static Vector norm(Vector v) 
 {
     var mag = Vector.mag(v);
     var div = (mag == 0) ? double.PositiveInfinity : 1.0 / mag;
     return Vector.times(div, v);
 }
Beispiel #7
0
 public Ray(Vector start, Vector dir)
 {
     this.start = start;
     this.dir = dir;
 }
Beispiel #8
0
 public Sphere(Vector center, double radius, Surface surface) 
 {
     this.center = center;
     this.radius2 = radius * radius;
     this.surface = surface;
 }
Beispiel #9
0
 public override Vector normal(Vector pos) 
 {
     return Vector.norm(Vector.minus(pos, this.center));
 }
Beispiel #10
0
 abstract public Vector normal(Vector pos);
Beispiel #11
0
 public Light(Vector pos, Color color)
 {
     this.pos = pos;
     this.color = color;
 }
Beispiel #12
0
 abstract public double reflect(Vector pos);
Beispiel #13
0
 abstract public Color specular(Vector pos);
Beispiel #14
0
 abstract public Color diffuse(Vector pos);
Beispiel #15
0
 private Color getNaturalColor(Thing thing, Vector pos, Vector norm, Vector rd, Scene scene) 
 {
     this.thing = thing;
     this.pos = pos;
     this.norm = norm;
     this.rd = rd;
     this.scene = scene;
     return Reduce(scene.lights, Color.defaultColor);
 }
Beispiel #16
0
 public static Vector times(double k, Vector v) 
 {
     return new Vector(k * v.x, k * v.y, k * v.z);
 }
Beispiel #17
0
 public static double mag(Vector v) 
 {
     return Math.Sqrt(v.x * v.x + v.y * v.y + v.z * v.z);
 }
Beispiel #18
0
 public override Vector normal(Vector pos)
 {
     return norm;
 }
Beispiel #19
0
 public static Vector cross(Vector v1, Vector v2) 
 {
     return new Vector(v1.y * v2.z - v1.z * v2.y,
                   v1.z * v2.x - v1.x * v2.z,
                   v1.x * v2.y - v1.y * v2.x);
 }
Beispiel #20
0
 public Camera (Vector pos, Vector lookAt) 
 {
     this.pos = pos;
     var down = new Vector(0.0, -1.0, 0.0);
     this.forward = Vector.norm(Vector.minus(lookAt, pos));
     this.right = Vector.times(1.5, Vector.norm(Vector.cross(this.forward, down)));
     this.up = Vector.times(1.5, Vector.norm(Vector.cross(this.forward, this.right)));
 }