String nodeName = dNode.getAttributeValue("name", (String) null);
if (nodeName == null) { // use id if name doesn't exist
nodeName = dNode.getAttributeValue("id", dNode.getName());
}
final Node node = new Node(nodeName);
final List<Element> transforms = new ArrayList<Element>();
for (final Element child : dNode.getChildren()) {
if (_dataCache.getTransformTypes().contains(child.getName())) {
transforms.add(child);
}
}
// process any transform information.
if (!transforms.isEmpty()) {
final Transform localTransform = getNodeTransforms(transforms);
node.setTransform(localTransform);
if (jointChildNode != null) {
jointChildNode.setSceneNode(node);
}
}
// process any instance geometries
for (final Element instance_geometry : dNode.getChildren("instance_geometry")) {
_colladaMaterialUtils.bindMaterials(instance_geometry.getChild("bind_material"));
final Spatial mesh = _colladaMeshUtils.getGeometryMesh(instance_geometry);
if (mesh != null) {
node.attachChild(mesh);
}
_colladaMaterialUtils.unbindMaterials(instance_geometry.getChild("bind_material"));
}
// process any instance controllers
for (final Element instanceController : dNode.getChildren("instance_controller")) {
_dataCache.getControllers().add(new ControllerStore(node, instanceController));
}
// process any instance nodes
for (final Element in : dNode.getChildren("instance_node")) {
final Node subNode = getNode(in, jointNode);
if (subNode != null) {
node.attachChild(subNode);
if (nodeType == NodeType.JOINT
&& getNodeType(_colladaDOMUtil.findTargetWithId(in.getAttributeValue("url"))) == NodeType.NODE) {
// make attachment
createJointAttachment(jointChildNode, node, subNode);
}
}
}
// process any concrete child nodes.
for (final Element n : dNode.getChildren("node")) {
final Node subNode = buildNode(n, jointNode);
if (subNode != null) {
node.attachChild(subNode);
if (nodeType == NodeType.JOINT && getNodeType(n) == NodeType.NODE) {
// make attachment
createJointAttachment(jointChildNode, node, subNode);