Polygonal Geometry

Polygonal geometry consists of polygons. For efficiency reasons, mental ray\ distinguishes simple convex polygons from general concave polygons or polygons with holes. Both are distinguished by keyword:

    c ["material_name"] vertex_ref_list  
    cp ["material_name"] vertex_ref_list  
    p ["material_name"] vertex_ref_list  
    p ["material_name"] vertex_ref_list hole vertex_ref_list ...  

If the enclosing object has the tagged flag set, mandatory label integers must be given instead of the optional materials:

    c label_numberint vertex_ref_list  
    cp label_numberint vertex_ref_list  
    p label_numberint vertex_ref_list  
    p label_numberint vertex_ref_list hole vertex_ref_list ...  

The c keyword selects convex polygons without holes. The results are unpredictable if the polygon is not convex. The cp keyword is a synonym for c for backwards compatibility; c should be used in new translators. The p keyword also renders concave polygons correctly, and allows specification of holes, using one or more hole keywords, each followed by a vertex_ref_list. If all polygons within the same object group are simple convex polygons containing three sides (triangles), mental ray will pre-process them in a more efficient manner than non-triangular polygons.

A vertex_ref_list is a list of non-negative integers index that reference vertices in the vertex list of the group described in the previous section. The first vertex in the vertex list is numbered 0.

Any vertex index can be used in both polygon and hole vertex_ref_lists. A polygon with n vertices is defined by n index values in the vertex list following the material name. The order of the polygon vertices is important. A counter-clockwise ordering of the vertices yields a front-facing polygon. The vertex list of a hole may be ordered either way. Any displaced polygon violating this rule, for example because it has been displaced such that its new normal points the wrong way, causes the error message "orientation of triangles inconsistent" and the surface to be dropped.

The material name must have been defined before the object definition that contains the polygon definition, in a statement like

    material "material_name"  
        ...  
    end material  

In both cases, it is recommended to quote the material name to avoid conflicts with reserved words, and to allow arbitrary characters in the name. For a detailed description of material definitions, see section material. Once a material name has been specified for a polygon, it becomes the default material. All following polygons may omit the material name. Polygons without explicit material use the same material as the last polygon that does have an explicit material. Not specifying materials improves parsing speed because no names must be looked up in the symbol table.

If no material is specified, polygons remain without material; in this case the material from the closest instance up the scene DAG is used instead. This is called material inheritance. Tagged objects always inherit their material from the instance. It can distinguish polygons by using the miQ_GEO_LABEL mode of the mi_query function during rendering (not in displacement shaders).

The tessellation of polygons assumes that polygons are "reasonably" planar. This means that every polygon will be tessellated, but the exact subdivision into triangles does not attempt to minimize curvature. If the curvature is low, different tessellations cannot be distinguished, but consider the extreme case where the four corners of a regular tetrahedron are given as polygon vertices: the resulting polygon will consist of two triangles, but it cannot be predicted which of the four possible triangles will be chosen.

The behavior will be different for convex polygons without holes (c keyword) and polygons which contain holes or are concave ( p keyword). Convex polygons without holes are triangulated by picking a vertex on the outer loop and connecting it with every other vertex except its direct neighbors. If polygons are not flagged with the c keyword but do not have any holes an automatic convexity test is performed and if they are indeed convex they are triangulated as described. Convex polygons with holes and concave polygons are triangulated with a different algorithm. In any case a projection plane is chosen such that the extents of the projection of the bounding box of the (outer) loop have maximal size. If the projection of the polygon onto that plane is not one-to-one the results of the triangulation will be erroneous.

If a textured polygon's material contains a displacement map the vertices are shifted along the normals accordingly. If an approximation statement is given triangles are subdivided until the specified criteria are fulfilled; see section approx for details.

Copyright © 1986-2008 by mental images GmbH