Log the camera before rendering
Implement an operator<< for Cameras. Log the scene's camera.
This commit is contained in:
parent
bcf93bb4ce
commit
f99608085e
4 changed files with 62 additions and 0 deletions
|
@ -123,6 +123,14 @@ Camera::LookAt(const Vector3& pt)
|
||||||
mUp *= upLength;
|
mUp *= upLength;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
Camera::WriteType(std::ostream& ost)
|
||||||
|
const
|
||||||
|
{
|
||||||
|
ost << "UNKNOWN";
|
||||||
|
}
|
||||||
|
|
||||||
#pragma mark - Perspective Camera
|
#pragma mark - Perspective Camera
|
||||||
|
|
||||||
PerspectiveCamera::PerspectiveCamera()
|
PerspectiveCamera::PerspectiveCamera()
|
||||||
|
@ -155,6 +163,14 @@ PerspectiveCamera::compute_primary_ray(const int x,
|
||||||
return Ray(GetOrigin(), direction.normalize());
|
return Ray(GetOrigin(), direction.normalize());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
PerspectiveCamera::WriteType(std::ostream& ost)
|
||||||
|
const
|
||||||
|
{
|
||||||
|
ost << "perspective";
|
||||||
|
}
|
||||||
|
|
||||||
#pragma mark - Orthographic Camera
|
#pragma mark - Orthographic Camera
|
||||||
|
|
||||||
OrthographicCamera::OrthographicCamera()
|
OrthographicCamera::OrthographicCamera()
|
||||||
|
@ -195,3 +211,26 @@ OrthographicCamera::compute_primary_ray(const int x,
|
||||||
y0, GetUp());
|
y0, GetUp());
|
||||||
return Ray(origin, get_direction());
|
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;
|
||||||
|
}
|
||||||
|
|
12
src/camera.h
12
src/camera.h
|
@ -66,6 +66,10 @@ private:
|
||||||
* this and mRight determine the aspect ratio of the image.
|
* this and mRight determine the aspect ratio of the image.
|
||||||
*/
|
*/
|
||||||
Vector3 mUp;
|
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,
|
Ray compute_primary_ray(const int x, const int width,
|
||||||
const int y, const int height) const;
|
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,
|
Ray compute_primary_ray(const int x, const int width,
|
||||||
const int y, const int height) const;
|
const int y, const int height) const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
void WriteType(std::ostream& ost) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
std::ostream& operator<<(std::ostream& ost, const Camera& camera);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
10
src/scene.cc
10
src/scene.cc
|
@ -150,7 +150,9 @@ Scene::render()
|
||||||
{
|
{
|
||||||
LOG_INFO << "Rendering scene with " << shapes.size() << " objects.";
|
LOG_INFO << "Rendering scene with " << shapes.size() << " objects.";
|
||||||
printf("Rendering scene with %lu objects.\n", shapes.size());
|
printf("Rendering scene with %lu objects.\n", shapes.size());
|
||||||
|
|
||||||
LogObjects();
|
LogObjects();
|
||||||
|
LogCamera();
|
||||||
|
|
||||||
std::chrono::time_point<std::chrono::system_clock> start, end;
|
std::chrono::time_point<std::chrono::system_clock> start, end;
|
||||||
start = std::chrono::system_clock::now();
|
start = std::chrono::system_clock::now();
|
||||||
|
@ -330,6 +332,14 @@ Scene::trace_ray(const Ray &ray,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
Scene::LogCamera()
|
||||||
|
const
|
||||||
|
{
|
||||||
|
LOG_DEBUG << *mCamera;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
Scene::LogObjects()
|
Scene::LogObjects()
|
||||||
const
|
const
|
||||||
|
|
|
@ -53,6 +53,7 @@ public:
|
||||||
private:
|
private:
|
||||||
Color trace_ray(const Ray &ray, const int depth = 0, const float weight = 1.0);
|
Color trace_ray(const Ray &ray, const int depth = 0, const float weight = 1.0);
|
||||||
|
|
||||||
|
void LogCamera() const;
|
||||||
void LogObjects() const;
|
void LogObjects() const;
|
||||||
|
|
||||||
// Pixel dimensions of the image.
|
// Pixel dimensions of the image.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue