Jump to content

Storm Keeper

Members
  • Posts

    17
  • Joined

  • Last visited

Personal Information

  • Name
    Dmitry

Recent Profile Visitors

2,227 profile views

Storm Keeper's Achievements

Newbie

Newbie (1/14)

0

Reputation

  1. Hi, guys. Does anyone know why file_* functions don't work in SOP context? Documentation says that these functions are present in all contexts, but none of them are represented as nodes in AttribVOP, and AttribWrangle says "undefined function". I also did not find one in SHOP context. What I am trying to do is to write custom data to an external file using VEX. I also tried to #include <file.h>, but no luck.
  2. Hello, guys! Probably a newbie question, but I can't figure it out. I have some animation curve and I want to select several keys and move them up, so that the new value of each key is, for example: newVal = oldVal + 1. I can just drag the keys, but it does not seem to be precise. Is there any precise way to do it? Or can I use Python to access selected keys?
  3. The way to do this is to create a spare parameter with any name on your Wrangle node (for example, call it "idx"), set an expression on it ( stamp("..","FORVALUE",) ), and reference it in your VEX code as follows: i = ch("idx");
  4. Hi there! I am working with some complex digital assets at the scene level. Each asset has many output nodes (nulls), which are referenced in other containers using Object Merge. The user has to reference some output nodes in this containers. I thought that it would be useful to do some encapsulation (like in Object-Oriented Programming) to allow user to reference only several "public" nodes inside this asset, and make other nodes "private". Is there any way to do such encapsulation?
  5. Hello, guys. While developing some complex operators in HDK I realized that defining lots of parameters becomes a bit tedious and routine task. So I decided to simplify this using C++ templates, and that's what I want to share. All you need is to define these parameters inside newSopOperator() function. Here's how it looks like: void newSopOperator(OP_OperatorTable *table) { PRM_LIST_START(myTemplateList); PRM_FLT(flt, "FLT", 0.01); PRM_INT(integer, "INT", 3); PRM_TOGGLE(toggle, "TOGGLE", ON); PRM_STRING(string, "STRING", "Hello, World!"); PRM_FLT2(flt2, "FLT2", 0.01, 0.02); PRM_FLT3(flt3, "FLT3", 0.01, 0.02, 0.03); PRM_XYZ(xyz, "XYZ", 0.01, 0.02, 0.03); PRM_RGB(rgb, "RGB", 0.3, 0.15, 0.85); PRM_UVW(uvw, "UVW", 1, 0.5, 0); PRM_BUTTON(btn, "Button", callback); PRM_LIST_END(); table->addOperator( new OP_Operator("hdkParmsDemo", "HDK Parms Demo", SOP_HDKParmsDemo::myConstructor, myTemplateList, 0, // Min # of sources 0, // Max # of sources 0) ); } The same easy thing is about reading: // Automatically create variables with parameter names READ_FLT(flt); // double flt; READ_INT(integer); // int integer; READ_TOGGLE(toggle); // bool toggle; READ_STRING(string); // UT_String string; READ_VEC2(flt2); // UT_Vector2 flt2; READ_VEC3(flt3); // UT_Vector3 flt3; Header and sample SOP are attached in the archive. Would appreciate your feedback HDK_Parms.zip
  6. Hello everyone! Inspired by this topic (http://forums.odforce.net/topic/12691-closest-point-on-the-primitive/) I've been trying to implement HDK function similar to VEX xyzdist using GU_RayIntersect class and its minumumPoint() method .Unfortunately, it always gives me zero values for uv. Tried it with different objects, no luck. Does anyone know how to make it right? OP_ERROR SOP_xyzdist::cookMySop(OP_Context &context) { if (lockInputs(context) >= UT_ERROR_ABORT) return error(); duplicateSource(0, context); UT_Vector3 pos(0,0,0); // just for testing GA_PrimitiveGroup* grp = 0; // Searching the whole geometry, I suppose GU_MinInfo mininfo(0, 100000, 1); GU_RayIntersect near(gdp, grp, 1); near.minimumPoint(pos, mininfo); float u = mininfo.u1; float v = mininfo.v1; std::cout << u << " " << v << std::endl; unlockInputs(); return error(); }
  7. Thanks for your interest, but my tool is a property of the studio that I work in, so I can't show much. But I'd like to share some ideas and concepts during the WIP.
  8. There are two possible reasons why your code might crash. First is that your code doesn't allocate memory for sphere_bbox variable, and the second is that no checking is done to determine if the prim is actually an instance of GEO_PrimSphere class. And, by the way, calling the castTo() function does not work here. Can't tell exactly why, but it gives strange values. Maybe the call to this function destroys the information about the sphere itself, leaving only the basic data that belongs to GU_Primitive class? Would be interesting if someone more experienced explained this behavour. So, the following code should work fine: GEO_Primitive *prim; GA_FOR_ALL_PRIMITIVES(gdp, prim) { if (prim->getTypeId().get() != GA_PRIMSPHERE) continue; UT_BoundingBox *bb = new UT_BoundingBox(); GEO_PrimSphere *ss=(GEO_PrimSphere*)prim; ss->getBBox(bb); }
  9. Yes, the brush selection mode would be a good choice where selection has to be dene before the actual brush editing. But in my case I have to select only the area that is currently under the brush. Yes, Edward, that's exactly what I've done. I takе the Stroke SOP, collect stroke_dir and stroke_origin attributes, and find the distances from the stroke ray to the points of my geometry, then filter these points by this distance. Then, the brush influence is calculated as a distance function from any given point to the stroke ray. The problem was that I implemented this algorithm in Python and it was too slow, so I tried to find an other solution. Now I've ported it to HDK and it works really fast.
  10. Alexey, thank you! I've posted a little comment on your channel)
  11. Alexey, my solution is to use origin and ray vectors and then iterate over the primitive's vertices to find minimal distance to the ray. Here is my code: def getN(point, orig, dir): pos = point.position() OP = pos - orig proj = OP.dot(dir) n = OP - proj * dir return n def nearestPrimPoint(prim, orig, dir): minD = float('inf') nearestPoint = prim.vertices()[0].point() for v in prim.vertices(): P = v.point() N = getN(P, orig, dir) D = N.length() if D < minD: minD = D nearestPoint = P return nearestPoint So you can pass the direction and position vectors to this function.
  12. Alexey, thanks for your reply! That's exactly what I needed, but as I expected, it works too slow, so I can't interactively query primitives when the brush radius is larger than approximately 5 pixels. Here is my code (I use a square brush for simplicity): def getPrimsUnderBrush(xy, rad): view = toolutils.sceneViewer().curViewport() xc = xy[0] yc = xy[1] for x in range(xc - rad, xc + rad): for y in range(yc - rad, yc + rad): node = view.queryNodeAtPixel(x, y) prim = view.queryPrimAtPixel(node, x, y)
  13. Thanks to this, http://odforce.net/wiki/doku.php?id=viewers I found that there is a method selectPositions in hou.SceneViewer class, which prompts a selection and returns a position in a given space (Screen, viewport XY and UV). So, the code might be: import toolutils pos = toolutils.sceneViewer().selectPositions(position_type=hou.positionType.ViewportXY) x = pos[0] y = pos[1] Unfortunately, it is not very suitable to use as a brush since it requires a click and cannot be used in an event loop with hou.ui.addEventLoopCallback() function. Still searching for a better solution. Will try to search into HDK.
×
×
  • Create New...