Approximations

Element type: -
Data type: miApprox
Sizes: -
Defaults: as set by miAPPROX_DEFAULT()
enum miApprox_method {
        miAPPROX_PARAMETRIC,
        miAPPROX_REGULAR,
        miAPPROX_SPATIAL,
        miAPPROX_CURVATURE,
        miAPPROX_LDA,
        miAPPROX_ADJACENCY,             /* only for curves */
        miAPPROX_ALGEBRAIC,             /* only for surfaces */
        miAPPROX_DEFTRIM,               /* only for miFace def_trim_approx */
        miAPPROX_REGULAR_PERCENT,       /* new in 3.2, regular param n% m% */
        miAPPROX_INDIRECT,
        miAPPROX_NMETHODS
};

enum miApprox_style {
        miAPPROX_STYLE_NONE,
        miAPPROX_STYLE_GRID,
        miAPPROX_STYLE_TREE,
        miAPPROX_STYLE_DELAUNAY,
        miAPPROX_STYLE_FINE,            /* sub-object/subpixel tessellation */
        miAPPROX_STYLE_FINE_NO_SMOOTHING,/* fine poly displacement without
                                            Hermite interpolation */
        miAPPROX_NSTYLES
};

#define miCNST_UPARAM   0               /* regular/parametric only */
#define miCNST_VPARAM   1
#define miCNST_LENGTH   0               /* curvature/spatial only */
#define miCNST_DISTANCE 1
#define miCNST_ANGLE    2

enum miCnst_type {
        miCNST_VISIBLE  = 0,            /* for accessing (int)cnst[0] */
        miCNST_TRACE,
        miCNST_SHADOW,
        miCNST_CAUSTIC,
        miCNST_GLOBILLUM,
        miCNST_NTYPES                   /* must not be > 7 ! */
};

typedef struct miApprox {
        miScalar             cnst[6];   /* indexed with miUPARAM...miANGLE */
        miUint1              sharp;     /* 0=smooth normals, 255=faceted */
        miCBoolean           spare;     /* not used */
        miCBoolean           any;       /* stop if any criterion is met */
        miCBoolean           view_dep;  /* view dependent? */
        enum miApprox_method method;
        enum miApprox_style  style;
        miUshort             subdiv[2]; /* recursive subdivision depth */
        miGeoIndex           max;       /* maximum number of triangles */
        miScalar             grading;   /* min angle bound for graded meshing*/
} miApprox;

#define miAPPROX_MAX_SUBDIV     7
#define miAPPROX_DEFAULT(A) do {                 \
        (A).style         = miAPPROX_STYLE_TREE; \
        (A).method        = miAPPROX_PARAMETRIC; \
        (A).sharp         = 0;                   \
        (A).flag          = miAPPROX_FLAG_ANY;   \
        (A).any           = miFALSE;             \
        (A).view_dep      = miFALSE;             \
        (A).cnst[0]       = 0.0;                 \
        (A).cnst[1]       = 0.0;                 \
        (A).cnst[2]       = 0.0;                 \
        (A).cnst[3]       = 0.0;                 \
        (A).cnst[4]       = 0.0;                 \
        (A).cnst[5]       = 0.0;                 \
        (A).subdiv[miMIN] = 0;                   \
        (A).subdiv[miMAX] = 5;                   \
        (A).max           = miHUGE_INT;          \
        (A).grading       = 0.0; } while (0)
#define miAPPROX_FINE_DEFAULT(A) do {            \
        (A).style         = miAPPROX_STYLE_FINE; \
        (A).method        = miAPPROX_LDA;        \
        (A).sharp         = 0;                   \
        (A).flag          = (1<<miCNST_NTYPES)-1;\
        (A).any           = miFALSE;             \
        (A).view_dep      = miTRUE;              \
        (A).cnst[0]       = 0.25;                \
        (A).cnst[1]       = 0.0;                 \
        (A).cnst[2]       = 0.0;                 \
        (A).cnst[3]       = 0.0;                 \
        (A).cnst[4]       = 0.0;                 \
        (A).cnst[5]       = 0.0;                 \
        (A).subdiv[miMIN] = 0;                   \
        (A).subdiv[miMAX] = miAPPROX_MAX_SUBDIV; \
        (A).max           = miHUGE_INT;          \
        (A).grading       = 0.0; } while (0)

