42 #define MSS_CLICK_BUTTONS (DM_PRIMARY_BUTTON|DM_SECONDARY_BUTTON)
44 using namespace HDK_Sample;
53 "SOP_proto_custombrush",
67 BM_SceneManager *scene)
75 BM_SceneManager *scene,
78 myBrushHandle((DM_SceneManager &)workbench(),
"MSS_CustomBrushState")
80 myIsBrushVisible =
false;
81 myResizingCursor =
false;
85 cparms.
gdp = &myBrushCursor;
89 #if defined(HOUDINI_11)
110 return "MSS_CustomBrushState";
136 myIsBrushVisible =
false;
160 myIsBrushVisible =
false;
173 int x =
event->state.values[
X];
174 int y =
event->state.values[
Y];
183 myResizingCursor =
true;
185 else if (myResizingCursor)
191 myBrushRadius *=
powf(1.01, dist);
194 myResizingCursor =
false;
223 sop->
setFloat(
"origin", 0, t, rayorig.
x());
224 sop->
setFloat(
"origin", 1, t, rayorig.
y());
225 sop->
setFloat(
"origin", 2, t, rayorig.
z());
227 sop->
setFloat(
"direction", 0, t, dir.
x());
228 sop->
setFloat(
"direction", 1, t, dir.
y());
229 sop->
setFloat(
"direction", 2, t, dir.
z());
231 sop->
setFloat(
"radius", 0, t, myBrushRadius);
319 myBrushHandle.
renderWire(r, 0, 0, 0, clr, &myBrushCursor);
328 showPrompt(
"LMB to apply stroke. MMB to erase. Shift-LMB to adjust radius.");
344 myBrushCursorXform.
translate(delta.
x(), delta.
y(), delta.
z());
347 myBrushCursorXform.
prescale(myBrushRadius, myBrushRadius, 1);
350 myIsBrushVisible =
true;
const GU_Detail * getCookedGeo(OP_Context &, int forced=0)
void popMatrix(bool all_matrices=true, RE_MatrixMode mmode=RE_MATRIX_VIEWING)
GA_API const UT_StringHolder dist
void interrupt(BM_SimpleState *state=0) override
void interrupt(BM_SimpleState *=0) override
fpreal getTime() const
Obtains the current global time.
void mapToWorld(float x, float y, UT_Vector3 &dir, UT_Vector3 &rayorig)
Map viewport coordinates to worldspace location and direction.
void beginDistributedUndoBlock(const char *operation, UT_UndoBlockType blocktype, bool ignore_log=false)
void xformToObjectCoord(UT_Vector3 &p)
static PRM_Template * ourTemplateList
parameters for this state
UT_Vector3T< float > UT_Vector3
const unsigned PI_NETMASK_SOP
constexpr SYS_FORCE_INLINE T & z() noexcept
#define DM_SECONDARY_BUTTON
SYS_API float powf(float x, float y)
**But if you need a result
~MSS_CustomBrushState() override
int enter(BM_SimpleState::BM_EntryType how) override
void setString(const UT_StringRef &val, CH_StringMeaning meaning, int parmi, int vectori, fpreal t)
void showPrompt(const char *msg)
Set the status bar text.
virtual int registerState(PI_StateTemplate *type)
void newModelState(BM_ResourceManager *m)
int enter(BM_SimpleState::BM_EntryType how) override
called when the user enters the state
void pushMatrix(bool all_matrices=true, RE_MatrixMode mmode=RE_MATRIX_VIEWING)
bool setHighlight(bool on_off)
static BM_State * ourConstructor(BM_View &view, PI_StateTemplate &templ, BM_SceneManager *scene)
used by DM to create our state
MSS_CustomBrushState(JEDI_View &view, PI_StateTemplate &templ, BM_SceneManager *scene, const char *cursor=BM_DEFAULT_CURSOR)
void wantsLocates(int yesNo)
void removeClickInterest(int buttons)
fpreal64 dot(const CE_VectorT< T > &a, const CE_VectorT< T > &b)
void setViewportMask(unsigned mask)
void prescale(T sx, T sy, T sz, T sw=1)
#define MSS_CLICK_BUTTONS
void exit() override
called when the user leaves the state
virtual void updatePrompt()
sets the prompt's text
void identity()
Set the matrix to identity.
void updateBrush(int x, int y)
repositions the brush's guide geometry
void resume(BM_SimpleState *=0) override
that also have some descendant prim *whose name begins with which in turn has a child named baz where *the predicate active
GEO_API const TypeMask GEOPRIMBEZCURVE
void translate(T dx, T dy, T dz=0)
UT_Vector3T< T > rowVecMult3(const UT_Vector3T< T > &v, const UT_Matrix4T< S > &m)
void setFloat(int parmi, int vectori, fpreal t, fpreal value, PRM_AddKeyType add_key=PRM_AK_MARK_PENDING)
void renderWire(RE_RenderContext r, int pickflag, uint id1, uint id2, const UT_Color &color, GU_Detail *gdp=NULL, const UT_DMatrix4 *xform=NULL)
int handleMouseEvent(UI_Event *event) override
Respond to mouse or keyboard events.
void addClickInterest(int buttons)
void resume(BM_SimpleState *state=0) override
#define DM_VIEWPORT_PERSPECTIVE
const char * className() const override
The name and type of this class:
void getViewportItransform(UT_Matrix4 &xform)
Get cameraspace to worldspace transform.
void multiplyMatrix(const UT_Matrix4 &m)
constexpr SYS_FORCE_INLINE T & y() noexcept
static GEO_Primitive * build(const GU_PrimCircleParms &parms, GA_PrimitiveTypeId type=GEO_PRIMCIRCLE)
OP_Node * getNode() const
void xformToObjectVector(UT_Vector3 &v)
void endDistributedUndoBlock(bool ignore_log=false)
void doRender(RE_Render *r, int x, int y, int ghost) override
Render the brush "cursor" geometry:
constexpr SYS_FORCE_INLINE T & x() noexcept
PcpNodeRef_ChildrenIterator begin(const PcpNodeRef::child_const_range &r)
Support for range-based for loops for PcpNodeRef children ranges.