HDK
|
Procedural primitive for mantra (RAY) More...
#include <RAY_Procedural.h>
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 int64 * | getIParm (int token, size_t &size) const |
const fpreal64 * | getFParm (int token, size_t &size) const |
const UT_StringHolder * | getSParm (int token, size_t &size) const |
const int64 * | getIParm (const char *name, size_t &size) const |
const fpreal64 * | getFParm (const char *name, size_t &size) const |
const UT_StringHolder * | getSParm (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_Attribute * | queryGeometrySegment (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_Matrix4D & | queryShaderTransform (RAY_ObjectHandle handle, int sample) const |
const STY_Styler & | queryStyler (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 () |
Procedural primitive for mantra (RAY)
The RAY_Procedural class provides a means to create procedural geometry during the rendering process.
Definition at line 631 of file RAY_Procedural.h.
RAY_Procedural::RAY_Procedural | ( | ) |
|
virtual |
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.
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):
|
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.
|
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.
|
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 .
|
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.
|
inlineprotected |
Change any setting on the object (geometry, procedural, volume)
changeSetting(const char *name, const char *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.
|
inlineprotected |
Change any setting on the object (geometry, procedural, volume)
changeSetting(const char *name, const char *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.
|
inlineprotected |
Change any setting on the object (geometry, procedural, volume)
changeSetting(const char *name, const char *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.
|
inlineprotected |
Change any setting on the object (geometry, procedural, volume)
changeSetting(const char *name, const char *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.
|
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.
|
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.
|
protected |
After all geometry, procedurals, volumes have been added and all the attributes have been set, the object can be closed.
|
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.
Definition at line 856 of file RAY_Procedural.h.
|
inline |
Allocate geometry for this procedural.
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.
|
inline |
: Access data internals
Definition at line 818 of file RAY_Procedural.h.
|
protected |
Print out the object's settings to stderr.
|
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:
This is equivalent to the ray_declare command in IFDs.
Definition at line 1033 of file RAY_Procedural.h.
|
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:
This is equivalent to the ray_declare command in IFDs.
Definition at line 1039 of file RAY_Procedural.h.
|
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:
This is equivalent to the ray_declare command in IFDs.
Definition at line 1046 of file RAY_Procedural.h.
|
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:
This is equivalent to the ray_declare command in IFDs.
Definition at line 1052 of file RAY_Procedural.h.
|
pure virtual |
The bounding box is the "object space" bounds of the procedural.
Implemented in RAY_ProcGT, HDK_Sample::RAY_DemoSprite, RAY_ProcIsoBase, 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.
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.
|
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.
Definition at line 709 of file RAY_Procedural.h.
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.
|
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.
Definition at line 704 of file RAY_Procedural.h.
|
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
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.
|
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.
Definition at line 714 of file RAY_Procedural.h.
The import functions can be used as a general purpose query mechanism. This will import values from:
The import functions can be used as a general purpose query mechanism. This will import values from:
The import functions can be used as a general purpose query mechanism. This will import values from:
The import functions can be used as a general purpose query mechanism. This will import values from:
The import functions can be used as a general purpose query mechanism. This will import values from:
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:
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.
|
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.
|
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).
|
staticprotected |
Cache the set of attributes to be used by RAY_ProceduralChild::processPrimitiveMaterial()
|
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.
|
protected |
Open a procedural object.
|
protected |
Open a volume object.
|
static |
When passed a GU_DetailHandle, mantra will run some internal optimizations on the geometry. These include, but are not limited to:
|
static |
|
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.
|
protected |
Convenience method to check for the following attributes on a primitive This method will check for the following attributes:
|
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.
|
protected |
Find out how many geometry samples associated with the object.
|
protected |
Query a geometry attribute segment for the given segment index. For seg == 0, this method simply returns attr. For example:
|
protected |
Find a handle to a given light in the scene. The light handle does not need to be closed.
|
protected |
Find a handle to a given material in the scene. The material handle does not need to be closed.
|
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))
|
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.
|
protected |
Get the name of the object which owns this procedural.
|
protected |
Get the shading transform associated with an object in the scene
|
protected |
Get the style sheet associated with an object in the scene.
|
protected |
Get the transform associated with an object in the scene
|
protected |
Query the number of transform samples for a given query object
|
protected |
Get the world transform.
|
protected |
Query the number of transform samples for the world.
|
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
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.
|
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.
|
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.
|
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.
|
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().
|
friend |
Definition at line 1279 of file RAY_Procedural.h.