A translator may provide: all fields.

The approximation structure is a substructure of miPolygon_list, miCurve, and miSurface. It does not have its own database entry and no associated SCENE functions of its own.

method is the approximation method, and must be one of miAPPROX_PARAMETRIC, miAPPROX_REGULAR, miAPPROX_SPATIAL, miAPPROX_CURVATURE, miAPPROX_LDA, miAPPROX_ADJACENCY (available for curves only), and miAPPROX_REGULAR_PERCENT. The default is miAPPROX_PARAMETRIC. "LDA" stands for Length, Distance, Angle; this mode combines the spatial and curvature-dependent modes which are now considered obsolete. As a special case, the value of miAPPROX_INDIRECT switches the meaning of the cnst array to an array of six integer offsets into the inherited approximation list, which contains up to ten approximations separately for visible, trace, shadow, and other flagged approximations.

tyle is the approximation style, and must be one of miAPPROX_NONE, miAPPROX_GRID, miAPPROX_TREE, miAPPROX_STYLE_FINE3.1, and miAPPROX_STYLE_FINE_NO_SMOOTHING3.4\. Tree mode is the default. The API and GAP module will automatically change the style field to grid mode if the method is parametric or regular. The fine approximation style3.1 only works with parametric and edge length criteria; the recommended mode is view-dependent edge length with a subpixel diagonal constant. If any approximation in an object uses fine approximation, the miObject should have the fine flag set. fine approximation, no smoothing can be used for polygon displacement for turning off a smoothing procedure which is used by default during fine polygon displacement. (See page fineapprox for more details about fine approximation.)

sharp3.1 controls the normal vector interpolation. If set to 0, mental ray uses the interpolated normal as specified by the base surface, modified by displacement if available. If set to 255 (which corresponds to 1.0 in the .mi scene file), mental ray will use the geometric normal for a faceted look. This is primarily useful in miAPPROX_STYLE_FINE3.1 mode. mental ray 3.2 also accepts values in the range 1..254 to blend smoothly between interpolated and faceted tessellations.

any, if miTRUE, makes the tessellation stop if any criterion is met, instead of when all criteria are met. Close faces are tessellated more finely than distant faces. This mode is not available for the parametric and regular method.

view_dep, if miTRUE, turns on view-dependent tessellation. Close faces are tessellated more finely than distant faces. This mode is not available for the parametric and regular method.

cnst[0], cnst[1], and cnst[2] specify the approximation precision. They depend on the approximation method. The defaults are 1.0 (which is not ideal for curvature-dependent tessellation). The cnst array should be indexed using the miCNST_* constants. The cnst array was a miGeoScalar array up to mental ray 3.1, and switch to miScalar in mental ray 3.2. If the method field is miAPPROX_INDIRECT, these six cnst fields are interpreted as integer offsets into the inherited approximation list, which contains the actual approximations to use. Indirection cannot be nested. For example, if the method is indirect, the approximation to use for shadow rays is inheritedlist [ (int)approx.cnst [ miCNST_SHADOW ]].

subdiv specifies the minimum and maximum number of subdivision recursion levels.

grading is used for Delaunay tessellation only, and specifies how gradually the triangle mesh should become finer.

technique cnst[0] cnst[1] cnst[2]
parametric (number of U subdivs) ⁄ degree (number of V subdivs) ⁄ degree -
regular number of U subdivs number of V subdivs -
spatial edge length limit - -
curvature - distance tolerance angle tolerance
lda edge length limit distance tolerance angle tolerance

subdiv[0] and subdiv[1] specify the recursion limits. The defaults are 0 and 5, respectively. The maximum value is 7. A subdivision level n means that the curve, triangle, or surface is halved in each parameter direction n times, yielding on the order of 2^n segments. The limits have no effect on Delaunay triangulation.

max is used only for Delaunay triangulation. It specifies the maximum number of triangles to create. The number may be exceeded if the trimming and hole curves have too many vertices.

Copyright © 1986-2010 by mental images GmbH