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, float t) = 0;
00094 virtual void setRayOrientation(const UT_Vector3 &orient, float t) = 0;
00095 virtual void setHitPrimitive(int primidx, float t) = 0;
00096 virtual void setHitPoint(int , float ) {}
00097 virtual void setHitUV(float u, float v, float t) = 0;
00098 virtual void setHitPressure(float pressure, float 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(float radius, float t) = 0;
00108 virtual void setUVRadius(float radius, float t) = 0;
00109
00110 virtual const GB_PrimitiveGroup *getPrimitiveSelection(void) const
00111 {
00112 return (const GB_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(float t, const UT_Vector3 &orig,
00140 const UT_Vector3 &dir,
00141 float scalehistory,
00142 bool isuv,
00143 const GEO_Primitive *prim,
00144 float hitu, float hitv);
00145
00146
00147 virtual const GU_Detail *getIsectGdp();
00148
00149
00150
00151
00152
00153
00154 static int applyStencilStatic(void *op, int idx, float t,
00155 const PRM_Template *);
00156 void applyStencil(float t, int recook = 1);
00157
00158
00159
00160 static int resetNormalStatic(void *op, int idx, float t,
00161 const PRM_Template *);
00162 void resetNormal(float t);
00163
00164
00165
00166 static int floodStatic(void *op, int idx, float t,
00167 const PRM_Template *);
00168 virtual void flood(float t);
00169
00170
00171
00172 virtual void clearAllDeltas(float t);
00173
00174 static void customMergeModeStatic(GEO_Point *pt,
00175 GEO_Vertex *vtx,
00176 UT_Vector3 &result,
00177 const UT_Vector3 &cd,
00178 const UT_Vector3 &origcol,
00179 void *data);
00180 void customMergeMode(GEO_Point *pt,
00181 GEO_Vertex *vtx,
00182 UT_Vector3 &result,
00183 const UT_Vector3 &cd,
00184 const UT_Vector3 &origcol);
00185
00186 static void brushOpCallbackStatic(
00187 GEO_Point *pt,
00188 const UT_PtrArray<const GEO_Point *> *ptneighbour,
00189 GEO_Vertex *vtx,
00190 const UT_PtrArray<const GEO_Vertex*> *vtxneighbor,
00191 GEO_Primitive *vtx_prim,
00192 int prim_vtx_idx,
00193 float alpha,
00194 GEO_Delta *delta,
00195 void *data);
00196 virtual void brushOpCallback(
00197 GEO_Point *pt,
00198 const UT_PtrArray<const GEO_Point *> *ptneighbour,
00199 GEO_Vertex *vtx,
00200 const UT_PtrArray<const GEO_Vertex *> *vtxneighbour,
00201 GEO_Primitive *vtx_prim,
00202 int prim_vtx_idx,
00203 float alpha,
00204 GEO_Delta *delta);
00205
00206
00207 bool hasStencil() const;
00208
00209 virtual void setCurrentColor(const UT_Vector3 &cd);
00210
00211
00212 void applyVisualizeStencil();
00213 void applyVisualize();
00214 void applyCaptureVisualize();
00215
00216 void setIsectNodeId(int node_id)
00217 {
00218 myIsectNodeId = node_id;
00219 }
00220
00221 virtual void unloadDataHack();
00222 virtual bool unloadData();
00223
00224 protected:
00225
00226
00227 virtual OP_ERROR cookMySop(OP_Context &context);
00228
00229
00230
00231
00232
00233 virtual void duplicateChangedSourceWrapper(
00234 unsigned idx,
00235 OP_Context &context,
00236 int *changed,
00237 bool force=false);
00238
00239
00240
00241
00242
00243
00244
00245
00246
00247 virtual OP_ERROR processBrushOp(OP_Context &context,
00248 bool changed_input, bool changed_group);
00249
00250
00251
00252
00253 virtual bool matchesUndo(const char *undoname) const;
00254
00255 protected:
00256
00257
00258 void doDeformation(float t, const UT_Vector3 &cd);
00259 void doPaint(float t, const UT_Vector3 &cd,
00260 int enablestamping = 1);
00261 virtual void doErase() = 0;
00262 virtual void addEraseAttributes(GU_Brush &brush) {}
00263
00264
00265
00266 const GEO_Point *getSeedPoint(const GEO_Primitive *prim,
00267 float u, float v,
00268 const UT_Vector3 &orig);
00269
00270 virtual OP_Node *getRestGeoInput() { return 0; }
00271
00272 public:
00273
00274
00275 virtual int altersGeometry() const = 0;
00276
00277
00278 virtual int altersColor() const = 0;
00279
00280
00281
00282
00283
00284 virtual float RADIUS(float t);
00285 virtual float RAWRADIUS(float t) = 0;
00286 virtual float RAWUVRADIUS(float t) = 0;
00287 virtual float RADIUSPRESSURE(float t) = 0;
00288 virtual float OPACITY(float t);
00289 virtual float RAWOPACITY(float t) = 0;
00290 virtual float OPACITYPRESSURE(float t) = 0;
00291
00292
00293
00294 virtual float DEPTH(float ) { return 1.0f; }
00295 virtual float HEIGHT(float ) { return 1.0f; }
00296
00297 virtual int USEDEPTH() { return 0; }
00298 virtual int USECONNECTIVITY() { return 1; }
00299
00300 virtual SOP_BrushOp OP(void) = 0;
00301 virtual int ACCUMSTENCIL(void) = 0;
00302 virtual int PROJECTIONTYPE(void) = 0;
00303 virtual int REALTIME(void) = 0;
00304 virtual int SHAPE(float t) = 0;
00305 protected:
00306 virtual int MERGEMODE() = 0;
00307
00308 virtual void SCRIPT(UT_String &s, float t) = 0;
00309 virtual int AXIS(void) = 0;
00310 virtual float USERX(float t) = 0;
00311 virtual float USERY(float t) = 0;
00312 virtual float USERZ(float t) = 0;
00313
00314 virtual float RAYORIENTX(float t) = 0;
00315 virtual float RAYORIENTY(float t) = 0;
00316 virtual float RAYORIENTZ(float t) = 0;
00317 virtual float RAYHITX(float t) = 0;
00318 virtual float RAYHITY(float t) = 0;
00319 virtual float RAYHITZ(float t) = 0;
00320 virtual float RAYHITU(float t) = 0;
00321 virtual float RAYHITV(float t) = 0;
00322 virtual float RAYHITPRESSURE(float t) = 0;
00323 virtual int PRIMHIT(float t) = 0;
00324 virtual int PTHIT(float ) { return -1; }
00325 virtual int EVENT() = 0;
00326
00327 virtual bool USE_FOREGROUND(void) = 0;
00328 virtual float FGR(float t) = 0;
00329 virtual float FGG(float t) = 0;
00330 virtual float FGB(float t) = 0;
00331 virtual float BGR(float t) = 0;
00332 virtual float BGG(float t) = 0;
00333 virtual float BGB(float t) = 0;
00334
00335 virtual float SOFTEDGE(float t) = 0;
00336 virtual void KERNEL(UT_String &str, float t) = 0;
00337 virtual int UPTYPE(float t) = 0;
00338 virtual float UPX(float t) = 0;
00339 virtual float UPY(float t) = 0;
00340 virtual float UPZ(float t) = 0;
00341
00342 virtual float PAPERNOISE(float t) = 0;
00343 virtual float SPLATTER(float t) = 0;
00344 virtual void BITMAP(UT_String &str, float t) = 0;
00345 virtual int BITMAPCHAN(float t) = 0;
00346 virtual float ANGLE(float t) = 0;
00347 virtual float SQUASH(float t) = 0;
00348 virtual int DOSTAMPING() = 0;
00349 virtual int WRITEALPHA() = 0;
00350 virtual int OVERRIDECD() = 0;
00351 virtual void CDNAME(UT_String &str, float t) = 0;
00352 virtual int OVERRIDEALPHA() = 0;
00353 virtual void ALPHANAME(UT_String &str, float t) = 0;
00354 virtual int PRESERVENML() { return 0; }
00355 virtual int OVERRIDENML() = 0;
00356 virtual void NMLNAME(UT_String &str, float t) = 0;
00357
00358 virtual float SYMMETRYDIRX(float t) = 0;
00359 virtual float SYMMETRYDIRY(float t) = 0;
00360 virtual float SYMMETRYDIRZ(float t) = 0;
00361 virtual float SYMMETRYORIGX(float t) = 0;
00362 virtual float SYMMETRYORIGY(float t) = 0;
00363 virtual float SYMMETRYORIGZ(float t) = 0;
00364 virtual int DOREFLECTION() = 0;
00365 virtual int DOPOINTREFLECTION() { return 0; };
00366 virtual int DOROTATION() = 0;
00367 virtual int SYMMETRYROT(float t) = 0;
00368 virtual float SYMMETRYDIST(float t) = 0;
00369
00370 virtual int DOUVREFLECTION() { return 0; }
00371 virtual float SYMMETRYUVORIGU(float ) { return 0.5f; }
00372 virtual float SYMMETRYUVORIGV(float ) { return 0.5f; }
00373 virtual float SYMMETRYUVANGLE(float ) { return 0.0f; }
00374
00375 virtual int ADDATTRIB() = 0;
00376 virtual int VISUALIZE() { return 0; }
00377 virtual int VISTYPE() { return 0; }
00378 virtual float VISLOW(float ) { return 0.0f; }
00379 virtual float VISHIGH(float ) { return 1.0f; }
00380 virtual int VISMODE() { return 0; }
00381 virtual float ZEROWEIGHTCOLOR_R() { return 1.0f; }
00382 virtual float ZEROWEIGHTCOLOR_G() { return 1.0f; }
00383 virtual float ZEROWEIGHTCOLOR_B() { return 1.0f; }
00384
00385 virtual int NORMALIZEWEIGHT() { return 0; }
00386
00387 virtual int USECAPTURE() { return 0; }
00388 virtual int CAPTUREIDX(float ) { return 0; }
00389 virtual GEO_Detail::CaptureType CAPTURETYPE()
00390 { return GEO_Detail::CAPTURE_BONE; }
00391
00392
00393
00394 virtual bool hasStrokeChanged(float t) = 0;
00395 virtual bool hasStyleChanged (float t) = 0;
00396
00397
00398 virtual bool hasNibFileChanged(float t) = 0;
00399
00400
00401 virtual bool hasNibLookChanged(float t) = 0;
00402 virtual bool hasAccumStencilChanged(float t) = 0;
00403
00404 virtual bool hasCaptureIdxChanged(float ) { return 0; }
00405
00406 virtual bool hasVisrangeChanged(float ) { return 0; }
00407
00408
00409 virtual bool wantsCookSelection(void) const { return false; }
00410
00411 virtual void rollbackCurrentDelta();
00412 virtual void applyAndClearCurrentDelta();
00413
00414 virtual const GB_PointGroup *getPointGroup() { return 0; }
00415 virtual bool isGroupParmDirty(OP_Context &context)
00416 {
00417 return isParmDirty(SOP_GDT_GRP_IDX, context.myTime);
00418 }
00419
00420 UT_Vector3 myLastPos;
00421 UT_Vector3 myBrushDir;
00422
00423
00424 int myPendingLastUVPrimitive;
00425 UT_Vector3 myPendingLastUVPrimitiveUV;
00426
00427
00428
00429 int myLastUVPrimitive;
00430 UT_Vector3 myLastUVPrimitiveUV;
00431
00432
00433 bool myLastUVPosValid;
00434 UT_Vector3 myLastUVPos;
00435
00436 UT_Vector3 myUVBrushDir;
00437 UT_Vector3 myUVBrushPos;
00438 GU_Brush myBrush;
00439 GU_RayIntersect *myRayIntersect;
00440 TIL_TextureMap *myNibFile;
00441 GU_Detail *myBrushCursor;
00442 UT_Matrix3 myCursorOrient;
00443
00444
00445
00446 int myForceVisualize;
00447 int myIsectNodeId;
00448
00449
00450 int myLastIsectGDPId;
00451 int myLastIsectGDPCacheCount;
00452
00453
00454 float myCookTime;
00455
00456 bool myHitInUV;
00457
00458 GDT_Detail myMirroredDelta;
00459
00460 GDT_MirrorTransform myMirrorTransform;
00461 };
00462
00463 #endif