void *mi_scene_create( miTag *tag, miScene_types type, ...)
creates a database element of a specified type, and provides defaults. For database elements that have a variable size, one or more arguments specify the sizes of the variable sections. There are no arguments to store specific values in the new database elements; instead, a pointer is returned that can be used to fill in the data. The tag of the new element is also returned. mi_scene_create always returns a valid pointer; allocation errors abort with mi_fatal. If the created element is an instance or an object, set its dirty flag.
void *mi_scene_recreate( miTag *tag, miScene_types type, ...)
This function is equivalent to mi_scene_create, but it expects tag to point to a valid tag number. The item will be deleted, and the new item will be created with this tag instead of choosing a new tag. This function is used for some types of incremental changes.
void *mi_scene_edit( miTag tag)
If the database element must be changed (as part of an incremental change), this call must be used to obtain a pointer to it. The DB call mi_db_access may not be used for this purpose, because Scene needs to keep track of edited elements to properly preprocess them before rendering starts. mi_scene_edit always returns a valid pointer; allocation errors abort with mi_fatal. If the edited element is an instance or an object, set its dirty flag.
void *mi_scene_growedit( miTag tag, ...)
This call is a variation of mi_scene_edit. It is used instead of mi_scene_edit if the modification requires an increase or decrease of the size of one of the sections of a variable-sized element. The size arguments have the same order as the arguments given in the mi_scene_create call. After the edit is complete, mi_scene_edit_end must be called. mi_scene_growedit always returns a valid pointer; allocation errors abort with mi_fatal. Note that resizes are inefficient and should be avoided. If the edited element is an instance or an object, set its dirty flag.
void mi_scene_edit_end( miTag tag)
After the incremental change of an element has completed, this function completes the edit. The pointer returned by mi_scene_edit is invalidated. Scene handles all pinning, flushing, and updates of expanded DAG elements (see functions in group 2).
Note that there are special Scene functions for accessing database elements that need to be written to, but no functions to access elements that are only read. For reading, the standard mi_db_access and mi_db_unpin functions are used. It is very inefficient to use mi_scene_edit for read-only accesses, and illegal to use mi_db_access for write accesses. There is no need to ever call mi_db_flush, this call is for use by the Scene module only.
Note also that the element delete function is in group 2, because it recursively deletes the subtree.
The Scene module supports the following types, defined by the miScene_types enumerator:
function | data type | purpose |
---|---|---|
miSCENE_FUNCTION_DECL | miFunction_decl | function declaration |
miSCENE_FUNCTION | miFunction | function call |
miSCENE_MATERIAL | miMaterial | material |
miSCENE_LIGHT | miLight | light |
miSCENE_CAMERA | miCamera | camera |
miSCENE_BASIS_LIST | miBasis_list | surface basis list |
miSCENE_OBJECT | miObject | geometry object |
miSCENE_BOX | miBox | renderable primitives |
miSCENE_LINEBOX | miLinebox | line stripes |
miSCENE_INSTANCE | miInstance | instance node |
miSCENE_GROUP | miGroup | group of instances |
miSCENE_OPTIONS | miOptions | render options |
miSCENE_FBINFO | miFb_info | frame buffer definition |
miSCENE_IMAGE | miImg_image | image frame huffer |
miSCENE_POLYGON | miPolygon[] | list of polygons |
miSCENE_api:mi_api_registry_lookup | miIndex[] | index list for polygons |
miSCENE_GEOapi:mi_api_registry_lookup | miGeoIndex[] | same, but miGeoIndex's |
miSCENE_VERTEX | miIndex[] | vertex list for polygons |
miSCENE_GEOVERTEX | miGeoIndex[] | same, but miGeoIndex's |
miSCENE_VECTOR | miVector[] | vector list for polygons |
miSCENE_GEOVECTOR | miGeoVector[] | same, but miGeoVectors |
miSCENE_FACE | miFace[] | surface geometry list |
miSCENE_SURFACE | miSurface[] | patch or texture surface |
miSCENE_CURVE | miCurve[] | curve list |
miSCENE_CURVPNT | miCurve_point[] | curve control point list |
miSCENE_SCALAR | miScalar[] | curve or surface scalars |
miSCENE_GEOSCALAR | miGeoScalar[] | same with high precision |
miSCENE_ALGEBRAIC | miAlgebraic[] | algebraic patch list |
miSCENE_TAG | miTag[] | used for box and string lists |
miSCENE_STRING | char[] | generic ASCII strings |
miSCENE_SPACECURVE | miSpacecurve[] | space curve |
miSCENE_BOOK | miBook | book |
miSCENE_PAGE | miPage | page for books |
miSCENE_SUBDIVSURF | miSurf_subsurf[] | subdivision surface |
miSCENE_USERDATA | char[] | user-defined custom data blocks |
miSCENE_LIGHTPROFILE | miLight_profile | IES/Eulumdat light profile |
There are several additional codes that are used by mental ray internally for temporary cached data. When one of these database element types is created or resized, the size must be given as a varargs list that depends on the type:
function | variable argument list for create/growedit |
---|---|
miSCENE_FUNCTION_DECL | int declsize, int nsubtags |
miSCENE_FUNCTION | int parmsize [1] |
miSCENE_BASIS_LIST | int nbases, int nscalars |
miSCENE_BOX | miVector_list *, miVertex_content *, int nvert, npri, enum miBox_type type, miBoolean moving [2] |
miSCENE_INSTANCE | int nuserbytes [3] |
miSCENE_GROUP | int nlinks, int nconnects [4] |
miSCENE_IMAGE | miImg_type type, int width, int height |
miSCENE_POLYGON | int npolygons |
miSCENE_api:mi_api_registry_lookup | int nindices |
miSCENE_VERTEX | int nvertices |
miSCENE_VECTOR | int nvectors |
miSCENE_GEOVECTOR | int nvectors |
miSCENE_FACE | int nfaces |
miSCENE_SURFACE | int nsurfaces |
miSCENE_CURVE | int ncurves |
miSCENE_CURVPNT | int npoints |
miSCENE_SCALAR | int nscalars |
miSCENE_ALGEBRAIC | int nalgebraics |
miSCENE_STRING | int nchars |
miSCENE_TAG | int ntags |
miSCENE_SPACECURVE | int nspcurves |
miSCENE_BOOK | int line_size, int no_lines, char *swap |
miSCENE_PAGE | int page_size, int line_size, char *swap |
miSCENE_SUBDIVSURF | int nsdsurfs |
miSCENE_USERDATA | int nbytes |
miSCENE_LIGHTPROFILE | int nvert, nhorz |
vect→no_vectors
and vect→sizeof_vertex
are used for calculating the box size. Resizing a box does not
shift box sections; the box contents except the header remain
unchanged.
[3] The user bytes are intended for
parameter information that is inherited down the DAG, either by
default or by an inheritance
function or traversal
function provided by the scene.
[4] The nlinks and
nconnects parameters are hints only. If more children are
added with mi_scene_link,
the Scene module will resize the group automatically if necessary.
However, resizes are inefficient and should be avoided by giving an
approximate number of links when creating the group.
miBoolean mi_scene_check( miTag tag) void mi_scene_checkall( miTag tag)
Do consistency check of a database element, and print mi_debug messages for every problem found. If no problems are found, miTRUE is returned. The mi_scene_check function checks only the given element, while the mi_scene_checkall function recursively checks all sub-elements too. If a database element of type miObject is checked, all geometric sub-elements linked to the object (faces, surfaces, curves, bases, and polygons) are also checked because the check can be much more thorough if the cross-dependencies (such as index bounds) can also be checked. This function can be slow and should be used only for debugging.
miBoolean mi_scene_dump( miTag tag, int verb)
Print a recursive dump of the database graph beginning at tag, using the mi_info message printing function (which means that the verbosity level must be at least 4). The verbosity verb ranges from 0 to 4, printing progressively more information. This function is useful for debugging.
char *mi_scene_type_name( miScene_types type)
Return the name of a SCENE data type. For example, when passed the type miSCENE_OBJECT, it returns the string "object". The returned string may not be written to, and need not be released (it points to a static array). This function is useful when writing debugging code or error messages.
Copyright © 1986, 2015 NVIDIA ARC GmbH. All rights reserved.