Open Inventor Release 2024.1.0
 
Loading...
Searching...
No Matches
SoToU3DAction Class Reference

HardCopy Export a scene graph to a U3D file. More...

#include <HardCopy/SoToU3DAction.h>

+ Inheritance diagram for SoToU3DAction:

Public Member Functions

virtual SoType getTypeId () const
 Returns the type identifier for this specific instance.
 
 SoToU3DAction ()
 
virtual ~SoToU3DAction ()
 
virtual SoNONUNICODE bool openFile (const char *filename)
 Set the U3D output file.
 
virtual bool openFile (const SbString &filename)
 Set the U3D output file.
 
virtual bool closeFile ()
 Finalize export to the U3D output file.
 
virtual void apply (SoNode *node)
 Initiates an action on the graph specified by a node.
 
virtual void apply (SoPath *path)
 Initiates an action on the graph specified by a path.
 
virtual void apply (const SoPathList &pathList, SbBool obeysRules=false)
 Initiates an action on the graph specified by list of paths.
 
void forcePolygonalText3 (bool force)
 Forces SoText2 nodes to be exported using SoText3 (default is true).
 
bool isPolygonalText3Forced () const
 Returns true if polygonal text3 is forced (see forcePolygonalText3).
 
void setExportDraggers (bool force)
 Allow the export of draggers (default is true).
 
bool areDraggersExported () const
 Returns true if draggers are exported.
 
virtual void forwardTraversal (SoNode *node)
 Traverse a node that is not part of the current scenegraph.
 
virtual void forwardTraversal (SoPath *path)
 Traverse a node that is not part of the current scenegraph.
 
- Public Member Functions inherited from SoCallbackAction
 SoCallbackAction ()
 The constructor.
 
void addPreCallback (SoType type, SoCallbackActionCB *cb, void *data)
 Adds a callback function to call when a node of the given type is encountered during traversal.
 
void addPostCallback (SoType type, SoCallbackActionCB *cb, void *data)
 Adds a callback function to call when a node of the given type is encountered during traversal.
 
void addPreTailCallback (SoCallbackActionCB *cb, void *data)
 Sets up a callback function to call when the action is applied to a path.
 
void addPostTailCallback (SoCallbackActionCB *cb, void *data)
 Sets up a callback function to call when the action is applied to a path.
 
void addTriangleCallback (SoType type, SoTriangleCB *cb, void *data)
 Routine to add callbacks for generated primitives (triangles) for all shapes of the given type.
 
void addLineSegmentCallback (SoType type, SoLineSegmentCB *cb, void *data)
 Routine to add callbacks for generated primitives (line segments) for all shapes of the given type.
 
void addPointCallback (SoType type, SoPointCB *cb, void *data)
 Routine to add callbacks for generated primitives (points) for all shapes of the given type.
 
float getComplexity () const
 Returns complexity information from the state.
 
SoComplexity::Type getComplexityType () const
 Returns complexity information from the state.
 
int32_t getNumCoordinates () const
 Returns the current coordinates from the state.
 
const SbVec3fgetCoordinate3 (int index) const
 Returns the current coordinates from the state.
 
const SbVec4fgetCoordinate4 (int index) const
 Returns the current coordinates from the state.
 
SoDecimationTypeElement::Type getDecimationType () const
 Returns the current decimation type from the state.
 
float getDecimationPercentage () const
 Returns the current decimation percentage from the state.
 
SoDrawStyle::Style getDrawStyle () const
 Returns the current drawing style information from the state.
 
u_short getLinePattern () const
 Returns the current drawing style information from the state.
 
int getLinePatternScaleFactor () const
 Returns the current drawing style information from the state.
 
float getLineWidth () const
 Returns the current drawing style information from the state.
 
float getPointSize () const
 Returns the current drawing style information from the state.
 
const SbStringgetFontName () const
 Returns the current font information from the state.
 
float getFontSize () const
 Returns the current font information from the state.
 
