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.x = stage.stageWidth / 2;
view.y = 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.COMPLETE, load_xml);
loader.addEventListener(SecurityErrorEvent.SECURITY_ERROR, load_error);
loader.addEventListener(IOErrorEvent.IO_ERROR, load_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:false, scaling: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_FRAME, enterFrameEventHandler);
}
private function enterFrameEventHandler(e:Event):void {
snowboard.rotationY += .7;
snowboard.rotationX -= .7;
view.render();
}
private function load_error(e:*):void {
trace("load error:"+e);
}
}
}
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!