| 91 | return group; |
| 92 | } |
| 93 | void run(int n, int level, int ss) { |
| 94 | Scene scene = create(level, new Vec(0, -1, 0), 1); |
| 95 | System.out.print("P5\n"+n+" "+n+"\n255\n"); |
| 96 | for (int y=n-1; y>=0; --y) |
| 97 | for (int x=0; x<n; ++x) { |
| 98 | double g=0; |
| 99 | for (int dx=0; dx<ss; ++dx) |
| 100 | for (int dy=0; dy<ss; ++dy) { |
| 101 | Vec d = new Vec(x+dx*1./ss-n/2., y+dy*1./ss-n/2., n); |
| 102 | Ray ray = new Ray(new Vec(0, 0, -4), unitise(d)); |
| 103 | g += ray_trace(unitise(new Vec(-1, -3, 2)), |
| 104 | ray, scene); |
| 105 | } |
| 106 | System.out.print((char)(.5+255*g/(ss*ss))); |
| 107 | } |
| 108 | } |
| 109 | public static void main(String[] args) { |
| 110 | (new raytracer()).run(Integer.parseInt(args[0]), 6, 4); |
| 111 | } |