scenegraphXML

scenegraphXML.py

Python classes to represent structured hierarchical scenegraph data that can be read and written using XML and Tako .hdf files.

class scenegraphXML.ArbitraryAttribute(name=None, dataType=None, value=None, numValues=None, channelIndex=None)

Class to hold animated static arbitrary attribute values. Values are typed, and can be single values or lists of the same value type. It also writes and reads the in-memory XML representation of these values using ElementTree.

readXMLData(xmlArbitraryAttribute)

Reads the Arbitrary Attribute values from the in-memory XML representation using ElementTree.

writeXMLData(xmlArbitraryAttribute)

Writes the Arbitrary Attribute values into the in-memory XML representation using ElementTree.

class scenegraphXML.AttributeFile(ref=None, groupName=None, customParser=None, channelIndex=None)
readXMLData(xmlAttributeFile)
writeXMLData(xmlAttributeFile)
class scenegraphXML.Bounds(minx=None, maxx=None, miny=None, maxy=None, minz=None, maxz=None, value=None, channelIndex=None)

Class to hold Bounding Box values. It also writes and reads the in-memory XML representation of these values using ElementTree.

getValue(channelData)
readXMLData(xmlBounds)

Reads the Bounding Box values from the in-memory XML representation using ElementTree.

setValue(value, channelData)
writeXMLData(xmlBounds)

Writes the Bounding Box values into the in-memory XML representation using ElementTree.

class scenegraphXML.ChannelData(startFrame=None, endFrame=None, ref=None)

Class to hold a animation Channel data. It also writes and reads the in-memory XML representation of these values using ElementTree.

getNoValues()
getValues(index, numElements)

Returns a single value from the channelData base

isStatic()
readXMLChannelFile(frameNumber)

Reads the contents of a channel xml file into the in-memory XML representation using ElemenTree. frameNumber will be used in the construction of the filename before the .xml extention using 4 zero padding.

readXMLData(xmlChannelData)

Read the Channel Data values from the in-memory XML representation using ElementTree.

setValue(index, value)

Adds a value in a given channel index. If the current number of indexes is smaller than the one specified, 0.0 will be added to all missing indexes between the currently last index and the one to be added.

writeXMLChannelFile(frameNumber, verbose=True)

Writes the in-memory XML representation using ElemenTree into a channel xml file. frameNumber will be used in the filename before the .xml extention using 4 zero padding.

writeXMLData(xmlChannelData)

Writes the Channel Data values into the in-memory XML representation using ElementTree.

class scenegraphXML.Group(name=None, instanceList=None, groupType=None, xform=None, bounds=None, proxyList=None, arbitraryList=None, lodData=None)

Represents a Group node. A group node contains children that an be of any node type.

addInstance(newInstance)
addInstances(newInstances)
getBounds(channelData=None)
readXMLData(xmlElement)
setInstanceList(instanceList)
writeXMLData(sgElement, xmlElement, channelMapping=None, channelData=None)
class scenegraphXML.LodData(tag=None, weight=None, channelIndex=None)

Class to hold a geometry LOD data. It also writes and reads the in-memory XML representation of these values using ElementTree.

readXMLData(xmlLodData)

Reads the LOD Data values from the in-memory XML representation using ElementTree.

writeXMLData(xmlLodData)

Writes the LOD Data values into the in-memory XML representation using ElementTree.

class scenegraphXML.LookFile(ref=None, channelIndex=None)
readXMLData(xmlLookFile)
writeXMLData(xmlLookFile)
class scenegraphXML.Proxy(name=None, ref=None)

Class to hold a geometry Proxy. It also writes and reads the in-memory XML representation of these values using ElementTree.

readXMLData(xmlProxy)

Reads the Proxy values from the in-memory XML representation using ElementTree.

writeXMLData(xmlProxy)

Writes the Proxy values into the in-memory XML representation using ElementTree.

class scenegraphXML.Reference(name=None, refFile=None, refType='xml', xform=None, bounds=None, proxyList=None, arbitraryList=None, lodData=None, lookFile=None, attributeFile=None, groupType=None)

Represents a Reference node. A Reference points to another xml file containing some sub-SceneGraph.

readXMLData(xmlElement)
setRefFile(refFile)
setRefType(refType)
setReference(refFile, refType='xml')
writeXMLData(sgElement, xmlElement, channelMapping=None, channelData=None)
class scenegraphXML.ScenegraphElement(name=None, elemType=None, xform=None, bounds=None, proxyList=None, arbitraryList=None, lodData=None, lookFile=None, attributeFile=None)

Base class used by Group, ScenegraphRoot and Reference classes

addArbitraryAttribute(name, dataType, value=None, numValues=None, channelIndex=None)

Adds an arbitrary attribute.

addProxy(name, ref)

Adds a proxy geometry (tagged by the provided name)

getBounds(channelData=None)
getXform(channelData)
readXMLCommonData(xmlElement)

Reads a full scene’s in-memory XML representation using ElementTree

setAttributeFile(ref=None, groupName=None, customParser=None, channelIndex=None)
setBounds(minx=None, maxx=None, miny=None, maxy=None, minz=None, maxz=None, value=None, channelIndex=None)

Sets a Bounding Box’s values.

setLodData(tag=None, weight=None, channelIndex=None)

Sets LOD values.

setLookFile(ref=None, channelIndex=None)
setXform(value=None, channelIndex=None)

Sets a Transform’s values.

writeXMLCommonData(xmlElement)

Writes the full scene’s in-memory XML representation using ElementTree

class scenegraphXML.ScenegraphRoot(name=None, instanceList=None, channelData=None)

Represents a root node of a full Scene.

addChannelMapping(channelNo, element)
calcBounds()
readXMLChannelFile(frameNumber)
readXMLFile(filepath)
setChannelDataValue(index, value)
writeXMLChannelFile(frameNumber)
writeXMLFile(filepath, verbose=True)
class scenegraphXML.Xform(value=None, channelIndex=None)

Class to hold Transform values. It also writes and reads the in-memory XML representation of these values using ElementTree.

getValue(channelData)
readXMLData(xmlXform)

Reads the Transformation values from the in-memory XML representation using ElementTree.

writeXMLData(xmlXform)

Writes the Transformation values into the in-memory XML representation using ElementTree.

scenegraphXML.applyXformToBounds(curXform, curBounds)

Utility function to calculate the effect of an Xform (list of 16 values) to a bounds (list of 6 values)

scenegraphXML.applyXformToVector(m, v)

Utility function to calculate the effect of an Xform (list of 16 values) on a 3D vector (list of 3 values)

scenegraphXML.createScenegraphElementFromXMLData(xmlElement)

Utility function to create appropriate scenegraph element type when reading in XML data. Uses the tag value of the XML data to create and instance of the appropriate class.

scenegraphXML.floatOrNone(val)

Returns None if val is None and cast it into float otherwise.

scenegraphXML.intOrNone(val)

Returns None if val is None and cast it into int otherwise.