00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef __SOP_BrushBase_h__
00021 #define __SOP_BrushBase_h__
00022
00023 #include "SOP_API.h"
00024 #include <GDT/GDT_MirrorTransform.h>
00025 #include <GU/GU_Brush.h>
00026
00027 #include "SOP_GDT.h"
00028
00029 class GEO_PointTree;
00030 class GU_RayIntersect;
00031 class TIL_TextureMap;
00032 class GEO_Primitive;
00033
00034 class PRM_MenuEntry;
00035
00036 enum SOP_BrushEvent {
00037 SOP_BRUSHSTROKE_BEGIN,
00038 SOP_BRUSHSTROKE_ACTIVE,
00039 SOP_BRUSHSTROKE_END,
00040 SOP_BRUSHSTROKE_CLICK,
00041 SOP_BRUSHSTROKE_NOP
00042 };
00043
00044 enum SOP_BrushOp {
00045 SOP_BRUSHOP_DEFORM,
00046 SOP_BRUSHOP_COMB,
00047 SOP_BRUSHOP_PAINT,
00048 SOP_BRUSHOP_SMOOTH,
00049 SOP_BRUSHOP_SCRIPT,
00050 SOP_BRUSHOP_SMOOTHDEFORM,
00051 SOP_BRUSHOP_EYEDROP,
00052 SOP_BRUSHOP_ERASE,
00053 SOP_BRUSHOP_SMOOTHATTRIB,
00054 SOP_BRUSHOP_SMOOTHNORMAL,
00055 SOP_BRUSHOP_CALLBACK,
00056 SOP_BRUSHOP_DRAGTEXTURE,
00057 SOP_BRUSHOP_SCALETEXTURE,
00058 SOP_BRUSHOP_SMOOTHTEXTURE,
00059 SOP_BRUSHOP_SMOOTHLAYER,
00060 SOP_BRUSHOP_SMOOTHSINGLE,
00061 SOP_BRUSHOP_REDUCE,
00062 SOP_BRUSHOP_ERASESINGLE
00063 };
00064
00065 enum SOP_BrushShape {
00066 SOP_BRUSHSHAPE_CIRCLE,
00067 SOP_BRUSHSHAPE_SQUARE,
00068 SOP_BRUSHSHAPE_BITMAP
00069 };
00070
00071 enum SOP_BrushUpType {
00072 SOP_BRUSHUP_STROKEDIR,
00073 SOP_BRUSHUP_FIXED
00074 };
00075
00076 enum SOP_BrushVisType {
00077 SOP_BRUSHVIS_FALSECOLOUR,
00078 SOP_BRUSHVIS_CAPTUREWEIGHT
00079 };
00080
00081 class SOP_API SOP_BrushBase : public SOP_GDT
00082 {
00083 public:
00084 SOP_BrushBase(OP_Network *net, const char *name, OP_Operator *entry);
00085 virtual ~SOP_BrushBase();
00086
00087 virtual OP_ERROR cookInputGroups(OP_Context &context,
00088 int alone = 0);
00089
00090
00091
00092 virtual void setAccumulateStencil(bool yesno) = 0;
00093 virtual void setRayOrigin(const UT_Vector3 &orig, fpreal t) = 0;
00094 virtual void setRayOrientation(const UT_Vector3 &orient, fpreal t) = 0;
00095 virtual void setHitPrimitive(int primidx, fpreal t) = 0;
00096 virtual void setHitPoint(int , fpreal ) {}
00097 virtual void setHitUV(fpreal u, fpreal v, fpreal t) = 0;
00098 virtual void setHitPressure(fpreal pressure, fpreal t) = 0;
00099 virtual void setHitInUV(bool inuv) { myHitInUV = inuv; }
00100 virtual void setBrushEvent(SOP_BrushEvent event) = 0;
00101 virtual void setBrushOp(SOP_BrushOp op) = 0;
00102 virtual void setBrushShape(SOP_BrushShape shape) = 0;
00103 virtual void setProjectionType(int projtype) = 0;
00104 virtual void useForegroundColor(void) = 0;
00105 virtual void useBackgroundColor(void) = 0;
00106
00107 virtual void setRadius(fpreal radius, fpreal t) = 0;
00108 virtual void setUVRadius(fpreal radius, fpreal t) = 0;
00109
00110 virtual const GA_PrimitiveGroup *getPrimitiveSelection(void) const
00111 {
00112 return (const GA_PrimitiveGroup*) myGroup;
00113 }
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124 virtual GU_RayIntersect *getRayIntersect(int checkgeochange = 0,
00125 int probeonly = 0);
00126
00127
00128 GEO_PointTree *getPointTree();
00129
00130
00131 GU_Detail *getCursorGdp();
00132
00133
00134
00135
00136
00137
00138
00139 void orientCursor(fpreal t, const UT_Vector3 &orig,
00140 const UT_Vector3 &dir,
00141 float scalehistory,
00142 bool isuv, GA_Index prim,
00143 float hitu, float hitv);
00144
00145
00146 virtual const GU_Detail *getIsectGdp();
00147
00148
00149
00150
00151
00152
00153 static int applyStencilStatic(void *op, int idx, fpreal t,
00154 const PRM_Template *);
00155 void applyStencil(fpreal t, int recook = 1);
00156
00157
00158
00159 static int resetNormalStatic(void *op, int idx, fpreal t,
00160 const PRM_Template *);
00161 void resetNormal(fpreal t);
00162
00163
00164
00165 static int floodStatic(void *op, int idx, fpreal t,
00166 const PRM_Template *);
00167 virtual void flood(fpreal t);
00168
00169
00170
00171 virtual void clearAllDeltas(fpreal t);
00172
00173 static void customMergeModeStatic(GEO_Point *pt,
00174 const GEO_Vertex &vtx,
00175 UT_Vector3 &result,
00176 const UT_Vector3 &cd,
00177 const UT_Vector3 &origcol,
00178 void *data);
00179 void customMergeMode(GEO_Point *pt,
00180 const GEO_Vertex &vtx,
00181 UT_Vector3 &result,
00182 const UT_Vector3 &cd,
00183 const UT_Vector3 &origcol);
00184
00185 static void brushOpCallbackStatic(
00186 GEO_Point *pt,
00187 const UT_PtrArray<const GEO_Point *> *ptneighbour,
00188 const GEO_Vertex &vtx,
00189 const UT_RefArray<GEO_Vertex> *vtxneighbor,
00190 GEO_Primitive *vtx_prim,
00191 int prim_vtx_idx,
00192 float alpha,
00193 GEO_Delta *delta,
00194 void *data);
00195 virtual void brushOpCallback(
00196 GEO_Point *pt,
00197 const UT_PtrArray<const GEO_Point *> *ptneighbour,
00198 const GEO_Vertex &vtx,
00199 const UT_RefArray<GEO_Vertex> *vtxneighbour,
00200 GEO_Primitive *vtx_prim,
00201 int prim_vtx_idx,
00202 float alpha,
00203 GEO_Delta *delta);
00204
00205
00206 bool hasStencil() const;
00207
00208 virtual void setCurrentColor(const UT_Vector3 &cd);
00209
00210
00211 void applyVisualizeStencil();
00212 void applyVisualize();
00213 void applyCaptureVisualize();
00214
00215 void setIsectNodeId(int node_id)
00216 {
00217 myIsectNodeId = node_id;
00218 }
00219
00220 virtual void unloadDataHack();
00221 virtual bool unloadData();
00222
00223 protected:
00224
00225
00226 virtual OP_ERROR cookMySop(OP_Context &context);
00227
00228
00229
00230
00231
00232 virtual void duplicateChangedSourceWrapper(
00233 unsigned idx,
00234 OP_Context &context,
00235 int *changed,
00236 bool force=false);
00237
00238
00239
00240
00241
00242
00243
00244
00245
00246 virtual OP_ERROR processBrushOp(OP_Context &context,
00247 bool changed_input, bool changed_group);
00248
00249
00250
00251
00252 virtual bool matchesUndo(const char *undoname) const;
00253
00254 protected:
00255
00256
00257 void doDeformation(fpreal t, const UT_Vector3 &cd);
00258 void doPaint(fpreal t, const UT_Vector3 &cd,
00259 int enablestamping = 1);
00260 virtual void doErase() = 0;
00261 virtual void addEraseAttributes(GU_Brush &brush) {}
00262
00263
00264
00265 const GEO_Point *getSeedPoint(const GEO_Primitive *prim,
00266 float u, float v,
00267 const UT_Vector3 &orig);
00268
00269 virtual OP_Node *getRestGeoInput() { return 0; }
00270
00271 public:
00272
00273
00274 virtual int altersGeometry() const = 0;
00275
00276
00277 virtual int altersColor() const = 0;
00278
00279
00280
00281
00282
00283 virtual fpreal RADIUS(fpreal t);
00284 virtual fpreal RAWRADIUS(fpreal t) = 0;
00285 virtual fpreal RAWUVRADIUS(fpreal t) = 0;
00286 virtual fpreal RADIUSPRESSURE(fpreal t) = 0;
00287 virtual fpreal OPACITY(fpreal t);
00288 virtual fpreal RAWOPACITY(fpreal t) = 0;
00289 virtual fpreal OPACITYPRESSURE(fpreal t) = 0;
00290
00291
00292
00293 virtual fpreal DEPTH(fpreal ) { return 1.0; }
00294 virtual fpreal HEIGHT(fpreal ) { return 1.0; }
00295
00296 virtual int USEDEPTH() { return 0; }
00297 virtual int USECONNECTIVITY() { return 1; }
00298
00299 virtual SOP_BrushOp OP(void) = 0;
00300 virtual int ACCUMSTENCIL(void) = 0;
00301 virtual int PROJECTIONTYPE(void) = 0;
00302 virtual int REALTIME(void) = 0;
00303 virtual int SHAPE(fpreal t) = 0;
00304 protected:
00305 virtual int MERGEMODE() = 0;
00306
00307 virtual void SCRIPT(UT_String &s, fpreal t) = 0;
00308 virtual int AXIS() = 0;
00309 virtual fpreal USERX(fpreal t) = 0;
00310 virtual fpreal USERY(fpreal t) = 0;
00311 virtual fpreal USERZ(fpreal t) = 0;
00312
00313 virtual fpreal RAYORIENTX(fpreal t) = 0;
00314 virtual fpreal RAYORIENTY(fpreal t) = 0;
00315 virtual fpreal RAYORIENTZ(fpreal t) = 0;
00316 virtual fpreal RAYHITX(fpreal t) = 0;
00317 virtual fpreal RAYHITY(fpreal t) = 0;
00318 virtual fpreal RAYHITZ(fpreal t) = 0;
00319 virtual fpreal RAYHITU(fpreal t) = 0;
00320 virtual fpreal RAYHITV(fpreal t) = 0;
00321 virtual fpreal RAYHITPRESSURE(fpreal t) = 0;
00322 virtual int PRIMHIT(fpreal t) = 0;
00323 virtual int PTHIT(fpreal ) { return -1; }
00324 virtual int EVENT() = 0;
00325
00326 virtual bool USE_FOREGROUND() = 0;
00327 virtual fpreal FGR(fpreal t) = 0;
00328 virtual fpreal FGG(fpreal t) = 0;
00329 virtual fpreal FGB(fpreal t) = 0;
00330 virtual fpreal BGR(fpreal t) = 0;
00331 virtual fpreal BGG(fpreal t) = 0;
00332 virtual fpreal BGB(fpreal t) = 0;
00333
00334 virtual fpreal SOFTEDGE(fpreal t) = 0;
00335 virtual void KERNEL(UT_String &str, fpreal t) = 0;
00336 virtual int UPTYPE(fpreal t) = 0;
00337 virtual fpreal UPX(fpreal t) = 0;
00338 virtual fpreal UPY(fpreal t) = 0;
00339 virtual fpreal UPZ(fpreal t) = 0;
00340
00341 virtual fpreal PAPERNOISE(fpreal t) = 0;
00342 virtual fpreal SPLATTER(fpreal t) = 0;
00343 virtual void BITMAP(UT_String &str, fpreal t) = 0;
00344 virtual int BITMAPCHAN(fpreal t) = 0;
00345 virtual fpreal ANGLE(fpreal t) = 0;
00346 virtual fpreal SQUASH(fpreal t) = 0;
00347 virtual int DOSTAMPING() = 0;
00348 virtual int WRITEALPHA() = 0;
00349 virtual int OVERRIDECD() = 0;
00350 virtual void CDNAME(UT_String &str, fpreal t) = 0;
00351 virtual int OVERRIDEALPHA() = 0;
00352 virtual void ALPHANAME(UT_String &str, fpreal t) = 0;
00353 virtual int PRESERVENML() { return 0; }
00354 virtual int OVERRIDENML() = 0;
00355 virtual void NMLNAME(UT_String &str, fpreal t) = 0;
00356
00357 virtual fpreal SYMMETRYDIRX(fpreal t) = 0;
00358 virtual fpreal SYMMETRYDIRY(fpreal t) = 0;
00359 virtual fpreal SYMMETRYDIRZ(fpreal t) = 0;
00360 virtual fpreal SYMMETRYORIGX(fpreal t) = 0;
00361 virtual fpreal SYMMETRYORIGY(fpreal t) = 0;
00362 virtual fpreal SYMMETRYORIGZ(fpreal t) = 0;
00363 virtual int DOREFLECTION() = 0;
00364 virtual int DOPOINTREFLECTION() { return 0; };
00365 virtual int DOROTATION() = 0;
00366 virtual int SYMMETRYROT(fpreal t) = 0;
00367 virtual fpreal SYMMETRYDIST(fpreal t) = 0;
00368
00369 virtual int DOUVREFLECTION() { return 0; }
00370 virtual fpreal SYMMETRYUVORIGU(fpreal ) { return 0.5; }
00371 virtual fpreal SYMMETRYUVORIGV(fpreal ) { return 0.5; }
00372 virtual fpreal SYMMETRYUVANGLE(fpreal ) { return 0.0; }
00373
00374 virtual int ADDATTRIB() = 0;
00375 virtual int VISUALIZE() { return 0; }
00376 virtual int VISTYPE() { return 0; }
00377 virtual fpreal VISLOW(fpreal ) { return 0.0; }
00378 virtual fpreal VISHIGH(fpreal ) { return 1.0; }
00379 virtual int VISMODE() { return 0; }
00380 virtual fpreal ZEROWEIGHTCOLOR_R() { return 1.0; }
00381 virtual fpreal ZEROWEIGHTCOLOR_G() { return 1.0; }
00382 virtual fpreal ZEROWEIGHTCOLOR_B() { return 1.0; }
00383
00384 virtual int NORMALIZEWEIGHT() { return 0; }
00385
00386 virtual int USECAPTURE() { return 0; }
00387 virtual int CAPTUREIDX(fpreal ) { return 0; }
00388 virtual GEO_Detail::CaptureType
00389 CAPTURETYPE() { return GEO_Detail::CAPTURE_BONE; }
00390
00391
00392
00393 virtual bool hasStrokeChanged(fpreal t) = 0;
00394 virtual bool hasStyleChanged (fpreal t) = 0;
00395
00396
00397 virtual bool hasNibFileChanged(fpreal t) = 0;
00398
00399
00400 virtual bool hasNibLookChanged(fpreal t) = 0;
00401 virtual bool hasAccumStencilChanged(fpreal t) = 0;
00402
00403 virtual bool hasCaptureIdxChanged(fpreal ) { return 0; }
00404
00405 virtual bool hasVisrangeChanged(fpreal ) { return 0; }
00406
00407
00408 virtual bool wantsCookSelection(void) const { return false; }
00409
00410 virtual void rollbackCurrentDelta();
00411 virtual void applyAndClearCurrentDelta();
00412
00413 virtual const GA_PointGroup *getPointGroup() { return 0; }
00414 virtual bool isGroupParmDirty(OP_Context &context)
00415 {
00416 return isParmDirty(SOP_GDT_GRP_IDX, context.getTime());
00417 }
00418
00419 UT_Vector3 myLastPos;
00420 UT_Vector3 myBrushDir;
00421
00422
00423 int myPendingLastUVPrimitive;
00424 UT_Vector3 myPendingLastUVPrimitiveUV;
00425
00426
00427
00428 int myLastUVPrimitive;
00429 UT_Vector3 myLastUVPrimitiveUV;
00430
00431
00432 bool myLastUVPosValid;
00433 UT_Vector3 myLastUVPos;
00434
00435 UT_Vector3 myUVBrushDir;
00436 UT_Vector3 myUVBrushPos;
00437 GU_Brush myBrush;
00438 GU_RayIntersect *myRayIntersect;
00439 TIL_TextureMap *myNibFile;
00440 GU_Detail *myBrushCursor;
00441 UT_Matrix3 myCursorOrient;
00442
00443
00444
00445 int myForceVisualize;
00446 int myIsectNodeId;
00447
00448
00449 int myLastIsectGDPId;
00450 int myLastIsectGDPCacheCount;
00451 int myLastIsectGDPSelectCacheCount;
00452
00453
00454 fpreal myCookTime;
00455
00456 bool myHitInUV;
00457
00458 GDT_Detail myMirroredDelta;
00459
00460 GDT_MirrorTransform myMirrorTransform;
00461 };
00462
00463 #endif