Open Inventor Release 2024.2.0
 
Loading...
Searching...
No Matches
Additional Shapes

Point Set

Marker Set

C++ :

int
main( int argc, char** argv )
{
// Initialize Inventor and Xt
Widget myWindow = SoXt::init( argv[0] );
// Array containing the coordinates
// of the markers.
SbVec3f markersCoords[NUM_MARKERS] = { SbVec3f( 0.5, 0.5, 0 ), SbVec3f( 1.5, 3.8, 0 ), SbVec3f( 1.8, 1.2, 0 ), SbVec3f( 2.4, 1.9, 0 ),
SbVec3f( 3.2, 6.3, 0 ), SbVec3f( 4.5, 7.2, 0 ), SbVec3f( 6.3, 9.3, 0 ), SbVec3f( 6.9, 7.2, 0 ),
SbVec3f( 8.0, 6.0, 0 ), SbVec3f( 8.5, 6.3, 0 ) };
};
// Array containing the colors of the markers.
SbColor markersColors[NUM_MARKERS] = { SbColor( 1, 0, 0 ), SbColor( 0, 1, 0 ), SbColor( 0, 0, 1 ), SbColor( 1, 1, 1 ), SbColor( 1, 1, 0 ),
SbColor( 1, 0, 1 ), SbColor( 0, 1, 1 ), SbColor( 1, 0, 0 ), SbColor( 0, 1, 0 ), SbColor( 0, 0, 1 ) };
}
;
// Array containing the indices of the markers.
int markersIndexes[NUM_MARKERS] = { 90,
91,
92,
SoMarkerSet::CIRCLE_FILLED_9_9,
SoMarkerSet::SQUARE_FILLED_9_9,
SoMarkerSet::DIAMOND_FILLED_9_9,
SoMarkerSet::TRIANGLE_FILLED_9_9,
SoMarkerSet::RHOMBUS_FILLED_9_9,
SoMarkerSet::HOURGLASS_FILLED_9_9 };
// Array containing a new marker "arrow"
static unsigned char arrowBits[] = { 0x00, 0xff, 0xff, 0x01, 0x00, 0x00, 0xff, 0xff, 0x01, 0x00, 0x00, 0xff, 0xff, 0x01, 0x00, 0x00, 0xff, 0xff, 0x01,
0x00, 0x00, 0xff, 0xff, 0x01, 0x00, 0x00, 0xff, 0xff, 0x01, 0x00, 0x00, 0xff, 0xff, 0x01, 0x00, 0x00, 0xff, 0xff,
0x01, 0x00, 0x00, 0xff, 0xff, 0x01, 0x00, 0x00, 0xff, 0xff, 0x01, 0x00, 0x00, 0xff, 0xff, 0x01, 0x00, 0x00, 0xff,
0xff, 0x01, 0x00, 0x00, 0xff, 0xff, 0x01, 0x00, 0x00, 0xff, 0xff, 0x01, 0x00, 0x00, 0xff, 0xff, 0x01, 0x00, 0x00,
0xff, 0xff, 0x01, 0x00, 0x00, 0xff, 0xff, 0x01, 0x00, 0x00, 0xff, 0xff, 0x01, 0x00, 0x00, 0xff, 0xff, 0x01, 0x00,
0x00, 0xff, 0xff, 0x01, 0x00, 0x00, 0xff, 0xff, 0x01, 0x00, 0x00, 0xff, 0xff, 0x01, 0x00, 0xff, 0xff, 0xff, 0xff,
0x01, 0xff, 0xff, 0xff, 0xff, 0x01, 0xfe, 0xff, 0xff, 0xff, 0x00, 0xf8, 0xff, 0xff, 0x3f, 0x00, 0xe0, 0xff, 0xff,
0x0f, 0x00, 0xc0, 0xff, 0xff, 0x03, 0x00, 0x00, 0xff, 0xff, 0x01, 0x00, 0x00, 0xfc, 0x7f, 0x00, 0x00, 0x00, 0xf8,
0x1f, 0x00, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0x00, 0x80, 0x01, 0x00, 0x00 };
// Array containing a new marker "target"
static unsigned char targetBits[] = { 0xe0, 0x0f, 0x00, 0x18, 0x31, 0x00, 0x04, 0x41, 0x00, 0xc2, 0x87, 0x00, 0x22, 0x89, 0x00, 0x11, 0x11,
0x01, 0x09, 0x21, 0x01, 0x09, 0x21, 0x01, 0xff, 0xff, 0x01, 0x09, 0x21, 0x01, 0x09, 0x21, 0x01, 0x11,
0x11, 0x01, 0x22, 0x89, 0x00, 0xc2, 0x87, 0x00, 0x04, 0x41, 0x00, 0x18, 0x31, 0x00, 0xe0, 0x0f, 0x00 };
// Array containing a new marker "tgs"
static unsigned char tgsBits[] = { 0xff, 0xff, 0x1f, 0x00, 0x00, 0x00, 0x1f, 0x1f, 0x1f, 0x04, 0x11, 0x11, 0x04, 0x01, 0x01, 0x04, 0x1d,
0x1f, 0x04, 0x11, 0x10, 0x04, 0x11, 0x11, 0x04, 0x1f, 0x1f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x1f };
// Add the new markers.
SoMarkerSet::addMarker( 90, SbVec2s( 17, 17 ), targetBits );
SoMarkerSet::addMarker( 91, SbVec2s( 33, 33 ), arrowBits );
SoMarkerSet::addMarker( 92, SbVec2s( 21, 11 ), tgsBits );
SoSeparator* root = new SoSeparator;
root->ref();
// Sets the coordinates of the markers.
SoCoordinate3* coords = new SoCoordinate3;
coords->point.setValues( 0, NUM_MARKERS, markersCoords );
// Sets the indices of the markers.
SoMarkerSet* markerSet = new SoMarkerSet;
markerSet->markerIndex.setValues( 0, NUM_MARKERS, markersIndexes );
SoMaterialBinding* matBind = new SoMaterialBinding;
matBind->value = SoMaterialBinding::PER_VERTEX;
// Sets the color of the markers.
SoMaterial* mat = new SoMaterial;
mat->diffuseColor.setValues( 0, NUM_MARKERS, markersColors );
root->addChild( coords );
root->addChild( new SoLineSet );
root->addChild( matBind );
root->addChild( mat );
root->addChild( markerSet );
// Create a viewer
SoXtExaminerViewer* myViewer;
myViewer = new SoXtExaminerViewer( myWindow );
// Attach and show viewer
myViewer->setSceneGraph( root );
myViewer->setTitle( "Marker" );
myViewer->setSize( SbVec2s( 554, 380 ) );
myViewer->show();
myViewer->viewAll();
// Loop forever
SoXt::show( myWindow );
SoXt::mainLoop();
return 0;
}

