HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RAY_Procedural Class Referenceabstract

Procedural primitive for mantra (RAY) More...

#include <RAY_Procedural.h>

+ Inheritance diagram for RAY_Procedural:

Public Member Functions

 RAY_Procedural ()
 
virtual ~RAY_Procedural ()
 
virtual const char * className () const =0
 
virtual int initialize (const UT_BoundingBox *box)=0
 
virtual void getBoundingBox (UT_BoundingBox &box)=0
 The bounding box is the "object space" bounds of the procedural. More...
 
virtual void render ()=0
 
virtual bool isEqual (const RAY_Procedural *) const
 
virtual bool canGenerateInstancedGeometry () const
 
int lookupParmToken (const char *name) const
 
RAY_ProceduralGeo createGeometry () const
 Allocate geometry for this procedural. More...
 
const int64getIParm (int token, size_t &size) const
 
const fpreal64getFParm (int token, size_t &size) const
 
const UT_StringHoldergetSParm (int token, size_t &size) const
 
const int64getIParm (const char *name, size_t &size) const
 
const fpreal64getFParm (const char *name, size_t &size) const
 
const UT_StringHoldergetSParm (const char *name, size_t &size) const
 
bool import (const char *name, int32 *value, int vectorsize) const
 
bool import (const char *name, int64 *value, int vectorsize) const
 
bool import (const char *name, fpreal32 *value, int vectorsize) const
 
bool import (const char *name, fpreal64 *value, int vectorsize) const
 
bool import (const char *name, UT_String &result, int idx=0) const
 
bool import (const char *name, UT_StringHolder &result, int idx=0) const
 
bool import (RAY_Handle handle, const char *name, int32 *value, int vectorsize) const
 
bool import (RAY_Handle handle, const char *name, int64 *value, int vectorsize) const
 
bool import (RAY_Handle handle, const char *name, fpreal32 *value, int vectorsize) const
 
bool import (RAY_Handle handle, const char *name, fpreal64 *value, int vectorsize) const
 
bool import (RAY_Handle handle, const char *name, UT_String &result, int idx=0) const
 
bool import (RAY_Handle handle, const char *name, UT_StringHolder &result, int idx=0) const
 
bool importAll (RAY_Handle handle, UT_Options &settings, bool local_only=false) const
 
RAY_ROProceduralGeo createGeometry (GU_DetailHandle &gdh) const
 
RAY_ROProceduralGeo createGeometry (GU_ConstDetailHandle &gdh) const
 
RAY_ROProceduralGeo createGeometry (const GU_DetailHandle *gdh, int nsegments, const fpreal *shutter_times=nullptr) const
 
RAY_ROProceduralGeo createGeometry (const GU_ConstDetailHandle *gdh, int nsegments, const fpreal *shutter_times=nullptr) const
 

Static Public Member Functions

static void optimizeGeometry (GU_Detail &gdp, bool create_normals_if_needed)
 
static void optimizeGeometry (GU_DetailHandle &gdp, bool create_normals_if_needed)
 

Protected Member Functions

const GA_AttributequeryGeometrySegment (const GA_Attribute *attr, int seg) const
 
void clearGeometrySegments (GA_Attribute *attr)
 
fpreal getLevelOfDetail (const UT_BoundingBox &box) const
 
RAY_ProceduralChildPtr createChild () const
 
void openGeometryObject ()
 
void addGeometry (GU_Detail *gdp, fpreal shutter)
 
int openProceduralObject ()
 Open a procedural object. More...
 
void addProcedural (RAY_Procedural *proc)
 
int addProcedural (int argc, char *argv[], const UT_BoundingBox *box=0)
 
void openVolumeObject ()
 Open a volume object. More...
 
void addVolume (VGEO_Volume *volume, fpreal shutter)
 
void setPreTransform (const UT_Matrix4D &transform, fpreal shutter)
 
void setTransform (const UT_Matrix4D &transform, fpreal shutter)
 
void setStylerInfo (const RAY_StylerInfo &styler_info)
 
bool setShopMaterialPath (const char *shop_materialpath, const char *material_override=nullptr, const char *property_map=nullptr)
 
void debugSettings (const char *style="object") const
 Print out the object's settings to stderr. More...
 
void processPrimitiveMaterial (const GEO_Primitive *prim)
 
