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

#include <BRAY_Procedural.h>

+ Inheritance diagram for BRAY_Procedural:

Classes

class  Hit
 
class  HitPtr
 
struct  Ray
 

Public Types

using Ray32 = Ray< fpreal32 >
 
using Ray64 = Ray< fpreal64 >
 

Public Member Functions

 BRAY_Procedural ()
 
virtual ~BRAY_Procedural ()
 
const UT_StringHolderclassName () const
 Return a name for this procedural. This defaults to factory()->name();. More...
 
const BRAY_ProceduralFactoryfactory () const
 Return the factory definition. More...
 
virtual const BRAY_AttribListattribList () const =0
 Return an attribute list for the attributes supported by this primitive. More...
 
virtual const BRAY_AttribListparamList () const
 
virtual void bounds (UT_BoundingBox &bounds, BRAYtime time) const =0
 Return the bounding box for the object at a given time. More...
 
bool isValid () const
 Check whether the procedural is valid. More...
 
virtual UT_Vector3 displayColor () const
 Return a display color for low-quality rendering. More...
 
virtual void update (BRAY_EventType event)=0
 This method can be used to be notified of changes to the object. More...
 
virtual void dumpInfo (UT_JSONWriter &w) const
 
template<typename T >
void setParameter (const UT_StringRef &key, const T &val)
 
template<typename T >
void setParameter (const UT_StringRef &key, const T *values, int n)
 
void beginUpdate ()
 
void endUpdate ()
 
virtual HitPtr intersect (const Ray32 &ray) const =0
 
virtual HitPtr intersect (const Ray64 &ray) const =0
 
virtual const int32attribVal (int attrib, BRAYtime time, const Hit &hit_info, int32 *buf, int size) const =0
 
virtual const int64attribVal (int attrib, BRAYtime time, const Hit &hit_info, int64 *buf, int size) const =0
 
virtual const fpreal32attribVal (int attrib, BRAYtime time, const Hit &hit_info, fpreal32 *buf, int size) const =0
 
virtual const fpreal64attribVal (int attrib, BRAYtime time, const Hit &hit_info, fpreal64 *buf, int size) const =0
 
virtual const UT_StringHolderattribVal (int attrib, BRAYtime time, const Hit &hit_info, UT_StringHolder *buf, int size) const =0
 
virtual const UT_ValArray
< int32 > * 
attribVal (int attrib, BRAYtime time, const Hit &hit_info, UT_ValArray< int32 > *buf, int size) const
 
virtual const UT_ValArray
< int64 > * 
attribVal (int attrib, BRAYtime time, const Hit &hit_info, UT_ValArray< int64 > *buf, int size) const
 
virtual const UT_ValArray
< fpreal32 > * 
attribVal (int attrib, BRAYtime time, const Hit &hit_info, UT_ValArray< fpreal32 > *buf, int size) const
 
virtual const UT_ValArray
< fpreal64 > * 
attribVal (int attrib, BRAYtime time, const Hit &hit_info, UT_ValArray< fpreal64 > *buf, int size) const
 
virtual const UT_StringArrayattribVal (int attrib, BRAYtime time, const Hit &hit_info, UT_StringArray *buf, int size) const
 

Protected Member Functions

HitPtr getHit () const
 
virtual HitPtr newHit () const
 