C# :

// Array containing the coordinates of the markers.
SbVec3f[] markersCoords = new SbVec3f[NUM_MARKERS] {
new SbVec3f( 0.5f, 0.5f, 0.0f ), new SbVec3f( 1.5f, 3.8f, 0.0f ), new SbVec3f( 1.8f, 1.2f, 0.0f ), new SbVec3f( 2.4f, 1.9f, 0.0f ),
new SbVec3f( 3.2f, 6.3f, 0.0f ), new SbVec3f( 4.5f, 7.2f, 0.0f ), new SbVec3f( 6.3f, 9.3f, 0.0f ), new SbVec3f( 6.9f, 7.2f, 0.0f ),
new SbVec3f( 8.0f, 6.0f, 0.0f ), new SbVec3f( 8.5f, 6.3f, 0.0f )
};
// Array containing the colors of the markers.
SbColor[] markersColors = new SbColor[NUM_MARKERS] {
new SbColor( 1, 0, 0 ), new SbColor( 0, 1, 0 ), new SbColor( 0, 0, 1 ), new SbColor( 1, 1, 1 ), new SbColor( 1, 1, 0 ), new SbColor( 1, 0, 1 ),
new SbColor( 0, 1, 1 ), new SbColor( 1, 0, 0 ), new SbColor( 0, 1, 0 ), new SbColor( 0, 0, 1 )
};
// Array containing the indices of the markers.
int[] markersIndexes = new int[NUM_MARKERS] {
90, 91, 92, ( int )SoMarkerSet.MarkerTypes.CIRCLE_FILLED_9_9, ( int )SoMarkerSet.MarkerTypes.SQUARE_FILLED_9_9,
( int )SoMarkerSet.MarkerTypes.DIAMOND_FILLED_9_9, ( int )SoMarkerSet.MarkerTypes.TRIANGLE_FILLED_9_9,
( int )SoMarkerSet.MarkerTypes.RHOMBUS_FILLED_9_9, ( int )SoMarkerSet.MarkerTypes.HOURGLASS_FILLED_9_9, 0
};
// Array containing a new marker ()"arrow"
byte[] arrowBits =
new byte[]{ 0x00, 0xff, 0xff, 0x01, 0x00, 0x00, 0xff, 0xff, 0x01, 0x00, 0x00, 0xff, 0xff, 0x01, 0x00, 0x00, 0xff, 0xff, 0x01, 0x00, 0x00,
0xff, 0xff, 0x01, 0x00, 0x00, 0xff, 0xff, 0x01, 0x00, 0x00, 0xff, 0xff, 0x01, 0x00, 0x00, 0xff, 0xff, 0x01, 0x00, 0x00, 0xff,
0xff, 0x01, 0x00, 0x00, 0xff, 0xff, 0x01, 0x00, 0x00, 0xff, 0xff, 0x01, 0x00, 0x00, 0xff, 0xff, 0x01, 0x00, 0x00, 0xff, 0xff,
0x01, 0x00, 0x00, 0xff, 0xff, 0x01, 0x00, 0x00, 0xff, 0xff, 0x01, 0x00, 0x00, 0xff, 0xff, 0x01, 0x00, 0x00, 0xff, 0xff, 0x01,
0x00, 0x00, 0xff, 0xff, 0x01, 0x00, 0x00, 0xff, 0xff, 0x01, 0x00, 0x00, 0xff, 0xff, 0x01, 0x00, 0x00, 0xff, 0xff, 0x01, 0x00,
0x00, 0xff, 0xff, 0x01, 0x00, 0xff, 0xff, 0xff, 0xff, 0x01, 0xff, 0xff, 0xff, 0xff, 0x01, 0xfe, 0xff, 0xff, 0xff, 0x00, 0xf8,
0xff, 0xff, 0x3f, 0x00, 0xe0, 0xff, 0xff, 0x0f, 0x00, 0xc0, 0xff, 0xff, 0x03, 0x00, 0x00, 0xff, 0xff, 0x01, 0x00, 0x00, 0xfc,
0x7f, 0x00, 0x00, 0x00, 0xf8, 0x1f, 0x00, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0x00, 0x80, 0x01, 0x00, 0x00 };
// Array containing a new marker ()"target"
byte[] targetBits = new byte[]{ 0xe0, 0x0f, 0x00, 0x18, 0x31, 0x00, 0x04, 0x41, 0x00, 0xc2, 0x87, 0x00, 0x22, 0x89, 0x00, 0x11, 0x11,
0x01, 0x09, 0x21, 0x01, 0x09, 0x21, 0x01, 0xff, 0xff, 0x01, 0x09, 0x21, 0x01, 0x09, 0x21, 0x01, 0x11,
0x11, 0x01, 0x22, 0x89, 0x00, 0xc2, 0x87, 0x00, 0x04, 0x41, 0x00, 0x18, 0x31, 0x00, 0xe0, 0x0f, 0x00 };
// Array containing a new marker ()"tgs"
byte[] tgsBits = new byte[]{ 0xff, 0xff, 0x1f, 0x00, 0x00, 0x00, 0x1f, 0x1f, 0x1f, 0x04, 0x11, 0x11, 0x04, 0x01, 0x01, 0x04, 0x1d,
0x1f, 0x04, 0x11, 0x10, 0x04, 0x11, 0x11, 0x04, 0x1f, 0x1f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x1f };
// Add the new markers.
SoMarkerSet.AddMarker( 90, new SbVec2s( 17, 17 ), targetBits );
SoMarkerSet.AddMarker( 91, new SbVec2s( 33, 33 ), arrowBits );
SoMarkerSet.AddMarker( 92, new SbVec2s( 21, 11 ), tgsBits );
SoSeparator root = new SoSeparator();
// Sets the coordinates of the markers.
SoCoordinate3 coords = new SoCoordinate3();
coords.point.SetValues( 0, markersCoords );
// Sets the indices of the markers.
SoMarkerSet markerSet = new SoMarkerSet();
markerSet.markerIndex.SetValues( 0, markersIndexes );
SoMaterialBinding matBind = new SoMaterialBinding();
matBind.value.SetValue( ( int )SoMaterialBinding.Bindings.PER_VERTEX );
// Sets the color of the markers.
SoMaterial mat = new SoMaterial();
mat.diffuseColor.SetValues( 0, markersColors );
root.AddChild( coords );
root.AddChild( new SoLineSet() );
root.AddChild( matBind );
root.AddChild( mat );
root.AddChild( markerSet );
// Create a viewer
SoWinExaminerViewer myViewer;
myViewer = new SoWinExaminerViewer( this, "", true, SoWinFullViewer.BuildFlags.BUILD_ALL, SoWinViewer.Types.BROWSER );
// attach and show viewer
myViewer.SetSceneGraph( root );
myViewer.SetTitle( "Marker" );
// myViewer.SetSize(SbVec2s(554, 380));
myViewer.Show();
myViewer.ViewAll();

