Point Object


Introduction

The Point object can be used to display clouds of points. A Point object is created with function
XintView3DCreatePoint. Based on the material type used, the color of each point can be uniform based on an attribute value (X, Y or Z), or specified individually for each point.

Example

The following code example (see file pointcloud.c in example directory) illustrates how to create a point cloud, the color of which varies based on the z value of the points.

    int i;
    XintView3DObject             *point_cloud;
    XintView3DMaterial           *material;
    XintVector3                  *vertices;
    XintView3DMaterialColor      color_range;
    XintView3DMaterialAttributes attributes;

    ...

    /* Create a color range material */
    color_range.range.range_direction = XintINTERPOLATE_Z;
    color_range.range.interp_method = XintINTERPOLATE_LINEAR;
    color_range.range.across_object = False;
    color_range.range.color_model = XintCOLOR_MODEL_HSV;

    color_range.range.min_color[0] = 1.0;
    color_range.range.min_color[1] = 0.;
    color_range.range.min_color[2] = 0.;
    color_range.range.min_color[3] = 1.0;

    color_range.range.max_color[0] = 0.;
    color_range.range.max_color[1] = 1.;
    color_range.range.max_color[2] = 0;
    color_range.range.max_color[3] = 1;

    attributes.light = False;
    material = XintView3DCreateMaterial(NULL, XintMATERIAL_RANGE_COLOR,
                                        &color_range, XintMA_LIGHT, 
                                        &attributes);

    /* Generate random points */
    vertices = (XintVector3 *) XtMalloc(sizeof(XintVector3) * NV);

    srand48((long) 100);
    for (i=0; i < NV; i++) {
         vertices[i][0] = drand48();
         vertices[i][1] = drand48();
         vertices[i][2] = drand48();
    }

    /* Create point object*/
    point_cloud = XintView3DCreatePoint("point_cloud", 2.0, NV,
                                        vertices, True, NULL, NULL);

    XtFree((char *) vertices);

    /* Add object to display */
    XintView3DAddObjectAndMaterial(view3d, point_cloud, material, NULL);

    ...

The output of example pointcloud.c is shown below.


Figure 15: Point cloud example