void closeObject ()
 
bool parseMaterialIFD (const char *filename)
 
int queryWorldTransformSamples () const
 Query the number of transform samples for the world. More...
 
UT_Matrix4D queryWorldTransform (int sample) const
 Get the world transform. More...
 
RAY_ObjectHandle queryObject (const char *name) const
 
RAY_MaterialHandle queryMaterial (const char *name) const
 
RAY_LightHandle queryLight (const char *name) const
 
int queryTransformSamples (RAY_Handle handle) const
 
UT_Matrix4D queryTransform (RAY_Handle handle, int sample) const
 
const UT_Matrix4DqueryShaderTransform (RAY_ObjectHandle handle, int sample) const
 
const STY_StylerqueryStyler (RAY_ObjectHandle handle) const
 
const char * queryName (RAY_Handle handle) const
 
const char * queryRootName () const
 Get the name of the object which owns this procedural. More...
 
int queryGeometrySamples (RAY_ObjectHandle handle) const
 
RAY_ROProceduralGeo queryGeometry (RAY_ObjectHandle handle) const
 
bool changeSetting (const char *name, const char *value, const char *style="object")
 
bool changeSetting (const char *name, int argc, const char *const *argv, const char *style="object")
 
bool changeSetting (const char *name, int argc, const int *argv, const char *style="object")
 
bool changeSetting (const char *name, int argc, const fpreal *argv, const char *style="object")
 
bool declareSetting (const char *name, const char *value)
 
bool declareSetting (const char *name, int argc, const char *const *argv)
 
bool declareSetting (const char *name, int argc, const int *argv)
 
bool declareSetting (const char *name, int argc, const fpreal *argv)
 

Static Protected Member Functions

static void lookupPrimitiveMaterialAttributes (const GEO_Detail &geo, RAY_PrimitiveMaterialAttributes &attribs)
 

Friends

class RAY_ProceduralChild
 
RAY_ProceduralData * data ()
 

Detailed Description

Constructor & Destructor Documentation

RAY_Procedural::RAY_Procedural ( )
virtual RAY_Procedural::~RAY_Procedural ( )
virtual

Member Function Documentation

void RAY_Procedural::addGeometry ( GU_Detail gdp,
fpreal  shutter 
)
protected

Before adding the geometry, you can change geometry settings by calling changeSettings(). For example, if you want to force computation of N, you can call: changeSetting("computeN", "true", "geometry"); This needs to be done BEFORE the addGeometry() call is made. Object settings can be changed after the geometry has been added.

Warning
The addGeometry(GU_Detail *) method was originally deprecated in H14.0, and you should seriously consider modernizing your code. The current implementation looks like this and doesn't properly handle motion blur (since the modern implementation stores motion segments on the RAY_ProceduralGeo object):
{
gdh.allocateAndSet(gdp, false); // User must delete gdp
myChild->addGeometry(createGeometry(gdh));
}
void RAY_Procedural::addProcedural ( RAY_Procedural proc)
protected

Add a procedural to the opened procedural object. Use this method when splitting a procedural into multiple sub-procedurals. This can be useful when it would be prohibitive (memory-wise) to generate geometry immediately, and allows mantra to delay generation of geometry for the sub-procedural until its bounding box is hit.

If you've allocated the procedural yourself, mantra assumes that the procedural is fully initialized. The initialize() method will not be called.

See Also
openProceduralObject()
int RAY_Procedural::addProcedural ( int  argc,
char *  argv[],
const UT_BoundingBox box = 0 
)
protected

Add a procedural the the opened procedural object. This method allows you to create any registered procedural by passing argc and argv arguments to initialize the procedural.

When allocating a procedural with arguments, mantra will call the initialize() method.

Returns
0 or 1 for failure/success
See Also
openProceduralObject()
void RAY_Procedural::addVolume ( VGEO_Volume volume,
fpreal  shutter 
)
protected

Add a volume primitive to the currently open volume object. Volume objects are reference counted, so if you need to keep a reference to the volume after calling addVolume(), use the incref()/decref() interface to retain a reference. An easy way to do this is to own a UT_IntrusivePtr<VGEO_Volume> object .

virtual bool RAY_Procedural::canGenerateInstancedGeometry ( ) const
inlinevirtual

