summaryrefslogtreecommitdiff
path: root/hw6/include/brdfSample.h
blob: eeaeb329f80534617396719cc413e8278f6bce85 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
/******************************************************************/
/* 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_ */