librtl

texture.h

This is the verbatim text of the texture.h include file.
#ifndef texture_h
#define texture_h

#include <jgl/linearalgebra.h>
#include <jgl/colour.h>
#include <jgl/image.h>

#include "collect_alloc.h"

class rtl_material;
class rtl_ray;


class rtl_texture : public dyn_collectable
{
protected:


    rtl_texture(){};


    virtual void texture( rtl_material*, rtl_ray&, const jVec3&, jNorm3& )=0;

    friend class rtl_material;
};


class rtl_solidtexture : public rtl_texture
{
public:
    rtl_solidtexture() : rtl_texture(),M(){};


    void transform( const jMat4& );


    const jMat4& transform() const;
protected:
    jMat4 M;
};


class rtl_binarytexture : public rtl_solidtexture
{
protected:


    rtl_binarytexture( rtl_material*, rtl_material* );


    void texture( rtl_material*, rtl_ray&, const jVec3&, jNorm3& );


    virtual jFlt weight( rtl_ray&, const jVec3&, jNorm3& ) = 0;
    
    rtl_material* left, * right;

};


class rtl_turbulence : public rtl_binarytexture
{
public:


    rtl_turbulence( jFlt = 3.0 );


    rtl_turbulence( const jColour&, const jColour&, jFlt = 3.0 );


    rtl_turbulence( rtl_material*, rtl_material*, jFlt = 3.0 );


    jFlt& weight();

protected:

    jFlt weight( rtl_ray&, const jVec3&, jNorm3& );

private:
    jFlt wt;
};


class rtl_tiles : public rtl_binarytexture
{
public:


    rtl_tiles( jFlt = 1, jFlt = 1, jFlt = 1, bool = false );


    rtl_tiles( const jColour&, const jColour&, jFlt = 1,
           jFlt = 1, jFlt = 1, bool = false );
    

    rtl_tiles( rtl_material*, rtl_material*,
           jFlt = 1, jFlt = 1, jFlt = 1, bool = false );

protected:

    jFlt weight( rtl_ray&, const jVec3&, jNorm3& );

private:
    const jFlt tmwidth, tmheight;
    const jFlt tgw, tgh;

    bool offset;
};


class rtl_checkers : public rtl_binarytexture
{
public:

    rtl_checkers();
    

    rtl_checkers( const jColour&, const jColour& );
    

    rtl_checkers( rtl_material*, rtl_material* );
    
protected:
    jFlt weight( rtl_ray&, const jVec3&, jNorm3& );
};


class rtl_texturemap : public rtl_texture
{
public:


    rtl_texturemap( const jImage&, jUSInt = 1, jUSInt = 1 );


    void transform( const jMat3& _T )
        { tsT = tsT*_T; transformations|=tsTransform; }


    void transform( const jMat4& _T )
        { osT = osT*_T; transformations|=osTransform; }
    
protected:

    jMat3 tsT;
    jMat4 osT;
    jImage image;
    jUSInt utile, vtile;
    jByte transformations;

    const static jByte tsTransform;
    const static jByte osTransform;
    
    void texture( rtl_material*, rtl_ray&, const jVec3&, jNorm3& );
};

#endif

JSP / librtl v0.2 mtigges@cpsc.ucalgary.ca