Java :

static SbVec3f markersCoords[] = { new SbVec3f( 0.5f, 0.5f, 0.f ), new SbVec3f( 1.5f, 3.8f, 0.f ), new SbVec3f( 1.8f, 1.2f, 0.f ),
new SbVec3f( 2.4f, 1.9f, 0.f ), new SbVec3f( 3.2f, 6.3f, 0.f ), new SbVec3f( 4.5f, 7.2f, 0.f ),
new SbVec3f( 6.3f, 9.3f, 0.f ), new SbVec3f( 6.9f, 7.2f, 0.f ), new SbVec3f( 8.0f, 6.0f, 0.f ),
new SbVec3f( 8.5f, 6.3f, 0.f ) };
static SbColor markersColors[] = { new SbColor( 1, 0, 0 ), new SbColor( 0, 1, 0 ), new SbColor( 0, 0, 1 ), new SbColor( 1, 1, 1 ),
new SbColor( 1, 1, 0 ), new SbColor( 1, 0, 1 ), new SbColor( 0, 1, 1 ), new SbColor( 1, 0, 0 ),
new SbColor( 0, 1, 0 ), new SbColor( 0, 0, 1 ) };
static byte arrowBits[] = {
( byte )0x00, ( byte )0xff, ( byte )0xff, ( byte )0x01, ( byte )0x00, ( byte )0x00, ( byte )0xff, ( byte )0xff, ( byte )0x01, ( byte )0x00,
( byte )0x00, ( byte )0xff, ( byte )0xff, ( byte )0x01, ( byte )0x00, ( byte )0x00, ( byte )0xff, ( byte )0xff, ( byte )0x01, ( byte )0x00,
( byte )0x00, ( byte )0xff, ( byte )0xff, ( byte )0x01, ( byte )0x00, ( byte )0x00, ( byte )0xff, ( byte )0xff, ( byte )0x01, ( byte )0x00,
( byte )0x00, ( byte )0xff, ( byte )0xff, ( byte )0x01, ( byte )0x00, ( byte )0x00, ( byte )0xff, ( byte )0xff, ( byte )0x01, ( byte )0x00,
( byte )0x00, ( byte )0xff, ( byte )0xff, ( byte )0x01, ( byte )0x00, ( byte )0x00, ( byte )0xff, ( byte )0xff, ( byte )0x01, ( byte )0x00,
( byte )0x00, ( byte )0xff, ( byte )0xff, ( byte )0x01, ( byte )0x00, ( byte )0x00, ( byte )0xff, ( byte )0xff, ( byte )0x01, ( byte )0x00,
( byte )0x00, ( byte )0xff, ( byte )0xff, ( byte )0x01, ( byte )0x00, ( byte )0x00, ( byte )0xff, ( byte )0xff, ( byte )0x01, ( byte )0x00,
( byte )0x00, ( byte )0xff, ( byte )0xff, ( byte )0x01, ( byte )0x00, ( byte )0x00, ( byte )0xff, ( byte )0xff, ( byte )0x01, ( byte )0x00,
( byte )0x00, ( byte )0xff, ( byte )0xff, ( byte )0x01, ( byte )0x00, ( byte )0x00, ( byte )0xff, ( byte )0xff, ( byte )0x01, ( byte )0x00,
( byte )0x00, ( byte )0xff, ( byte )0xff, ( byte )0x01, ( byte )0x00, ( byte )0x00, ( byte )0xff, ( byte )0xff, ( byte )0x01, ( byte )0x00,
( byte )0x00, ( byte )0xff, ( byte )0xff, ( byte )0x01, ( byte )0x00, ( byte )0x00, ( byte )0xff, ( byte )0xff, ( byte )0x01, ( byte )0x00,
( byte )0xff, ( byte )0xff, ( byte )0xff, ( byte )0xff, ( byte )0x01, ( byte )0xff, ( byte )0xff, ( byte )0xff, ( byte )0xff, ( byte )0x01,
( byte )0xfe, ( byte )0xff, ( byte )0xff, ( byte )0xff, ( byte )0x00, ( byte )0xf8, ( byte )0xff, ( byte )0xff, ( byte )0x3f, ( byte )0x00,
( byte )0xe0, ( byte )0xff, ( byte )0xff, ( byte )0x0f, ( byte )0x00, ( byte )0xc0, ( byte )0xff, ( byte )0xff, ( byte )0x03, ( byte )0x00,
( byte )0x00, ( byte )0xff, ( byte )0xff, ( byte )0x01, ( byte )0x00, ( byte )0x00, ( byte )0xfc, ( byte )0x7f, ( byte )0x00, ( byte )0x00,
( byte )0x00, ( byte )0xf8, ( byte )0x1f, ( byte )0x00, ( byte )0x00, ( byte )0x00, ( byte )0xe0, ( byte )0x07, ( byte )0x00, ( byte )0x00,
( byte )0x00, ( byte )0x80, ( byte )0x01, ( byte )0x00, ( byte )0x00
};
static byte targetBits[] = { ( byte )0xe0, ( byte )0x0f, ( byte )0x00, ( byte )0x18, ( byte )0x31, ( byte )0x00, ( byte )0x04, ( byte )0x41,
( byte )0x00, ( byte )0xc2, ( byte )0x87, ( byte )0x00, ( byte )0x22, ( byte )0x89, ( byte )0x00, ( byte )0x11,
( byte )0x11, ( byte )0x01, ( byte )0x09, ( byte )0x21, ( byte )0x01, ( byte )0x09, ( byte )0x21, ( byte )0x01,
( byte )0xff, ( byte )0xff, ( byte )0x01, ( byte )0x09, ( byte )0x21, ( byte )0x01, ( byte )0x09, ( byte )0x21,
( byte )0x01, ( byte )0x11, ( byte )0x11, ( byte )0x01, ( byte )0x22, ( byte )0x89, ( byte )0x00, ( byte )0xc2,
( byte )0x87, ( byte )0x00, ( byte )0x04, ( byte )0x41, ( byte )0x00, ( byte )0x18, ( byte )0x31, ( byte )0x00,
( byte )0xe0, ( byte )0x0f, ( byte )0x00 };
static byte tgsBits[] = { ( byte )0xff, ( byte )0xff, ( byte )0x1f, ( byte )0x00, ( byte )0x00, ( byte )0x00, ( byte )0x1f,
( byte )0x1f, ( byte )0x1f, ( byte )0x04, ( byte )0x11, ( byte )0x11, ( byte )0x04, ( byte )0x01,
( byte )0x01, ( byte )0x04, ( byte )0x1d, ( byte )0x1f, ( byte )0x04, ( byte )0x11, ( byte )0x10,
( byte )0x04, ( byte )0x11, ( byte )0x11, ( byte )0x04, ( byte )0x1f, ( byte )0x1f, ( byte )0x00,
( byte )0x00, ( byte )0x00, ( byte )0xff, ( byte )0xff, ( byte )0x1f };
static
{
SoMarkerSet.addMarker( 90, new SbVec2s( ( short )17, ( short )17 ), targetBits, true, true );
SoMarkerSet.addMarker( 91, new SbVec2s( ( short )33, ( short )33 ), arrowBits, true, true );
SoMarkerSet.addMarker( 92, new SbVec2s( ( short )21, ( short )11 ), tgsBits, true, true );
}
...
SoCoordinate3 coords = new SoCoordinate3();
coords.point.setValues( 0, markersCoords );
markerSet = new SoMarkerSet();
markerSet.markerIndex.setValue( 0 );
SoMaterialBinding matBind = new SoMaterialBinding();
matBind.value.setValue( SoMaterialBinding.Bindings.PER_VERTEX );
SoMaterial mat = new SoMaterial();
mat.diffuseColor.setValues( 0, markersColors );
// Create the root of the scene graph
SoSeparator root = new SoSeparator();
{ // assemble scene graph
root.addChild( coords );
root.addChild( new SoLineSet() );
root.addChild( matBind );
root.addChild( mat );
root.addChild( markerSet );
}
SwSimpleViewer viewer = new SwSimpleViewer( SwSimpleViewer.EXAMINER );
viewer.setSceneGraph( root );
viewer.viewAll();

