00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef __IMG_FileTTMap__
00020 #define __IMG_FileTTMap__
00021
00022 #include <UT/UT_Vector4.h>
00023 #include <UT/UT_FilterType.h>
00024 #include <UT/UT_Filter.h>
00025 #include "IMG_API.h"
00026 #include "IMG_File.h"
00027
00028 class UT_Filter;
00029 class UT_FilterWindow;
00030 class UT_Options;
00031 class IMG_TTMipSampler;
00032 class IMG_Raster;
00033 class TBF_Channel;
00034
00035 class img_DSMPixelHandle;
00036
00037
00038
00039 typedef enum {
00040 IMG_TT_DEEP_DISCRETE = 0,
00041 IMG_TT_DEEP_LINEAR = 1
00042 } IMG_TT_DEEP_INTERP;
00043
00044 class IMG_API IMG_TTFilterInfo {
00045 public:
00046 IMG_TTFilterInfo();
00047 ~IMG_TTFilterInfo();
00048
00049
00050 const char *getChannelName() const { return myChannelName; }
00051
00052
00053 int getChannelIndex() const { return myChannelIndex; }
00054
00055
00056 void setChannelName(const char *channel);
00057
00058 void setChannelIndex(int i) { myChannelIndex = i; }
00059
00060 void setFilter(UT_FilterType ftype,
00061 float x, float y);
00062 void setXFilter(UT_FilterType ftype);
00063 void setYFilter(UT_FilterType ftype);
00064 void setFilterWidths(float x, float y);
00065 void setFilterBlurs(float x, float y);
00066 void setMipInterpolate(int onoff);
00067 void setWrap(UT_FilterWrap uwrap, UT_FilterWrap vwrap,
00068 const UT_Vector4 &border);
00069 void setDeepInterp(IMG_TT_DEEP_INTERP interp);
00070 void setZSkew(float zskew) { myZSkew = zskew; }
00071 void swapBorder(UT_Vector4 &b, int ncomponents=4);
00072
00073 float xsupport() const { return myXFilter->getSupport(); }
00074 float ysupport() const { return myYFilter->getSupport(); }
00075 float xblur() const { return myXBlur; }
00076 float yblur() const { return myYBlur; }
00077 float zskew() const { return myZSkew; }
00078
00079 public:
00080 UT_String myChannelName;
00081 UT_Filter *myXFilter, *myYFilter;
00082 float myXWidth, myYWidth;
00083 UT_FilterWrap myUWrap, myVWrap;
00084 UT_Vector4 myBorder;
00085 int myInterp;
00086 IMG_TT_DEEP_INTERP myDeepInterp;
00087 int myChannelIndex;
00088 float myXBlur, myYBlur;
00089 float myZSkew;
00090 };
00091
00092
00093
00094
00095 class IMG_API IMG_TTChannel {
00096 public:
00097 IMG_TTChannel();
00098 virtual ~IMG_TTChannel();
00099
00100 virtual void filterPixels(float *rgba, int nchan,
00101 int first_x, int first_y,
00102 const UT_Vector3 &zeqn,
00103 const float *xweights,
00104 const float *yweights,
00105 int usize, int vsize,
00106 IMG_TT_DEEP_INTERP interp) = 0;
00107
00108 virtual void getPixel(float *rgba, int nchan, int iu, int iv) = 0;
00109
00110
00111 virtual void getPixel(void *pixel, int iu, int iv) = 0;
00112
00113
00114 virtual void closeChannel() {};
00115 };
00116
00117
00118
00119
00120
00121
00122 class IMG_API IMG_FileTTMap : public IMG_File {
00123 public:
00124 IMG_FileTTMap();
00125 virtual ~IMG_FileTTMap();
00126
00127 virtual const char *className() const { return "IMG_FileTTMap"; }
00128
00129 int getOGLRaster(void *data, int xres, int yres,
00130 IMG_ColorModel cm, IMG_DataType dt,
00131 int raster_number=0);
00132
00133
00134
00135 void sample(float *result, int tuple_size, float u, float v,
00136 const IMG_TTFilterInfo &info,
00137 int channel, int raster, int validate);
00138 void bilerp(float *result, int tuple_size, float u, float v,
00139 const IMG_TTFilterInfo &info,
00140 int channel, int raster, int validate);
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151 void sample(float *result, int tuple_size,
00152 float u[4], float v[4], int nsamples, float quality,
00153 const IMG_TTFilterInfo &info,
00154 const UT_Vector3 &zeqn,
00155 int channel, int raster, int validate);
00156 void sample(float *result, int tuple_size,
00157 float u[4], float v[4], int nsamples, float quality,
00158 const IMG_TTFilterInfo &info,
00159 int channel, int raster, int validate)
00160 {
00161 sample(result, tuple_size, u, v, nsamples, quality,
00162 info, UT_Vector3(), channel, raster, validate);
00163 }
00164
00165
00166
00167 void envLookup(float *result, int tuple_size, const UT_Vector3 &r,
00168 int channel, int validate);
00169
00170 void envLookup(float *result, int tuple_size,
00171 const UT_Vector3 &r00, const UT_Vector3 &r01,
00172 const UT_Vector3 &r11, const UT_Vector3 &r10,
00173 const IMG_TTFilterInfo &info,
00174 int channel, int validate);
00175
00176 fpreal getUPixelSize() const { return myDx; }
00177 fpreal getVPixelSize() const { return myDy; }
00178
00179
00180 virtual UT_Options *getTextureOptions();
00181
00182
00183 virtual int getRasterCount() const { return 0; }
00184 int getChannelTupleSize(int ch) const;
00185 virtual int getNumChannels() const { return 0; }
00186 virtual int findChannelIndex(const char *name,
00187 int raster_index) const
00188 {
00189
00190 return 0;
00191 }
00192
00193 virtual int isReflMap() const { return 0; }
00194 virtual int isDSM() const { return 0; }
00195
00196
00197 virtual void dsmResolution(int &xres, int &yres);
00198 virtual int dsmGetChannels(UT_PtrArray<TBF_Channel *>&channels);
00199 virtual img_DSMPixelHandle *dsmGetReadHandle();
00200 virtual bool dsmOpenRawPixel(img_DSMPixelHandle &h, int x, int y);
00201 virtual void dsmDeleteReadHandle(img_DSMPixelHandle *h);
00202 virtual int dsmDepthComplexity(const img_DSMPixelHandle &h);
00203 virtual bool dsmPixelData(const img_DSMPixelHandle &h,
00204 int channel, fpreal *data,
00205 int data_size);
00206
00207 protected:
00208 void initialize(int xres, int yres,
00209 const fpreal *cscale,
00210 const int *csize,
00211 int mipcount,
00212 IMG_TTChannel **channels);
00213
00214 virtual int closeFile();
00215
00216 protected:
00217
00218 int myMipRead;
00219
00220 private:
00221
00222
00223
00224
00225
00226 void clearMips();
00227
00228
00229 int getMipOffset(int channel, int raster)
00230 {
00231 channel *= getRasterCount();
00232 channel += raster;
00233 return myMipCount * channel;
00234 }
00235
00236 float myDx, myDy;
00237
00238
00239
00240
00241 fpreal *myColorScale;
00242 int *myColorSize;
00243
00244
00245
00246
00247
00248 int myMipCount;
00249 IMG_TTMipSampler **myMips;
00250 };
00251
00252 #endif