This is a stop-gap measure to help improve LOD computation when the procedural generates multiple instances of the same underlying geometry. If this method returns false, the procedural will not be processed when flattenprocedural is set.

Reimplemented in RAY_ProcGT.

Definition at line 681 of file RAY_Procedural.h.

bool RAY_Procedural::changeSetting ( const char *  name,
const char *  value,
const char *  style = "object" 
)
inlineprotected

Change any setting on the object (geometry, procedural, volume)

  • changeSetting(const char *name, const char *value)
    Parses the string into arguments and changes the setting If you want to change a setting to a single string value, it is better to call: changeSettings(name, 1, &value);
  • changeSetting(const char *name, int argc, char **argv)
  • changeSetting(const char *name, int argc, int *argv)
  • changeSetting(const char *name, int argc, fpreal *argv) If the setting specified by "name" isn't found, the function will fail (return false).

Definition at line 991 of file RAY_Procedural.h.

bool RAY_Procedural::changeSetting ( const char *  name,
int  argc,
const char *const argv,
const char *  style = "object" 
)
inlineprotected

Change any setting on the object (geometry, procedural, volume)

  • changeSetting(const char *name, const char *value)
    Parses the string into arguments and changes the setting If you want to change a setting to a single string value, it is better to call: changeSettings(name, 1, &value);
  • changeSetting(const char *name, int argc, char **argv)
  • changeSetting(const char *name, int argc, int *argv)
  • changeSetting(const char *name, int argc, fpreal *argv) If the setting specified by "name" isn't found, the function will fail (return false).

Definition at line 998 of file RAY_Procedural.h.

bool RAY_Procedural::changeSetting ( const char *  name,
int  argc,
const int argv,
const char *  style = "object" 
)
inlineprotected

Change any setting on the object (geometry, procedural, volume)

  • changeSetting(const char *name, const char *value)
    Parses the string into arguments and changes the setting If you want to change a setting to a single string value, it is better to call: changeSettings(name, 1, &value);
  • changeSetting(const char *name, int argc, char **argv)
  • changeSetting(const char *name, int argc, int *argv)
  • changeSetting(const char *name, int argc, fpreal *argv) If the setting specified by "name" isn't found, the function will fail (return false).

Definition at line 1006 of file RAY_Procedural.h.

bool RAY_Procedural::changeSetting ( const char *  name,
int  argc,
const fpreal argv,
const char *  style = "object" 
)
inlineprotected

Change any setting on the object (geometry, procedural, volume)

  • changeSetting(const char *name, const char *value)
    Parses the string into arguments and changes the setting If you want to change a setting to a single string value, it is better to call: changeSettings(name, 1, &value);
  • changeSetting(const char *name, int argc, char **argv)
  • changeSetting(const char *name, int argc, int *argv)
  • changeSetting(const char *name, int argc, fpreal *argv) If the setting specified by "name" isn't found, the function will fail (return false).

Definition at line 1013 of file RAY_Procedural.h.

virtual const char* RAY_Procedural::className ( ) const
pure virtual

The class name is used in diagnostic messages. It can simply be the name of the class, or alternatively, you can choose a unique name for each procedural instance.

Implemented in RAY_ProcGT, HDK_Sample::RAY_DemoSprite, HDK_Sample::RAY_DemoMountain, HDK_Sample::ray_ChildBox, HDK_Sample::RAY_DemoGT, HDK_Sample::RAY_DemoStamp, HDK_Sample::RAY_DemoVolumeSphere, HDK_Sample::RAY_DemoFile, and HDK_Sample::RAY_DemoBox.

void RAY_Procedural::clearGeometrySegments ( GA_Attribute attr)
protected

Delete existing geometry segments and prepare the detail for addition of new motion blur segments. This method can be useful if you want to reuse geometry between renders but change the motion blur. Do not call this method on geometry that has already been added to the current render.

void RAY_Procedural::closeObject ( )
protected

After all geometry, procedurals, volumes have been added and all the attributes have been set, the object can be closed.

RAY_ProceduralChildPtr RAY_Procedural::createChild ( ) const
inlineprotected

Create a child object. Each child can be operated upon in separate threads. This allows a single procedural to create multiple child objects in a threaded fashion.

