Importing COLLADA DAE files

Software: Away3D 3.x

pelkin000, Newbie
Posted: 24 July 2011 04:43 PM   Total Posts: 2

I have a question regarding my implementation of a collada 3d file. This is really my first venture into the realm of 3d and I’ve read some of the basic tutorials so I’m not 100% clueless, but I am a bit confused by what is appearing with the following class (this is a document root class, loaded by the .fla file):

package {
 import away3d
.core.base.Mesh;
 
import away3d.core.base.Object3D;
 
import away3d.loaders.*;
 
import away3d.containers.*;
 
import away3d.materials.*;
 
import away3d.core.render.*;
 
import away3d.primitives.*;
 
import flash.utils.getQualifiedClassName;

 
import flash.display.*;
 
import flash.events.*;
 
import flash.net.*;

 
[SWF(width="500"height="500"frameRate="60"backgroundColor="#FFFFFF")]
 
public class dae extends MovieClip {
  
  
private var view:View3D;
  private var 
snowboard:ObjectContainer3D;
  private var 
wireColorMaterial:WireColorMaterial;
  private var 
snowboardMaterial:BitmapFileMaterial;
  private var 
beachMaterial:BitmapFileMaterial;
  private var 
loader:Loader3D;
  private var 
loaded:uint 0;
  
  public function 
dae() {
   stage
.scaleMode StageScaleMode.NO_SCALE;
   
   
// Show 3d Rendering View
   
view = new View3D();
   
view.stage.stageWidth 2;
   
view.stage.stageHeight 2;
   
addChild(view); // Add viewport to the stage
   
   // Create a color for the sphere wire model. Optional.
   
wireColorMaterial = new WireColorMaterial();
   
wireColorMaterial.alpha 0// Default wireColorMaterial.color is transparent.;
   
wireColorMaterial.wireColor 0x0000ff;
   
   
// Load bitmap material
   
beachMaterial = new BitmapFileMaterial("http://travelsmaps.com/uploads/Miami-Beach-Vacations-sunset.jpg");
   
beachMaterial.addOnLoadSuccess(startLoadingXML);
   
beachMaterial.alpha .9;
   
snowboardMaterial = new BitmapFileMaterial("http://i27.photobucket.com/albums/c181/Aubree2006/snowboard_toon.jpg");
   
snowboardMaterial.addOnLoadSuccess(startLoadingXML);
   
snowboardMaterial.alpha .9;
  
}
  
  
private function startLoadingXML(x:*):void {
   loaded
++;
   if (
loaded == 2{
    
var loader:URLLoader = new URLLoader();
    
loader.addEventListener(Event.COMPLETEload_xml);
    
loader.addEventListener(SecurityErrorEvent.SECURITY_ERRORload_error);
    
loader.addEventListener(IOErrorEvent.IO_ERRORload_error);
    
loader.load(new URLRequest('Urban_152.dae'));
   
}
  }
  
  
private function load_xml(e:Event):void {
   
   
// Parse loaded XML (gets put into an ObjectContainer3D file
   
snowboard Collada.parse(e.target.data{ autoLoadTextures:falsescaling:500 } );
   
view.scene.addChild(snowboard);
   
   for 
each (var i:Object3D in snowboard.children{
    trace
("Qualified Class Name: " getQualifiedClassName(i));
    if (
i is Mesh{
     Mesh
(i).material snowboardMaterial// pushes it to the face, but now I'm seeing lots of triangles still
     
Mesh(i).material beachMaterial;
    
}
   }
   
   
// Register listener for the ENTER_FRAME event.
   
addEventListener(Event.ENTER_FRAMEenterFrameEventHandler);
  
}
  
  
private function enterFrameEventHandler(e:Event):void {
   snowboard
.rotationY += .7;
   
snowboard.rotationX -= .7;
   
view.render();
  
}
  
  
private function load_error(e:*):void {
   trace
("load error:"+e);
  
}
 }
 

DAE file

The result can be seen here: resulting image . As you can see, the images I loaded to skin the board with are showing up, but just in specific triangles. I want it to skin across the whole board. Is there something special I need to do to achieve this?

Also, my final goal with this project is to skin (texture map) one side of the board with a bitmap (drawn from an MC) and the other side with a different bitmap.

Any thoughts? Thanks!

   

Richard Olsson, Administrator
Posted: 24 July 2011 06:39 PM   Total Posts: 1192   [ # 1 ]

That looks very odd. But if you are just exporting a static mesh, you really should not be using COLLADA. The only advantage that COLLADA has over other formats is that it supports (almost) everything that one could wish for in a 3D transfer format. But if you’re not using fancy features like skeletal animation, then you should stick to simpler formats like OBJ or 3DS, which will result in much smaller files and hence load faster.

COLLADA is great in theory, but because it’s so versatile and different generator applications implements the format differently, it’s very hard to create a importer that works with any COLLADA file, and it’s probably a bug in that category that is causing this. So bottom line is, try to use a better suiting format.

   

pelkin000, Newbie
Posted: 24 July 2011 06:58 PM   Total Posts: 2   [ # 2 ]

Good point, I sort of got that feeling when I started researching what the files were. Unfortunately, these files were generated by someone else and that person I don’t think that person is available to change the export format.

I suppose one work around might be to use Blender to import and then re-export. Do you think that’d be a good idea? I dont even know what format it’d export as, I’ll see if either OBJ or 3DS is available.

In the meantime, however, would the be another work around?

   

thomm, Newbie
Posted: 24 July 2011 08:51 PM   Total Posts: 1   [ # 3 ]

I had the same problem, with one simple model I did in Blender.

I converted quads to triangles, which was the cause of the problem on my side, when I reversed to quads the model was fine.

Hope this help.

   

pelkin000, Newbie
Posted: 25 July 2011 10:39 PM   Total Posts: 2   [ # 4 ]

Thanks for all the suggestions everyone. I really appreciate it.

What I ended up doing (which is working OK so far) is to use blender to convert the DAE files to 3DS. Then, I rearranged some of code following the examples at http://code.google.com/p/away3d/source/browse/trunk/fp10/Examples/Away3D/as/src/Basic_LoadModel.as . When I loaded the model using my own texture it wrapped cleanly on the image like I anticipated.

My next step is to figure out how to dynamically build a UV mapped PNG/JPG in Flash so that I can apply it to this model. If anyone has any suggestions I’d really appreciate it. Otherwise I’ll give it a shot and if I can’t figure it out I’ll come back to start a new thread.

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X