Package com.openinventor.hardcopy
Class SoToU3DAction
- java.lang.Object
-
- com.openinventor.inventor.Inventor
-
- com.openinventor.inventor.actions.SoAction
-
- com.openinventor.inventor.actions.SoCallbackAction
-
- com.openinventor.hardcopy.SoToU3DAction
-
- Direct Known Subclasses:
SoToPDFAction
public class SoToU3DAction extends SoCallbackAction
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, seeSoToPDFAction
.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
- Modeling clipping (
SoClipPlane
) is ignored. - Drawstyle is ignored.
- Screen-aligned rendering (
SoText2
,SoBillboard
, etc) is not supported.
- Modeling clipping (
- 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
andSoShape
, 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.
- Node names are exported for
- 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 = new SoToU3DAction(); boolean result = u3dAction.openFile( "output.u3d" ); if ( !result ) { // Report error } u3dAction.apply( root ); result = u3dAction.closeFile(); if ( !result ) { // Report error } 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
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.openinventor.inventor.actions.SoCallbackAction
SoCallbackAction.Material, SoCallbackAction.Responses, SoCallbackAction.TextureImage
-
Nested classes/interfaces inherited from class com.openinventor.inventor.actions.SoAction
SoAction.AppliedCodes, SoAction.DistribModes, SoAction.PathCodes, SoAction.PathIndices
-
Nested classes/interfaces inherited from class com.openinventor.inventor.Inventor
Inventor.ConstructorCommand
-
-
Field Summary
-
Fields inherited from class com.openinventor.inventor.Inventor
VERBOSE_LEVEL, ZeroHandle
-
-
Constructor Summary
Constructors Constructor Description SoToU3DAction()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
areDraggersExported()
Returns true if draggers are exported.boolean
closeFile()
Finalize export to the U3D output file.static void
enableElement(java.lang.Class<? extends Inventor> t, int stkIndex)
void
forcePolygonalText3(boolean force)
boolean
isPolygonalText3Forced()
Returns true if polygonal text3 is forced (see forcePolygonalText3).boolean
openFile(java.lang.String filename)
Set the U3D output file.void
setExportDraggers(boolean force)
Allow the export of draggers (default is true).-
Methods inherited from class com.openinventor.inventor.actions.SoCallbackAction
addLineSegmentCallback, addPointCallback, addPostCallback, addPostTailCallback, addPreCallback, addPreTailCallback, addTriangleCallback, getComplexity, getComplexityType, getCoordinate3, getCoordinate4, getCreaseAngle, getCurrentResponse, getDecimationPercentage, getDecimationType, getDrawStyle, getFaceType, getFocalDistance, getFontName, getFontRenderStyle, getFontSize, getLightAttenuation, getLightModel, getLinePattern, getLinePatternScaleFactor, getLineWidth, getMaterial, getMaterial, getMaterialBinding, getModelMatrix, getNormal, getNormalBinding, getNumCoordinates, getNumNormals, getNumProfileCoordinates, getNumTextureCoordinates, getPickStyle, getPointSize, getProfile, getProfileCoordinate2, getProfileCoordinate3, getProjectionMatrix, getShapeType, getSwitch, getTextureBlendColor, getTextureCoordinate2, getTextureCoordinate4, getTextureCoordinateBinding, getTextureFileName, getTextureImage, getTextureMatrix, getTextureModel, getTextureTransformNode, getTextureWrapS, getTextureWrapT, getTransparencyType, getUnits, getVertexOrdering, getViewingMatrix, getViewVolume, invokeLineSegmentCallbacks, invokePointCallbacks, invokePostCallbacks, invokePreCallbacks, invokeTriangleCallbacks, isCallbackAll, setCallbackAll, shouldGeneratePrimitives
-
Methods inherited from class com.openinventor.inventor.actions.SoAction
apply, apply, clearApplyResult, forwardTraversal, forwardTraversal, getContinueActionInBranchFlag, getCurPath, getDistribMode, getNodeAppliedTo, getOriginalPathListAppliedTo, getPathAppliedTo, getPathCode, getPathListAppliedTo, getPipeId, getSceneManager, getState, getWhatAppliedTo, hasTerminated, invalidateState, isBeingApplied, isLastPathListAppliedTo, isUsingAlternateRep, nullAction, postDelayedTraversal, preDelayedTraversal, resetContinueActionInBranchFlag, setPipeId, setSceneManager, setUpState, stopActionInBranch, traverse, useAlternateRep
-
Methods inherited from class com.openinventor.inventor.Inventor
dispose, getNativeResourceHandle
-
-
-
-
Method Detail
-
setExportDraggers
public void setExportDraggers(boolean force)
Allow the export of draggers (default is true).
-
enableElement
public static void enableElement(java.lang.Class<? extends Inventor> t, int stkIndex)
-
areDraggersExported
public boolean areDraggersExported()
Returns true if draggers are exported.
-
isPolygonalText3Forced
public boolean isPolygonalText3Forced()
Returns true if polygonal text3 is forced (see forcePolygonalText3).
-
forcePolygonalText3
public void forcePolygonalText3(boolean force)
-
closeFile
public boolean closeFile()
Finalize export to the U3D output file. Returns false if an error has occured.
-
openFile
public boolean openFile(java.lang.String filename)
Set the U3D output file. Returns false if an error has occured.Use the String version instead.
-
-