Boxes

Element type: miSCENE_NBOX
Data type: miBox
Sizes:
Defaults: all nulls
typedef struct miBox {
        miCBoolean      mtl_is_label;
        miUchar         sharp;
        miUchar         spare[2];
        miUint          spare2;

        miVector        bbox_min;       /* bounding box: low corner */
        miVector        bbox_max;       /* bounding box: high corner */
        miUint          no_primlists;   /* number of lists of prims,
                                           excluding border primlists */
        miUint          no_prims;       /* total number of primitives
                                           contained in all primitive lists,
                                           excluding border prims */
        miUint          no_border_primlists; /* number of border primlists */
        miUint          no_border_prims;/* number of primitives contained */
                                        /* in all border primlists */
        miUint          primdata_size;  /* prim data: size per primitive */
        miUint          pdata_size;     /* prim data: total size (there could
                                           be extra data after primlist data */
        miTag           topology;       /* adjacency information for all
                                           primitives (region+border) */

        miUint          prim_offset;    /* byte offset: primitives */
        miUint          mtl_offset;     /* byte offset: materials */
        miUint          dim_offset;     /* byte offset: tex/usr offset table*/
        miUint          pdata_offset;   /* byte offset: prim data */
        miVertex_info   vertex_info;    /* vertex specification */
        miScalar        data[1];        /* vertex lines begin, more follow */
} miBox;

In mental ray 3.4, miBox was introduced to improve efficiency. miBox optimizes memory coherence.

A translator should not change the fields in an miBox directly; the api functions mi_api_primlist_begin, mi_api_primlist_border, mi_api_primlist_dimensions, mi_api_primlist_approx, mi_api_primlist_topology, mi_api_primlist_end should be used. Writing boxes directly makes rendering faster because no tessellation is involved, but it does make the code more susceptible to changes in mental ray. miBox is an internal data structure that changes in incompatible ways periodically, unlike miObjects.

mtl_is_label is a flag that informs the renderer that the material field in the primitives does not hold a material but an integer label. The renderer must ignore the material in this case and use the inherited material. This flag is set for tagged objects in the mi2 language.

sharp stores the tessellation sharpness: 0 means interpolated and 255 means faceted. mental ray 3.2 also allows intermediate values in the range 1..254.

bbox_min and bbox_max are the low and high corners respectively of the bounding box around the vextex positions. no_prims is the total number of primitives (triangles, strip faces, quads etc) contained in all primitive lists, excluding border primitives.

no_primlists is the total number of primitive lists contained in the box. Each primitive list consists of prims, excluding border primitives.

no_border_prims is the total number of primitives in all border primitive lists.

no_border_primlists is the number of primitive lists defining the border.

primdata_size specifies the number of 32-bit integers which are assigned to each primitive from the pdata_offset array. For example primdata_size = 1 means that for subsequent primitives one integer from pdata_offset can be used as user data.

pdata_size specifies the size of the whole pdata section. There may be extra space after primlist data, for individual needs.

prim_offset is the offset to an array of integers defining multiple primitive lists. Each primitive list begins with a primitive type combined with a count into a single 32-bit value: type is stored in bits 28-31, count in bits 0-27. The primitive vertex integers follow, referring to the vertex lines.

mtl_offset is the offset to an array of integers defining materials.

dim_offset is the offset to the array of scalar offsets within a vertex line for all texture and user spaces. The dim_offset array has at least one entry for texture spaces and one for user data spaces, which are identical to no_textures or no_users. If no_textures or no_users is greater than zero, additional entries are present with values of at least three (defined after position in the vertex line).

pdata_offset is the offset to the user data, swapped as integers. Interpretation is up to the application.

data[1] is the beginning of the vertex line storage.

vertex_info defines a primitive vertex. Vertex data is stored as an interleaved array of lines of scalars in the box. A line contains a 3-d vertex position and may contain, for example, a normal (3 scalars), first derivatives (6 scalars), second derivatives (9 scalars), textures, and user data. miVertex_info describes the layout of the lines.

typedef struct miVertex_info {
        miUint2         line_size;      /* vertex line size in #scalars */
        miUchar         normal_offset;  /* when 0, not present */
        miUchar         derivs_offset;  /* surf derivs, when 0, not present */
        miUchar         derivs2_offset; /* surf 2nd derivs, when 0, not pr. */
        miUchar         bump_offset;    /* bump basis vectors if non null */
        miUchar         no_bumps;       /* number of bump vectors */
        miUchar         motion_offset;  /* when 0, not present */
        miUchar         no_motions;     /* number of motion vectors */
        miUchar         texture_offset; /* when 0, not present */
        miUchar         no_textures;    /* number of textures */
        miUchar         user_offset;    /* when 0, not present */
        miUchar         no_users;       /* number of user vectors */
        miUchar         spare[3]}       /* not used */
} miVertex_info}

line_size is the number of scalars in a line of vertex data. normal_offset is the to the normal vector.

derivs_offset is the offset to the first partial derivatives.

derivs2_offset is the offset to the second partial derivatives.

bump_offset is the offset to the bump vectors. no_bumps is the number of bump vectors. motion_offset is the offset to the motion vectors.

no_motions is the number of motion vectors. texture_offset is the offset to the texture vectors.

no_textures is the number of texture spaces. user_offset is the offset to the user vectors. no_users is the number of user spaces.

A number of macros exist to provide access to miBox contents.

Copyright © 1986-2009 by mental images GmbH