...
Code Block | ||
---|---|---|
| ||
class CcameraLensExtension : public CbaseExtension { public: virtual bool initializeForRendering( Cmaxwell::Ccamera& camera, Cmaxwell* pMaxwell ) = 0; // Returns camera origin and direction (normalized) in world coordinates, given a point in the 2D buffer (in [0,xRes],[0,yRes] range) virtual bool getCameraRay( Cpoint& origin, Cvector& direction, const Cvector2D& bufferPoint ) = 0; // Returns true if the lens has real area or false if this is an ideal lens (pinhole, spherical, etc) virtual bool hasArea( void ) const { return ( false ); } // Returns true if the lens supports Bidirectional Path Tracing virtual bool supportsBPT( void ) const { return ( false ); } // Returns by reference a 2D point in the film in [1,1] coordinates // Returns by value the PDF associated to the given input direction // If returned PDF is 0.0 the direction is not valid virtual real onLensToFilm( Cvector2D& filmPoint, const Cvector& direction ) { return ( 0.0 ); } }; |
The most important part of the extension functionality resides in getCameraRay, which must be implemented. The rest are optional functions. hasArea, as it name says, returns whether the lens has area or is it a pinhole kind of lens. supportsBPT tells maxwell if the lens supports bi-directional path tracing.
onLensToFilm does two things. First, returns a point in the film, and second, calculates the probability density function of the input direction. If the direction is not valid, the pdf should be 0.0.
The class extension constructor is used mainly to create the extension parameters (look at the example below) and, possibly, allocate data structures needed throughout the life of the extension. These data structures must be freed in the class destructor. initializeForRendering is called just before rendering starts, and the incoming pMaxwell (always check != NULL ) is useful for accessing the scene if needed.