Evaluate Material Properties

Prepare for Evaluation

To prepare for material evaluation, you'll have to create a rendering engine and pass desired geometric objects into the renderer and specify the object whose material properties you want to evaluate. All this can be done by calling:


    evaluator= R3SendMsgA(level, R3PRIMM_MATEVALBEGIN, objtobeevaluated);

The method returns NULL if the scene cannot be prepared for evaluation.

For example, let's assume you have a wooden sphere object and you would like to evaluate the color of the sphere. The structure of you scene would be as follows:


    woodensphere
     /    \
sphere parallelmap(wood)

To prepare the scene for material evaluation, call:


    evaluator = R3DoA(woodensphere, R3PRIMM_MATEVALBEGIN, sphere);

Evaluating Properties

To evaluate desired material properties, you need to pass a 3d position in absolute space and 'uvw' coordinates to R3PRIMM_MATEVAL method. The channels to be evaluated and the corresponding value buffers are passed in 'p3'. Any number of channels can be evaluated in a single call.

For example, to evaluate Color and Transparency:


    R3VECTOR point = ...
    R3VECTOR uvw = ...
    R3VECTOR color;
    R3VECTOR transp;

    R3Do3(woodensphere, R3PRIMM_MATEVAL, &uvw, &point,
         R3T("Color", &color),
         R3T("Transparency", &transp),
         R3TAG_END);

The method evaluates given material properties using given input position and uvw coordinates and returns 1d or 3d value depending on the class of the channel.

When you no longer need to evaluate material properties, call:


    R3DoA(woodensphere, R3PRIMM_MATEVALEND, sphere);