00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef __GU_BrushNib__
00020 #define __GU_BrushNib__
00021
00022 #include "GU_API.h"
00023 #include <UT/UT_Vector3.h>
00024 #include <UT/UT_Matrix3.h>
00025
00026 class TS_MetaKernel;
00027 class TIL_TextureMap;
00028
00029
00030 enum GU_BrushBitmapChan {
00031 GU_BRUSHBMPCHAN_ALPHA,
00032 GU_BRUSHBMPCHAN_LUM,
00033 GU_BRUSHBMPCHAN_RED,
00034 GU_BRUSHBMPCHAN_GREEN,
00035 GU_BRUSHBMPCHAN_BLUE
00036 };
00037
00038
00039
00040
00041
00042 class GU_API GU_BrushNib
00043 {
00044 public:
00045 GU_BrushNib();
00046 virtual ~GU_BrushNib();
00047
00048
00049
00050
00051 bool testDepth(const UT_Vector3 &pos, float &depth)
00052 const;
00053
00054 virtual float getAlpha(const UT_Vector3 &pos);
00055
00056 virtual float getAlphaColor(const UT_Vector3 &pos,
00057 UT_Vector3 &cd);
00058
00059 int hasStamping() const { return myStampColor; }
00060
00061 void setOpacity(float val) { myOpacity = val; }
00062 float getOpacity() const { return myOpacity; }
00063
00064 void setDepth(bool usedepth,
00065 float depth, float height)
00066 { myUseDepth = usedepth;
00067 myDepth = depth;
00068 myHeight = height;
00069 }
00070
00071 void setStamping(int stamp)
00072 { myStampColor = stamp; }
00073 void setColor(const UT_Vector3 &cd)
00074 { myColor = cd; }
00075
00076 void setOrientation(const UT_Vector3 &orig,
00077 const UT_Vector3 &dir, const UT_Vector3 &upvector,
00078 float rad, float angle, float squash);
00079
00080 void setSoftEdge(float softedge,
00081 TS_MetaKernel *kernel);
00082
00083 void toBrushSpace(UT_Vector3 &pos);
00084 float getBrushDist2(const UT_Vector3 &pos);
00085
00086 void setSplatter(float brush, float paper)
00087 { myPaperNoise = paper; myBrushNoise = brush; }
00088
00089
00090
00091 float getSplatter(const UT_Vector3 &pos);
00092
00093 void getOrientation(UT_Matrix3 &orient) const
00094 { orient = myOrient; }
00095
00096 protected:
00097 float myOpacity, myInvRadius, myInvRadius2;
00098 float myRadius, myRadius2;
00099 bool myUseDepth;
00100 float myDepth;
00101 float myHeight;
00102 float myAngle, mySquash;
00103 UT_Vector3 myOrig, myDir, myUpVector;
00104 UT_Matrix3 myOrient;
00105
00106 float myPaperNoise, myBrushNoise;
00107
00108 UT_Vector3 myColor;
00109 int myStampColor;
00110
00111
00112 float mySoftEdge;
00113 TS_MetaKernel *myKernel;
00114 };
00115
00116 class GU_API GU_BrushNibSquare : public GU_BrushNib
00117 {
00118 public:
00119 GU_BrushNibSquare();
00120 virtual ~GU_BrushNibSquare();
00121
00122 virtual float getAlpha(const UT_Vector3 &pos);
00123 };
00124
00125 class GU_API GU_BrushNibBitmap : public GU_BrushNib
00126 {
00127 public:
00128 GU_BrushNibBitmap();
00129 virtual ~GU_BrushNibBitmap();
00130
00131 virtual float getAlphaColor(const UT_Vector3 &pos,
00132 UT_Vector3 &cd);
00133
00134
00135 void setRaster(TIL_TextureMap *raster);
00136 void setRasterChan(GU_BrushBitmapChan chanidx)
00137 { myChannel = chanidx; }
00138
00139 virtual float getAlpha(const UT_Vector3 &pos);
00140
00141 protected:
00142 float getAlphaFromColor(const UT_Vector4 &clr) const;
00143
00144 TIL_TextureMap *myRaster;
00145 GU_BrushBitmapChan myChannel;
00146 };
00147
00148
00149 #endif
00150