diff options
author | 53hornet <53hornet@gmail.com> | 2019-02-02 23:33:15 -0500 |
---|---|---|
committer | 53hornet <53hornet@gmail.com> | 2019-02-02 23:33:15 -0500 |
commit | db072ad4dc181eca5a1458656b130beb43f475bf (patch) | |
tree | a3c03c7f5497cb70503e2486662fa85cfb53415a /hw5/include/reflectanceParameter.h | |
download | csci427-master.tar.xz csci427-master.zip |
Diffstat (limited to 'hw5/include/reflectanceParameter.h')
-rw-r--r-- | hw5/include/reflectanceParameter.h | 106 |
1 files changed, 106 insertions, 0 deletions
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 <memory> +#include <ostream> + +#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<const texture_base>& 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<const texture_base> _texture; +}; + + +class colorReflectanceParameter { + public: + ///////////////// + // Constructor // + ///////////////// + colorReflectanceParameter(color value=color(0.0f)); + colorReflectanceParameter(const std::shared_ptr<const texture_base>& 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<const texture_base> _texture; +}; + +#endif /* _REFLECTANCEPARAMETER_BASE_H_ */ |