Class SoExtrusion
- java.lang.Object
-
- All Implemented Interfaces:
SafeDisposable
public class SoExtrusion extends SoBaseExtrusion
Geometric shape formed by extruding a 2D cross section along a 3D spine. TheSoExtrusionnode specifies geometric shapes based on a two-dimensional cross section extruded along a three-dimensional spine. The cross section can be scaled and rotated at each spine point to produce a wide variety of shapes.An
SoExtrusionis defined by:crossSection
The shape that will be extruded, defined by a 2D piecewise linear curve in the XZ plane (described as a series of connected vertices).spine
The cross-section is extruded along this path, defined by a 3D piecewise linear curve (described as a series of connected vertices). This field is inherited from the parent classSoBaseExtrusion.scalevalues
The cross-section curve is scaled by this value on the X and Z axes. If one value is specified it applies to every spine point, else there should be as many values as there are points in the spine. All scale values must be > 0.orientationvalues, The cross-section curve is rotated by this value relative to a local reference system with origin at the current spine point and X / Z axes in the plane containing the cross-section curve. If one value is specified it applies to every spine point, else there should be as many values as there are points in the spine.
Shapes are constructed as follows - For each point in the spine, the cross-section curve, which is a curve in the XZ plane, is scaled about the origin by the corresponding
scaleparameter (first value scales in X, second value scales in Z), rotated about the origin by the correspondingorientationparameter and translated by the vector defined by the corresponding vertex of thespinecurve. Each instance of the cross-section is then connected to the following instance.The
scaleModefield is used to select the points that will be scaled by the current transformation (for exampleSoTransform), if any. Translation and rotation are applied in all cases. The options are:- DEFAULT : Every point in the generated geometry is scaled.
- SPINE_ONLY : Only the spine points are scaled. The cross section points are not scaled, so the cross section shape is undistorted even is scaling is non-uniform.
- SECTION_ONLY : Only the cross section points are scaled. Not currently implemented.
- NONE :
SoExtrusionignores the scaling state. Not currently implemented.
A transformed cross section is found for each joint (that is, at each vertex of the
spinecurve, where segments of the extrusion connect), and the joints and segments are connected to form the surface. No check is made for self-penetration. Each transformed cross section is determined as follows:1. Start with the cross section as specified, in the XZ plane.
2. Scale it about (0, 0, 0) by the value for
scalegiven for the current joint.3. Apply a rotation so that when the cross section is placed at its proper location on the spine it will be oriented properly. Essentially, this means that the cross section's Y axis ( up vector coming out of the cross section) is rotated to align with an approximate tangent to the spine curve.
For all points other than the first or last: The tangent for
spine[ i ] is found by normalizing the vector defined by (spine[ i +1] -spine[ i -1]).If the spine curve is closed: The first and last points need to have the same tangent. This tangent is found as above, but using the points
spine[0] forspine[ i ],spine[1] forspine[ i +1] andspine[ n -2] forspine[ i -1], wherespine[ n -2] is the next to last point on the curve. The last point in the curve,spine[ n -1], is the same as the first,spine[0].If the spine curve is not closed: The tangent used for the first point is just the direction from
spine[0] tospine[1], and the tangent used for the last is the direction fromspine[ n -2] tospine[ n -1].In the simple case where the spine curve is flat in the XY plane, these rotations are all just rotations about the Z axis. In the more general case where the spine curve is any 3D curve, you need to find the destinations for all 3 of the local X, Y, and Z axes so you can completely specify the rotation. The Z axis is found by taking the cross product of:
(
spine[ i -1] -spine[ i ]) and (spine[ i +1] -spine[ i ]).If the three points are collinear then this value is zero, so take the value from the previous point. Once you have the Z axis (from the cross product) and the Y axis (from the approximate tangent), calculate the X axis as the cross product of the Y and Z axes.
4. Given the plane computed in step 3, apply the
orientationto the cross-section relative to this new plane. Rotate it counterclockwise about the axis and by the angle specified in theorientationfield at that joint.5. Finally, the cross section is translated to the location of the
spinepoint.
Surfaces of revolution: If the cross section is an approximation of a circle and the spine is straight, then the
SoExtrusionis equivalent to a surface of revolution, where thescaleparameters define the size of the cross section along the spine.Cookie-cutter extrusions: If the scale is 1, 1 and the spine is straight, then the cross section acts like a cookie cutter, with the thickness of the cookie equal to the length of the spine.
Bend/twist/taper objects: These shapes are the result of using all fields. The spine curve bends the extruded shape defined by the cross section, the orientation parameters twist it around the spine, and the scale parameters taper it (by scaling about the spine).
SoExtrusionhas three parts: the sides, thebeginCap(the surface at the initial end of the spine) and theendCap(the surface at the final end of the spine). The caps have an associated SFBool field that indicates whether it exists (true) or doesn't exist (false).When the
beginCaporendCapfields are specified as true, planar cap surfaces will be generated regardless of whether thecrossSectionis a closed curve. (IfcrossSectionisn't a closed curve, the caps are generated as if it wereequivalent to adding a final point to crossSectionthat's equal to the initial point. Note that an open surface can still have a cap, resulting (for a simple case) in a shape something like a soda can sliced in half vertically.) These surfaces are generated even ifspineis also a closed curve. If a field value is false, the corresponding cap is not generated.SoExtrusionautomatically generates its own normals. Orientation of the normals is determined by the vertex ordering of the quads generated bySoExtrusion. The vertex ordering is in turn determined by thecrossSectioncurve. If thecrossSectionis counterclockwise when viewed from the +Y axis, then the polygons will have counterclockwise ordering when viewed from 'outside' of the shape (and vice versa for clockwise orderedcrossSectioncurves).Texture coordinates are automatically generated by extrusions. Textures are mapped so that the coordinates range in the U direction from 0 to 1 along the
crossSectioncurve (with 0 corresponding to the first point incrossSectionand 1 to the last) and in the V direction from 0 to 1 along thespinecurve (again with 0 corresponding to the first listedspinepoint and 1 to the last). WhencrossSectionis closed, the texture has a seam that follows the line traced by thecrossSection's start/end point as it travels along thespine. If theendCapand/orbeginCapexist, thecrossSectioncurve is uniformly scaled and translated so that the largest dimension of the cross-section (X or Z) produces texture coordinates that range from 0.0 to 1.0. ThebeginCapandendCaptextures' S and T directions correspond to the X and Z directions in which thecrossSectioncoordinates are defined.Also 3D texture coordinates are automatically generated, in a similar way to 2D textures.
NOTE: If your extrusion appears to twist unexpectedly, try setting environment variable OIV_EXTRUSION_EPSILON to a value slightly smaller number than the default, which is .998.
NOTE: If your
crossSectionis not convex, you must use aSoShapeHintsand set the faceType field to UNKNOWN_FACE_TYPE.File format/default:
Extrusion {
beginCap true endCap true spine [ 0 0 0, 0 1 0 ] scaleMode DEFAULT crossSection [ 1 1, 1 -1, -1 -1, -1 1, 1 1 ] orientation 0 0 1 0 scale 1 1 - See Also:
SoBaseExtrusion
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.openinventor.inventor.nodes.SoBaseExtrusion
SoBaseExtrusion.ExtrusionModes, SoBaseExtrusion.ScaleModes
-
Nested classes/interfaces inherited from class com.openinventor.inventor.nodes.SoShape
SoShape.ShapeTypes
-
Nested classes/interfaces inherited from class com.openinventor.inventor.nodes.SoNode
SoNode.RenderModes
-
Nested classes/interfaces inherited from class com.openinventor.inventor.Inventor
Inventor.ConstructorCommand
-
-
Field Summary
Fields Modifier and Type Field Description SoMFVec2fcrossSectionThe shape that will be extruded, defined by a 2D piecewise linear curve in the XZ plane (described as a series of connected vertices).SoMFRotationorientationThe cross-section curve is rotated by this value relative to a local reference system with origin at the current spine point and X / Z axes in the plane containing the cross-section curve.SoMFVec2fscaleThe cross-section curve is scaled by this value on the X and Z axes.-
Fields inherited from class com.openinventor.inventor.nodes.SoBaseExtrusion
beginCap, endCap, extrusionMode, scaleMode, spine
-
Fields inherited from class com.openinventor.inventor.nodes.SoShape
boundingBoxIgnoring
-
Fields inherited from class com.openinventor.inventor.Inventor
VERBOSE_LEVEL, ZeroHandle
-
-
Constructor Summary
Constructors Constructor Description SoExtrusion()Constructor.
-
Method Summary
-
Methods inherited from class com.openinventor.inventor.nodes.SoShape
getShapeType, isPrimitiveRestartAvailable, isPrimitiveRestartAvailable
-
Methods inherited from class com.openinventor.inventor.nodes.SoNode
affectsState, callback, copy, copy, distribute, doAction, getAlternateRep, getBoundingBox, getByName, getMatrix, getPrimitiveCount, getRenderEngineMode, getRenderUnitID, GLRender, GLRenderBelowPath, GLRenderInPath, GLRenderOffPath, grabEventsCleanup, grabEventsSetup, handleEvent, isBoundingBoxIgnoring, isOverride, pick, rayPick, search, setOverride, touch, write
-
Methods inherited from class com.openinventor.inventor.fields.SoFieldContainer
copyFieldValues, copyFieldValues, enableNotify, fieldsAreEqual, get, getAllFields, getEventIn, getEventOut, getField, getFieldName, hasDefaultValues, isNotifyEnabled, set, setToDefaults
-
Methods inherited from class com.openinventor.inventor.misc.SoBase
dispose, getName, isDisposable, isSynchronizable, setName, setSynchronizable
-
Methods inherited from class com.openinventor.inventor.Inventor
getNativeResourceHandle
-
-
-
-
Field Detail
-
crossSection
public final SoMFVec2f crossSection
The shape that will be extruded, defined by a 2D piecewise linear curve in the XZ plane (described as a series of connected vertices). Default is a square [ 1 1, 1 -1, -1 -1, -1 1, 1 1 ].
-
orientation
public final SoMFRotation orientation
The cross-section curve is rotated by this value relative to a local reference system with origin at the current spine point and X / Z axes in the plane containing the cross-section curve. If one value is specified it applies to every spine point, else there should be as many values as there are points in the spine. Default is no rotation.
-
scale
public final SoMFVec2f scale
The cross-section curve is scaled by this value on the X and Z axes. If one value is specified it applies to every spine point, else there should be as many values as there are points in the spine. All scale values must be > 0. Default is (1,1) meaning no scaling.
-
-