Personal tools

HDKNotebook

From Odwiki

Jump to: navigation, search


A loose collection of tips, tricks, and assorted gotchas.
These should get categorized at some point as the number grows, but I'm starting it as a plain list for now

Contents


[edit] Tip: VRAY_Procedural

The sample code for writing a Mantra procedural that ships with version 7.x is a little confusing. Specifically, it's hard to determine exactly how the command line passed to the initialize function relates to the Houdini settings. The following is an excerpt from an odForce thread that attempted to clear up the issue:

  1. The syntax for the ray_procedural IFD command seems to be something like
    ray_procedural <params> procedural_command_line
    And at least two of the valid params are '-m' (lower bound) and '-M' (upper bound). These will typically get inserted by Houdini, not the user.
  2. Due to #1, the parameters -m and -M are for the ray_procedural command's eyes only, *not* the procedural itself. IOW, they are invisible to the procedural as they get consumed by Mantra before the procedural gets called.
  3. The sample must be outdated since given #1 and #2, I don't think there would ever be a case where the test
    if (args.found('m') && args.found('M')) {/*...*/}
    would ever evaluate to true (unless the procedural itself coincidentally used those parameters).
  4. In the event that the user *does* define a bounding box for the procedural (via either Render>Geometry>Procedural (explicit bounds) or Render>Geometry>Procedural (render SOP bounds)), this bounding box is made available to the procedural's initialize() function through its third parameter (which is ignored in the sample). So this is the mechanism made available to get at the user-defined bounding box.
To test the above, the example's inintialize function was changed to the following:
int VRAY_DemoBox::initialize(int argc, char *argv[], const UT_BoundingBox *usrbox) {
 for(unsigned i=0;i<argc;i++) std::cerr<<"ARG["<<i<<"]: "<<argv[i]<<"\n";
  if(usrbox) {
     std::cerr<<"UserBounds: "<<(*usrbox)<<"\n";
     myBox = *usrbox;
  } else {
     myBox.initBounds(-1,-1,-1);
     myBox.enlargeBounds(1,1,1);
  }
  return 1;
}