Examples:
RAY/RAY_DemoBox.C, RAY/RAY_DemoFile.C, RAY/RAY_DemoGT.C, RAY/RAY_DemoMountain.C, RAY/RAY_DemoSprite.C, RAY/RAY_DemoStamp.C, and RAY/RAY_DemoVolumeSphere.C.

Definition at line 856 of file RAY_Procedural.h.

RAY_ProceduralGeo RAY_Procedural::createGeometry ( ) const
inline

Allocate geometry for this procedural.

Examples:
RAY/RAY_DemoBox.C, RAY/RAY_DemoFile.C, RAY/RAY_DemoMountain.C, RAY/RAY_DemoSprite.C, and RAY/RAY_DemoStamp.C.

Definition at line 765 of file RAY_Procedural.h.

RAY_ROProceduralGeo RAY_Procedural::createGeometry ( GU_DetailHandle gdh) const

Allocate geometry given a GU_DetailHandle/GU_ConstDetailHandle

RAY_ROProceduralGeo RAY_Procedural::createGeometry ( GU_ConstDetailHandle gdh) const

Allocate geometry given a GU_DetailHandle/GU_ConstDetailHandle

RAY_ROProceduralGeo RAY_Procedural::createGeometry ( const GU_DetailHandle gdh,
int  nsegments,
const fpreal shutter_times = nullptr 
) const

Allocate geometry given an array of GU_DetailHandle's, one for each motion segment.

RAY_ROProceduralGeo RAY_Procedural::createGeometry ( const GU_ConstDetailHandle gdh,
int  nsegments,
const fpreal shutter_times = nullptr 
) const

Allocate geometry given an array of GU_DetailHandle's, one for each motion segment.

RAY_ProceduralData* RAY_Procedural::data ( )
inline

: Access data internals

Definition at line 818 of file RAY_Procedural.h.

void RAY_Procedural::debugSettings ( const char *  style = "object") const
protected

Print out the object's settings to stderr.

bool RAY_Procedural::declareSetting ( const char *  name,
const char *  value 
)
inlineprotected

Once an object is open for processing, it's possible to add settings specifically for that individual object. These properties can be accessed using the VEX renderstate() function.

It is illegal to:

  • redefine a built-in property
  • change the type of an existing property
  • change the tuple size of an existing property

This is equivalent to the ray_declare command in IFDs.

Definition at line 1033 of file RAY_Procedural.h.

bool RAY_Procedural::declareSetting ( const char *  name,
int  argc,
const char *const argv 
)
inlineprotected

Once an object is open for processing, it's possible to add settings specifically for that individual object. These properties can be accessed using the VEX renderstate() function.

It is illegal to:

  • redefine a built-in property
  • change the type of an existing property
  • change the tuple size of an existing property

This is equivalent to the ray_declare command in IFDs.

Definition at line 1039 of file RAY_Procedural.h.

bool RAY_Procedural::declareSetting ( const char *  name,
int  argc,
const int argv 
)
inlineprotected

Once an object is open for processing, it's possible to add settings specifically for that individual object. These properties can be accessed using the VEX renderstate() function.

It is illegal to:

  • redefine a built-in property
  • change the type of an existing property
  • change the tuple size of an existing property

This is equivalent to the ray_declare command in IFDs.

Definition at line 1046 of file RAY_Procedural.h.

bool RAY_Procedural::declareSetting ( const char *  name,
int  argc,
const fpreal argv 
)
inlineprotected

Once an object is open for processing, it's possible to add settings specifically for that individual object. These properties can be accessed using the VEX renderstate() function.

It is illegal to:

  • redefine a built-in property
  • change the type of an existing property
  • change the tuple size of an existing property

This is equivalent to the ray_declare command in IFDs.

Definition at line 1052 of file RAY_Procedural.h.

virtual void RAY_Procedural::getBoundingBox ( UT_BoundingBox box)
pure virtual
const fpreal64* RAY_Procedural::getFParm ( int  token,
size_t &  size 
) const

Get the raw data pointers for a parameter by either name or value. These functions return the size of the array in size, and will fail if the type requested doesn't match the storage type.

See Also
import()
const fpreal64* RAY_Procedural::getFParm ( const char *  name,
size_t &  size 
) const
inline

Get the raw data pointers for a parameter by either name or value. These functions return the size of the array in size, and will fail if the type requested doesn't match the storage type.