SoFont::RenderStyle getFontRenderStyle () const
 Returns the current font information from the state.
 
SoLightModel::Model getLightModel () const
 Returns the current lighting model information from the state.
 
const SbVec3fgetLightAttenuation () const
 Returns the current lighting model information from the state.
 
void getMaterial (SbColor &ambient, SbColor &diffuse, SbColor &specular, SbColor &emission, float &shininess, float &transparency, int mtlIndex=0) const
 Returns the current material information from the state.
 
SoMaterialBinding::Binding getMaterialBinding () const
 Returns the current material information from the state.
 
SoGLRenderAction::TransparencyType getTransparencyType () const
 Returns the current Transparency Type information from the state.
 
int32_t getNumNormals () const
 Returns the current normal information from the state.
 
const SbVec3fgetNormal (int index) const
 Returns the current normal information from the state.
 
SoNormalBinding::Binding getNormalBinding () const
 Returns the current normal information from the state.
 
int32_t getNumProfileCoordinates () const
 Returns the current profiles and their coordinates from the state.
 
const SbVec2fgetProfileCoordinate2 (int index) const
 Returns the current profiles and their coordinates from the state.
 
const SbVec3fgetProfileCoordinate3 (int index) const
 Returns the current profiles and their coordinates from the state.
 
const SoNodeListgetProfile () const
 Returns the current profiles and their coordinates from the state.
 
SoShapeHints::VertexOrdering getVertexOrdering () const
 Returns the current shape hints from the state.
 
SoShapeHints::ShapeType getShapeType () const
 Returns the current shape hints from the state.
 
SoShapeHints::FaceType getFaceType () const
 Returns the current shape hints from the state.
 
float getCreaseAngle () const
 Returns the current shape hints from the state.
 
int32_t getNumTextureCoordinates () const
 Returns texture information from the state.
 
const SbVec2fgetTextureCoordinate2 (int index) const
 Returns texture information from the state.
 
const SbVec4fgetTextureCoordinate4 (int index) const
 Returns texture information from the state.
 
SoTextureCoordinateBinding::Binding getTextureCoordinateBinding () const
 Returns texture information from the state.
 
const SbColorgetTextureBlendColor () const
 
const unsigned char * getTextureImage (SbVec2i32 &size, int &numComps) const
 Returns texture information from the state.
 
const SbNamegetTextureFileName () const
 Returns texture information from the state.
 
const SbMatrixgetTextureMatrix () const
 Returns the current texture mapping information from the state.
 
const SoTexture2TransformgetTextureTransformNode () const
 Returns the current texture mapping information from the state.
 
SoTexture::Model getTextureModel () const
 Returns the current texture mapping information from the state.
 
SoTexture::Wrap getTextureWrapS () const
 Returns the current texture mapping information from the state.
 
SoTexture::Wrap getTextureWrapT () const
 Returns the current texture mapping information from the state.
 
const SbMatrixgetModelMatrix () const
 Returns the current modeling transformation from the state.
 
SoUnits::Units getUnits () const
 Returns the current units from the state.
 
float getFocalDistance () const
 Returns the current camera and viewing information from the state.
 
const SbMatrixgetProjectionMatrix () const
 Returns the current camera and viewing information from the state.
 
const SbMatrixgetViewingMatrix () const
 Returns the current camera and viewing information from the state.
 
const SbViewVolumegetViewVolume () const
 Returns the current camera and viewing information from the state.
 
SoPickStyle::Style getPickStyle () const
 Returns the current picking style.
 
int32_t getSwitch () const
 Returns the current switch value.
 
void setCallbackAll (SbBool flag)
 Sets whether the callback uses normal traversal (switches, etc.) or whether it traverses every single node.
 
SbBool isCallbackAll () const
 Returns whether the callback uses normal traversal (switches, etc.) or whether it traverses every single node.
 
