On 08/08/2014 at 12:03, xxxxxxxx wrote:
This is what I have:
//=================================================================================================
class Sampler
//=================================================================================================
{
public:
Sampler();
~Sampler();
//init this sampler, always call one of this before everything else.
INIT_SAMPLER_RESULT Init(BaseObject *obj,LONG chnr=CHANNEL_COLOR,Real time=0.0);
INIT_SAMPLER_RESULT Init(BaseMaterial *mat ,LONG chnr,Real time,BaseDocument *doc,BaseObject *op=nullptr);
INIT_SAMPLER_RESULT Init(TextureTag *textag,LONG chnr,Real time,BaseDocument *doc,BaseObject *op=nullptr);
//return true if Init was called before.
inline Bool IsInit(){ return TexInit; };
//return color at UVW coordinates.
Vector SampleUV(const Vector &uv;, Real time=0.0);
//return color at 3D coordinates p, if shader is not 3D then uv will be used.
Vector Sample3D(const Vector &pos3d;, const Vector &uv; = Vector(0.0), Real time=0.0);
//return average color of the shader
Vector AverageColor(LONG num_samples = 128);
void Free();
private:
BaseShader *texShader; //NON owning ptr
AutoAlloc<VolumeData> vd; //Owning ptr
AutoAlloc<TexData> tex; //Owning ptr
RayObject *rop; //Owning ptr
InitRenderStruct irs;
ChannelData cd;
Matrix omg;
Real offsetX;
Real offsetY;
Real lenX;
Real lenY;
Bool TexInit;
};