Buffered Shape

The purpose of the node SoBufferedShape is to manage the rendering of large geometry, provide application control over where the data is stored (CPU or GPU) and to integrate rendering with the Open Inventor computing framework (through the SoBufferObject classes). SoBufferedShape provides fields for:

  • Vertices
  • Indices (optional)
  • Colors (optional)
  • Normals (optional)
  • Texture coordinates (optional) In this sense it is similar to the SoVertexProperty node, but SoVertexProperty is just a property node. SoBufferedShape also does the rendering of the shape. Properties that are not specified are taken from the traversal state (e.g. colors) or computed (e.g. normals).

SoBufferedShape can render multiple geometric primitives of the same type. You specify the number of vertices (or indices if provided) to use for each primitive in the SoMFInt32 field primitiveCount. SoBufferedShape can render many types of geometric primitives. You specify the type of primitive in the SoSFEnum field shapeType:

  • POINTS

Draws each vertex as a single point.

  • LINES

Connects every other pair of vertices with a line. Given vertices A B C D, it draws the line segments AB and CD.

  • LINE_STRIP

Connects every pair of vertices with a line, i.e. a polyline. Given vertices A B C D, it draws the line segments AB, BC and CD.

  • LINE_LOOP

Like LINE_STRIP, but an extra line segment is drawn connecting the last vertex to the first vertex.

  • TRIANGLES

