Log the camera before rendering

Implement an operator<< for Cameras. Log the scene's camera.
This commit is contained in:
Eryn Wells 2014-08-03 19:10:31 -07:00
parent bcf93bb4ce
commit f99608085e
4 changed files with 62 additions and 0 deletions

View file

@ -123,6 +123,14 @@ Camera::LookAt(const Vector3& pt)
mUp *= upLength;
}
void
Camera::WriteType(std::ostream& ost)
const
{
ost << "UNKNOWN";
}
#pragma mark - Perspective Camera
PerspectiveCamera::PerspectiveCamera()
@ -155,6 +163,14 @@ PerspectiveCamera::compute_primary_ray(const int x,
return Ray(GetOrigin(), direction.normalize());
}
void
PerspectiveCamera::WriteType(std::ostream& ost)
const
{
ost << "perspective";
}
#pragma mark - Orthographic Camera
OrthographicCamera::OrthographicCamera()
@ -195,3 +211,26 @@ OrthographicCamera::compute_primary_ray(const int x,
y0, GetUp());
return Ray(origin, get_direction());
}
void
OrthographicCamera::WriteType(std::ostream& ost)
const
{
ost << "orthographic";
}
std::ostream&
operator<<(std::ostream& ost,
const Camera& camera)
{
ost << "[Camera ";
camera.WriteType(ost);
ost << " origin=" << camera.mOrigin
<< " direction=" << camera.mDirection
<< " right=" << camera.mRight
<< " up=" << camera.mUp
<< "]";
return ost;
}

View file

@ -66,6 +66,10 @@ private:
* this and mRight determine the aspect ratio of the image.
*/
Vector3 mUp;
virtual void WriteType(std::ostream& ost) const;
friend std::ostream& operator<<(std::ostream& ost, const Camera& camera);
};
@ -78,6 +82,9 @@ public:
Ray compute_primary_ray(const int x, const int width,
const int y, const int height) const;
private:
void WriteType(std::ostream& ost) const;
};
@ -90,7 +97,12 @@ public:
Ray compute_primary_ray(const int x, const int width,
const int y, const int height) const;
private:
void WriteType(std::ostream& ost) const;
};
std::ostream& operator<<(std::ostream& ost, const Camera& camera);
#endif

View file

@ -150,7 +150,9 @@ Scene::render()
{
LOG_INFO << "Rendering scene with " << shapes.size() << " objects.";
printf("Rendering scene with %lu objects.\n", shapes.size());
LogObjects();
LogCamera();
std::chrono::time_point<std::chrono::system_clock> start, end;
start = std::chrono::system_clock::now();
@ -330,6 +332,14 @@ Scene::trace_ray(const Ray &ray,
}
void
Scene::LogCamera()
const
{
LOG_DEBUG << *mCamera;
}
void
Scene::LogObjects()
const

View file

@ -53,6 +53,7 @@ public:
private:
Color trace_ray(const Ray &ray, const int depth = 0, const float weight = 1.0);
void LogCamera() const;
void LogObjects() const;
// Pixel dimensions of the image.