See Also
import()

Definition at line 709 of file RAY_Procedural.h.

const int64* RAY_Procedural::getIParm ( int  token,
size_t &  size 
) const

Get the raw data pointers for a parameter by either name or value. These functions return the size of the array in size, and will fail if the type requested doesn't match the storage type.

See Also
import()
const int64* RAY_Procedural::getIParm ( const char *  name,
size_t &  size 
) const
inline

Get the raw data pointers for a parameter by either name or value. These functions return the size of the array in size, and will fail if the type requested doesn't match the storage type.

See Also
import()

Definition at line 704 of file RAY_Procedural.h.

fpreal RAY_Procedural::getLevelOfDetail ( const UT_BoundingBox box) const
protected

This method allows you to compute the level of detail (LOD) of an arbitrary bounding box. The LOD indicates the rough screen space size of the bounding box, as an average projected length in micropolygons.

For example, if the box occupies 10 horizontal pixels and 20 vertical pixels, at a shading quality of 1.0 the LOD will be around

  1. At a shading quality of 2.0, the LOD would be around 30. If the box surrounds the camera, the LOD will be clamped at a large number.
Examples:
RAY/RAY_DemoMountain.C, and RAY/RAY_DemoSprite.C.
const UT_StringHolder* RAY_Procedural::getSParm ( int  token,
size_t &  size 
) const

Get the raw data pointers for a parameter by either name or value. These functions return the size of the array in size, and will fail if the type requested doesn't match the storage type.

See Also
import()
const UT_StringHolder* RAY_Procedural::getSParm ( const char *  name,
size_t &  size 
) const
inline

Get the raw data pointers for a parameter by either name or value. These functions return the size of the array in size, and will fail if the type requested doesn't match the storage type.

See Also
import()

Definition at line 714 of file RAY_Procedural.h.

bool RAY_Procedural::import ( const char *  name,
int32 value,
int  vectorsize 
) const

The import functions can be used as a general purpose query mechanism. This will import values from:

  • The argument list for the procedural
  • The argument list for the object defining the procedural
  • A global rendering setting. Aside from a parameter name, the name could be "object:name", "object:shadingquality", "camera:pixelaspect", or any of the other setting defined in mantra.
bool RAY_Procedural::import ( const char *  name,
int64 value,
int  vectorsize 
) const

The import functions can be used as a general purpose query mechanism. This will import values from:

  • The argument list for the procedural
  • The argument list for the object defining the procedural
  • A global rendering setting. Aside from a parameter name, the name could be "object:name", "object:shadingquality", "camera:pixelaspect", or any of the other setting defined in mantra.
bool RAY_Procedural::import ( const char *  name,
fpreal32 value,
int  vectorsize 
) const

The import functions can be used as a general purpose query mechanism. This will import values from:

  • The argument list for the procedural
  • The argument list for the object defining the procedural
  • A global rendering setting. Aside from a parameter name, the name could be "object:name", "object:shadingquality", "camera:pixelaspect", or any of the other setting defined in mantra.
bool RAY_Procedural::import ( const char *  name,
fpreal64 value,
int  vectorsize 
) const

The import functions can be used as a general purpose query mechanism. This will import values from:

  • The argument list for the procedural
  • The argument list for the object defining the procedural
  • A global rendering setting. Aside from a parameter name, the name could be "object:name", "object:shadingquality", "camera:pixelaspect", or any of the other setting defined in mantra.
bool RAY_Procedural::import ( const char *  name,
UT_String result,
int  idx = 0 
) const

The import functions can be used as a general purpose query mechanism. This will import values from:

  • The argument list for the procedural
  • The argument list for the object defining the procedural
  • A global rendering setting. Aside from a parameter name, the name could be "object:name", "object:shadingquality", "camera:pixelaspect", or any of the other setting defined in mantra.
bool RAY_Procedural::import ( const char *  name,
UT_StringHolder result,
int  idx = 0 
) const

The import functions can be used as a general purpose query mechanism. This will import values from:

  • The argument list for the procedural
  • The argument list for the object defining the procedural
  • A global rendering setting. Aside from a parameter name, the name could be "object:name", "object:shadingquality", "camera:pixelaspect", or any of the other setting defined in mantra.
