summaryrefslogblamecommitdiff
path: root/hw6/include/brdfSample.h
blob: eeaeb329f80534617396719cc413e8278f6bce85 (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 _BRDFSAMPLE_H_
#define _BRDFSAMPLE_H_

#include "vec3d.h"
#include "color.h"
#include "transformation3d.h"
#include <ostream>

class brdfSample {
 public:
  //////////////////
  // Constructors //
  //////////////////
  brdfSample(void);
  brdfSample(const vec3d& out, const float pdf, const color& reflectance);
  brdfSample(const brdfSample& bs);

  ///////////////
  // Operators //
  ///////////////
  brdfSample& operator=(const brdfSample& bs);

  brdfSample operator*(float pdf) const;
  brdfSample& operator*=(float pdf);
  

  ////////////////
  // Inspectors //
  ////////////////
  const vec3d& exitantDirection(void) const;
  float pdf(void) const;
  const color& reflectance(void) const;

  /////////////
  // Methods //
  /////////////
  brdfSample& transform(const transformation3d& t);
  brdfSample& inverseTransform(const transformation3d& t);

  /////////////
  // Friends //
  /////////////
  friend void swap(brdfSample& a, brdfSample& b) { a._swap(b); }

  friend brdfSample transform(const brdfSample& s, const transformation3d& t) { brdfSample result(s); return result.transform(t); }
  friend brdfSample inverseTransform(const brdfSample& s, const transformation3d& t) { brdfSample result(s); return result.inverseTransform(t); }

  friend std::ostream& operator<<(std::ostream& s, const brdfSample& bs)
  {
    s << "BrdfSample: -> " << bs._out << " with PDF: " << bs._pdf << ", and reflectance: " << bs._reflectance;
    return s;
  }

 private:
  /////////////////////
  // Private Methods //
  /////////////////////
  void _swap(brdfSample& bs);
  void _assign(const brdfSample& bs);

  //////////////////////////
  // Private Data Members //
  //////////////////////////
  vec3d _out;
  float _pdf;
  color _reflectance;
};

#endif /* _BRDFSAMPLE_H_ */