Fill Settings for 3D Objects

This section covers how to configure fill settings for standard models and polygons.

By changing these settings, you can disable filling for polygon surfaces and render only their edges. This allows you to render models in wireframe style, for example.

- Table of Contents -

Fill Settings

Fill settings determine whether the surfaces inside the edges of polygons -- used to form 3D models -- should be filled when rendering.

By default, filling is enabled, so 3D models appear as a collection of filled surfaces. However, if you disable this setting, 3D models will be rendered as collections of lines instead, giving them a wireframe appearance often seen in sci-fi works and debugging tools.

Fill Settings for Models

To configure fill settings for an entire model, use the setModelFill(...) function.

- Function Format -

void setModelFill ( int modelID, bool fill )

Arguments:

Fill Settings for Polygons

To configure fill settings for a specific polygon, use the setPolygonFill(...) function.

- Function Format -

void setPolygonFill ( int polygonID, bool fill )

Arguments:

Example Program

Let's actually create a sphere model and disable its fill setting to render it in wireframe style. Try entering and running the following program:


import graphics3d.Graphics3DFramework;
import Graphics3D;

// Function called at the start of the program
void onStart ( int rendererID ) {

	// Optional: set window size and background color
	setWindowSize( 800, 600 );
	setBackgroundColor( 0, 0, 0, 255 );


	// Create and mount a coordinate axis model
	int axis = newAxisModel( 3.0, 3.0, 3.0 );
	mountModel( axis, rendererID );

	// Create and mount a sphere model
	int sphere = newSphereModel( 2.0, 2.0, 2.0, 10, 8 );
	mountModel( sphere, rendererID );

	// Disable fill setting to render as wireframe
	setModelFill( sphere, false );
}
Sample.vcssl

When you run this program, a white sphere will be rendered in wireframe on a black background.

Execution Result
Execution Result
The result shows that the fill setting for the sphere model has been changed to "disabled".

Normally, the inner faces of a model are not rendered, since they are typically not visible. However, when rendering in wireframe mode as shown in the example above, the absence of inner faces might look unnatural. If you also want to render the inner sides, add the following line after creating the sphere model in the program above:

setModelCull(sphere, false, false);

This disables the backface culling feature, allowing the back sides of polygons to be rendered as well.