SoDEPRECATED const unsigned char * getTextureImage (SbVec2s &size, int &numComps) const
 Returns texture information from the state.
 
- Public Member Functions inherited from SoAction
virtual ~SoAction ()
 Destructor.
 
virtual void clearApplyResult ()
 When applied, an action may reference nodes or create objects (e.g.
 
virtual void invalidateState ()
 Invalidates the current traversal state in the action, forcing it to be recreated when the action is next applied.
 
void stopActionInBranch ()
 This function stops the action in the current Scene Graph branch.
 
SbBool getContinueActionInBranchFlag () const
 This function indicates if the action must stop in the current branch.
 
void resetContinueActionInBranchFlag ()
 This function resets the continue action flag.
 
void useAlternateRep (const SbBool enable)
 Tell the action to use alternate representations during traversal when available.
 
SbBool isUsingAlternateRep () const
 Returns TRUE if current action is using alternate representations.
 
void setSceneManager (SoSceneManager *mgr)
 Set the scene manager associated with this action (if any ).
 
SoSceneManagergetSceneManager () const
 Return the SoSceneManager associated with this action.
 
DistribMode getDistribMode () const
 Returns the distribution mode of this action across a cluster (ScaleViz-Cluster only).
 
AppliedCode getWhatAppliedTo () const
 Returns code indicating what action is being applied to.
 
SoNodegetNodeAppliedTo () const
 Returns the node the action is being applied to.
 
SoPathgetPathAppliedTo () const
 Returns the path the action is being applied to.
 
const SoPathListgetPathListAppliedTo () const
 Returns the path list the action is being applied to.
 
const SoPathListgetOriginalPathListAppliedTo () const
 Returns the original path list the action is being applied to.
 
SbBool isLastPathListAppliedTo () const
 Returns TRUE if the current list is the last one from the original.
 
PathCode getPathCode (int &numIndices, const int *&indices)
 Returns path code based on where current node (the node at the end of the current path) lies with respect to the path(s) the action is being applied to.
 
PathCode getPathCodeMI (int &numIndices, const int *&indices, const int *&instanceIndices)
 Extender API: available to programmers who wish to extend the toolkit
 
void traverse (SoNode *node)
 Does traversal of a graph rooted by a node.
 
SbBool hasTerminated () const
 Returns TRUE if the traversal has reached a termination condition.
 
const SoPathgetCurPath ()
 Returns the path accumulated during traversal, i.e., the chain of nodes from the root of the traversed graph to the current node being traversed.
 
SoStategetState () const
 Gets the state from the action.
 
virtual void setUpState ()
 Creates state if it is NULL or it is no longer valid because new elements have been enabled since it was created.
 
void setPipeId (int id)
 Sets pipe identifier in the range [1..N] associated to this render action while running a ScaleViz Multipipe configuration.
 
int getPipeId () const
 Gets pipe identifier in the range [1..N] associated to this render action while running a ScaleViz Multipipe configuration.
 
bool isBeingApplied ()
 Returns TRUE if this action is currently being applied.
 
virtual bool preDelayedTraversal ()
 Method called by SoMultiPassManager before delayed pass traversals.
 
virtual void postDelayedTraversal ()
 Method called by SoMultiPassManager after delayed pass traversals.
 
- Public Member Functions inherited from SoTypedObject
SbBool isOfType (const SoType &type) const
 Returns TRUE if this object is of the type specified in type or is derived from that type.
 
template<typename TypedObjectClass >
SbBool isOfType () const
 Returns TRUE if this object is of the type of class TypedObjectClass or is derived from that class.
 

Static Public Member Functions

static SoType getClassTypeId ()
 Returns the type identifier for this class.
 
- Static Public Member Functions inherited from SoCallbackAction
static SoType getClassTypeId ()
 Returns the type identifier for this class.
 
- Static Public Member Functions inherited from SoAction
static SoType getClassTypeId ()
 Returns the type identifier for this class.
 
static void nullAction (SoAction *, SoNode *)
 Null action method that can be stored in lookup table when desired.
 
- Static Public Member Functions inherited from SoTypedObject
static SoType getClassTypeId ()
 Returns the type identifier for this class.
 

Additional Inherited Members

- Public Types inherited from SoCallbackAction
enum  Response {
  CONTINUE ,
  ABORT ,
  PRUNE
}
 Possible responses from a pre or post callback. More...
 
typedef Response SoCallbackActionCB(void *userData, SoCallbackAction *action, const SoNode *node)
 The SoCallbackActionCB typedef is defined within the class, since it needs to refer to the Response enumerated type.
 
- Public Types inherited from SoAction
enum  DistribMode {
  LOCAL_ONLY ,
  CLUSTER_ONLY ,
  ALL
}
 This is used to define the way an action is distributed across a cluster. More...
 
enum  AppliedCode {
  NODE ,
  PATH ,
  PATH_LIST
}
 This enum is used to determine what the action is being applied to. More...
 
enum  PathCode {
  NO_PATH ,
  IN_PATH ,
  BELOW_PATH ,
  OFF_PATH
}
 This enum may be used during traversal of nodes to indicate where the node is with respect to the path being traversed. More...
 

Detailed Description

HardCopy Export a scene graph to a U3D file.

This class can export an Open Inventor scenegraph to a U3D file. U3D files can be used to import a 3D scene into a PDF file. For a simple PDF export, see SoToPDFAction.

U3D is a much simpler format than the Open Inventor scene graph and limits what can be exported.

Limitations of U3D:

  • Cameras
    • Multiple cameras are ignored, only the main scenegraph is exported (no legends, logos...).
    • PoViews (PoSceneView, PoView, PoBaseView) are not supported.
  • Lights
    • Lights affect the whole scenegraph no matter where they are placed in the scenegraph.
    • Per-vertex lighting is precomputed with default lights.
    • Two-sided lighting is not supported. Incorrect normals will result in black triangles. However note that the end user can enable two sided rendering in the Acrobat Reader preferences dialog under the "3D & Multimedia" tab.
  • Lines
    • Line width is not supported.
    • Per-vertex coloring and lighting are not supported on lines.
    • Precision issue on line vertices. Point locations may drasticaly diverge from orginal. Since this problem increases with the number of vertices per shape, try to split lines into smaller shapes.
  • MeshVizXLM
    • Enhanced coloring (MoMaterial) is not supported.
    • Fading threshold (MoDrawStyle) is not supported.
    • Polygon offset is not supported, so rendering cells with both faces and edges may result in depth buffering problems in the Adobe viewer.
  • Miscellaneous
    • FXViz representations are not supported.
    • Engines are ignored.
    • Dragger shapes are not exported.
  • Points
    • Coloring is not supported on points.
  • Rendering
  • Text
    • Text2 and textured Text3 are converted into polygonal Text3.
  • Textures
    • Only MODULATE and REPLACE texture models are supported.
    • Only REPEAT and CLAMP texture wraps are supported.
    • Multitexturing is not supported.
  • Transparency
    • Transparency is exported, but Adobe Reader's transparency algorithm is limited. Solid objects, MeshVizXLM mesh skin for example, can be handled correctly by Open Inventor's SORTED_PIXEL algorithm, but are not (in general) handled correctly by Adobe Reader (as of version 10.1 anyway).
  • VolumeViz
    • VolumeViz representations are not supported, except orthoslice, obliqueslice and volumeskin.
    • VolumeViz slices are exported with their current LOD (NB: LOD is minimal if the node has never been rendered).
    • LDM volumes with overlap of zero will not export correctly (gaps between tiles will be visible.
    • ROIs are ignored.
    • Lighting on VolumeViz slices is not supported.
    • VolumeViz slices are exported as simple RGBA textures (no colormap), which impacts visual quality (as if useRGBA field set)

Tips

  • Node names
    • Node names are exported for SoSeparator and SoShape, as well as all derived classes. These names will appear in the "Model Tree" in Acrobat Reader. The end user can set visibility, render mode, etc for each object. You can also use these names in JavaScript functions that manipulate the model in the PDF file.
    • Separator nodes with no assigned name will appear in the tree as "Group-XXX" and Shape nodes with no assigned name will appear in the tree as "Model-XXX", where "XXX" is the address of the node (just to make the name unique).
    • Names in the U3D file must be unique. Nodes with duplicate names will have a numeric value automatically appended to their name.
  • Lights: Lights in the scene graph will be exported. However note that the viewer's headlight will be exported as a directional light with a fixed position (it will not automatically rotate with the camera). If Acrobat Reader finds lights in the U3D file it will use those lights. So it may be better to export without lights and also to turn off the viewer's headlight before exporting to U3D. Note that one of the lighting options in Acrobat Reader is a headlight (that rotates with the camera).
  • Camera: If the action finds a camera in the scene graph, that camera will define the default view for the model in the PDF file. Therefore if you apply the action to a Separator above the viewer's camera, the exported model will be displayed with the current on-screen view.
  • Background color: You can export a background color using an SoGradientBackground node. The exported color will be the average of the color0 and color1 fields. However you can also change the background color using Adobe Acrobat Pro after inserting the U3D file in a PDF.
  • Two sided rendering: If the back faces of your geometry are black when displayed in Acrobat Reader, you may want to advise your users to enable the two sided rendering option in Reader's Preferences dialog under the "3D & Multimedia" tab.
  • Tools:
    • You can use the commercial tool Adobe Acrobat Pro to create and modify PDFs with embedded U3D content. Adobe calls this content "3D annotations".
    • You can also use open source tools like pdflatex, with the movie15 package, to create a PDF file with embedded 3D from a LaTeX source file.

Use case

...
// setup the root scene graph to export
SoSeparator* root = new SoSeparator;
...
SoToU3DAction u3dAction;
bool result = u3dAction.openFile( "output.u3d" );
if ( !result )
{
// Report error
}
u3dAction.apply( root );
result = u3dAction.closeFile();
if ( !result )
{
// Report error
}
static void init()
Initializes all classes of HardCopy by registering them in the database.
Group node that saves and restores traversal state.

Warning

  • On some platforms, some applications may encounter problems loading, displaying an error message like: "IFXOSFileIterator::ProcessDir: error opening /usr/local/u3d/lib/Plugins/ No such file or directory". In this case, declare the environment variable U3D_LIBDIR (UNIX only) and set it with the path to the Open Inventor libraries ($OIVHOME/lib).
  • It is now possible to specify a directory name which will contain the U3D plug-ins by setting the environment variable U3D_PLUGINS_DIRNAME for instance: "U3DPlugins". Important: This is not a path to the directory. Moreover this directory must remain in the same folder as fei_ifx_core.so/dll.
  • By default this action always uses the alternate representation of an SoNode derived class (if one exists).
  • The U3D_LIBDIR path is limited to 103 characters, path plus filename. If this length is exceeded, an error message is outputed and U3D library is not loaded.

SEE ALSO

SoToPDFAction.

Definition at line 212 of file SoToU3DAction.h.

Constructor & Destructor Documentation

◆ SoToU3DAction()

SoToU3DAction::SoToU3DAction ( )

◆ ~SoToU3DAction()

virtual SoToU3DAction::~SoToU3DAction ( )
virtual

Member Function Documentation

◆ apply() [1/3]

virtual void SoToU3DAction::apply ( const SoPathList pathList,
SbBool  obeysRules = false 
)
virtual

Initiates an action on the graph specified by list of paths.

TRUE can be passed for the obeysRules flag if the given path list has the following four properties:

  • All paths have the same head node,
  • Paths are sorted in traversal order,
  • If one path ends at node A, no other path continues through A,
  • No two paths are the same.

These rules will be obeyed by path lists returned by picking and by searches for non-group nodes.

Reimplemented from SoAction.

◆ apply() [2/3]

virtual void SoToU3DAction::apply ( SoNode node)
virtual

Initiates an action on the graph specified by a node.

Reimplemented from SoAction.

◆ apply() [3/3]

virtual void SoToU3DAction::apply ( SoPath path)
virtual

Initiates an action on the graph specified by a path.

Reimplemented from SoAction.

◆ areDraggersExported()

bool SoToU3DAction::areDraggersExported ( ) const

Returns true if draggers are exported.

◆ closeFile()

virtual bool SoToU3DAction::closeFile ( )
virtual

Finalize export to the U3D output file.

Returns false if an error has occured.

Reimplemented in SoToPDFAction.

◆ forcePolygonalText3()

void SoToU3DAction::forcePolygonalText3 ( bool  force)

Forces SoText2 nodes to be exported using SoText3 (default is true).

◆ forwardTraversal() [1/2]

virtual void SoToU3DAction::forwardTraversal ( SoNode node)
virtual

Traverse a node that is not part of the current scenegraph.

Like an SoNodeKit, the contents of the specified sub-scenegraph won't be visible as an SoPath. Casting the path to a SoFullPath allows access to the whole path.

This method can be used to delegate an action to an internal/private scene graph. So a node can have an internal scene graph without actually being a "group" node. This is a convenient way to implement "composite" nodes that create their behavior using other Open Inventor nodes.

The node parameter can be of any type. Sensors may still be attached directly to nodes and fields in the internal scene graph.

This method must not be called from a node derived from SoGroup or SoBaseKit. This method should not be called on nodes that are part of the public/visible scene graph.

Note : The pre and post callbacks are not called if the traversed shape is a forward traversed shape.

Reimplemented from SoAction.

◆ forwardTraversal() [2/2]

virtual void SoToU3DAction::forwardTraversal ( SoPath path)
virtual

Traverse a node that is not part of the current scenegraph.

Like an SoNodeKit, the contents of the specified sub-scenegraph won't be visible as an SoPath. Casting the path to a SoFullPath allows access to the whole path.

This method can be used to delegate an action to an internal/private scene graph. So a node can have an internal scene graph without actually being a "group" node. This is a convenient way to implement "composite" nodes that create their behavior using other Open Inventor nodes.

The node parameter can be of any type. Sensors may still be attached directly to nodes and fields in the internal scene graph.

This method must not be called from a node derived from SoGroup or SoBaseKit. This method should not be called on nodes that are part of the public/visible scene graph.

Note : The pre and post callbacks are not called if the traversed shape is a forward traversed shape.

Reimplemented from SoAction.

◆ getClassTypeId()

static SoType SoToU3DAction::getClassTypeId ( )
static

Returns the type identifier for this class.


◆ getTypeId()

virtual SoType SoToU3DAction::getTypeId ( ) const
virtual

Returns the type identifier for this specific instance.

Reimplemented from SoCallbackAction.

Reimplemented in SoToPDFAction.

◆ isPolygonalText3Forced()

bool SoToU3DAction::isPolygonalText3Forced ( ) const

Returns true if polygonal text3 is forced (see forcePolygonalText3).

◆ openFile() [1/2]

virtual SoNONUNICODE bool SoToU3DAction::openFile ( const char *  filename)
virtual

Set the U3D output file.

Returns false if an error has occured.

Non Unicode: This function should not be used in a Unicode application. Use the SbString version instead.

Reimplemented in SoToPDFAction.

◆ openFile() [2/2]

virtual bool SoToU3DAction::openFile ( const SbString filename)
virtual

Set the U3D output file.

Returns false if an error has occured.

Reimplemented in SoToPDFAction.

◆ setExportDraggers()

void SoToU3DAction::setExportDraggers ( bool  force)

Allow the export of draggers (default is true).


The documentation for this class was generated from the following file: