equal
deleted
inserted
replaced
47 */ |
47 */ |
48 class Shape |
48 class Shape |
49 { |
49 { |
50 public: |
50 public: |
51 Material *material; |
51 Material *material; |
|
52 |
52 Shape() {}; |
53 Shape() {}; |
53 virtual ~Shape() {}; |
54 virtual ~Shape() {}; |
54 |
55 |
55 // first intersection point |
56 // first intersection point |
56 virtual bool intersect(const Ray &ray, Float &dist) const = 0; |
57 virtual bool intersect(const Ray &ray, Float &dist) const = 0; |
174 /** |
175 /** |
175 * triangle shape |
176 * triangle shape |
176 */ |
177 */ |
177 class Triangle: public Shape |
178 class Triangle: public Shape |
178 { |
179 { |
|
180 Vector N; |
179 #ifdef TRI_BARI_PRE |
181 #ifdef TRI_BARI_PRE |
180 Float nu, nv, nd; |
182 Float nu, nv, nd; |
181 int k; // dominant axis |
|
182 Float bnu, bnv; |
183 Float bnu, bnv; |
183 Float cnu, cnv; |
184 Float cnu, cnv; |
|
185 int k; // dominant axis |
184 #endif |
186 #endif |
185 #ifdef TRI_BARI |
187 #ifdef TRI_BARI |
186 int k; // dominant axis |
188 int k; // dominant axis |
187 #endif |
189 #endif |
188 #ifdef TRI_PLUCKER |
190 #ifdef TRI_PLUCKER |
189 Float pla[6], plb[6], plc[6]; |
191 Float pla[6], plb[6], plc[6]; |
190 #endif |
192 #endif |
191 Vector N; |
193 |
192 const Vector smooth_normal(const Vector &P) const |
194 const Vector smooth_normal(const Vector &P) const |
193 { |
195 { |
194 #ifdef TRI_BARI_PRE |
196 #ifdef TRI_BARI_PRE |
195 const Vector &NA = static_cast<NormalVertex*>(A)->N; |
197 const Vector &NA = static_cast<NormalVertex*>(A)->N; |
196 const Vector &NB = static_cast<NormalVertex*>(B)->N; |
198 const Vector &NB = static_cast<NormalVertex*>(B)->N; |
207 return n; |
209 return n; |
208 #else |
210 #else |
209 return N; // not implemented for other algorithms |
211 return N; // not implemented for other algorithms |
210 #endif |
212 #endif |
211 }; |
213 }; |
|
214 |
212 public: |
215 public: |
213 Vertex *A, *B, *C; |
216 Vertex *A, *B, *C; |
214 |
217 |
215 Triangle() {}; |
218 Triangle() {}; |
216 Triangle(Vertex *aA, Vertex *aB, Vertex *aC, Material *amaterial); |
219 Triangle(Vertex *aA, Vertex *aB, Vertex *aC, Material *amaterial); |