NAME
-
vzAppearance - Appearance description of a shape node.
INHERITS FROM
-
vzObject
HEADER FILE
-
#include <Volumizer2/Appearance.h>
PUBLIC METHOD SUMMARY
| void setParameter ( |
const char* name, vzParameter* parameter); |
PROTECTED METHOD SUMMARY
CLASS DESCRIPTION
-
The vzAppearance class describes how the shape should look
when it is rendered. A vzShader must be specified, together
with a set of shading parameters that affect the appearance. Each parameter
associated with a vzAppearance has a name which is used by the
vzShader to extract the corresponding values and take the appropriate
actions. To get information about the specific shaders that are
available for each render action, refer to the specific render
action documentation: (e.g. vzTMRenderAction)
EXAMPLES
-
The following sample code shows how to use the vzAppearance class
to describe the appearance of a vzShape. The following example
initializes an appearance using the built-in shader vzTMLUTShader,
which expects two parameters; One of type vzParameterVolumeTexture
and name "volume" and two of type vzParameterLookupTable
and name "lookup_table"
// Create the shader
vzShader *shader = new vzTMLUTShader();
// Create the appearance
vzAppearance *appearance = new vzAppearance(shader);
// Create the volume texture
vzParameterVolumeTexture *texture = myInitVolumeTexture();
// Create the lookup table
vzParameterLookupTable *table = myInitLookupTable();
// Set the respective parameters for the appearance
appearance->setParameter("volume", texture);
appearance->setParameter("lookup_table", table);
-
METHOD DESCRIPTIONS
vzAppearance()
| vzAppearance ( |
vzShader* shader); |
-
Appearance constructor. The shader specifies the
the volumetric shader to be used to render the shape. For example,
vzTMLUTShader is a built-in shader which provides
volume rendering of 3D textures using lookup tables.
The shader is ref-counted by the appearance in the constructor.
-
Passing a NULL shader to the constructor will cause a vzError::error().
~vzAppearance()
| virtual ~vzAppearance ( |
); |
-
Appearance destructor. The shader and all the parameters for this appearance
are unref'ed in the destructor.
getNumParameters()
| int getNumParameters ( |
) const; |
-
Retrieve the number of parameters attached to the vzAppearance.
getParameter()
| vzParameter* getParameter ( |
const char* name) const; |
-
Retrieve the parameter with name. If a parameter with name
is not attached to the appearance, than a NULL is returned.
getParameter()
| vzParameter* getParameter ( |
int index) const; |
-
Retrieve a parameter by its index in the list. The first element
in the list is the 0th element. A NULL pointer is returned
if index is not in the range [0 .. numParameters-1].
This method can be useful for iterating through the list of parameters.
For example -
// Get the number of parameters -
int numParams = appearance->getNumParameters();
// Now iterate through the parameters
for(int i = 0; i < numParams; i++) {
// Get the individual parameter by index
vzParameter *param = appearance->getParameter(i);
// Get the parameter's name
char *name = appearance->getParameterName(i);
........
}
-
getParameterName()
| const char* getParameterName ( |
int index) const; |
-
Retrieve a parameter name by its index in the list. The first
element in the list is the 0th element. A NULL pointer is returned
if index is not in the range [0 .. numParameters-1].
getShader()
| vzShader* getShader ( |
) const; |
-
Retrieve the shader attached to this appearance.
setParameter()
| void setParameter ( |
const char* name, vzParameter* parameter); |
-
Adds the given parameter to the list of parameters for this
appearance. The parameter will be ref counted by the class. If a parameter with the given name
already exists, then its reference count will be decremented and
it will be replaced by the new one.
setShader()
| void setShader ( |
vzShader* shader); |
-
Sets the vzShader to be used with this appearance.
The shader is ref-counted by the appearance and will be used
for all future draw calls. Also, the initial shader's reference count
will be decremented.
The psuedocode for the method looks like -
void vzAppearance::setShader (vzShader *shader) {
// Ref the new shader
shader->ref();
// unref the old shader
currentShader->unref();
// set the old shader to the new one
currentShader = shader;
}
-
SEE ALSO
-
vzAppearance, vzObject, vzParameterLookupTable, vzParameterVolumeTexture, vzShader, vzShape, vzTMLUTShader, vzTMRenderAction