From 368039b57c7382d15398447de4f39efa7d699717 Mon Sep 17 00:00:00 2001 From: vonhyou Date: Thu, 14 Mar 2024 18:47:29 -0400 Subject: [PATCH] reformat light --- src/Light.cc | 9 ++++----- src/Light.h | 14 +++++++------- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/src/Light.cc b/src/Light.cc index ba199b8..5a0de3f 100644 --- a/src/Light.cc +++ b/src/Light.cc @@ -12,9 +12,9 @@ void Light::setUseCenter(bool useCenter) { this->useCenter = useCenter; } void Light::setIsUse(bool isUse) { this->use = isUse; } -Vector3f Light::getDiffuse() const { return diffuse; } +Vector3f Light::id() const { return id_; } -Vector3f Light::getSpecular() const { return specular; } +Vector3f Light::is() const { return is_; } bool Light::isUse() const { return use; } @@ -32,13 +32,12 @@ Vector3f PointLight::illumination(const HitRecord &hit, Vector3f ambient_ = geometry->ka() * geometry->ca(); - Vector3f diffuse_ = geometry->kd() * geometry->cd().array() * - diffuse.array() * + Vector3f diffuse_ = geometry->kd() * geometry->cd().array() * id_.array() * std::max(0.0f, hit.normal().dot(rayDirection)); Vector3f halfWay = (hit.viewDirection() + rayDirection).normalized(); Vector3f specular_ = - geometry->ks() * geometry->cs().array() * specular.array() * + geometry->ks() * geometry->cs().array() * is_.array() * pow(std::max(0.0f, hit.normal().dot(halfWay)), geometry->phong()); return specular_ + ambient_ + diffuse_; diff --git a/src/Light.h b/src/Light.h index 60afbce..7f21867 100644 --- a/src/Light.h +++ b/src/Light.h @@ -21,11 +21,11 @@ public: protected: Light(Type type, const Vector3f &id, const Vector3f &is) - : type(type), diffuse(id), specular(is) {} + : type_(type), id_(id), is_(is) {} - Type type; - Vector3f diffuse; - Vector3f specular; + Type type_; + Vector3f id_; + Vector3f is_; Matrix4f transform = Matrix4f::Identity(); // optional member `transform` unsigned int gridSize = 0; // optional member `n` bool useCenter = false; // optional member `usecenter` @@ -36,8 +36,8 @@ public: void setGridSize(unsigned int); void setUseCenter(bool); void setIsUse(bool); - Vector3f getDiffuse() const; - Vector3f getSpecular() const; + Vector3f id() const; + Vector3f is() const; bool isUse() const; }; @@ -60,7 +60,7 @@ public: : Light(Type::Point, id, is), center(center) {} PointLight(const AreaLight &al, const Vector3f ¢er) - : PointLight(al.getDiffuse(), al.getSpecular(), center) {} + : PointLight(al.id(), al.is(), center) {} virtual Vector3f illumination(const HitRecord &, const vector &) const override;