From db072ad4dc181eca5a1458656b130beb43f475bf Mon Sep 17 00:00:00 2001 From: 53hornet <53hornet@gmail.com> Date: Sat, 2 Feb 2019 23:33:15 -0500 Subject: Init. --- hw5/include/reflectanceParameter.h | 106 +++++++++++++++++++++++++++++++++++++ 1 file changed, 106 insertions(+) create mode 100644 hw5/include/reflectanceParameter.h (limited to 'hw5/include/reflectanceParameter.h') diff --git a/hw5/include/reflectanceParameter.h b/hw5/include/reflectanceParameter.h new file mode 100644 index 0000000..c924653 --- /dev/null +++ b/hw5/include/reflectanceParameter.h @@ -0,0 +1,106 @@ +/******************************************************************/ +/* This file is part of the homework assignments for CSCI-427/527 */ +/* at The College of William & Mary and authored by Pieter Peers. */ +/* No part of this file, whether altered or in original form, can */ +/* be distributed or used outside the context of CSCI-427/527 */ +/* without consent of either the College of William & Mary or */ +/* Pieter Peers. */ +/******************************************************************/ +#ifndef _REFLECTANCEPARAMETER_H_ +#define _REFLECTANCEPARAMETER_H_ + +#include +#include + +#include "vec2d.h" +#include "vec3d.h" +#include "color.h" +#include "texture_base.h" + +class scalarReflectanceParameter { + public: + ///////////////// + // Constructor // + ///////////////// + scalarReflectanceParameter(float value=0.0f); + scalarReflectanceParameter(const std::shared_ptr& texture, unsigned int channel=0); + scalarReflectanceParameter(const scalarReflectanceParameter& src); + + ////////////// + // Operator // + ////////////// + scalarReflectanceParameter& operator=(const scalarReflectanceParameter& src); + + float operator()(const vec2d& textureCoord) const; + + ///////////// + // Friends // + ///////////// + friend void swap(scalarReflectanceParameter& a, scalarReflectanceParameter& b) { a._swap(b); } + + friend std::ostream& operator<<(std::ostream& s, const scalarReflectanceParameter& param) + { + if(param._texture) s << param._texture << "(channel=" << param._channel << ")"; + else s << param._value; + return s; + } + + private: + ///////////////////// + // Private Methods // + ///////////////////// + void _assign(const scalarReflectanceParameter& src); + void _swap(scalarReflectanceParameter& swp); + + ////////////////// + // Data Members // + ////////////////// + float _value; + unsigned int _channel; + std::shared_ptr _texture; +}; + + +class colorReflectanceParameter { + public: + ///////////////// + // Constructor // + ///////////////// + colorReflectanceParameter(color value=color(0.0f)); + colorReflectanceParameter(const std::shared_ptr& texture); + colorReflectanceParameter(const colorReflectanceParameter& src); + + ////////////// + // Operator // + ////////////// + colorReflectanceParameter& operator=(const colorReflectanceParameter& src); + + color operator()(const vec2d& textureCoord) const; + + ///////////// + // Friends // + ///////////// + friend void swap(colorReflectanceParameter& a, colorReflectanceParameter& b) { a._swap(b); } + + friend std::ostream& operator<<(std::ostream& s, const colorReflectanceParameter& param) + { + if(param._texture) s << param._texture; + else s << param._value; + return s; + } + + private: + ///////////////////// + // Private Methods // + ///////////////////// + void _assign(const colorReflectanceParameter& src); + void _swap(colorReflectanceParameter& swp); + + ////////////////// + // Data Members // + ////////////////// + color _value; + std::shared_ptr _texture; +}; + +#endif /* _REFLECTANCEPARAMETER_BASE_H_ */ -- cgit v1.2.3