HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
RAY_Procedural.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * NAME: RAY_Procedural.h ( RAY Library, C++)
7  *
8  * COMMENTS: RAY Procedural Primitive
9  *
10  * This primitive is used to generate procedural geometry during the
11  * rendering process.
12  *
13  * The procedural primitive can generate further procedural primitives, or
14  * as a leaf node, generate a GU_Detail.
15  *
16  * Shaders for the geometry are inherited from the instance of the detail
17  * unless additional shaders are specified using the vm_surface or
18  * vm_displace attributes.
19  */
20 
21 #ifndef __RAY_Procedural__
22 #define __RAY_Procedural__
23 
24 #include "RAY_API.h"
25 #include <SYS/SYS_Types.h>
26 #include <GA/GA_Handle.h>
27 #include <GU/GU_DetailHandle.h>
28 #include <UT/UT_BoundingBox.h>
29 #include <UT/UT_String.h>
30 #include <UT/UT_StringHolder.h>
31 #include <UT/UT_SharedPtr.h>
32 #include <UT/UT_IntrusivePtr.h>
33 
34 class UT_Options;
35 class GU_Detail;
36 class GEO_Detail;
37 class GEO_Primitive;
38 class GA_Attribute;
39 class ray_ProcInstance;
40 class RAY_Procedural;
41 class RAY_ProceduralArg;
42 class VGEO_Volume;
43 class STY_Styler;
44 class RAY_StylerInfo;
45 class RAY_ProceduralData;
46 class RAY_PackedQuery;
48 
49 /// @brief Mantra procedural primitives
50 ///
51 /// When a procedural is defined as a dynamic object, the allocProcedural()
52 /// function is called to build a new instance of the procedural. The name
53 /// passed in will be the name defined by the table entry. This can be used
54 /// for:
55 /// a) Error checking -- you can verify that you're name is what you
56 /// expect. However, this isn't mandatory.
57 /// b) To have more than one procedural defined per C++ class. Using
58 /// the name, you can create procedurals of different types.
59 ///
60 /// The argument list for the procedural is specified by a list of arguments.
61 /// The getProceduralArgs() method should return a pointer to an array of
62 /// RAY_ProceduralArg's. The list should be terminated by an entry with
63 /// default arguments (i.e. null pointers). For example:
64 /// Arguments can then be queried using the argValue() methods in the procedural
65 ///
66 extern "C" {
67  /// Dynamic load entry point to create an instance
69  /// Dynamic load entry point to query arguments for a procedural
71 
72  /// Modern interface to register procedurals
74  RAY_ProceduralFactory *factory);
75 }
76 
77 /// @brief Aliases for different handle types
78 
79 /// A generic handle that can be used by RAY_Procedural::import and
80 /// RAY_Procedural::importAll.
81 typedef void *RAY_Handle;
82 
83 /// A handle for objects. Can also be used anywhere a RAY_Handle is expected.
84 typedef void *RAY_ObjectHandle;
85 
86 /// A handle for materials. Can also be used anywhere a RAY_Handle is expected.
87 typedef void *RAY_MaterialHandle;
88 
89 /// A handle for lights. Can also be used anywhere a RAY_Handle is expected.
90 typedef void *RAY_LightHandle;
91 
92 /// @brief Parameter definition for arguments to RAY_Procedural
93 ///
94 /// Each RAY_Procedural has its arguments defined by a table of
95 /// RAY_ProceduralArg objects. The procedural can query the value of these
96 /// parameters using RAY_Procedural::import() at run time (without having to
97 /// parse argument lists). The list of arguments should be terminated by an
98 /// entry constructed with default arguments. For example:
99 /// @code
100 /// static RAY_ProceduralArg theArgs[] = {
101 /// RAY_ProceduralArg("intarg", "int", "0" ),
102 /// RAY_ProceduralArg("realarg", "real", "3.1415" ),
103 /// RAY_ProceduralArg("stringarg", "string", "foo bar" ),
104 /// RAY_ProceduralArg("vectorarg", "real", "1 2 3" ),
105 /// RAY_ProceduralArg()
106 /// }
107 /// const RAY_ProceduralArg *getProceduralArgs() { return theArgs; }
108 /// @endcode
110 {
111 public:
112  /// @param name @n The name of the parameter (must be unique)
113  /// @param type @n
114  /// The storage type of the parameter. This should be one of
115  /// - @c int = Integer
116  /// - @c real = Floating point (fpreal) value
117  /// - @c string = String value
118  /// @param value @n A @b string representing the default values for the
119  /// argument. For @c int and @c real types, the string is tokenized and
120  /// the number of tokens in the trin determines the vector/tuple size of
121  /// the argument. For example @code
122  /// RAY_ProceduralArg("a", "int", "1 2 3 4")
123  /// @endcode
124  /// would specify a parameter named "a" which consists of 4 integers,
125  /// and has a default value of {1,2,3,4}. @n
126  /// For string types, the vector size is always 1, and the string is
127  /// used as the default value.
128  ///
129  /// @warning The procedural keeps shallow references to the
130  /// <tt>const char *</tt> passed in.
131  RAY_ProceduralArg(const char *name=0, const char *type=0,
132  const char *value=0)
133  {
134  myName = name;
135  myType = type;
136  myValue = value;
137  }
139  {
140  }
141 
142  /// Return the name of the argument
143  const char *getName() const { return myName; }
144  /// Return the storage type of the argument
145  const char *getType() const { return myType; }
146  /// Return the default value
147  const char *getValue() const { return myValue; }
148 
149 private:
150  const char *myName;
151  const char *myType;
152  const char *myValue;
153 };
154 
155 class RAY_ProceduralGeo;
156 
157 /// @brief Reference counted geometry handle for procedurals
158 ///
159 /// Mantra has internal reference counted "smart" pointers for geometry.
160 /// The interface for managing these reference counts manually
161 /// (referenceGeometry()/freeGeometry() was obfuscated and is now deprecated
162 /// in favour of using the VGEO_ProceduralGeo class).
163 ///
164 /// The @c RAY_ROProceduralGeo provides a read-only handle to geometry. This
165 /// is typically used to access geometry that exists in mantra already (i.e.
166 /// geometry returned by <tt>queryGeometry()</tt>).
167 ///
168 /// @c RAY_ProceduralGeo is a read-write handle on mantra geometry.
169 ///
170 /// Each geometry object can have multiple deformation segments.
172 {
173 public:
175 
176  /// Copy c-tor
178  /// Destructor
179  virtual ~RAY_ROProceduralGeo();
180 
181  RAY_ROProceduralGeo& operator=(const RAY_ROProceduralGeo &src);
182 
183  /// Clear the geometry
184  void clear();
185 
186  /// @{
187  /// Equivalence
188  bool operator==(const RAY_ROProceduralGeo &g) const
189  { return get() == g.get(); }
190  bool operator!=(const RAY_ROProceduralGeo &g) const
191  { return get() != g.get(); }
192  /// @}
193 
194  /// @{
195  /// Standard "pointer" operations
196  const GU_Detail *operator->() const { return get(); }
197  const GU_Detail &operator*() const { return *get(); }
198  const GU_Detail *get(int segment=0) const;
199  /// @}
200 
201  /// Access the GU_ConstDetailHandle for a given segment
202  GU_ConstDetailHandle handle(int segment=0) const;
203 
204  /// Test validity
205  bool isValid() const;
206 
207  /// Bool operator on handle
208  SYS_SAFE_BOOL operator bool() const { return isValid(); }
209 
210  /// Return the maximum velocity displacement (so bounding boxes can be
211  /// computed).
212  fpreal velocityBounds() const;
213 
214  /// Return the number of motion segments
215  int motionSegments() const;
216 
217  /// Return reference count on the underlying geometry
218  int getRef() const;
219 
220 protected:
221  friend class RAY_Procedural;
222  friend class RAY_ProceduralChild;
223  class Data;
224 
225  /// @{
226  /// Create a read handle with a geometry.
227  /// @note This method will fail if the handle isn't currently empty
228  bool setGeometry(const GU_ConstDetailHandle &gdh);
229  bool setGeometry(const GU_ConstDetailHandle *gdh, int nsegments);
230  /// @}
231 
232  // Internal method to create read-only geometry from a procedural
234  bool writeable);
236  const GU_ConstDetailHandle *gdh,
237  int nsegments,
238  const fpreal *shutter_times,
239  bool writeable);
240 
242 };
243 
244 /// RAY_ProceduralGeo is a read-write handle on mantra's geometry.
245 ///
246 /// You can create these handles by calling RAY_Procedural::createGeometry()
247 /// and then access the underlying GU_Detail, creating or manipulating
248 /// geometry.
249 ///
250 /// It's also possible to add motion segments to the geometry in one of three
251 /// ways:
252 /// - Pass in a reference to another VGEO_ROProceduralGeo object. This
253 /// will add a motion segment, capturing transform changes on quadric and
254 /// packed primitives as well as motion of points.
255 /// - You can add a "motion segment" attribute. This method returns an
256 /// attribute which you can fill out for the given segment. This method
257 /// is fine in most cases, but doesn't caputre transforms on primitives.
258 /// - Compute velocity blur.
260 {
261 public:
262  /// Default constructor
264 
265  /// Copy c-tor
267  : RAY_ROProceduralGeo(src)
268  {
269  }
270  /// Destructor
272 
274  {
276  return *this;
277  }
278 
279  /// @{
280  /// Standard "pointer" operations
281  GU_Detail *operator->() const { return get(); }
282  GU_Detail &operator*() const { return *get(); }
283  GU_Detail *get(int segment=0) const;
284  /// @}
285 
286  /// Access the geometry using a GU_DetailHandle. If the geometry is
287  /// locked, this method will return an invalid handle. The geometry will
288  /// be locked if it's already been passed to mantra.
289  GU_DetailHandle handle(int segment=0) const;
290 
291  /// Set the geometry for the first motion segment. This method will fail if
292  /// there are any motion segments already. This will delete any geometry
293  /// already assigned to the object.
294  bool setHandle(GU_ConstDetailHandle &gdh);
295 
296  /// Set the shutter start value. This should be set @b before any motion
297  /// segments are added to the geometry. The default shutter open is 0.
298  void setShutterOpen(fpreal shutter);
299 
300  /// Append a motion segment.
301  ///
302  /// The shutter times for all segments should be sequential and added in
303  /// increasing order. A warning will be printed if the segments are added
304  /// out of order.
305  ///
306  /// The method will return an invalid GU_DetailHandle if the geometry has
307  /// been locked (passed to mantra).
308  GU_DetailHandle appendSegmentGeometry(fpreal shutter);
309 
310  /// Remove a motion segment that was added with appendSegmentGeometry()
311  ///
312  /// The method will return an invalid GU_DetailHandle if the geometry has
313  /// been locked (passed to mantra).
314  bool removeSegmentGeometry(const GU_ConstDetailHandle &geo);
315 
316  /// Add a motion segment for the given attribute. This returns the motion
317  /// segment. Note that adding motion segments this way doesn't capture
318  /// per-primitive transforms (i.e. quadrics, packed primitives, etc.)
319  ///
320  /// The shutter times for all segments should be sequential and added in
321  /// increasing order. A warning will be printed if the segments are added
322  /// out of order.
323  ///
324  /// The method will return a @c nullptr if the geometry has been locked
325  /// (passed to mantra).
326  ///
327  /// This method may return a "detached" attribute. The method should be
328  /// called @b after the original geometry attributes have been created so
329  /// the length of the segment attribute is the correct length.
330  GA_Attribute *appendSegmentAttribute(fpreal shutter,
331  const char *name="P");
332 
333  /// Add motion blur based on the velocity attribute. This returns the
334  /// maximum velocity displacement (for bounding box computation). The
335  /// displacement is cached and can be retrieved by calling @c
336  /// velocityBounds().
337  ///
338  /// The method will returns -1 if the geometry has been locked (passed to
339  /// mantra). This should be considered an error.
340  fpreal addVelocityBlur(fpreal pre_blur, fpreal post_blur,
341  const UT_StringHolder &velocity_attribute
342  = UTmakeUnsafeRef("v"));
343 
344  /// @{
345  /// Change a geometry setting:
346  /// - <tt>changeSetting(const char *name, int argc, char **argv)</tt>
347  /// - <tt>changeSetting(const char *name, int argc, int *argv)</tt>
348  /// - <tt>changeSetting(const char *name, int argc, fpreal *argv)</tt>
349  /// If the setting specified by "name" isn't found, the function will fail
350  /// (return false).
351  ///
352  /// Some settings which can be changed on geometry include:
353  /// - "timescale": The time scale for velocity motion blur
354  /// - "segmentattrs": The attributes to keep on motion segments
355  /// - "volumevelocitynames": Names for velocity attributes on volume prims
356  bool changeSetting(const UT_StringRef &name,
357  int argc, const char *const*argv);
358  bool changeSetting(const UT_StringRef &name,
359  int argc, const int *argv);
360  bool changeSetting(const UT_StringRef &name,
361  int argc, const fpreal *argv);
362  /// @}
363 
364 private:
365  /// Create new geometry for a procedural. Internal method.
368  const GU_ConstDetailHandle *geo,
369  int nsegments,
370  const fpreal *shutter_times,
371  bool writeable);
372 
373  friend class RAY_Procedural;
374  friend class RAY_ProceduralChild;
375 };
376 
377 /// Simple struct to capture the standard attributes for material
378 /// specifications on procedural geometry.
380 {
387 };
388 
389 /// @brief Class representing a child object of the current procedural
390 ///
391 /// When a RAY_Procedural is rendered, the procedural can create child
392 /// geometry objects, further procedurals, or even a mix of the two.
393 ///
394 /// When creating geometry to be rendered, the code would look something along
395 /// the lines of: @code
396 /// // Create geometry by loading geometry from disk.
397 /// RAY_ProceduralGeo geo = createGeometry();
398 /// geo->load("defgeo.bgeo");
399 ///
400 /// // Add the geometry to the render
401 /// RAY_ProceduralChildPtr obj = createChild();
402 /// obj->addGeometry(geo);
403 /// @endcode
404 ///
405 /// When adding further procedural children, the code might look something
406 /// like: @code
407 /// RAY_ProceduralChildPtr obj = createChild();
408 /// child->addProcedural(new procedural_subclass(parameters));
409 /// @endcode
410 ///
411 /// @note: RAY_ProceduralChildPtr's are thread safe. So, unlike the
412 /// deprecated addGeometry()/addProcedural() methods, multiple child objects
413 /// can be created in a threaded fashion within a render() method. @code
414 /// // Create geometry by loading geometry from disk.
415 /// RAY_ProceduralGeo geo = createGeometry();
416 /// geo->load("defgeo.bgeo");
417 ///
418 /// UTparallelFor(UT_BlockedRange<int>(0, 100),
419 /// [=](const UT_BlockedRange<int> &r)) {
420 /// for (auto it = r.begin(); it != r.end(); ++it) {
421 /// RAY_ProceduralChildPtr obj = createChild();
422 /// obj->addGeometry(geo);
423 /// }
424 /// }
425 /// @endcode
426 ///
427 /// See the HDK examples RAY_DemoMountain or RAY_DemoBox for concrete
428 /// examples.
430  : public UT_IntrusiveRefCounter<RAY_ProceduralChild>
431 {
432 public:
435 
436  /// Test whether the child is valid. This checks to see whether there's a
437  /// valid geometry, child procedural or a volume attached.
438  bool isValid() const;
439 
440  /// Bool operator on handle
441  SYS_SAFE_BOOL operator bool() const { return isValid(); }
442 
443  /// Return parent procedural
444  const RAY_Procedural *parent() const { return myParent; }
445 
446  /// Set the geometry for the child procedural. This is the preferred
447  /// interface for setting a child's geometry.
448  void addGeometry(const RAY_ROProceduralGeo &geo);
449 
450  /// Set a child procedural. There are two ways to add a procedural.
451  ///
452  /// The first process is to call with an argc/argv and an optional bounding
453  /// box. This invokes the standard mantra process of creating a procedural
454  /// object. Using this interface will cause the initialize() method to be
455  /// called on the created procedural. The creation status is returned.
456  bool addProcedural(int argc, char *argv[],
457  const UT_BoundingBox *box=0);
458  /// The second process for adding a procedural is to add the procedural
459  /// directly. Using this process bypasses the standard mantra
460  /// initialization proces (i.e. the initialize() virtual will not be
461  /// called). This can be used to add procedural objects which aren't
462  /// registered with mantra (i.e. private classes).
463  void addProcedural(RAY_Procedural *proc);
464 
465  /// Add a volume primitive to the currently open volume object. Volume
466  /// objects are reference counted, so if you need to keep a reference
467  /// to the volume after calling addVolume(), use the incref()/decref()
468  /// interface to retain a reference. An easy way to do this is to own
469  /// a UT_IntrusivePtr<VGEO_Volume> object. If you do not own a reference,
470  /// it's possible the VGEO_Volume pointer will be invalid after this call.
471  void addVolume(VGEO_Volume *volume, fpreal shutter);
472 
473  /// Transform the currently open object (geometry, procedural, volume) at
474  /// the shutter time specified. The transform is a pre-transform that
475  /// acts on the parent procedural's existing transform. This interface
476  /// should be used to achieve the expected parenting behavior for
477  /// procedurals, in which the transform is an object space transform
478  /// inside the parent space.
479  void setPreTransform(const UT_Matrix4D &transform, fpreal shutter);
480 
481  /// Assign new style sheet node to the currently open object.
482  /// Procedurals often prune the style sheet of entries that no longer
483  /// apply to the geometry hierarchy.
484  void setStylerInfo(const RAY_StylerInfo &styler_info);
485 
486  /// Transform the currently open object (geometry, procedural, volume) at
487  /// the shutter time specified. The transform is a post-transform that
488  /// acts on the parent procedural's existing transform. This method is
489  /// preferred when you need to change the world transform from within
490  /// the procedural. In most cases, setPreTransform() is preferred
491  /// over setTransform().
492  void setTransform(const UT_Matrix4D &transform, fpreal shutter);
493 
494  /// @{
495  /// Change any setting on the object (geometry, procedural, volume)
496  /// - <tt>changeSetting(const char *name, const char *value)</tt> @n
497  /// Parses the string into arguments and changes the setting If you want
498  /// to change a setting to a single string value, it is better to call:
499  /// changeSettings(name, 1, &value);
500  /// - <tt>changeSetting(const char *name, int argc, char **argv)</tt>
501  /// - <tt>changeSetting(const char *name, int argc, int *argv)</tt>
502  /// - <tt>changeSetting(const char *name, int argc, fpreal *argv)</tt>
503  /// If the setting specified by "name" isn't found, the function will fail
504  /// (return false).
505  bool changeSetting(const char *name, const char *value,
506  const char *style = "object");
507  bool changeSetting(const char *name, int argc,
508  const char *const*argv,
509  const char *style = "object");
510  bool changeSetting(const char *name, int argc, const int *argv,
511  const char *style = "object");
512  bool changeSetting(const char *name, int argc, const fpreal *argv,
513  const char *style = "object");
514  /// @}
515 
516  /// @{
517  /// It's possible to add new settings to a child object. These settings
518  /// can be accessed in shaders using the VEX renderstate() function.
519  ///
520  /// It is illegal to:
521  /// - redefine a built-in property
522  /// - change the type of an existing property
523  /// - change the tuple size of an existing property
524  ///
525  /// This is equivalent to the ray_declare command in IFDs.
526  bool declareSetting(const char *name, const char *value);
527  bool declareSetting(const char *name, int argc,
528  const char *const*argv);
529  bool declareSetting(const char *name, int argc, const int *argv);
530  bool declareSetting(const char *name, int argc, const fpreal *argv);
531  /// @}
532 
533  /// Print out the object's settings to stderr
534  void debugSettings(const char *style="object") const;
535 
536  /// Convenience method that declares settings for all attributes associated
537  /// with a given primitive, including the corresponding vertices, points,
538  /// and parent detail. This is primarily used for packed primitives.
539  /// The name of the setting will be the same as the attribute name prefixed
540  /// with the given prefix.
541  SYS_DEPRECATED_REPLACE(16.0, setPackedQuery)
542  void declarePrimitiveAttributeSettings(
543  const GEO_Primitive &prim,
544  const char *prefix);
545 
546  /// Calling @c setShopMaterialPath() will simulate adding the
547  /// "shop_materialpath" and optionally the "material_override" and
548  /// attributes on the geometry.
549  /// This must be called after the @c openGeometryObject() and
550  /// before the corresponding @c closeObject() calls.
551  /// The @c property_map string is used to map the Houdini parameter names
552  /// in the @c material_override string to mantra property names. Without
553  /// this map, properties will not be overridden properly.
554  bool setShopMaterialPath(const char *shop_materialpath,
555  const char *material_override=nullptr,
556  const char *property_map=nullptr);
557 
558  /// Convenience method to check for the following attributes on a primitive
559  /// This method will check for the following attributes:
560  /// - shop_materialpath
561  /// - material_override
562  /// - property_override
563  /// - lightcategories
564  /// - lightmask
565  /// - categories
566  /// @{
567  void processPrimitiveMaterial(const GEO_Primitive *prim);
568 
569  /// This version takes a set of cached attributes for faster processing.
570  void processPrimitiveMaterial(
571  const GEO_Primitive *prim,
573  /// @}
574 
575  /// This function has no implementation in H16.0 and beyond.
576  /// Please use @c setPackedQuery();
577  SYS_DEPRECATED_REPLACE(16.0, setPackedQuery)
578  void declarePackedPrimRenderStateSetting(const GEO_Primitive &)
579  { return; }
580 
581  /// Set the packed query lookup for this procedural. This method takes
582  /// ownership of the query passed in.
583  void setPackedQuery(RAY_PackedQuery *q);
584 
585  /// @{
586  /// @private
587  /// Only called by RAY_Procedural
588  ray_ProcInstance *handle() { return myHandle; }
589  /// @}
590 
591 private:
592  RAY_Procedural *myParent;
593  ray_ProcInstance *myHandle;
594 };
595 
597 
598 /// @brief Procedural primitive for mantra (RAY)
599 ///
600 /// The RAY_Procedural class provides a means to create procedural geometry
601 /// during the rendering process.
603 {
604 public:
605  RAY_Procedural();
606  virtual ~RAY_Procedural();
607 
608  /// The class name is used in diagnostic messages. It can simply be the
609  /// name of the class, or alternatively, you can choose a unique name for
610  /// each procedural instance.
611  virtual const char *className() const = 0;
612 
613  /// The initialize method is called when the procedural is created.
614  /// Returning zero (failure) will abort the rendering of this procedural.
615  ///
616  /// The bounding box passed in is the user defined bounding box. If the
617  /// user didn't specify a bounding box, then the box will be NULL.
618  virtual int initialize(const UT_BoundingBox *box) = 0;
619 
620  /// The bounding box is the "object space" bounds of the procedural.
621  virtual void getBoundingBox(UT_BoundingBox &box) = 0;
622 
623  /// The render method is called when the procedural is required to either
624  /// generate geometry or split into more procedurals. Inside the
625  /// render() method you should make calls to open/add/close geometry or
626  /// sub-procedurals.
627  ///
628  /// The way that a procedural splits is critical to the performance of
629  /// mantra's ray tracer. For optimal performance, make sure that
630  /// sub-procedural bounding boxes overlap as little as possible - which
631  /// allows mantra to build more optimal trees for ray tracing.
632  ///
633  /// In multi-threaded renders, the render() method needs to be reentrant
634  /// - that is, the render() method on different RAY_Procedural objects
635  /// may be called simultaneously by different threads. This means that
636  /// you should design the code in your procedural such that global data
637  /// structures are protected by a thread lock (for example, a UT_Lock).
638  /// @note The render method may be called more than once during a render to
639  /// regenerate the geometry.
640  virtual void render() = 0;
641 
642  /// Called by IPR so that the procedural can determine whether it is
643  /// equal to the updated procedural. This is useful if the procedural
644  /// is dependent on object properties other than the its arguments.
645  virtual bool isEqual( const RAY_Procedural *) const { return true; }
646 
647 
648  /// This is a stop-gap measure to help improve LOD computation when the
649  /// procedural generates multiple instances of the same underlying
650  /// geometry. If this method returns false, the procedural will not be
651  /// processed when flattenprocedural is set.
652  virtual bool canGenerateInstancedGeometry() const { return false; }
653 
654  /// The getParm() methods evaluate parameters attached to the procedural.
655  /// The lookup may be performed by name or by token. Each parameter has a
656  /// unique token associated with it. The token lookup methods are more
657  /// efficient than the name lookups and should be almost as efficient as
658  /// accessing member data.
659 
660  /// Parameters to the procedural are stored as a list of RAY_ProceduralArg
661  /// objects. Each parameter is given a unique integer. This allows for
662  /// more efficient evaluation (avoiding comparing strings).
663  int lookupParmToken(const char *name) const;
664 
665  /// @{
666  /// Get the raw data pointers for a parameter by either name or value.
667  /// These functions return the size of the array in @c size, and will fail
668  /// if the type requested doesn't match the storage type.
669  /// @see import()
670  ///
671  const int64 *getIParm(int token, size_t &size) const;
672  const fpreal *getFParm(int token, size_t &size) const;
673  const UT_StringHolder *getSParm(int token, size_t &size) const;
674 
675  const int64 *getIParm(const char *name, size_t &size) const
676  {
677  auto &&id = lookupParmToken(name);
678  return id >= 0 ? getIParm(id, size) : nullptr;
679  }
680  const fpreal *getFParm(const char *name, size_t &size) const
681  {
682  auto &&id = lookupParmToken(name);
683  return id >= 0 ? getFParm(id, size) : nullptr;
684  }
685  const UT_StringHolder *getSParm(const char *name, size_t &size) const
686  {
687  auto &&id = lookupParmToken(name);
688  return id >= 0 ? getSParm(id, size) : nullptr;
689  }
690  /// @}
691 
692  /// @{
693  /// The import functions can be used as a general purpose query mechanism.
694  /// This will import values from:
695  /// - The argument list for the procedural
696  /// - The argument list for the object defining the procedural
697  /// - A global rendering setting.
698  /// Aside from a parameter name, the name could be "object:name",
699  /// "object:shadingquality", "camera:pixelaspect", or any of the other
700  /// setting defined in mantra.
701  bool import(const char *name, int32 *value, int vectorsize) const;
702  bool import(const char *name, int64 *value, int vectorsize) const;
703  bool import(const char *name, fpreal32 *value, int vectorsize) const;
704  bool import(const char *name, fpreal64 *value, int vectorsize) const;
705  SYS_DEPRECATED(16.0) bool import(const char *name, UT_String &result, int idx=0) const;
706  bool import(const char *name, UT_StringHolder &result, int idx=0) const;
707  /// @}
708 
709  /// @{
710  /// If you've opened a handle using queryObject(), queryLight() or
711  /// queryMaterial(), it's possible to query the settings of that object.
712  /// This makes it possible to query the parameters/values/settings of other
713  /// objects in the scene.
714  bool import(RAY_Handle handle, const char *name,
715  int32 *value, int vectorsize) const;
716  bool import(RAY_Handle handle, const char *name,
717  int64 *value, int vectorsize) const;
718  bool import(RAY_Handle handle, const char *name,
719  fpreal32 *value, int vectorsize) const;
720  bool import(RAY_Handle handle, const char *name,
721  fpreal64 *value, int vectorsize) const;
722  SYS_DEPRECATED(16.0) bool import(RAY_Handle handle, const char *name,
723  UT_String &result, int idx = 0) const;
724  bool import(RAY_Handle handle, const char *name,
725  UT_StringHolder &result, int idx = 0) const;
726 
727  /// Using a handle, import all settings on the object. By default this
728  /// includes settings at default values. However, by setting local_only
729  /// to true, it's possible to query only values from the handle that were
730  /// explicitly set on that object/light/material.
731  bool importAll(RAY_Handle handle, UT_Options &settings,
732  bool local_only = false) const;
733  /// @}
734 
735  /// Allocate geometry for this procedural
736  RAY_ProceduralGeo createGeometry() const
737  {
738  return RAY_ProceduralGeo(SYSconst_cast(this));
739  }
740 
741  /// When passed a GU_DetailHandle, mantra will run some internal
742  /// optimizations on the geometry. These include, but are not limited to:
743  /// - Optimizing layout of polygon soups
744  /// - Conversion of closed Bezier/NURBS curves
745  /// - Clearing DAGS on pasted surfaces
746  /// - Creation of the N attribute for smooth shading of polygons
747  /// However, when passed a GU_ConstDetailHandle, mantra assumes that it's
748  /// not allowed to alter the geometry and thus does not run these
749  /// optimizations. Some of these "optimizations" will change behaviour
750  /// (i.e. without optimization, closed Bezier/NURBS will not render). This
751  /// hook allows you to run the internal optimizations on the geometry
752  /// before passing the GU_ConstDetailHandle to mantra.
753  /// This is typically called: @code
754  /// int computeN;
755  /// if (!import("geometry:computeN", &computeN, 1))
756  /// computeN = 1;
757  /// optimizeGeometry(gdh, computeN != 0);
758  /// @endcode
759  static void optimizeGeometry(GU_Detail &gdp,
760  bool create_normals_if_needed);
761  static void optimizeGeometry(GU_DetailHandle &gdp,
762  bool create_normals_if_needed);
763 
764  /// @{
765  /// Allocate geometry given a GU_DetailHandle/GU_ConstDetailHandle
766  RAY_ROProceduralGeo createGeometry(GU_DetailHandle &gdh) const;
767  RAY_ROProceduralGeo createGeometry(GU_ConstDetailHandle &gdh) const;
768  /// @}
769 
770  /// @{
771  /// Allocate geometry given an array of GU_DetailHandle's, one for each
772  /// motion segment.
773  RAY_ROProceduralGeo createGeometry(const GU_DetailHandle *gdh,
774  int nsegments,
775  const fpreal *shutter_times=nullptr
776  ) const;
777  RAY_ROProceduralGeo createGeometry(const GU_ConstDetailHandle *gdh,
778  int nsegments,
779  const fpreal *shutter_times=nullptr
780  ) const;
781  /// @}
782 
783  /// @private: Forward declaration of handle map
784  class HandleMap;
785 
786  /// @{
787  /// @private: Access data internals
788  const RAY_ProceduralData *data() const { return myData; }
789  RAY_ProceduralData *data() { return myData; }
790  /// @}
791 
792 protected:
793  /// Query a geometry attribute segment for the given segment index.
794  /// For seg == 0, this method simply returns attr. For example: @code
795  /// const GA_Attribute *p1 = queryGeometrySegment(gdp->getP(), 1);
796  /// @endcode
797  const GA_Attribute *queryGeometrySegment(
798  const GA_Attribute *attr, int seg) const;
799 
800  /// Delete existing geometry segments and prepare the detail for
801  /// addition of new motion blur segments. This method can be useful if
802  /// you want to reuse geometry between renders but change the motion
803  /// blur. Do not call this method on geometry that has already been
804  /// added to the current render.
805  void clearGeometrySegments(GA_Attribute *attr);
806 
807  // The following methods are now obsolete. The settings/flags should be
808  // set by calling changeSetting()
809  // - setGeometryFlag()
810  // - copyGeometryFlags()
811 
812  /// This method allows you to compute the level of detail (LOD) of an
813  /// arbitrary bounding box. The LOD indicates the rough screen space
814  /// size of the bounding box, as an average projected length in
815  /// micropolygons.
816  ///
817  /// For example, if the box occupies 10 horizontal pixels and 20
818  /// vertical pixels, at a shading quality of 1.0 the LOD will be around
819  /// 15. At a shading quality of 2.0, the LOD would be around 30. If the
820  /// box surrounds the camera, the LOD will be clamped at a large
821  /// number.
822  fpreal getLevelOfDetail(const UT_BoundingBox &box) const;
823 
824  /// Create a child object. Each child can be operated upon in separate
825  /// threads. This allows a single procedural to create multiple child
826  /// objects in a threaded fashion.
828  {
829  return RAY_ProceduralChildPtr(
831  }
832 
833  /// When the render method is called, the procedural can add objects to
834  /// the scene. It is possible for the render() method to add multiple
835  /// objects.
836  ///
837  /// The process for adding a geometry object:
838  /// - open a geometry object (openGeometryObject())
839  /// - add geometry to the object (addGeometry())
840  /// - modify any settings (changeSetting())
841  /// - close the object (closeObject())
842  ///
843  /// The process for adding a new procedural is fairly similar:
844  /// - open a procedural object (openProcecuralObject())
845  /// - add procedural(s) to the object (addProcedural())
846  /// - modify any settings (changeSetting())
847  /// - close the object (closeObject())
848  ///
849  /// For a geometry object, deformation motion blur is done by adding
850  /// multiple geometry objects or by using appendGeometrySegment() to
851  /// append motion blur segments without allocating new GU_Detail
852  /// objects.
853  ///
854  /// If settings are not overridden by the procedural, they will be
855  /// inherited from the object defining the procedural.
856  ///
857  /// The shutter time should be between 0 and 1. Shutter values are
858  /// used to order the geometry objects added to the procedural, so that
859  /// the order of calls to addGeometry() will not affect the resulting
860  /// motion blur. Additionally, the distribution and offset of shutter
861  /// values are currently ignored. For example, shutters of (0, 0.9, 1)
862  /// and (0, 0.5, 1) will produce identical motion blur, as will
863  /// shutters of (0, 0.5) and (0.5, 1). The difference between the
864  /// largest and smallest shutter value will be used to scale the
865  /// positions of additional motion segments toward the initial
866  /// position. For example, if a shutter of (0, 0.4) is specified, with
867  /// P0 and P1 being points on the first and second segment, the
868  /// rendered motion end points will be P0 and P0+0.4*(P1-P0).
869  ///
870  /// The renderer assumes ownership of any geometry or procedurals written
871  /// to objects. Thus, the geometry and procedurals should not be free'd
872  /// by the user.
873  SYS_DEPRECATED(16.0) void openGeometryObject();
874 
875  /// Before adding the geometry, you can change @b geometry settings by
876  /// calling changeSettings(). For example, if you want to force
877  /// computation of N, you can call:
878  /// changeSetting("computeN", "true", "geometry");
879  /// This needs to be done @b BEFORE the addGeometry() call is made.
880  /// Object settings can be changed after the geometry has been added.
881  ///
882  /// @warning The @c addGeometry(GU_Detail *) method was originally
883  /// deprecated in H14.0, and you should seriously consider modernizing your
884  /// code. The current implementation looks like this and doesn't properly
885  /// handle motion blur (since the modern implementation stores motion
886  /// segments on the RAY_ProceduralGeo object): @code
887  /// void RAY_Procedural::addGeometry(GU_Detail *gdp, fpreal)
888  /// {
889  /// GU_DetailHandle gdh;
890  /// gdh.allocateAndSet(gdp, false); // User must delete gdp
891  /// myChild->addGeometry(createGeometry(gdh));
892  /// }
893  /// @endcode
894  SYS_DEPRECATED(16.0) void addGeometry(GU_Detail *gdp, fpreal shutter);
895 
896  /// Open a procedural object
897  SYS_DEPRECATED(16.0) int openProceduralObject();
898  /// Add a procedural to the opened procedural object. Use this method
899  /// when splitting a procedural into multiple sub-procedurals. This can
900  /// be useful when it would be prohibitive (memory-wise) to generate
901  /// geometry immediately, and allows mantra to delay generation of
902  /// geometry for the sub-procedural until its bounding box is hit.
903  ///
904  /// If you've allocated the procedural yourself, mantra assumes that the
905  /// procedural is fully initialized. The initialize() method will not be
906  /// called.
907  /// @see openProceduralObject()
908  SYS_DEPRECATED(16.0) void addProcedural(RAY_Procedural *proc);
909  /// Add a procedural the the opened procedural object. This method allows
910  /// you to create any registered procedural by passing @c argc and @c argv
911  /// arguments to initialize the procedural.
912  ///
913  /// When allocating a procedural with arguments, mantra will call the
914  /// initialize() method.
915  ///
916  /// @return 0 or 1 for failure/success
917  /// @see openProceduralObject()
918  SYS_DEPRECATED(16.0) int addProcedural(int argc, char *argv[],
919  const UT_BoundingBox *box=0);
920 
921  /// Open a volume object
922  SYS_DEPRECATED(16.0) void openVolumeObject();
923  /// Add a volume primitive to the currently open volume object. Volume
924  /// objects are reference counted, so if you need to keep a reference
925  /// to the volume after calling addVolume(), use the incref()/decref()
926  /// interface to retain a reference. An easy way to do this is to own
927  /// a UT_IntrusivePtr<VGEO_Volume> object .
928  SYS_DEPRECATED(16.0) void addVolume(VGEO_Volume *volume, fpreal shutter);
929 
930  /// Transform the currently open object (geometry, procedural, volume) at
931  /// the shutter time specified. The transform is a pre-transform that
932  /// acts on the parent procedural's existing transform. This interface
933  /// should be used to achieve the expected parenting behavior for
934  /// procedurals, in which the transform is an object space transform
935  /// inside the parent space.
936  SYS_DEPRECATED(16.0) void setPreTransform(const UT_Matrix4D &transform, fpreal shutter);
937 
938  /// Transform the currently open object (geometry, procedural, volume) at
939  /// the shutter time specified. The transform is a post-transform that
940  /// acts on the parent procedural's existing transform. This method is
941  /// preferred when you need to change the world transform from within
942  /// the procedural. In most cases, setPreTransform() is preferred
943  /// over setTransform().
944  SYS_DEPRECATED(16.0) void setTransform(const UT_Matrix4D &transform, fpreal shutter);
945 
946  /// Assign new style information to the currently open object.
947  /// Procedurals often prune the style sheet of entries that no longer
948  /// apply to the geometry hierarchy.
949  SYS_DEPRECATED(16.0) void setStylerInfo(const RAY_StylerInfo &styler_info);
950 
951  /// @{
952  /// Change any setting on the object (geometry, procedural, volume)
953  /// - <tt>changeSetting(const char *name, const char *value)</tt> @n
954  /// Parses the string into arguments and changes the setting If you want
955  /// to change a setting to a single string value, it is better to call:
956  /// changeSettings(name, 1, &value);
957  /// - <tt>changeSetting(const char *name, int argc, char **argv)</tt>
958  /// - <tt>changeSetting(const char *name, int argc, int *argv)</tt>
959  /// - <tt>changeSetting(const char *name, int argc, fpreal *argv)</tt>
960  /// If the setting specified by "name" isn't found, the function will fail
961  /// (return false).
962  SYS_DEPRECATED(16.0) bool changeSetting(const char *name, const char *value,
963  const char *style = "object")
964  {
965  if (!checkChild("changeSetting"))
966  return false;
967  return myChild->changeSetting(name, value, style);
968  }
969  SYS_DEPRECATED(16.0) bool changeSetting(const char *name, int argc,
970  const char *const*argv,
971  const char *style = "object")
972  {
973  if (!checkChild("changeSetting"))
974  return false;
975  return myChild->changeSetting(name, argc, argv, style);
976  }
977  SYS_DEPRECATED(16.0) bool changeSetting(const char *name, int argc, const int *argv,
978  const char *style = "object")
979  {
980  if (!checkChild("changeSetting"))
981  return false;
982  return myChild->changeSetting(name, argc, argv, style);
983  }
984  SYS_DEPRECATED(16.0) bool changeSetting(const char *name, int argc, const fpreal *argv,
985  const char *style = "object")
986  {
987  if (!checkChild("changeSetting"))
988  return false;
989  return myChild->changeSetting(name, argc, argv, style);
990  }
991  /// @}
992 
993  /// @{
994  /// Once an object is open for processing, it's possible to add settings
995  /// specifically for that individual object. These properties can be
996  /// accessed using the VEX renderstate() function.
997  ///
998  /// It is illegal to:
999  /// - redefine a built-in property
1000  /// - change the type of an existing property
1001  /// - change the tuple size of an existing property
1002  ///
1003  /// This is equivalent to the ray_declare command in IFDs.
1004  SYS_DEPRECATED(16.0) bool declareSetting(const char *name, const char *value)
1005  {
1006  if (!checkChild("declareSetting"))
1007  return false;
1008  return myChild->declareSetting(name, value);
1009  }
1010  SYS_DEPRECATED(16.0) bool declareSetting(const char *name, int argc,
1011  const char *const*argv)
1012  {
1013  if (!checkChild("declareSetting"))
1014  return false;
1015  return myChild->declareSetting(name, argc, argv);
1016  }
1017  SYS_DEPRECATED(16.0) bool declareSetting(const char *name, int argc, const int *argv)
1018  {
1019  if (!checkChild("declareSetting"))
1020  return false;
1021  return myChild->declareSetting(name, argc, argv);
1022  }
1023  SYS_DEPRECATED(16.0) bool declareSetting(const char *name, int argc, const fpreal *argv)
1024  {
1025  if (!checkChild("declareSetting"))
1026  return false;
1027  return myChild->declareSetting(name, argc, argv);
1028  }
1029  /// @}
1030 
1031  /// Calling @c setShopMaterialPath() will simulate adding the
1032  /// "shop_materialpath" and optionally the "material_override" and
1033  /// attributes on the geometry.
1034  /// This must be called after the @c openGeometryObject() and
1035  /// before the corresponding @c closeObject() calls.
1036  /// The @c property_map string is used to map the Houdini parameter names
1037  /// in the @c material_override string to mantra property names. Without
1038  /// this map, properties will not be overridden properly.
1039  SYS_DEPRECATED(16.0) bool setShopMaterialPath(
1040  const char *shop_materialpath,
1041  const char *material_override=nullptr,
1042  const char *property_map=nullptr);
1043 
1044  /// Print out the object's settings to stderr
1045  void debugSettings(const char *style="object") const;
1046 
1047  /// Cache the set of attributes to be used by
1048  /// RAY_ProceduralChild::processPrimitiveMaterial()
1049  static void lookupPrimitiveMaterialAttributes(
1050  const GEO_Detail &geo,
1052 
1053  /// Convenience method to check for the following attributes on a primitive
1054  /// This method will check for the following attributes:
1055  /// - shop_materialpath
1056  /// - material_override
1057  /// - property_override
1058  /// - lightcategories
1059  /// - lightmask
1060  /// - categories
1061  SYS_DEPRECATED(16.0) void processPrimitiveMaterial(const GEO_Primitive *prim);
1062 
1063  /// The following methods are for backwards compatibility and are
1064  /// simply wrappers around changeSettings().
1065  /// @private
1066  SYS_DEPRECATED(16.0) void setSurface(const char *shader, fpreal=0);
1067  /// @private
1068  SYS_DEPRECATED(16.0) void setDisplacement(const char *shader, fpreal=0);
1069  /// @private
1070  SYS_DEPRECATED(16.0) void setDisplacementBounds(fpreal bounds);
1071  /// @private
1072  SYS_DEPRECATED(16.0) void setComputeN(int value);
1073 
1074  /// After all geometry, procedurals, volumes have been added and all the
1075  /// attributes have been set, the object can be closed.
1076  SYS_DEPRECATED(16.0) void closeObject();
1077 
1078  /// Load materials from an IFD stream. This is the code used by the file
1079  /// procedural to load material definitions. Using this to load data other
1080  /// than material statements will likely cause bad things to happen.
1081  bool parseMaterialIFD(const char *filename);
1082 
1083 protected:
1084  /// Query the number of transform samples for the world.
1085  int queryWorldTransformSamples() const;
1086 
1087  /// Get the world transform.
1088  UT_Matrix4D queryWorldTransform(int sample) const;
1089 
1090  /// It is possible to query information about other objects in the scene to
1091  /// some extent. This is done using the following query methods.
1092 
1093  /// Find a handle to a given object in the scene. Note that for objects
1094  /// which are rendered using point instances, the object handle will be a
1095  /// single instance rather than all of the instances.
1096  ///
1097  /// If a null pointer is passed in for the name, then the object refers to
1098  /// the object containing this procedural. The object handle does not need
1099  /// to be closed.
1100  ///
1101  /// Note that the initialize() method on procedurals is called as the IFD
1102  /// is parsed, so not all objects may be available at this time (depending
1103  /// on the order of objects in the IFD). The render() method is called
1104  /// after the entire scene has been parsed, so other objects should be
1105  /// available at that point. You should always get a valid handle when
1106  /// querying your own object (passing an empty string for the name) in the
1107  /// initialize method.
1108  RAY_ObjectHandle queryObject(const char *name) const;
1109 
1110  /// Find a handle to a given material in the scene. The material handle does
1111  /// not need to be closed.
1112  RAY_MaterialHandle queryMaterial(const char *name) const;
1113 
1114  /// Find a handle to a given light in the scene. The light handle does
1115  /// not need to be closed.
1116  RAY_LightHandle queryLight(const char *name) const;
1117 
1118  //
1119  // Given an object handle, it is now possible to query information about
1120  // the object.
1121  //
1122 
1123  /// Query the number of transform samples for a given query object
1124  /// @see queryObject()
1125  int queryTransformSamples(RAY_Handle handle) const;
1126  /// Get the transform associated with an object in the scene
1127  /// @see queryObject()
1128  const UT_Matrix4D &queryTransform(RAY_Handle handle, int sample) const;
1129 
1130  /// Get the shading transform associated with an object in the scene
1131  /// @see queryObject()
1132  const UT_Matrix4D &queryShaderTransform(RAY_ObjectHandle handle,
1133  int sample) const;
1134 
1135  /// Get the style sheet associated with an object in the scene.
1136  /// @see queryObject()
1137  const STY_Styler &queryStyler(RAY_ObjectHandle handle) const;
1138 
1139  /// Find out the name of the object queried. This is useful when trying to
1140  /// find out which object the procedural belongs to (i.e. queryObject(0))
1141  /// @see queryObject()
1142  const char *queryName(RAY_Handle handle) const;
1143 
1144  /// @private Use queryName instead.
1145  const char *queryObjectName(RAY_Handle handle) const;
1146 
1147  /// Get the name of the object which owns this procedural.
1148  const char *queryRootName() const;
1149 
1150  /// Find out how many geometry samples associated with the object.
1151  /// @see queryObject()
1152  int queryGeometrySamples(RAY_ObjectHandle handle) const;
1153 
1154  /// Access the geometry from another object (or the geometry passed to this
1155  /// object in the IFD). This method will return all segments of geometry
1156  /// for the handle's object.
1157  RAY_ROProceduralGeo queryGeometry(RAY_ObjectHandle handle) const;
1158 
1159  /// Find out shader information about the object. This information is only
1160  /// roughly accurate since the object shaders may be overridden by geometry
1161  /// attributes. The shader information returned is the object level
1162  /// shaders. The shaders returned are simply the setting bound at the
1163  /// instance level (including arguments).
1164  /// @private: Use import()
1165  SYS_DEPRECATED(16.0) void querySurfaceShader(RAY_ObjectHandle handle,
1166  UT_String &shader) const
1167  {
1168  UT_StringHolder tmp;
1169  if (!import(handle, "object:surface", tmp, 0))
1170  tmp.clear();
1171  shader = tmp;
1172  }
1173  /// @private: Use import()
1174  SYS_DEPRECATED(16.0) void queryDisplacementShader(RAY_ObjectHandle h,
1175  UT_String &shader) const
1176  {
1177  UT_StringHolder tmp;
1178  if (!import(h, "object:displace", tmp, 0))
1179  tmp.clear();
1180  shader = tmp;
1181  }
1182  /// @private: Use import()
1183  SYS_DEPRECATED(16.0) fpreal queryDisplacementBounds(RAY_ObjectHandle handle)
1184  {
1185  fpreal dbound;
1186  if (!import(handle, "object:displacebound",
1187  &dbound, 1))
1188  dbound = 0;
1189  return dbound;
1190  }
1191  /// @private: Use import()
1192  SYS_DEPRECATED(16.0) int queryPhantom(RAY_ObjectHandle handle)
1193  {
1194  int phantom;
1195  if (!import(handle, "object:phantom", &phantom, 1))
1196  phantom = 0;
1197  return phantom;
1198  }
1199  /// @private: Use import()
1200  SYS_DEPRECATED(16.0) int queryReflectBounce(RAY_ObjectHandle handle)
1201  {
1202  int bounce;
1203  if (!import(handle, "object:reflectbounce", &bounce, 1))
1204  bounce = 0;
1205  return bounce;
1206  }
1207  /// @private: Use import()
1208  SYS_DEPRECATED(16.0) int queryRefractBounce(RAY_ObjectHandle handle)
1209  {
1210  int bounce;
1211  if (!import(handle, "object:refractbounce", &bounce, 1))
1212  bounce = 0;
1213  return bounce;
1214  }
1215  /// @private: Use import()
1216  SYS_DEPRECATED(16.0)
1217  void queryReflectScope(RAY_ObjectHandle handle, UT_String &mask)
1218  {
1219  UT_StringHolder tmp;
1220  if (!import(handle, "object:reflectmask", tmp, 0))
1221  tmp.clear();
1222  mask = tmp;
1223  }
1224  /// @private: Use import()
1225  SYS_DEPRECATED(16.0)
1226  void queryRefractScope(RAY_ObjectHandle handle, UT_String &mask)
1227  {
1228  UT_StringHolder tmp;
1229  if (!import(handle, "object:refractmask", tmp, 0))
1230  tmp.clear();
1231  mask = tmp;
1232  }
1233 
1234 private:
1235  RAY_ROProceduralGeo makeGeometry(const GU_ConstDetailHandle *gdh,
1236  int nsegments,
1237  const fpreal *shutter_times,
1238  bool writeable) const;
1239 
1240  template <typename T>
1241  bool importType(RAY_Handle handle, const char *name,
1242  T &value, int vectorsize) const;
1243 
1244  bool checkChild(const char *method) const;
1245  void processChild(RAY_ProceduralChild *kid);
1246 
1247 private:
1248  RAY_ProceduralData *myData;
1249  RAY_ProceduralChildPtr myChild;
1250  friend class RAY_ProceduralChild;
1251 };
1252 
1253 #endif
RAY_ProceduralData * data()
const char * getValue() const
Return the default value.
bool operator==(const RAY_ROProceduralGeo &g) const
Definition of a geometry attribute.
Definition: GA_Attribute.h:189
GU_ConstDetailHandle handle(int segment=0) const
Access the GU_ConstDetailHandle for a given segment.
const GU_Detail * operator->() const
#define SYS_DEPRECATED(__V__)
void * RAY_LightHandle
A handle for lights. Can also be used anywhere a RAY_Handle is expected.
virtual bool isEqual(const RAY_Procedural *) const
SYS_VISIBILITY_EXPORT RAY_Procedural * allocProcedural(const char *name)
Mantra procedural primitives.
#define SYS_VISIBILITY_EXPORT
Class representing a child object of the current procedural.
SYS_FORCE_INLINE void clear()
typedef void(APIENTRYP PFNGLCULLFACEPROC)(GLenum mode)
const RAY_Procedural * parent() const
Return parent procedural.
SYS_FORCE_INLINE T * SYSconst_cast(const T *foo)
Definition: SYS_Types.h:126
GLboolean GLboolean g
Definition: glcorearb.h:1221
Reference counted geometry handle for procedurals.
Base class for volume primitives in mantra.
Definition: VGEO_Volume.h:41
RAY_ProceduralGeo & operator=(const RAY_ProceduralGeo &src)
virtual bool canGenerateInstancedGeometry() const
Procedural primitive for mantra (RAY)
GLint GLuint mask
Definition: glcorearb.h:123
RAY_ProceduralArg(const char *name=0, const char *type=0, const char *value=0)
const char * getType() const
Return the storage type of the argument.
bool operator!=(const RAY_ROProceduralGeo &g) const
GU_Detail & operator*() const
A reference counter base class for use with UT_IntrusivePtr.
const UT_StringHolder * getSParm(const char *name, size_t &size) const
const GU_Detail & operator*() const
IFDmantra you can see code vm_image_mplay_direction endcode When SOHO starts a render
Definition: HDK_Image.dox:266
const char * getName() const
Return the name of the argument.
GLsizeiptr size
Definition: glcorearb.h:663
#define SYS_DEPRECATED_REPLACE(__V__, __R__)
long long int64
Definition: SYS_Types.h:106
GLdouble n
Definition: glcorearb.h:2007
void * RAY_ObjectHandle
A handle for objects. Can also be used anywhere a RAY_Handle is expected.
const fpreal * getFParm(const char *name, size_t &size) const
GA_API const UT_StringHolder material_override
void * RAY_Handle
Aliases for different handle types.
#define SYS_SAFE_BOOL
Definition: SYS_Compiler.h:56
double fpreal64
Definition: SYS_Types.h:191
SYS_FORCE_INLINE const UT_StringHolder & UTmakeUnsafeRef(const UT_StringRef &ref)
Convert a UT_StringRef into a UT_StringHolder that is a shallow reference.
int method
Definition: png.h:1924
GLboolean * data
Definition: glcorearb.h:130
OPENVDB_API void initialize()
Global registration of basic types.
Definition: logging.h:316
GLuint const GLchar * name
Definition: glcorearb.h:785
int int32
Definition: SYS_Types.h:34
const int64 * getIParm(const char *name, size_t &size) const
RAY_ProceduralChildPtr createChild() const
GA_API const UT_StringHolder transform
RAY_ProceduralGeo(const RAY_ProceduralGeo &src)
Copy c-tor.
Parameter definition for arguments to RAY_Procedural.
GLfloat GLfloat GLfloat GLfloat h
Definition: glcorearb.h:2001
GLuint shader
Definition: glcorearb.h:784
GLsizei const GLfloat * value
Definition: glcorearb.h:823
double fpreal
Definition: SYS_Types.h:269
A map of string to various well defined value types.
Definition: UT_Options.h:42
typedef int
Definition: png.h:1175
#define RAY_API
Definition: RAY_API.h:12
RAY_ROProceduralGeo & operator=(const RAY_ROProceduralGeo &src)
GU_Detail * operator->() const
SYS_VISIBILITY_EXPORT void registerProcedural(RAY_ProceduralFactory *factory)
Modern interface to register procedurals.
Definition: RAY_DemoBox.C:56
GLint GLint GLsizei GLint GLenum GLenum type
Definition: glcorearb.h:107
UT_IntrusivePtr< RAY_ProceduralChild > RAY_ProceduralChildPtr
SYS_VISIBILITY_EXPORT const RAY_ProceduralArg * getProceduralArgs(const char *n)
Dynamic load entry point to query arguments for a procedural.
const GU_Detail * get(int segment=0) const
#define const
Definition: zconf.h:214
Read-only handle for string attribute data.
Definition: GA_Handle.h:873
UT_SharedPtr< Data > myData
float fpreal32
Definition: SYS_Types.h:190
GA_API const UT_StringHolder shop_materialpath
RAY_ProceduralGeo()
Default constructor.
void * RAY_MaterialHandle
A handle for materials. Can also be used anywhere a RAY_Handle is expected.
GLenum src
Definition: glcorearb.h:1792