00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #include "stdafx.h"
00027 #include "shape.h"
00028
00029
00030 Shape::~Shape() {
00031 }
00032
00033
00034 Shape::Shape(const Transform *o2w, const Transform *w2o, bool ro)
00035 : ObjectToWorld(o2w), WorldToObject(w2o), ReverseOrientation(ro),
00036 TransformSwapsHandedness(o2w->SwapsHandedness()),
00037 shapeId(nextshapeId++) {
00038
00039 PBRT_CREATED_SHAPE(this);
00040 }
00041
00042
00043 uint32_t Shape::nextshapeId = 1;
00044 BBox Shape::WorldBound() const {
00045 return (*ObjectToWorld)(ObjectBound());
00046 }
00047
00048
00049 bool Shape::CanIntersect() const {
00050 return true;
00051 }
00052
00053
00054 void Shape::Refine(vector<Reference<Shape> > &refined) const {
00055 Severe("Unimplemented Shape::Refine() method called");
00056 }
00057
00058
00059 bool Shape::Intersect(const Ray &ray, float *tHit, float *rayEpsilon,
00060 DifferentialGeometry *dg) const {
00061 Severe("Unimplemented Shape::Intersect() method called");
00062 return false;
00063 }
00064
00065
00066 bool Shape::IntersectP(const Ray &ray) const {
00067 Severe("Unimplemented Shape::IntersectP() method called");
00068 return false;
00069 }
00070
00071
00072 float Shape::Area() const {
00073 Severe("Unimplemented Shape::Area() method called");
00074 return 0.;
00075 }
00076
00077
00078 float Shape::Pdf(const Point &p, const Vector &wi) const {
00079
00080 DifferentialGeometry dgLight;
00081 Ray ray(p, wi, 1e-3f);
00082 ray.depth = -1;
00083 float thit, rayEpsilon;
00084 if (!Intersect(ray, &thit, &rayEpsilon, &dgLight)) return 0.;
00085
00086
00087 float pdf = DistanceSquared(p, ray(thit)) /
00088 (AbsDot(dgLight.nn, -wi) * Area());
00089 if (isinf(pdf)) pdf = 0.f;
00090 return pdf;
00091 }
00092
00093