Geometric Object


Introduction

The Geometric object offers a simplified interface for generating simple 3D shapes. A geometric object can be either a cylinder, cone, cube or sphere. Geometric objects are created using function
XintView3DCreateGeometric.

Figure 19: Geometric Object Example


Example

The following code example (see file geom.c in example directory) illustrates how to create Geometric objects.

     ...
     Widget view3d;
     XintView3DObject *cylinder;
     XintView3DObject *cone;
     XintView3DObject *cube;
     XintView3DObject *sphere;
     XintView3DMaterialColor color;
     XintView3DMaterial	*material[4];
     XintVector3 location[4] = {
	                        { 0.0,  0.0, 0.0},
	                        {20.0,  0.0, 0.0},
	                        {20.0, 20.0, 0.0},
	                        { 0.0, 20.0, 0.0}
                               };
     double dimension[4][3] = {
	                       {20.0, 10.0,  0.0},
	                       {20.0, 10.0,  0.0},
	                       {20.0, 20.0, 20.0},
	                       {10.0,  0.0,  0.0}
                              };

     ...

     /* Create the View3D widget */
     view3d = XtVaCreateManagedWidget("Viewer3D", xintView3DWidgetClass, 
	                              top_level, XmNwidth,  400,
	                              XmNheight, 400, XmNgridOn, False,
	                              XmNxUnit, "meters",
	                              XmNyUnit, "meters",
	                              XmNzUnit, "meters",
	                              XmNrotationMode, XintROTATE_WIREFRAME,
	                              NULL);

     ...

     /* Create a single color material */
     color.single[0] = 1.0;
     color.single[1] = 1.0;
     color.single[2] = 1.0;
     color.single[3] = 1.0;
     material[0] = XintView3DCreateMaterial(NULL,XintMATERIAL_SINGLE_COLOR,
 	                                    &color, 0, NULL);
     
     ...

     /* Create the geometric objects */
     cylinder = XintView3DCreateGeometric("Cylinder", 
	                                  XintOBJECT_GEOMETRIC_CYLINDER,
	                                  dimension[0],location[0], 30, True,
	                                  NULL, NULL);

     ...

     /* Add all the objects */
     XintView3DAddObjectAndMaterial(view3d, cylinder, material[0], NULL);


Material Property

Geometric objects can use all existing material types with some limitations.

Each geometric object can only be displayed with a single color. Although you can assign multiple color materials to a geometric object, only a single color will be used.

Texture mapping is fully supported. The top of the texture map will be mapped to the top of the object (except for cubes), and the bottom of the texture map will be mapped to the bottom of the object (except for cubes). The remainder of the texture map will be wrapped around the object.

The cube geometric object (XintOBJECT_GEOMETRIC_CUBE) will have the complete texture map visible on all 6 surfaces.