Source: raytracer/pigment3d.h


Annotated List
Files
Globals
Hierarchy
Index
/* *************************************************************************
                          pigment3d.h  -  description
                             -------------------
    begin                : Wed Oct 16 2002    
    copyright            : (C) 2002 by Micha Riser
    email                : mriser@gmx.net
 ************************************************************************* */

/* *************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ************************************************************************* */
 
#ifndef PIGMENT3D_H
#define PIGMENT3D_H

#include "vector.h"
#include "function.h"
#include "colour.h"
#include "transformatable.h"
#include "pattern.h"
#include "intervalmap.h"

/**Describes a colour for each point in space.
  *@author Micha Riser
  */
class Pigment3D: public Function<Vector3, Colour5>, public Transformatable {

public: // Constructors and destructor
    Pigment3D() {}
    virtual ~Pigment3D() {}

public: // Public pure virtual methods
    /**Evaluate pigment.
      *@param p evaluation point
      *@returns colour belonging to this point
      */
//    virtual Colour5 evaluateAt(const Vector3 &p) = 0;

    /**Copy pigment.
      */
    virtual Pigment3D* copy() const = 0;

protected:
    Pigment3D(const Pigment3D& p): Function<Vector3, Colour5>(), Transformatable(p) {}

private:
    Pigment3D& operator=(const Pigment3D&);

};


/**Single-coloured pigment.
  *@author Micha Riser
  */
class Pigment3DConstant: public Pigment3D  {

public: // Constructors and destructor
    Pigment3DConstant(const Colour5& c): colour(c) {}
    ~Pigment3DConstant() {}

public: // Public methods

    // Inherited from Pigment3D
    Colour5 evaluateAt(const Vector3&) const {return colour;}
    Pigment3D* copy() const {return new Pigment3DConstant(colour);}

    // Inherited from Transformatable
    void translate(const Vector3&) {}
    void scale(Vector3) {}
    void rotate(const Vector3&) {}
    void applyOrthogonalMatrix(const Matrix&) {}

private: // Private attributes
    Colour5 colour;

};


/**Patterned pigment.
  *@author Micha Riser
  */
  
class Pigment3DMapped: public Pigment3D, public IntervalMap<Pigment3D, Colour5> {

public: // Constructor and destructor
    Pigment3DMapped(const Pattern* p):
      Pigment3D(), IntervalMap<Pigment3D, Colour5>(), pattern(p) {};

    /**Copy constructor.
      */
    Pigment3DMapped(const Pigment3DMapped& p): Pigment3D(p), IntervalMap<Pigment3D, Colour5>(p),
      pattern(p.pattern->copy()) {};      

    ~Pigment3DMapped();

public: // Public methods
    Colour5 evaluateAt(const Vector3&) const;
    Pigment3D* copy() const;

    void insertCol(FLT value, const Colour5& obj) {
        insert(value,new Pigment3DConstant(obj));
    }


private:
    const Pattern* pattern;

};  

#endif

Generated by: micha@laptop on Thu Oct 24 20:25:24 2002, using kdoc 2.0a53.