blob: c9246537deed38f134bc1b4479e6ad1ef9bfb316 (
plain) (
tree)
|
|
/******************************************************************/
/* 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_ */
|