Changing An Material's Properties


Introduction

Material properties can be queried and changed by using the two API calls
XintView3DQueryMaterial and XintView3DChangeMaterial.

    extern void XintView3DQueryMaterial(
	                                XintView3DMaterial *material,
	                                unsigned long flags,
	                                XintView3DMaterialAttributes *attr,
	                                XintView3DMaterialColor *color
                                       );

    extern void XintView3DChangeMaterial(
	                                 XintView3DMaterial *material,
	                                 unsigned long flags,
	                                 XintView3DMaterialAttributes *attr,
	                                 XintView3DMaterialColor *color
	                                );

Both calls take as arguments, the material to query/change a structure of type XintView3DMaterialAttributes, XintView3DMaterialColor and a series of flags which specify the component(s) of the material you want to query/change. flags is created by combining any of the following flags listed below. For each of the different material types, the following tables list what properties can be queried and changed. The tables list the property, required flags, whether the property can be queried (Q) or changed (C), and if any memory is allocated. If memory is allocated, the application is responsible for freeing the resources.

    typedef struct _XintView3DMaterialAttributes {
	                      Boolean light;
	                      int shade_model;
	                      int draw_mode;
	                      Boolean draw_grid;
	                      Boolean image_flag
    } XintView3DMaterialAttributes;

    typedef struct _XintView3DMaterialColor {
                              XintColor4 single;
	                      XintView3DColorRange range;
	                      XintView3DColorScale scale;
	                      XintView3DColorIndex index;
	                      XintView3DColorMulti multi
    } XintView3DMaterialColor;

    typedef struct _XintView3DColorRange {
	                      XintView3DColorScaleOrientation orientation;
	                      XintReal *range;
	                      int num_colors;
	                      XintColor4 *colors;
    } XintView3DColorRange;

    typedef struct _XintView3DColorScale {
	                      XintView3DColorScaleOrientation orientation;
	                      XintReal *range;
	                      int num_colors;
	                      XintColor4 *colors;
    } XintView3DColorScale;

    typedef struct _XintView3DColorIndex{
	                      XintView3DColorTable *table;
	                      int num_indices;
	                      int *index;
    } XintView3DColorIndex;

    typedef struct _XintView3DColorMulti {
	                      int num_colors;
	                      XintColor4 *colors;
    } XintView3DColorMulti;

    typedef struct _XintView3DColorTable {
	                      char *name;
	                      int num_colors;
	                      XintColor4 *colors;
    } XintView3DColorTable;

    typedef enum _XintView3DColorScaleOrientation {
	                      XintCOLOR_SCALE_ORIENTATION_X,
	                      XintCOLOR_SCALE_ORIENTATION_Y,
	                      XintCOLOR_SCALE_ORIENTATION_Z,
	                      XintCOLOR_SCALE_ORIENTATION_4D
    } XintView3DColorScaleOrientation;

All Material Types
PropertyRequired FlagQ/CMemory Allocated
attributes->lightXintMA_LIGHTQCNo
attributes->shade_modelXintMA_SHADE_MODELQCNo
attributes->draw_modeXintMA_DRAW_MODEQCNo
attributes->draw_gridXintMA_DRAW_GRIDQCNo
attributes->image_flagXintMA_IMAGE_FLAGQNo

XintMATERIAL_SINGLE_COLOR
PropertyRequired FlagQ/CMemory Required
color->singleXintMA_SINGLE_COLORQCNo

XintMATERIAL_MULTI_COLOR
PropertyRequired FlagQ/CMemory Required
color->multi.colorsXintMA_MULTI_COLORQCYes
color->multi.num_colorsXintMA_MULTI_COLORQNo

XintMATERIAL_COLOR_SCALE
PropertyRequired FlagQ/CMemory Required
color->scale.orientationXintMA_SCALE_ORIENTATIONQCNo
color->scale.rangeXintMA_SCALE_RANGEQCYes
color->scale.colorsXintMA_SCALE_COLORSQCYes
color->scale.num_colorsAny of the above.QNo

XintMATERIAL_RANGE_COLOR
PropertyRequired FlagQ/CMemory Required
color->range.min_colorXintMA_RANGE_MINQCNo
color->range.max_colorXintMA_RANGE_MAXQCNo
color->range.range_directionXintMA_RANGE_DIRECTIONQCNo
color->range.interp_methodXintMA_RANGE_INTERPQCNo
color->range.across_objectXintMA_RANGE_ACROSSQCNo
color->range.color_modelXintMA_RANGE_MODELQCNo

XintMATERIAL_COLOR_INDEX
PropertyRequired FlagQ/CMemory Required
color->index.tableXintMA_INDEX_TABLEQCNo
color->index.indexXintMA_INDEXQCYes
color->index.num_indicesAny of the above.QNo

You only need to supply data for those properties that you wish to change. Currently, View3D does not support changing the number of colors/indices of a material. If you need to change the number of colors/indices of a material, you will need to create a new material with the number of colors/indices that you require. Because View3D does not support changing the number of vertices of objects, you should never need to change the number of colors/indices.