public class DAEUtils
extends java.lang.Object
COLLADA (DAE) utils.
This class implements some low- and mid-level routines to convert a
subset of DAE geometry and effect elements to/from corresponding RX
,
JOGLGeometry
, Widget
, and Java3D Appearance.
Also see DAEObject
.
Modifier and Type | Class and Description |
---|---|
static class |
DAEUtils.DAERigidTransform
DAE representation of a rigid transform
|
(package private) static class |
DAEUtils.FloatBlockAccessor
Access a FloatBuffer backing a COLLADA "float_array" according to the
configuration of a COLLADA "accessor".
|
static class |
DAEUtils.RXAndScale
combination of an
RX and a scale factor |
Modifier and Type | Field and Description |
---|---|
static double |
DEF_EPSILON
default
epsilon |
protected static DAEUtils |
defaultInstance
singleton default DAEUtils instance
|
protected static java.lang.Object |
defaultInstanceLock
synchronization object for
defaultInstance |
boolean |
enableDataSharing
Whether to allow data sharing in the various dae*To*() and *toDAE*()
methods.
|
double |
epsilon
numerc epsilon
|
boolean |
invertTransparency
Whether to invert read DAE "transparency" value.
|
static java.lang.String |
JAXB_CONTEXT_PACKAGE_PATH
package paths for creating the JAXB context
|
protected javax.xml.bind.JAXBContext |
jaxbContext
JAXB context for this DAEUtils instance
|
static int |
MSG_DEBUG
message level, see
message(String, DAEObject, int) |
static int |
MSG_ERROR
message level, see
message(String, DAEObject, int) |
static java.lang.String[] |
MSG_PREFIX
message prefix, see
message(String, DAEObject, int) |
static int |
MSG_WARNING
message level, see
message(String, DAEObject, int) |
int |
msgLevel
Max message level, see
message(String, DAEObject, int) . |
java.io.PrintStream |
msgStream
Destination for warnings issued by the various dae*To*() and *ToDAE*()
methods, or null to silence.
|
protected java.util.Map<java.lang.String,java.lang.Integer> |
nextUIDMap
State for
nextUID(java.lang.String) . |
protected vona.dae.jaxb.dae.ObjectFactory |
objectFactory
JAXB
ObjectFactory for this DAEUtils
instance. |
boolean |
strict
Strict mode setting.
|
private static java.lang.String |
svnid |
Constructor and Description |
---|
DAEUtils()
uses defaults
|
DAEUtils(boolean strict,
java.io.PrintStream msgStream,
int msgLevel,
boolean enableDataSharing,
boolean invertTransparency,
double epsilon)
sets instance fields
|
Modifier and Type | Method and Description |
---|---|
vona.dae.jaxb.dae.ParamType |
consDAEAccessorParam(java.lang.String name,
java.lang.String type)
cons a DAE "source/technique_common/accessor/param"
|
vona.dae.jaxb.dae.FxCommonColorOrTextureType |
consDAEFXColor(float r,
float g,
float b)
|
vona.dae.jaxb.dae.FxCommonColorOrTextureType |
consDAEFXColor(float r,
float g,
float b,
DAEObject parent)
cons a new DAE FX color entity
|
vona.dae.jaxb.dae.FxCommonFloatOrParamType |
consDAEFXFloat(float o)
consDAEFXFloat(float, vona.dae.util.DAEObject) , null parent |
vona.dae.jaxb.dae.FxCommonFloatOrParamType |
consDAEFXFloat(float o,
DAEObject parent)
cons a new DAE FX float entity
|
javax.media.j3d.Appearance |
consDefaultAppearance()
Hook called by
daeMaterialInstanceToJ3DAppearance(vona.dae.jaxb.dae.InstanceMaterialType) to
initialize return value. |
vona.dae.jaxb.dae.EffectType |
consDefaultDAEEffect()
Hook called by
j3dAppearanceToDAEEffect(javax.media.j3d.Appearance, float) to initialize return
value. |
DAEUtils.DAERigidTransform |
consDefaultDAERigidTransform()
Hook called by
rxToDAERigidTransform(vona.math.RX) to initialize return
falue. |
DAEUtils.RXAndScale |
consDefaultRXAndScale()
Hook called by
daeTransformsToRXAndScale(java.util.List<? extends vona.dae.util.DAEObject>) to initialize return
falue. |
java.util.List<Widget> |
daeGeometryInstancesToWidgets(java.util.List<vona.dae.jaxb.dae.InstanceGeometryType> geometries)
daeGeometryInstanceToWidget(vona.dae.jaxb.dae.InstanceGeometryType) multiple "instance_geometry"s. |
java.util.List<Widget> |
daeGeometryInstancesToWidgets(vona.dae.jaxb.dae.NodeType node)
|
Widget |
daeGeometryInstanceToWidget(vona.dae.jaxb.dae.InstanceGeometryType geometry)
Convert a DAE "instance_geometry" into a
Widget . |
javax.media.j3d.Appearance |
daeMaterialInstanceToJ3DAppearance(vona.dae.jaxb.dae.InstanceMaterialType daeMaterial)
Convert a DAE "instance_material" into a corresponding Java3D
Appearance.
|
JOGLGeometry |
daePrimsToJOGLGeometry(DAEObject prims)
Convert a DAE geometric primitives object (e.g.
|
DAEUtils.RXAndScale |
daeTransformsToRXAndScale(vona.dae.jaxb.dae.KinematicsFrameType frame)
convenience cover of
daeTransformsToRXAndScale(List) |
DAEUtils.RXAndScale |
daeTransformsToRXAndScale(vona.dae.jaxb.dae.LinkType.AttachmentEnd a)
convenience cover of
daeTransformsToRXAndScale(List) |
DAEUtils.RXAndScale |
daeTransformsToRXAndScale(vona.dae.jaxb.dae.LinkType.AttachmentFull a)
convenience cover of
daeTransformsToRXAndScale(List) |
DAEUtils.RXAndScale |
daeTransformsToRXAndScale(vona.dae.jaxb.dae.LinkType.AttachmentStart a)
convenience cover of
daeTransformsToRXAndScale(List) |
DAEUtils.RXAndScale |
daeTransformsToRXAndScale(vona.dae.jaxb.dae.LinkType link)
convenience cover of
daeTransformsToRXAndScale(List) |
DAEUtils.RXAndScale |
daeTransformsToRXAndScale(java.util.List<? extends DAEObject> transforms)
Distill a sequence of DAE transform entities into a single equivalent
RX and scale factor. |
DAEUtils.RXAndScale |
daeTransformsToRXAndScale(vona.dae.jaxb.dae.NodeType node)
convenience cover of
daeTransformsToRXAndScale(List) |
protected void |
dbg(java.lang.String msg)
message(String, DAEObject, int) , MSG_DEBUG , no
context. |
protected void |
dbg(java.lang.String msg,
DAEObject context)
|
protected void |
error(java.lang.String msg)
message(String, DAEObject, int) , MSG_ERROR , no
context. |
protected void |
error(java.lang.String msg,
DAEObject context)
|
static DAEUtils |
getInstance()
Get a reference to the singleton default instance.
|
javax.xml.bind.JAXBContext |
getJAXBContext()
Get a reference to
jaxbContext , consing it if necessary. |
vona.dae.jaxb.dae.ObjectFactory |
getObjectFactory()
Get a reference to
objectFactory , consing it if necessary. |
static boolean |
isJAXBMappedClass(java.lang.Class c)
Check if c is class that may contain fields that JAXB maps to
XML elements, attributes, or content (value).
|
static boolean |
isListOfDAEObjects(java.lang.reflect.Type type)
Check if type can be considered a List of
DAEObject . |
static boolean |
isRelativeSidRef(java.lang.String sidref)
check if sidref is empty or starts with '.'
|
static boolean |
isURLFragment(java.lang.String url)
check if url starts with '#'
|
static boolean |
isXMLElementField(java.lang.reflect.Field field)
Check if the given Java field on this object corresponds to a (single)
XML child element.
|
static boolean |
isXMLElementsField(java.lang.reflect.Field field)
Check if the given Java field on this object corresponds to a list of
XML child elements.
|
vona.dae.jaxb.dae.EffectType |
j3dAppearanceToDAEEffect(javax.media.j3d.Appearance a,
float extraAlpha)
Convert a Java3D Appearance into a corresponding DAE "effect".
|
vona.dae.jaxb.dae.FxCommonColorOrTextureType |
j3dColorToDAEFX(javax.vecmath.Color3f c)
j3dColorToDAEFX(Color3f, DAEObject) , null parent |
vona.dae.jaxb.dae.FxCommonColorOrTextureType |
j3dColorToDAEFX(javax.vecmath.Color3f c,
DAEObject parent)
Convert a Java3D color to DAE FX via
consDAEFXColor(float,
float, float, DAEObject) . |
vona.dae.jaxb.dae.MeshType |
joglGeometryToDAEMesh(JOGLGeometry geometry)
joglGeometryToDAEMesh(JOGLGeometry, RX, DAEObject) , no
rx, no context. |
vona.dae.jaxb.dae.MeshType |
joglGeometryToDAEMesh(JOGLGeometry geometry,
RX rx)
joglGeometryToDAEMesh(JOGLGeometry, RX, DAEObject) , no
context. |
vona.dae.jaxb.dae.MeshType |
joglGeometryToDAEMesh(JOGLGeometry geometry,
RX rx,
DAEObject context)
Convert a
JOGLGeometry into a corresponding COLLADA "mesh". |
static void |
marshalDAE(vona.dae.jaxb.dae.COLLADA dae,
java.io.File file)
|
static void |
marshalDAE(vona.dae.jaxb.dae.COLLADA dae,
java.io.File file,
DAEUtils daeUtils)
marshalDAE(COLLADA, File, JAXBContext) , using getJAXBContext() of daeUtils. |
static void |
marshalDAE(vona.dae.jaxb.dae.COLLADA dae,
java.io.File file,
javax.xml.bind.JAXBContext context)
Marshal a COLLADA document to file.
|
static void |
marshalDAE(vona.dae.jaxb.dae.COLLADA dae,
java.lang.String path)
Covers
marshalDAE(COLLADA, File) . |
protected void |
message(java.lang.String msg,
DAEObject context,
int level)
|
java.lang.String |
nextUID(java.lang.String base)
Create the next sequentially numbered unique identifier with the given
prefix.
|
java.lang.String |
nextUID(java.lang.String base,
DAEObject context)
Find the
nextUID(String) that is unique int the COLLADA
document containing context. |
DAEUtils.FloatBlockAccessor |
resolveDAEFloatSource(java.lang.String ref,
int b,
DAEObject context)
Attempt to resolve a reference to a "source" (from an "input").
|
javax.vecmath.Color3f |
resolveDAEFXColor(DAEObject obj,
java.lang.String fieldName)
|
javax.vecmath.Color3f |
resolveDAEFXColor(vona.dae.jaxb.dae.FxCommonColorOrTextureType colorOrTexture) |
java.lang.Float |
resolveDAEFXFloat(DAEObject obj,
java.lang.String fieldName)
Similar to
resolveDAEFXColor(DAEObject, String) . |
java.lang.Float |
resolveDAEFXFloat(vona.dae.jaxb.dae.FxCommonFloatOrParamType floatOrParam)
Similar to
resolveDAEFXColor(FxCommonColorOrTextureType) . |
DAEUtils.DAERigidTransform |
rxToDAERigidTransform(RX rx)
Convert a
RX into an equivalent DAEUtils.DAERigidTransform . |
DAEUtils.DAERigidTransform |
rxToDAERigidTransform(RX rx,
vona.dae.jaxb.dae.KinematicsFrameType frame)
convenience cover of
rxToDAERigidTransform(RX, List) |
DAEUtils.DAERigidTransform |
rxToDAERigidTransform(RX rx,
vona.dae.jaxb.dae.LinkType.AttachmentEnd a)
convenience cover of
rxToDAERigidTransform(RX, List) |
DAEUtils.DAERigidTransform |
rxToDAERigidTransform(RX rx,
vona.dae.jaxb.dae.LinkType.AttachmentFull a)
convenience cover of
rxToDAERigidTransform(RX, List) |
DAEUtils.DAERigidTransform |
rxToDAERigidTransform(RX rx,
vona.dae.jaxb.dae.LinkType.AttachmentStart a)
convenience cover of
rxToDAERigidTransform(RX, List) |
DAEUtils.DAERigidTransform |
rxToDAERigidTransform(RX rx,
vona.dae.jaxb.dae.LinkType link)
convenience cover of
rxToDAERigidTransform(RX, List) |
DAEUtils.DAERigidTransform |
rxToDAERigidTransform(RX rx,
java.util.List<DAEObject> rotatesAndTranslates)
rxToDAERigidTransform(RX) , then add the generated DAE "rotate"
and "translate" to rotatesAndTranslates. |
DAEUtils.DAERigidTransform |
rxToDAERigidTransform(RX rx,
vona.dae.jaxb.dae.NodeType node)
convenience cover of
rxToDAERigidTransform(RX, List) |
static vona.dae.jaxb.dae.COLLADA |
unmarshalDAE(java.net.URL url)
|
static vona.dae.jaxb.dae.COLLADA |
unmarshalDAE(java.net.URL url,
DAEUtils daeUtils)
unmarshalDAE(URL, JAXBContext) , using getJAXBContext()
of daeUtils. |
static vona.dae.jaxb.dae.COLLADA |
unmarshalDAE(java.net.URL url,
javax.xml.bind.JAXBContext context)
Unmarshal a COLLADA document at url.
|
protected void |
warning(java.lang.String msg)
message(String, DAEObject, int) , MSG_WARNING , no
context. |
protected void |
warning(java.lang.String msg,
DAEObject context)
|
java.util.List<vona.dae.jaxb.dae.InstanceGeometryType> |
widgetToDAEGeometryInstances(Widget widget,
vona.dae.jaxb.dae.LibraryGeometriesType geometriesLibrary,
vona.dae.jaxb.dae.LibraryMaterialsType materialsLibrary,
vona.dae.jaxb.dae.LibraryEffectsType effectsLibrary)
Convert a
Widget to a list of DAE "instance_geometry", along
the way creating the necessary subsidiary DAE "geometry", "material", and
"effect" elements. |
private static final java.lang.String svnid
public static final java.lang.String JAXB_CONTEXT_PACKAGE_PATH
public static final double DEF_EPSILON
epsilon
public static final int MSG_ERROR
message(String, DAEObject, int)
public static final int MSG_WARNING
message(String, DAEObject, int)
public static final int MSG_DEBUG
message(String, DAEObject, int)
public static final java.lang.String[] MSG_PREFIX
message(String, DAEObject, int)
protected static final java.lang.Object defaultInstanceLock
defaultInstance
protected static DAEUtils defaultInstance
protected javax.xml.bind.JAXBContext jaxbContext
protected vona.dae.jaxb.dae.ObjectFactory objectFactory
JAXB ObjectFactory
for this DAEUtils
instance.
protected java.util.Map<java.lang.String,java.lang.Integer> nextUIDMap
State for nextUID(java.lang.String)
.
public boolean strict
Strict mode setting.
In strict mode, the various dae*To*() and *ToDAE*() methods throw
exceptions if the conversion cannot be made in a reasonably exact way. In
non-strict mode exceptions are never thrown, and default values are used
as necessary. In either case warnings about potential inexact conversions
may be emitted to msgStream
, if set.
Default false.
public java.io.PrintStream msgStream
Destination for warnings issued by the various dae*To*() and *ToDAE*() methods, or null to silence.
Default null.
public int msgLevel
Max message level, see message(String, DAEObject, int)
.
Default MSG_WARNING
.
public boolean enableDataSharing
Whether to allow data sharing in the various dae*To*() and *toDAE*() methods.
For example, this could enable sharing the vertex array in joglGeometryToDAEMesh(vona.j3d.JOGLGeometry, vona.math.RX, vona.dae.util.DAEObject)
. If not enabled, data is never shared. But there
is no guarantee that any data will be shared even if enabled: data sharing
is best-effort.
Default false.
public boolean invertTransparency
Whether to invert read DAE "transparency" value.
Apparrently, there is a known bug in at least sketchup export that requires this.
public double epsilon
public DAEUtils(boolean strict, java.io.PrintStream msgStream, int msgLevel, boolean enableDataSharing, boolean invertTransparency, double epsilon)
public DAEUtils()
public static boolean isURLFragment(java.lang.String url)
public static boolean isRelativeSidRef(java.lang.String sidref)
public static boolean isJAXBMappedClass(java.lang.Class c)
Check if c is class that may contain fields that JAXB maps to XML elements, attributes, or content (value).
public static boolean isXMLElementField(java.lang.reflect.Field field)
Check if the given Java field on this object corresponds to a (single) XML child element.
public static boolean isXMLElementsField(java.lang.reflect.Field field)
Check if the given Java field on this object corresponds to a list of XML child elements.
public static boolean isListOfDAEObjects(java.lang.reflect.Type type)
Check if type can be considered a List of DAEObject
.
public static DAEUtils getInstance()
Get a reference to the singleton default instance.
public static vona.dae.jaxb.dae.COLLADA unmarshalDAE(java.net.URL url, javax.xml.bind.JAXBContext context) throws javax.xml.bind.JAXBException
Unmarshal a COLLADA document at url.
javax.xml.bind.JAXBException
- if there was a problem creating the unmarshallerjavax.xml.bind.UnmarshalException
- if there was a problem unmarshalling or if
the unmarshalled root element is not COLLADApublic static vona.dae.jaxb.dae.COLLADA unmarshalDAE(java.net.URL url, DAEUtils daeUtils) throws javax.xml.bind.JAXBException
unmarshalDAE(URL, JAXBContext)
, using getJAXBContext()
of daeUtils.
javax.xml.bind.JAXBException
public static vona.dae.jaxb.dae.COLLADA unmarshalDAE(java.net.URL url) throws javax.xml.bind.JAXBException
javax.xml.bind.JAXBException
public static void marshalDAE(vona.dae.jaxb.dae.COLLADA dae, java.io.File file, javax.xml.bind.JAXBContext context) throws javax.xml.bind.JAXBException
Marshal a COLLADA document to file.
javax.xml.bind.JAXBException
- if there was a problem creating the marshallerjavax.xml.bind.MarshalException
- if there was a problem marshallingpublic static void marshalDAE(vona.dae.jaxb.dae.COLLADA dae, java.io.File file, DAEUtils daeUtils) throws javax.xml.bind.JAXBException
marshalDAE(COLLADA, File, JAXBContext)
, using getJAXBContext()
of daeUtils.
javax.xml.bind.JAXBException
public static void marshalDAE(vona.dae.jaxb.dae.COLLADA dae, java.io.File file) throws javax.xml.bind.JAXBException
javax.xml.bind.JAXBException
public static void marshalDAE(vona.dae.jaxb.dae.COLLADA dae, java.lang.String path) throws javax.xml.bind.JAXBException
Covers marshalDAE(COLLADA, File)
.
javax.xml.bind.JAXBException
public javax.xml.bind.JAXBContext getJAXBContext() throws javax.xml.bind.JAXBException
Get a reference to jaxbContext
, consing it if necessary.
javax.xml.bind.JAXBException
public vona.dae.jaxb.dae.ObjectFactory getObjectFactory()
Get a reference to objectFactory
, consing it if necessary.
public java.lang.String nextUID(java.lang.String base)
Create the next sequentially numbered unique identifier with the given prefix.
Uniqueness is only guaranteed relative to other identifiers created by this factory.
public java.lang.String nextUID(java.lang.String base, DAEObject context)
Find the nextUID(String)
that is unique int the COLLADA
document containing context.
This is only effective if the document has already been indexed,
otherwise the return is the same as nextUID(String)
.
protected void message(java.lang.String msg, DAEObject context, int level)
Either throw an IllegalArgumentException, if level is MSG_ERROR
and strict
, or emit a message on msgStream
,
if any, and if level <= msgLevel
.
context
- COLLADA context of error or null if noneprotected void error(java.lang.String msg, DAEObject context)
protected void error(java.lang.String msg)
message(String, DAEObject, int)
, MSG_ERROR
, no
context.
protected void warning(java.lang.String msg, DAEObject context)
protected void warning(java.lang.String msg)
message(String, DAEObject, int)
, MSG_WARNING
, no
context.
protected void dbg(java.lang.String msg, DAEObject context)
protected void dbg(java.lang.String msg)
message(String, DAEObject, int)
, MSG_DEBUG
, no
context.
public DAEUtils.RXAndScale daeTransformsToRXAndScale(java.util.List<? extends DAEObject> transforms)
Distill a sequence of DAE transform entities into a single equivalent
RX
and scale factor.
The conversion cannot be exact if any of the included transforms
involve skew or non-uniform scale. strict
conversion fails in
this case; non-strict conversion skips the offending transform and emits a
warning.
Uses consDefaultRXAndScale()
.
Also see rxToDAERigidTransform(vona.math.RX)
.
transforms
- an ordered list of DAE "lookat", "matrix", "rotate",
"translate", "scale", and "skew" elementsDAEUtils.RXAndScale
corresponding to the
left-to-right concatenation of transformsjava.lang.IllegalArgumentException
- if strict
and any of the
transforms is not rigidjava.lang.IllegalArgumentException
- if strict
and any of the
transforms is one of the TBD types lookat or skewpublic DAEUtils.RXAndScale consDefaultRXAndScale()
Hook called by daeTransformsToRXAndScale(java.util.List<? extends vona.dae.util.DAEObject>)
to initialize return
falue.
Default impl returns identity transform.
public DAEUtils.RXAndScale daeTransformsToRXAndScale(vona.dae.jaxb.dae.NodeType node)
daeTransformsToRXAndScale(List)
public DAEUtils.RXAndScale daeTransformsToRXAndScale(vona.dae.jaxb.dae.LinkType link)
daeTransformsToRXAndScale(List)
public DAEUtils.RXAndScale daeTransformsToRXAndScale(vona.dae.jaxb.dae.LinkType.AttachmentFull a)
daeTransformsToRXAndScale(List)
public DAEUtils.RXAndScale daeTransformsToRXAndScale(vona.dae.jaxb.dae.LinkType.AttachmentStart a)
daeTransformsToRXAndScale(List)
public DAEUtils.RXAndScale daeTransformsToRXAndScale(vona.dae.jaxb.dae.LinkType.AttachmentEnd a)
daeTransformsToRXAndScale(List)
public DAEUtils.RXAndScale daeTransformsToRXAndScale(vona.dae.jaxb.dae.KinematicsFrameType frame)
daeTransformsToRXAndScale(List)
public DAEUtils.DAERigidTransform rxToDAERigidTransform(RX rx)
Convert a RX
into an equivalent DAEUtils.DAERigidTransform
.
Uses consDefaultDAERigidTransform()
.
Also see daeTransformsToRXAndScale(java.util.List<? extends vona.dae.util.DAEObject>)
.
public DAEUtils.DAERigidTransform rxToDAERigidTransform(RX rx, java.util.List<DAEObject> rotatesAndTranslates)
rxToDAERigidTransform(RX)
, then add the generated DAE "rotate"
and "translate" to rotatesAndTranslates.
public DAEUtils.DAERigidTransform rxToDAERigidTransform(RX rx, vona.dae.jaxb.dae.NodeType node)
rxToDAERigidTransform(RX, List)
public DAEUtils.DAERigidTransform rxToDAERigidTransform(RX rx, vona.dae.jaxb.dae.LinkType link)
rxToDAERigidTransform(RX, List)
public DAEUtils.DAERigidTransform rxToDAERigidTransform(RX rx, vona.dae.jaxb.dae.LinkType.AttachmentFull a)
rxToDAERigidTransform(RX, List)
public DAEUtils.DAERigidTransform rxToDAERigidTransform(RX rx, vona.dae.jaxb.dae.LinkType.AttachmentStart a)
rxToDAERigidTransform(RX, List)
public DAEUtils.DAERigidTransform rxToDAERigidTransform(RX rx, vona.dae.jaxb.dae.LinkType.AttachmentEnd a)
rxToDAERigidTransform(RX, List)
public DAEUtils.DAERigidTransform rxToDAERigidTransform(RX rx, vona.dae.jaxb.dae.KinematicsFrameType frame)
rxToDAERigidTransform(RX, List)
public DAEUtils.DAERigidTransform consDefaultDAERigidTransform()
Hook called by rxToDAERigidTransform(vona.math.RX)
to initialize return
falue.
Default impl returns identity transform.
public javax.media.j3d.Appearance daeMaterialInstanceToJ3DAppearance(vona.dae.jaxb.dae.InstanceMaterialType daeMaterial)
Convert a DAE "instance_material" into a corresponding Java3D Appearance.
The current impl only converts "profile_COMMON" effects. Parameters,
textures, "reflective", "reflectivity", "transparent", and
"index_of_refraction" are all currently ignored. strict
conversion will fail if any of these assumptions is violated;
otherwise the conversion will proceed with default values.
If multiple profiles are available, only the (last) "profile_COMMON" is used (otherwise a warning is emitted).
The "target" attribute of the passed "instance_material" is resolved as
a relative URL fragment within the enclosing COLLADA document with DAEObject.resolveIDRef(java.lang.String)
(the document is assumed to have already been
indexed). The "url" attribute of the resulting "material/instance_effect"
is resolved similarly. strict
conversion will fail if either of
these resolutions are empty; otherwise the conversion will proceed with
default values.
The user data of the returned Appearance is set to the value of the "symbol" attribute of the passed "instance_material".
Uses consDefaultAppearance()
.
Also see j3dAppearanceToDAEEffect(javax.media.j3d.Appearance, float)
.
public javax.media.j3d.Appearance consDefaultAppearance()
Hook called by daeMaterialInstanceToJ3DAppearance(vona.dae.jaxb.dae.InstanceMaterialType)
to
initialize return value.
Default impl returns a default Java3D Appearance with a default Material child and a PolygonAttributes child with offset and factor set to 1.
public vona.dae.jaxb.dae.EffectType j3dAppearanceToDAEEffect(javax.media.j3d.Appearance a, float extraAlpha)
Convert a Java3D Appearance into a corresponding DAE "effect".
The current impl only converts Material, ColoringAttributes (iff no
Material), and TransparencyAttributes with default blending functions.
Other Appearance attribues are all currently ignored. strict
conversion will fail if any of these assumptions is violated; otherwise
the conversion will proceed with default values.
Uses consDefaultDAEEffect()
.
Also see daeMaterialInstanceToJ3DAppearance(vona.dae.jaxb.dae.InstanceMaterialType)
.
a
- the appearance to convertextraAlpha
- if in the range [0,1] then this is an extra
multiplicative alpha to apply in the conversionjava.lang.IllegalArgumentException
- if strict
and
appearance has unhandled aspectspublic vona.dae.jaxb.dae.EffectType consDefaultDAEEffect()
Hook called by j3dAppearanceToDAEEffect(javax.media.j3d.Appearance, float)
to initialize return
value.
Default impl returns "effect/profile_COMMON/technique/blinn" initialized equivalent to the Java3D Material defaults.
public javax.vecmath.Color3f resolveDAEFXColor(vona.dae.jaxb.dae.FxCommonColorOrTextureType colorOrTexture)
public javax.vecmath.Color3f resolveDAEFXColor(DAEObject obj, java.lang.String fieldName)
public java.lang.Float resolveDAEFXFloat(vona.dae.jaxb.dae.FxCommonFloatOrParamType floatOrParam)
Similar to resolveDAEFXColor(FxCommonColorOrTextureType)
.
public java.lang.Float resolveDAEFXFloat(DAEObject obj, java.lang.String fieldName)
Similar to resolveDAEFXColor(DAEObject, String)
.
public vona.dae.jaxb.dae.FxCommonColorOrTextureType consDAEFXColor(float r, float g, float b, DAEObject parent)
public vona.dae.jaxb.dae.FxCommonColorOrTextureType consDAEFXColor(float r, float g, float b)
public vona.dae.jaxb.dae.FxCommonColorOrTextureType j3dColorToDAEFX(javax.vecmath.Color3f c, DAEObject parent)
Convert a Java3D color to DAE FX via consDAEFXColor(float,
float, float, DAEObject)
.
public vona.dae.jaxb.dae.FxCommonColorOrTextureType j3dColorToDAEFX(javax.vecmath.Color3f c)
j3dColorToDAEFX(Color3f, DAEObject)
, null parentpublic vona.dae.jaxb.dae.FxCommonFloatOrParamType consDAEFXFloat(float o, DAEObject parent)
public vona.dae.jaxb.dae.FxCommonFloatOrParamType consDAEFXFloat(float o)
consDAEFXFloat(float, vona.dae.util.DAEObject)
, null parentpublic JOGLGeometry daePrimsToJOGLGeometry(DAEObject prims)
Convert a DAE geometric primitives object (e.g. "triangles") into a
corresponding JOGLGeometry
.
The JOGLGeometry.mode
is set as follows:
GL_LINES
GL_LINE_STRIP
GL_TRIANGLES
GL_TRIANGLE_STRIP
GL_TRIANGLE_FAN
strict
conversion throws
exception, else return is nullOnly COLLADA "input"s with semantic="VERTEX", "POSITION", "NORMAL",
or "COLOR" are recognized. "VERTEX" is expanded in-place to the set of
"input" contained in the referenced "vertices" element, which is resolved
by DAEObject.resolveIDRef(java.lang.String)
(and thus must be a local URL fragment
in the current implementation); the same set of semantic values is
recognized, minus "VERTEX". Only the last "POSITION", "NORMAL", and
"COLOR" inputs are used, if there are others, a warning is generated.
strict
conversion fails if there are inputs with unrecognized
semantics; otherwise they are ignored.
If there is no "POSITION" input, strict
conversion throws
exception, else return is null.
The JOGLGeometry.format
is set as follows:
JOGLGeometry.Format.F_V
JOGLGeometry.Format.F_C3_V
JOGLGeometry.Format.F_N_V
JOGLGeometry.Format.F_C4_N_V
The index list(s) are read in blocks of size b where b is
one greater than the largest offset for any input (the offset of each of
the implied inputs expanded from an input i that is a VERTEX
reference is the offset of i itself). strict
conversion
fails if any index list is not an exact multiple of b, otherwise
the trailing indices are ignored.
The current implementation always unindexes the geometry.
The "source" attribute each (non-ignored) "input" must resolve to a
"source" element within the enclosing COLLADA document (again using DAEObject.resolveIDRef(java.lang.String)
). There are two possiblities for this
"source" (see resolveDAEFloatSource(java.lang.String, int, vona.dae.util.DAEObject)
):
DAEObject.resolveIDRef(java.lang.String)
) to a "float_array".strict
conversion throws an exception. Non-strict
conversion will recover as long as a "count" and a "float_array" could be
resolved.
The value of the "material" attribute of prims, if any, is stored as the user data on the returned JOGLGeometry.
Also see joglGeometryToDAEMesh(vona.j3d.JOGLGeometry, vona.math.RX, vona.dae.util.DAEObject)
.
public DAEUtils.FloatBlockAccessor resolveDAEFloatSource(java.lang.String ref, int b, DAEObject context)
Attempt to resolve a reference to a "source" (from an "input").
If the resolved "source" contains a "technique_common/accessor" child then that is used. Otherwise the "source" itself must contain a "float_array" and the accessor is assumed to have offset=0, stride=b, and count=n/b where n is the count of the "float_array".
References are resolved with DAEObject.resolveIDRef(java.lang.String)
in context
of the COLLADA document containing context.
DAEUtils.FloatBlockAccessor
or null if not strict
and no "float_array" could be resolvedjava.lang.IllegalArgumentException
- if strict
and no
"float_array" could be resolvedpublic vona.dae.jaxb.dae.MeshType joglGeometryToDAEMesh(JOGLGeometry geometry, RX rx, DAEObject context)
Convert a JOGLGeometry
into a corresponding COLLADA "mesh".
A copy is made of the vertex and index data, unless enableDataSharing
, in which case the vertex data of geometry may
be referenced. Indices are always copied, but only those that are
currently enabled (see JOGLGeometry.getNumEnabledVertices()
).
The JOGLGeometry.mode
is converted to a child of the mesh as
follows:
GL_LINES
->"mesh/lines"GL_LINE_STRIP
->"mesh/linestrips"GL_TRIANGLES
->"mesh/triangles"GL_TRIANGLE_STRIP
->"mesh/tristrips"GL_TRIANGLE_FAN
->"mesh/trifans"GL_POINTS, GL_LINE_LOOP, GL_POLYGON, GL_QUADS,
GL_QUAD_STRIP
TBD: strict
conversion throws exception,
else return is nullThe generated "mesh/prims" child has a single "input" child and
"p" children corresponding to the primitive array(s) in geometry.
The "input" has "semantic" "VERTEX" and a "source" attribute referencing a
"mesh/vertices" element that is added as a sibling to prims. The
"vertices" element has up to three "input" children with "POSITION",
"COLOR", and "NORMAL" "semantic" attributes according to theJOGLGeometry.format
. Texture coordinates and per-vertex alpha are
currently ignored in the format, if any are present they are ignored in
non-strict
conversion, and generate an exception otherwise.
Each generated "vertices/input" has a "source" attribute referencing a "mesh/source" element that is added as a sibling to prims. There are up to three such "mesh/source" elements, corresponding 1:1 to the generated "vertices/input"s. Each contains a "technique_common/accessor" to interleaved data in a "float_array" child of an additional "mesh/source" which is also added as a sibling of prims.
IDs are generated for all referenced entities via nextUID(String, DAEObject)
, if context is not null, else nextUID(String)
.
geometry
- the geometry to convertrx
- an extra rigid transform to apply to the geometry as the mesh is
created, or null for identity. Non-identity rx prevents data
sharing.context
- the DAE context, or null if unknownpublic vona.dae.jaxb.dae.ParamType consDAEAccessorParam(java.lang.String name, java.lang.String type)
public vona.dae.jaxb.dae.MeshType joglGeometryToDAEMesh(JOGLGeometry geometry, RX rx)
joglGeometryToDAEMesh(JOGLGeometry, RX, DAEObject)
, no
context.
public vona.dae.jaxb.dae.MeshType joglGeometryToDAEMesh(JOGLGeometry geometry)
joglGeometryToDAEMesh(JOGLGeometry, RX, DAEObject)
, no
rx, no context.
public Widget daeGeometryInstanceToWidget(vona.dae.jaxb.dae.InstanceGeometryType geometry)
Convert a DAE "instance_geometry" into a Widget
.
The current impl only converts "mesh" geometries containing DAE
primitives supported by daePrimsToJOGLGeometry(vona.dae.util.DAEObject)
. strict
conversion will fail if unsupported geometry or primitive types are
encountered; otherwise they will be ignored.
Note that, while a DAE "geometry/mesh" can enclose multiple primitive
arrays ("lines", "triangles", etc), they must all reference a single
"vertices". The current geometry->Widget implementation allows
multiple primitive arrays but contains a separate vertex array for each.
Upon load, this method will make duplicates of the referenced DAE
"vertices" as necessary. Also, this mismatch is the reason that the
inverse Widget->geometry mapping (widgetToDAEGeometryInstances(vona.j3d.Widget, vona.dae.jaxb.dae.LibraryGeometriesType, vona.dae.jaxb.dae.LibraryMaterialsType, vona.dae.jaxb.dae.LibraryEffectsType)
) must be one-to-many.
Each DAE primitives object which had a "material" attribute set to
match an "instance_material" within geometry is given the
corresponding Appearance. Failure to resolve a set "material" attribute
raises exception for strict
conversion, else a default Appearance
is substituted.
Uses daePrimsToJOGLGeometry(vona.dae.util.DAEObject)
and daeMaterialInstanceToJ3DAppearance(vona.dae.jaxb.dae.InstanceMaterialType)
.
java.lang.IllegalArgumentException
- if strict
and geometry
has unhandled aspects (see daePrimsToJOGLGeometry(vona.dae.util.DAEObject)
and daeMaterialInstanceToJ3DAppearance(vona.dae.jaxb.dae.InstanceMaterialType)
for specific restrictions)public java.util.List<Widget> daeGeometryInstancesToWidgets(java.util.List<vona.dae.jaxb.dae.InstanceGeometryType> geometries)
daeGeometryInstanceToWidget(vona.dae.jaxb.dae.InstanceGeometryType)
multiple "instance_geometry"s.
public java.util.List<Widget> daeGeometryInstancesToWidgets(vona.dae.jaxb.dae.NodeType node)
public java.util.List<vona.dae.jaxb.dae.InstanceGeometryType> widgetToDAEGeometryInstances(Widget widget, vona.dae.jaxb.dae.LibraryGeometriesType geometriesLibrary, vona.dae.jaxb.dae.LibraryMaterialsType materialsLibrary, vona.dae.jaxb.dae.LibraryEffectsType effectsLibrary)
Convert a Widget
to a list of DAE "instance_geometry", along
the way creating the necessary subsidiary DAE "geometry", "material", and
"effect" elements.
The subsidiary elements are added to the corresponding libraries.
Only enabled JOGLGeometry
geometries are converted from
widget. strict
conversion fails if widget has
other (old Java3D) geometries, else they are ignored.
A separate "instance_geometry" is generated for each successfully converted JOGLGeometry in widget. Note that, while a DAE "geometry/mesh" can enclose multiple primitive arrays ("lines", "triangles", etc), they must all reference a single "vertices". This mismatch is the reason that the Widget->geometry mapping must be one-to-many.
Any non-identity Widget.rx
is baked-in to the generated DAE
geometries. Similar for Widget.alpha
in the range [0,1].
Uses joglGeometryToDAEMesh(vona.j3d.JOGLGeometry, vona.math.RX, vona.dae.util.DAEObject)
, j3dAppearanceToDAEEffect(javax.media.j3d.Appearance, float)
,
and nextUID(String, DAEObject)
.
java.lang.IllegalArgumentException
- if strict
and widget
has unhandled aspects (see joglGeometryToDAEMesh(vona.j3d.JOGLGeometry, vona.math.RX, vona.dae.util.DAEObject)
and j3dAppearanceToDAEEffect(javax.media.j3d.Appearance, float)
for specific restrictions)