[Patch] Collada Import Hierarchical Nodes Away3d 3.6.0

Software: Away3D 3.x

___Martin___, Newbie
Posted: 15 June 2011 01:52 PM   Total Posts: 1

preamble:

I tried to send this patch also to the mailing list away-dev at google groups but the group doesnt accept emails from the public.
Please open the group so people without google accounts can contribute too.
Not everybody wants to share his cell phone number with google wink


Hello everyone,

Cinema4d’s collada exporter may produce files where node tags include subnodes and instance geometry.
Something like this:

<visual_scene>
<node>
<instance_geometry>
          ..
</instance_geometry>
<node>
          ...
</node>
</node>
</visual_scene>

I’m not into collada that much so i don’t know if this is part of the spec but i’d like to share a patch which also handles this setup.
First look at source it seems these changes can also be easily applied to the away3dlite and 2.5.x versions. I can provide patches therefore too if you like.

kind regards
Martin

Patch:

Index: Collada.as
===================================================================
—- Collada.as (revision 3293)
+++ Collada.as (working copy)
@@ -516,7 +516,10 @@
    return;
    _objectData = new ContainerData();
    }
-  }else{
+  //node contains subnodes
+  } else if(String(node[“node”])!=”“){
+  _objectData = new ContainerData();
+  } else {
    _objectData = new MeshData();
  }
 
@@ -540,6 +543,7 @@
        var sid:String;
  var instance_material:XML;
  var arrayChild:Array;
+  var mesh:MeshData;
  var boneData:BoneData = (_objectData as BoneData);
 
        for each (var childNode:XML in node.children())
@@ -602,7 +606,17 @@
     
      geo = collada[“library_geometries”].geometry.(@id == getId(childNode.@url))[0];
     
-                (_objectData as MeshData).geometry = geometryLibrary.addGeometry(geo.@id, geo);
+    if(_objectData is MeshData) {
+      mesh = _objectData as MeshData;
+    } else {
+      mesh = new MeshData();
+    }
+   
+    mesh.geometry = geometryLibrary.addGeometry(geo.@id, geo);
+   
+    if(_objectData is ContainerData) {
+      (_objectData as ContainerData).children.push(mesh);
+    }
              }
             
                break;
@@ -616,9 +630,18 @@
    ctrlr = collada[“library_controllers”].controller.(@id == getId(childNode.@url))[0];
    geo = collada[“library_geometries”].geometry.(@id == getId(ctrlr[“skin”][0].@source))[0];
   
-              (_objectData as MeshData).geometry = geometryLibrary.addGeometry(geo.@id, geo, ctrlr);
+    if(_objectData is MeshData) {
+    mesh = _objectData as MeshData;
+    } else {
+    mesh = new MeshData();
+    }
   
-    (_objectData as MeshData).skeleton = getId(childNode[“skeleton”]);
+    mesh.geometry = geometryLibrary.addGeometry(geo.@id, geo, ctrlr);
+    mesh.skeleton = getId(childNode[“skeleton”]);
+   
+    if(_objectData is ContainerData) {
+    (_objectData as ContainerData).children.push(mesh);
+    }
    break;
            }
        }

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X