summaryrefslogtreecommitdiff
path: root/hw6/include/reflectanceParameter.h
diff options
context:
space:
mode:
author53hornet <53hornet@gmail.com>2019-02-02 23:33:15 -0500
committer53hornet <53hornet@gmail.com>2019-02-02 23:33:15 -0500
commitdb072ad4dc181eca5a1458656b130beb43f475bf (patch)
treea3c03c7f5497cb70503e2486662fa85cfb53415a /hw6/include/reflectanceParameter.h
downloadcsci427-master.tar.xz
csci427-master.zip
Diffstat (limited to 'hw6/include/reflectanceParameter.h')
-rw-r--r--hw6/include/reflectanceParameter.h106
1 files changed, 106 insertions, 0 deletions
diff --git a/hw6/include/reflectanceParameter.h b/hw6/include/reflectanceParameter.h
new file mode 100644
index 0000000..c924653
--- /dev/null
+++ b/hw6/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_ */