Draws unconnected triangles. Given vertices A B C D E F, it draws the triangles ABC and DEF.

  • TRIANGLE_STRIP

Draws a strip of connected triangles. Given vertices A B C D E F, it draws the triangles ABC, CBD, CDE and EDF.

  • TRIANGLE_FAN

Draws a fan of triangles. Given vertices A B C D E F, it draws the triangles ABC, ACD, ADE and AEF.

  • QUADS

Draws unconnected quadrilaterals. Given vertices A B C D E F G H, it draws the quadrilaterals ABCD and EFGH.

  • QUAD_STRIP

Draws a strip of connected quadrilaterals. Given vertices A B C D E F, it draws the quadrilaterals ABCD and CDFE.

  • POLYGON

Draws a single polygon using all the vertices (in each primitive). The geometry and its attributes must be stored in buffer objects (See Open Inventor Computing framework for more information). The buffer objects can be SoGLBufferObjects stored directly on the graphics board or SoCpuBufferObjects stored in system memory. This allows the application to control what data is stored where SoBufferedShape provides fields to describe the content of the buffers, e.g. the data type and number of components in each buffer, as well as how to access the buffers, e.g. the offset into the buffer and “stride” separating data values in the buffer.

Examples:

  • AnimatedShape (src\Inventor\examples\Features\BufferObjects)

an example of dynamic buffered shapes based on time animation.

  • BufferedShape (src\Inventor\examples\Features\BufferObjects)

an example of a large dataset loaded in SoGLBufferObjects (i.e. data stored directly on the GPU) and used in a SoBufferedShape.

Extrusion