Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

The actual work of this extension is done in getRGB. This is the speed critical routine. Make every effort to optimize this function. Do not allocate memory in it. Avoid any OS and/or SDK function calls in this critical routine. Most of the memory can be pre-allocated in initializeForRendering. If you want to access the global scene pointer, store it in initializeForRendering and use it later. This can save a huge amount of time.

getRGB

virtual

...

bool

...

getRGB(

...

Crgb&

...

rgb,

...

real

...

u,

...

real

...

v,

...

const

...

IntersectionInfo*

...

intersectionInfo

...

=

...

0

...

)

...

=

...

0;

Calculate and return the color at the given texture coordinates u and v.

Arguments

Crgb& rgb : output, calculated color, float values.

real u, v : input, texture coordinates at which the color must be calculated.

const IntersectionInfo* intersectionInfo : input, pointer to a structure with intersection information. Always check != NULL. Class IntersectionInfo is defined as follows:

Code Block
class IntersectionInfo
{
public:
    Cvector barycentric;
    Cpoint* intersectionGlobals;
    Cpoint* normalGlobals;
};

  Where:

    Cvector barycentric are the barycentric coordinates of the triangle (when dealing with actual meshes) or the natural parametric coordinates (if dealing with a procedural geometry object )

    Cpoint* intersectionGlobals : point of intersection in global coordinates.

    Cpoint* normalGlobals : normal at the point of intersection in global coordinates.

...