Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

vrml
communitycreator

What is an extrusion node in VRML?

Hemashree Kilari

In Virtual Reality Modeling Language (VRML), extrusion is a node. In mechanical terms, extrusion is a process that changes or makes an object change from its normal position by force. For example, if we want a shaped object like a rod or a tube, we force material into that particular cross-section.

Extrusion nodes can be used to define various complex shapes in VRML. This can be achieved by two main attributes of extrusion:

  • Cross-section
  • Spine

Cross-section

The cross-section attribute can be considered as a base process of how the final extruded shape looks, i.e., the final extruded shape depends on the 2-dimensional cross-section of the shape. In VRML, the cross-section is represented by a 2D array, and any number of dimensions can be given.

For example, consider a cube. The cross-section is a square. Here, the cross-section is defined in the XZ plane. The cross-section for a cube can be defined with the following points:

In the code below, the dimensions [-1 -1, -1 1, 1 -1, -1 -1] in the cross-section will result in a square cross-section.

#VRML V2.0 utf8
Transform{
children
Shape{
appearance Appearance {   
material Material { 
diffuseColor 0 1 1
}
}
geometry Extrusion{
crossSection [-1 -1, -1 1, 1 1, 1 -1, -1 -1]
spine [0 -1 0, 0 1 0]
}
}

The output for the code above will be a simple cube, as shown below:

This cross-section can be in different shapes; it all depends on the dimensions we give. For example, the output of three different cross-sections is given below:

Spine

The spine also plays a very important role in extruding a shape. The spine defines the path on which the whole cross-section will be done, or, based on these spine points, the cross-section will travel through those points to create the required shape. The coordinates given to the spine are always 3-dimensional. In VRML, a 3D array is used to represent the spine points.

For instance:

#VRML V2.0 utf8
Transform{
children
Shape{ appearance Appearance { material Material { diffuseColor 0 1 1}}
geometry Extrusion{
crossSection [-1 -1, -1 1, 1 1, 1 -1, -1 -1]
spine [0 -1 0, 0 1 0]
}
}

When attempting to construct a cube, one might begin with the cross-section at (0, -1, 0) and work upwards to (0, 1, 0). The cube’s spine and the cross-section route are depicted in the following figures.

In the diagram above, the spine is defined by the points (0, -1, 0), (0, -1, 0), and (0, 1, 0). The steps taken by the browser to create an extruded form with two spine points are listed below:

  1. Transform the cross-section to the first point on the spine.
  2. Reorient the cross-section in the XZ plane so that the Y-axis corresponds to the direction determined by the two spine points.
  3. Move the cross-section to the last position on the spine.

The browser will build the cube’s sidewalls after the last step is completed. The outcome is shown in the diagram below.

There is no restriction on how many spine points one can have because it all depends on the required shape. The spine can be compared to a drawing guide because you can obtain the 2D cross-section based on these spine points.

For instance, if we want a “V” shape, then we would just need to change the spine point so that the appropriate cross-section can be achieved.

#VRML V2.0 utf8

Transform{
children
Shape{ appearance Appearance { material Material { diffuseColor 1 1 0}}
geometry Extrusion{
crossSection [-1 -1, -1 1, 1 1, 1 -1, -1 -1]
spine [3 5 0, 0 0 0, -3 5 0]
}
}

As we can see from the previous code, below is the outcome of a “V” shaped spine with a square cross-section, specified by the points (3,5,0), (0,0,0), and (-3,5,0):

Extrusion can also be utilized to produce surfaces of revolution by using a circular spine. The example below shows how extrusion as a revolution surface is used to make a cone. The cross-section points would be (-1,0), (0,0), (-2, -1), (-1,0). Here, eight evenly spaced points in a unitary circle define the spine. The figure below depicts the cross-section (note that the Z-axis points downwards) and a circular spine defined in the XY plane.

With the cross-section as [ -1 0, 0 0, -1 -2 -1 0] and the spine as [1 0 0, 0.707 0 0.707, 0 0 1, -0.707 0 0.707, -1 0 0, -0.707 0 -0.707, 0 0 -1, 0.707 0 -0.707 ,1 0 0], the result will be as follows:

Other attributes

Similarly, the extrusion node has other attributes like begincap and endcap, which specify whether the extruded shape is closed or open at the ends. There are caps present at the ends of an extruded shape by default. These are Boolean values attributes; when both the attributes are “FALSE,” the ends are uncapped.

#VRML V2.0 utf8
  
Shape{
	geometry Box{size 10 0.1 0.1}
}
Shape{
	geometry Box{size 0.1 10 0.1}
}

Shape
{
	geometry Box{size 0.1 0.1 10
}
}

Transform {
        children 
		Shape {  appearance Appearance {material Material { }}
geometry Extrusion{
crossSection [ -1 -1, -1 1, 1 1, 1 -1, -1 -1]
				spine [0 0 -1, 0 0 0, 0 0 1 ]
				scale [1 1, 1 1, 1 1]
				orientation [0 0 1 0, 0 0 1 0, 0 0 1 0]
				solid TRUE
				beginCap TRUE
				endCap TRUE
				convex TRUE
				ccw TRUE
				creaseAngle 0
				solid TRUE
}
}
}

When the example above is executed, the ends of the extruded shape are uncapped, as seen in the figures below:

In the example above, we can see other attributes; they are all boolean-valued attributes. These include:

CCW

The CCW field indicates whether the points that constitute the cross-section are in counter-clockwise (TRUE) or clockwise (FALSE) order.

Convex

The convex field indicates whether or not the cross-section is convex. The browser converts concave cross-sections into smaller convex cross-sections when faced with them. This is a lengthy process. If you are certain that the cross-section is convex, setting this option to TRUE instructs the browser not to split the cross-section, saving time.

Crease angle

The angle threshold is specified by the creaseAngle property. If two adjacent faces form an angle greater than the creaseAngle, the point where the two faces meet will be visible, and the edge connecting the two faces will be sharp. Otherwise, the transition between the two faces’ edges will be seamless.

RELATED TAGS

vrml
communitycreator
RELATED COURSES

View all Courses

Keep Exploring