bool RAY_Procedural::import ( RAY_Handle  handle,
const char *  name,
int32 value,
int  vectorsize 
) const

If you've opened a handle using queryObject(), queryLight() or queryMaterial(), it's possible to query the settings of that object. This makes it possible to query the parameters/values/settings of other objects in the scene.

bool RAY_Procedural::import ( RAY_Handle  handle,
const char *  name,
int64 value,
int  vectorsize 
) const

If you've opened a handle using queryObject(), queryLight() or queryMaterial(), it's possible to query the settings of that object. This makes it possible to query the parameters/values/settings of other objects in the scene.

bool RAY_Procedural::import ( RAY_Handle  handle,
const char *  name,
fpreal32 value,
int  vectorsize 
) const

If you've opened a handle using queryObject(), queryLight() or queryMaterial(), it's possible to query the settings of that object. This makes it possible to query the parameters/values/settings of other objects in the scene.

bool RAY_Procedural::import ( RAY_Handle  handle,
const char *  name,
fpreal64 value,
int  vectorsize 
) const

If you've opened a handle using queryObject(), queryLight() or queryMaterial(), it's possible to query the settings of that object. This makes it possible to query the parameters/values/settings of other objects in the scene.

bool RAY_Procedural::import ( RAY_Handle  handle,
const char *  name,
UT_String result,
int  idx = 0 
) const

If you've opened a handle using queryObject(), queryLight() or queryMaterial(), it's possible to query the settings of that object. This makes it possible to query the parameters/values/settings of other objects in the scene.

bool RAY_Procedural::import ( RAY_Handle  handle,
const char *  name,
UT_StringHolder result,
int  idx = 0 
) const

If you've opened a handle using queryObject(), queryLight() or queryMaterial(), it's possible to query the settings of that object. This makes it possible to query the parameters/values/settings of other objects in the scene.

bool RAY_Procedural::importAll ( RAY_Handle  handle,
UT_Options settings,
bool  local_only = false 
) const

Using a handle, import all settings on the object. By default this includes settings at default values. However, by setting local_only to true, it's possible to query only values from the handle that were explicitly set on that object/light/material.

virtual int RAY_Procedural::initialize ( const UT_BoundingBox box)
pure virtual

The initialize method is called when the procedural is created. Returning zero (failure) will abort the rendering of this procedural.

The bounding box passed in is the user defined bounding box. If the user didn't specify a bounding box, then the box will be NULL.

Implemented in RAY_ProcGT, HDK_Sample::RAY_DemoSprite, HDK_Sample::RAY_DemoMountain, HDK_Sample::ray_ChildBox, HDK_Sample::RAY_DemoVolumeSphere, HDK_Sample::RAY_DemoGT, HDK_Sample::RAY_DemoStamp, HDK_Sample::RAY_DemoBox, and HDK_Sample::RAY_DemoFile.

virtual bool RAY_Procedural::isEqual ( const RAY_Procedural ) const
inlinevirtual

Called by IPR so that the procedural can determine whether it is equal to the updated procedural. This is useful if the procedural is dependent on object properties other than the its arguments.

Definition at line 674 of file RAY_Procedural.h.

int RAY_Procedural::lookupParmToken ( const char *  name) const

The getParm() methods evaluate parameters attached to the procedural. The lookup may be performed by name or by token. Each parameter has a unique token associated with it. The token lookup methods are more efficient than the name lookups and should be almost as efficient as accessing member data. Parameters to the procedural are stored as a list of RAY_ProceduralArg objects. Each parameter is given a unique integer. This allows for more efficient evaluation (avoiding comparing strings).

static void RAY_Procedural::lookupPrimitiveMaterialAttributes ( const GEO_Detail geo,
RAY_PrimitiveMaterialAttributes attribs 
)
staticprotected

Cache the set of attributes to be used by RAY_ProceduralChild::processPrimitiveMaterial()

void RAY_Procedural::openGeometryObject ( )
protected

When the render method is called, the procedural can add objects to the scene. It is possible for the render() method to add multiple objects.

The process for adding a geometry object:

The process for adding a new procedural is fairly similar:

For a geometry object, deformation motion blur is done by adding multiple geometry objects or by using appendGeometrySegment() to append motion blur segments without allocating new GU_Detail objects.

If settings are not overridden by the procedural, they will be inherited from the object defining the procedural.

