00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef RU_SMOOTHCURVE_H
00021 #define RU_SMOOTHCURVE_H
00022
00023 #include "RU_API.h"
00024 #include <UT/UT_FloatArray.h>
00025 #include <UT/UT_Vector2Array.h>
00026 #include <TIL/TIL_Defines.h>
00027
00028 #include "RU_PixelFunction.h"
00029
00030 class GU_Detail;
00031 class GU_Curve;
00032
00033 class RU_API RU_ColorCurve
00034 {
00035 public:
00036 RU_ColorCurve();
00037 ~RU_ColorCurve();
00038
00039 void reset();
00040 void addPoint(float pos, float val, float sharpness);
00041 void create(bool extend_slopes = true);
00042
00043 float evaluate(float pos) const;
00044
00045
00046 UT_FloatArray myDivs;
00047 UT_FloatArray myValues;
00048 UT_FloatArray mySharp;
00049 UT_Vector2Array myPoints;
00050 float myPreSlope, myPostSlope;
00051 bool myExtendSlope;
00052 int myNumPoints;
00053 int myNumSplines;
00054 };
00055
00056
00057 class RU_API RU_ColorCurveFunc : public RU_PixelFunction
00058 {
00059 public:
00060 RU_ColorCurveFunc(RU_ColorCurve *curve);
00061 RU_ColorCurveFunc(RU_ColorCurve **curves, int num);
00062
00063 virtual ~RU_ColorCurveFunc();
00064
00065 protected:
00066 virtual bool eachComponentDifferent() const { return myNumCurves > 1; }
00067
00068 static float curve(RU_PixelFunction *pf, float val, int);
00069 virtual RUPixelFunc getPixelFunction() const { return curve; }
00070 virtual void getPixelShader(UT_String &frag_shader);
00071
00072 RU_ColorCurve *myCurves[4];
00073 int myNumCurves;
00074 float *myCurveData;
00075 };
00076
00077 class RU_API RU_HueCurveFunc : public RU_PixelFunction
00078 {
00079 public:
00080
00081 RU_HueCurveFunc(RU_ColorCurve *curve, int mode);
00082
00083 virtual ~RU_HueCurveFunc();
00084
00085 protected:
00086 virtual bool needAllComponents() const { return true; }
00087
00088 static void hueSat(RU_PixelFunction *f, float **vals,
00089 const bool *scope);
00090 static void hueLum(RU_PixelFunction *f, float **vals,
00091 const bool *scope);
00092 virtual RUVectorFunc getVectorFunction() const
00093 { return myMode ? hueLum:hueSat; }
00094 virtual void getPixelShader(UT_String &frag_shader);
00095
00096 RU_ColorCurve *myCurve;
00097 float *myScales;
00098 int myMode;
00099 UT_Lock myLock;
00100 float myAvgScale;
00101 };
00102
00103
00104 #endif