Ejemplo n.º 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));
 }
Ejemplo n.º 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);
 }
Ejemplo n.º 3
0
 public static double dot(Vector v1, Vector v2) 
 {
     return v1.x * v2.x + v1.y * v2.y + v1.z * v2.z;
 }
Ejemplo n.º 4
0
 public Plane(Vector norm, double offset, Surface surface) 
 {
     this.norm = norm;
     this.offset = offset;
     this.surface = surface;
 }
Ejemplo n.º 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);
 }
Ejemplo n.º 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);
 }
Ejemplo n.º 7
0
 public Ray(Vector start, Vector dir)
 {
     this.start = start;
     this.dir = dir;
 }
Ejemplo n.º 8
0
 public Sphere(Vector center, double radius, Surface surface) 
 {
     this.center = center;
     this.radius2 = radius * radius;
     this.surface = surface;
 }
Ejemplo n.º 9
0
 public override Vector normal(Vector pos) 
 {
     return Vector.norm(Vector.minus(pos, this.center));
 }
Ejemplo n.º 10
0
 abstract public Vector normal(Vector pos);
Ejemplo n.º 11
0
 public Light(Vector pos, Color color)
 {
     this.pos = pos;
     this.color = color;
 }
Ejemplo n.º 12
0
 abstract public double reflect(Vector pos);
Ejemplo n.º 13
0
 abstract public Color specular(Vector pos);
Ejemplo n.º 14
0
 abstract public Color diffuse(Vector pos);
Ejemplo n.º 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);
 }
Ejemplo n.º 16
0
 public static Vector times(double k, Vector v) 
 {
     return new Vector(k * v.x, k * v.y, k * v.z);
 }
Ejemplo n.º 17
0
 public static double mag(Vector v) 
 {
     return Math.Sqrt(v.x * v.x + v.y * v.y + v.z * v.z);
 }
Ejemplo n.º 18
0
 public override Vector normal(Vector pos)
 {
     return norm;
 }
Ejemplo n.º 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);
 }
Ejemplo n.º 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)));
 }