The shutter time should be between 0 and 1. Shutter values are used to order the geometry objects added to the procedural, so that the order of calls to addGeometry() will not affect the resulting motion blur. Additionally, the distribution and offset of shutter values are currently ignored. For example, shutters of (0, 0.9, 1) and (0, 0.5, 1) will produce identical motion blur, as will shutters of (0, 0.5) and (0.5, 1). The difference between the largest and smallest shutter value will be used to scale the positions of additional motion segments toward the initial position. For example, if a shutter of (0, 0.4) is specified, with P0 and P1 being points on the first and second segment, the rendered motion end points will be P0 and P0+0.4*(P1-P0).

The renderer assumes ownership of any geometry or procedurals written to objects. Thus, the geometry and procedurals should not be free'd by the user.

int RAY_Procedural::openProceduralObject ( )
protected

Open a procedural object.

void RAY_Procedural::openVolumeObject ( )
protected

Open a volume object.

static void RAY_Procedural::optimizeGeometry ( GU_Detail gdp,
bool  create_normals_if_needed 
)
static

When passed a GU_DetailHandle, mantra will run some internal optimizations on the geometry. These include, but are not limited to:

  • Optimizing layout of polygon soups
  • Conversion of closed Bezier/NURBS curves
  • Clearing DAGS on pasted surfaces
  • Creation of the N attribute for smooth shading of polygons However, when passed a GU_ConstDetailHandle, mantra assumes that it's not allowed to alter the geometry and thus does not run these optimizations. Some of these "optimizations" will change behaviour (i.e. without optimization, closed Bezier/NURBS will not render). This hook allows you to run the internal optimizations on the geometry before passing the GU_ConstDetailHandle to mantra. This is typically called:
    int computeN;
    if (!import("geometry:computeN", &computeN, 1))
    computeN = 1;
    optimizeGeometry(gdh, computeN != 0);
static void RAY_Procedural::optimizeGeometry ( GU_DetailHandle gdp,
bool  create_normals_if_needed 
)
static
bool RAY_Procedural::parseMaterialIFD ( const char *  filename)
protected

Load materials from an IFD stream. This is the code used by the file procedural to load material definitions. Using this to load data other than material statements will likely cause bad things to happen.

void RAY_Procedural::processPrimitiveMaterial ( const GEO_Primitive prim)
protected

Convenience method to check for the following attributes on a primitive This method will check for the following attributes:

  • shop_materialpath
  • material_override
  • property_override
  • lightcategories
  • lightmask
  • categories
RAY_ROProceduralGeo RAY_Procedural::queryGeometry ( RAY_ObjectHandle  handle) const
protected

Access the geometry from another object (or the geometry passed to this object in the IFD). This method will return all segments of geometry for the handle's object.

Examples:
RAY/RAY_DemoSprite.C.
int RAY_Procedural::queryGeometrySamples ( RAY_ObjectHandle  handle) const
protected

Find out how many geometry samples associated with the object.

See Also
queryObject()
const GA_Attribute* RAY_Procedural::queryGeometrySegment ( const GA_Attribute attr,
int  seg 
) const
protected

Query a geometry attribute segment for the given segment index. For seg == 0, this method simply returns attr. For example:

const GA_Attribute *p1 = queryGeometrySegment(gdp->getP(), 1);
RAY_LightHandle RAY_Procedural::queryLight ( const char *  name) const
protected

Find a handle to a given light in the scene. The light handle does not need to be closed.

RAY_MaterialHandle RAY_Procedural::queryMaterial ( const char *  name) const
protected

Find a handle to a given material in the scene. The material handle does not need to be closed.

const char* RAY_Procedural::queryName ( RAY_Handle  handle) const
protected

Find out the name of the object queried. This is useful when trying to find out which object the procedural belongs to (i.e. queryObject(0))

See Also
queryObject()
RAY_ObjectHandle RAY_Procedural::queryObject ( const char *  name) const
protected

It is possible to query information about other objects in the scene to some extent. This is done using the following query methods. Find a handle to a given object in the scene. Note that for objects which are rendered using point instances, the object handle will be a single instance rather than all of the instances.

If a null pointer is passed in for the name, then the object refers to the object containing this procedural. The object handle does not need to be closed.