virtual void errorMessage (const char *fmt,...) SYS_PRINTF_CHECK_ATTRIBUTE(2
 
virtual void virtual void doBeginUpdate ()=0
 
virtual void doEndUpdate ()=0
 
virtual bool checkIsValid () const =0
 Check to see whether the procedural is valid. More...
 
virtual void doSetParameter (const UT_StringRef &key, const int32 *values, int n=1)=0
 
virtual void doSetParameter (const UT_StringRef &key, const int64 *values, int n=1)=0
 
virtual void doSetParameter (const UT_StringRef &key, const fpreal32 *values, int n=1)=0
 
virtual void doSetParameter (const UT_StringRef &key, const fpreal64 *value, int n=1)=0
 
virtual void doSetParameter (const UT_StringRef &key, const UT_StringHolder *value, int n=1)=0
 

Detailed Description

Member Typedef Documentation

Definition at line 38 of file BRAY_Procedural.h.

Definition at line 39 of file BRAY_Procedural.h.

Constructor & Destructor Documentation

BRAY_Procedural::BRAY_Procedural ( )
virtual BRAY_Procedural::~BRAY_Procedural ( )
virtual

Member Function Documentation

virtual const BRAY_AttribList* BRAY_Procedural::attribList ( ) const
pure virtual

Return an attribute list for the attributes supported by this primitive.

Implemented in BRAY_ProceduralScene.

virtual const int32* BRAY_Procedural::attribVal ( int  attrib,
BRAYtime  time,
const Hit hit_info,
int32 buf,
int  size 
) const
pure virtual

Evaluate an attribute on this primitive. The methods should return a pointer to the attribute data. If there isn't a direct raw pointer to the data, the buffer passed in can be used to store the data and that pointer can be returned. The element is the element

Implemented in BRAY_ProceduralScene.

Examples:
karma_procedurals/BRAY_HdSphere.C.
virtual const int64* BRAY_Procedural::attribVal ( int  attrib,
BRAYtime  time,
const Hit hit_info,
int64 buf,
int  size 
) const
pure virtual

Evaluate an attribute on this primitive. The methods should return a pointer to the attribute data. If there isn't a direct raw pointer to the data, the buffer passed in can be used to store the data and that pointer can be returned. The element is the element

Implemented in BRAY_ProceduralScene.

virtual const fpreal32* BRAY_Procedural::attribVal ( int  attrib,
BRAYtime  time,
const Hit hit_info,
fpreal32 buf,
int  size 
) const
pure virtual

Evaluate an attribute on this primitive. The methods should return a pointer to the attribute data. If there isn't a direct raw pointer to the data, the buffer passed in can be used to store the data and that pointer can be returned. The element is the element

Implemented in BRAY_ProceduralScene.

virtual const fpreal64* BRAY_Procedural::attribVal ( int  attrib,
BRAYtime  time,
const Hit hit_info,
fpreal64 buf,
int  size 
) const
pure virtual

Evaluate an attribute on this primitive. The methods should return a pointer to the attribute data. If there isn't a direct raw pointer to the data, the buffer passed in can be used to store the data and that pointer can be returned. The element is the element

Implemented in BRAY_ProceduralScene.

virtual const UT_StringHolder* BRAY_Procedural::attribVal ( int  attrib,
BRAYtime  time,
const Hit hit_info,
UT_StringHolder buf,
int  size 
) const
pure virtual

Evaluate an attribute on this primitive. The methods should return a pointer to the attribute data. If there isn't a direct raw pointer to the data, the buffer passed in can be used to store the data and that pointer can be returned. The element is the element

Implemented in BRAY_ProceduralScene.

virtual const UT_ValArray<int32>* BRAY_Procedural::attribVal ( int  attrib,
BRAYtime  time,
const Hit hit_info,
UT_ValArray< int32 > *  buf,
int  size 
) const
virtual

Evaluation of array attributes (each attribute can have an arbitrary number of entries. By default, the array attribute evaluators set the arrays to a size of 0 and return the storage array.

Reimplemented in BRAY_ProceduralScene.

virtual const UT_ValArray<int64>* BRAY_Procedural::attribVal ( int  attrib,
BRAYtime  time,
const Hit hit_info,
UT_ValArray< int64 > *  buf,
int  size 
) const
virtual

Evaluation of array attributes (each attribute can have an arbitrary number of entries. By default, the array attribute evaluators set the arrays to a size of 0 and return the storage array.

Reimplemented in BRAY_ProceduralScene.

virtual const UT_ValArray<fpreal32>* BRAY_Procedural::attribVal ( int  attrib,
BRAYtime  time,
const Hit hit_info,
UT_ValArray< fpreal32 > *  buf,
int  size 
) const
virtual

Evaluation of array attributes (each attribute can have an arbitrary number of entries. By default, the array attribute evaluators set the arrays to a size of 0 and return the storage array.

Reimplemented in BRAY_ProceduralScene.

virtual const UT_ValArray<fpreal64>* BRAY_Procedural::attribVal ( int  attrib,
BRAYtime  time,
const Hit hit_info,
UT_ValArray< fpreal64 > *  buf,
int  size 
) const
virtual

Evaluation of array attributes (each attribute can have an arbitrary number of entries. By default, the array attribute evaluators set the arrays to a size of 0 and return the storage array.

Reimplemented in BRAY_ProceduralScene.

virtual const UT_StringArray* BRAY_Procedural::attribVal ( int  attrib,
BRAYtime  time,
const Hit hit_info,
UT_StringArray buf,
int  size 
) const
virtual

Evaluation of array attributes (each attribute can have an arbitrary number of entries. By default, the array attribute evaluators set the arrays to a size of 0 and return the storage array.

Reimplemented in BRAY_ProceduralScene.

void BRAY_Procedural::beginUpdate ( )
inline

Signal the procedural

We allow for the Procedural to update itself and do any further processing in case any parameters have been set. The set parameter methods are generally invoked on the procedural, which might be implemented by the procedural to copy data, precompute stuff, validate parameter ranges etc. Once these have been set, the begin/end update methods can be used by the procedural to perform operations that can be performed only when there's nothing more to set as parameters to the procedural. The procedural can now start working on doing other things with the set parameters because it can be sure that the parameters now have become immutable.

Definition at line 236 of file BRAY_Procedural.h.

virtual void BRAY_Procedural::bounds ( UT_BoundingBox bounds,
BRAYtime  time 
) const
pure virtual

Return the bounding box for the object at a given time.

Implemented in BRAY_ProceduralScene.

virtual bool BRAY_Procedural::checkIsValid ( ) const
protectedpure virtual

Check to see whether the procedural is valid.

Implemented in BRAY_ProceduralScene.

const UT_StringHolder& BRAY_Procedural::className ( ) const
inline

Return a name for this procedural. This defaults to factory()->name();.

Definition at line 179 of file BRAY_Procedural.h.

virtual UT_Vector3 BRAY_Procedural::displayColor ( ) const
inlinevirtual

Return a display color for low-quality rendering.

Definition at line 274 of file BRAY_Procedural.h.

virtual void virtual void BRAY_Procedural::doBeginUpdate ( )
protectedpure virtual

These functions are the ones that each procedural will override for doing preupdate/post update operations.

Implemented in BRAY_ProceduralScene.

virtual void BRAY_Procedural::doEndUpdate ( )
protectedpure virtual

Implemented in BRAY_ProceduralScene.

virtual void BRAY_Procedural::doSetParameter ( const UT_StringRef key,
const int32 values,
int  n = 1 
)
protectedpure virtual

These methods will be used by the implementing classes to set parameters that the procedural will support

virtual void BRAY_Procedural::doSetParameter ( const UT_StringRef key,
const int64 values,
int  n = 1 
)
protectedpure virtual
virtual void BRAY_Procedural::doSetParameter ( const UT_StringRef key,
const fpreal32 values,
int  n = 1 
)
protectedpure virtual
virtual void BRAY_Procedural::doSetParameter ( const UT_StringRef key,
const fpreal64 value,
int  n = 1 
)
protectedpure virtual
virtual void BRAY_Procedural::doSetParameter ( const UT_StringRef key,
const UT_StringHolder value,
int  n = 1 
)
protectedpure virtual
virtual void BRAY_Procedural::dumpInfo ( UT_JSONWriter w) const
virtual

Dump out information about the procedural for debugging. By default, a null is written to the stream.

void BRAY_Procedural::endUpdate ( )
inline

Signal the procedural

We allow for the Procedural to update itself and do any further processing in case any parameters have been set. The set parameter methods are generally invoked on the procedural, which might be implemented by the procedural to copy data, precompute stuff, validate parameter ranges etc. Once these have been set, the begin/end update methods can be used by the procedural to perform operations that can be performed only when there's nothing more to set as parameters to the procedural. The procedural can now start working on doing other things with the set parameters because it can be sure that the parameters now have become immutable.

Definition at line 241 of file BRAY_Procedural.h.

virtual void BRAY_Procedural::errorMessage ( const char *  fmt,
  ... 
)
protectedvirtual

This method will be called to print out an error if the procedural isn't set up properly. You can override it to silence the errors.

const BRAY_ProceduralFactory* BRAY_Procedural::factory ( ) const
inline

Return the factory definition.

Definition at line 182 of file BRAY_Procedural.h.

HitPtr BRAY_Procedural::getHit ( ) const
protected

Hit objects are virtual which allows you to create a sub-class that stores information specific to your procedural type. The Hit structure should be kept relatively small if possible. When you need to allocate a Hit object for your intersect method, you should call getHit().

To implement the actual allocation of the custom Hit object, you need to implement newHit().

virtual HitPtr BRAY_Procedural::intersect ( const Ray32 ray) const
pure virtual

Perform ray-intersection

If the distanct to the closest intersection point for the procedural object is closer than the distance already stored in the hit_info, the hit information should be replaced and the intersect() method should return true.

If the distance to the closest intersection point is farther than the existing distance, then the hit_info should remain unchanged.

NOTE: The ray's direction vector CANNOT be expected to be unit length Hence the procedural is responsible for accounting and returning the correct 't' in the hit_info struct if it ever scaled it internally to unit length.

Implemented in BRAY_ProceduralScene.

virtual HitPtr BRAY_Procedural::intersect ( const Ray64 ray) const
pure virtual

Perform ray-intersection

If the distanct to the closest intersection point for the procedural object is closer than the distance already stored in the hit_info, the hit information should be replaced and the intersect() method should return true.

If the distance to the closest intersection point is farther than the existing distance, then the hit_info should remain unchanged.

NOTE: The ray's direction vector CANNOT be expected to be unit length Hence the procedural is responsible for accounting and returning the correct 't' in the hit_info struct if it ever scaled it internally to unit length.

Implemented in BRAY_ProceduralScene.

bool BRAY_Procedural::isValid ( ) const
inline

Check whether the procedural is valid.

Definition at line 248 of file BRAY_Procedural.h.

virtual HitPtr BRAY_Procedural::newHit ( ) const
protectedvirtual

The newHit() method is used to allocate a custom Hit type. The typical way this is done is:

class MyHit : public Hit { };
HitPtr newHit() const override { return HitPtr(new MyHit(...)); }

Reimplemented in BRAY_ProceduralScene.

virtual const BRAY_AttribList* BRAY_Procedural::paramList ( ) const
inlinevirtual

Return a parameter list that the procedural exposes to the outside world that could be set using the setParameter() methods The default implementation calls factory()->paramList();

Definition at line 190 of file BRAY_Procedural.h.

template<typename T >
void BRAY_Procedural::setParameter ( const UT_StringRef key,
const T val 
)
inline

Set parameters on procedurals in addition to attributes that the procedural might provide. One way to think of parameters and attributes is that attributes are what procedurals bring to the table internally, where as parameters are something that can be applied onto procedurals. For example, a 'Sphere' object is a procedural. It's attributes could be like 'color', 'normal' on vertices. whereas 'parameters' could be 'radius', etc. Depending upon the procedural the meaning of these two terms change contextually.

The templates are specialized for:

Definition at line 211 of file BRAY_Procedural.h.

template<typename T >
void BRAY_Procedural::setParameter ( const UT_StringRef key,
const T values,
int  n 
)
inline

Set parameters on procedurals in addition to attributes that the procedural might provide. One way to think of parameters and attributes is that attributes are what procedurals bring to the table internally, where as parameters are something that can be applied onto procedurals. For example, a 'Sphere' object is a procedural. It's attributes could be like 'color', 'normal' on vertices. whereas 'parameters' could be 'radius', etc. Depending upon the procedural the meaning of these two terms change contextually.

The templates are specialized for:

Definition at line 217 of file BRAY_Procedural.h.

virtual void BRAY_Procedural::update ( BRAY_EventType  event)
pure virtual

This method can be used to be notified of changes to the object.


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