All V-Ray-related classes and functions are defined in a separate namespace, the VR:: namespace. See the notes in the V-Ray support classes section.
The V-Ray Geometry API allows 3dsmax plugins to generate custom render geometry. V-Ray's geometry system is very flexible and therefore may appear somewhat complex at first. Please read the explanations below for a general idea of how things work.
Additional topics:
V-Ray Shading SDK additional classes
We'll begin with a short discussion of how things get rendered in 3dsmax.
In 3dsmax, a renderable object must be a subclass of the GeomObject 3dsmax class. At render time, the object is requested to return its geometry as a 3dsmax Mesh class. It's the renderer's job to render the resulting mesh. This approach has some limitations, for example it allows only triangle meshes; motion blur is very difficult for the renderer etc.
In V-Ray, another approach is taken, in order to allow for complex custom and procedural geometry. Instead of requesting from the object a representation of its geometry, V-Ray exposes its raycasting system to the plugin, which may then modify it as needed.
Thing work in approximately the following way.
When rendering starts, V-Ray scans the entire scene for renderable objects. Instanced objects are detected at this point. V-Ray distinguishes between instanced and non-instanced objects. As a first pass, V-Ray identifies the unique objects, regardless of how many times they are instanced. As a second pass, V-Ray identifies the individual instances.
During the first pass, V-Ray identifies the type of an object. As in 3dsmax, a renderable object must be a subclass of the GeomObject class. If the class also supports the I_VRAYGEOMETRY interface, then the interface is cast to a VRenderObject class and treated as native V-Ray geometry. Otherwise, a standard wrapper is constructed internally to allow the rendering of normal 3dsmax objects.
During the second pass, for each separate instance of an object, VRenderObject::newRenderInstance() is called to return a VRenderInstance class, representing the actual instance.
That concludes the scene scanning phase, as far as renderable objects are concerned. After that, the actual rendering begins.
V-Ray calls the methods renderBegin(), frameBegin(), frameEnd() and renderEnd() first for every VRenderObject and then for each VRenderInstance respectively at the start of the rendering, start of each frame, end of each frame and end of the rendering. Note that these are different from the 3dsmax Animatable::RenderBegin() and Animatable::RenderEnd(), which are called too for compatibility reasons. If your plugin supports the V-Ray geometry interface, then you should do any work in the V-Ray methods and leave the 3dsmax ones empty.
After frameBegin() has been called for all objects and instances for a given frame, V-Ray calls the compileGeometry() method for every VRenderInstance, passing a pointer to the VRayCore as an argument. The VRayCore class represents the current V-Ray implementation. It allows your plugin to access all V-Ray parameters, since the geometry that is generated may be influenced by them - for example, if motion blur is turned on, your plugin should generate the appropriate moving geometry if the object is changing, as opposed to the static geometry that should be generated if motion blur is off or if the object doesn't move. The VRayCore also gives access to the V-Ray RayServerInterface. The ray server is responsible for handling intersections between rays and the scene geometry. You must use the methods of the ray server to store the geometric description for your plugin. You do this by storing one or several primitives in the ray server. There are several generic primitive types, which you can use (simple static and moving triangles, infinite primitives, finite primitives etc). For each primitive, you must specify its owner. The owner of a primitive will be called to provide information about an intersection of a ray with the primitive (for example surface normals, shader etc). This is necessary since often the primitive itself doesn't have enough information to provide all necessary dat; however its owner usually has that information. For example, a simple triangle doesn't keep information about vertex normals and texture coordinates, however its owner (usually a mesh wrapper) has this information. See The Ray Server section for more details on geometric primitives.
Storing the appropriate primitives in the ray server concludes the geometry compilation phase. The ray server then builds its own internal data structures for efficient raycasting through the supplied geometry, and rendering begins.
During the rendering, the ray server is given rays to trace through the supplied geometry primitives. When an intersection with a primitive is found, the owner of the primitive is called to fill in the appropriate intersection data, which will later on be used during the shading phase.
In the present implementation, when a frame is completed all geometry is removed from the ray server. For each new frame, the geometry must be inserted again in the ray server.
This in short, is the way V-Ray's geometry system works.