Note that the initialize() method on procedurals is called as the IFD is parsed, so not all objects may be available at this time (depending on the order of objects in the IFD). The render() method is called after the entire scene has been parsed, so other objects should be available at that point. You should always get a valid handle when querying your own object (passing an empty string for the name) in the initialize method.

Examples:
RAY/RAY_DemoSprite.C.
const char* RAY_Procedural::queryRootName ( ) const
protected

Get the name of the object which owns this procedural.

Examples:
RAY/RAY_DemoSprite.C.
const UT_Matrix4D& RAY_Procedural::queryShaderTransform ( RAY_ObjectHandle  handle,
int  sample 
) const
protected

Get the shading transform associated with an object in the scene

See Also
queryObject()
const STY_Styler& RAY_Procedural::queryStyler ( RAY_ObjectHandle  handle) const
protected

Get the style sheet associated with an object in the scene.

See Also
queryObject()
UT_Matrix4D RAY_Procedural::queryTransform ( RAY_Handle  handle,
int  sample 
) const
protected

Get the transform associated with an object in the scene

See Also
queryObject()
Examples:
RAY/RAY_DemoSprite.C.
int RAY_Procedural::queryTransformSamples ( RAY_Handle  handle) const
protected

Query the number of transform samples for a given query object

See Also
queryObject()
UT_Matrix4D RAY_Procedural::queryWorldTransform ( int  sample) const
protected

Get the world transform.

int RAY_Procedural::queryWorldTransformSamples ( ) const
protected

Query the number of transform samples for the world.

virtual void RAY_Procedural::render ( )
pure virtual

The render method is called when the procedural is required to either generate geometry or split into more procedurals. Inside the render() method you should make calls to open/add/close geometry or sub-procedurals.

The way that a procedural splits is critical to the performance of mantra's ray tracer. For optimal performance, make sure that sub-procedural bounding boxes overlap as little as possible - which allows mantra to build more optimal trees for ray tracing.

In multi-threaded renders, the render() method needs to be reentrant

  • that is, the render() method on different RAY_Procedural objects may be called simultaneously by different threads. This means that you should design the code in your procedural such that global data structures are protected by a thread lock (for example, a UT_Lock).
    Note
    The render method may be called more than once during a render to regenerate the geometry.

Implemented in RAY_ProcGT, RAY_ProcIsoBase, HDK_Sample::RAY_DemoSprite, HDK_Sample::ray_ChildBox, HDK_Sample::RAY_DemoMountain, HDK_Sample::RAY_DemoVolumeSphere, HDK_Sample::RAY_DemoGT, HDK_Sample::RAY_DemoStamp, HDK_Sample::RAY_DemoBox, and HDK_Sample::RAY_DemoFile.

void RAY_Procedural::setPreTransform ( const UT_Matrix4D transform,
fpreal  shutter 
)
protected

Transform the currently open object (geometry, procedural, volume) at the shutter time specified. The transform is a pre-transform that acts on the parent procedural's existing transform. This interface should be used to achieve the expected parenting behavior for procedurals, in which the transform is an object space transform inside the parent space.

bool RAY_Procedural::setShopMaterialPath ( const char *  shop_materialpath,
const char *  material_override = nullptr,
const char *  property_map = nullptr 
)
protected

Calling setShopMaterialPath() will simulate adding the "shop_materialpath" and optionally the "material_override" and attributes on the geometry. This must be called after the openGeometryObject() and before the corresponding closeObject() calls. The property_map string is used to map the Houdini parameter names in the material_override string to mantra property names. Without this map, properties will not be overridden properly.

void RAY_Procedural::setStylerInfo ( const RAY_StylerInfo styler_info)
protected

Assign new style information to the currently open object. Procedurals often prune the style sheet of entries that no longer apply to the geometry hierarchy.

void RAY_Procedural::setTransform ( const UT_Matrix4D transform,
fpreal  shutter 
)
protected

Transform the currently open object (geometry, procedural, volume) at the shutter time specified. The transform is a post-transform that acts on the parent procedural's existing transform. This method is preferred when you need to change the world transform from within the procedural. In most cases, setPreTransform() is preferred over setTransform().

Friends And Related Function Documentation

friend class RAY_ProceduralChild
friend

Definition at line 1279 of file RAY_Procedural.h.


The documentation for this class was generated from the following file: