You can export collada from 3dsmax 2010 but it won’t load properly in Papervision3D and throw an error. You will need a plugin called “Collada Max NextGen” from SourceForge.
To load a collada file “box.dae”, write the code like below:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | package { import flash.display.Sprite; import flash.events.Event; import flash.events.MouseEvent; import org.papervision3d.cameras.CameraType; import org.papervision3d.core.proto.MaterialObject3D; import org.papervision3d.events.FileLoadEvent; import org.papervision3d.events.InteractiveScene3DEvent; import org.papervision3d.objects.DisplayObject3D; import org.papervision3d.objects.parsers.Collada; import org.papervision3d.render.BasicRenderEngine; import org.papervision3d.scenes.Scene3D; import org.papervision3d.view.BasicView; import org.papervision3d.view.Viewport3D; [SWF(width="640", height="480", frameRate="30", backgroundColor="#000000")] public class ColladaExample extends BasicView { private var collada:Collada; public function ColladaExample () { super(0, 0, true, true, CameraType.FREE); init(); } private function init():void { camera.z = -1500; camera.focus = 200; camera.zoom = 2; addCollada(); } private function addCollada():void { collada = new Collada(); collada.load("box.dae"); collada.addEventListener(FileLoadEvent.LOAD_COMPLETE, onColladaLoaded); scene.addChild(collada); } private function onColladaLoaded(e:FileLoadEvent):void { collada.removeEventListener(FileLoadEvent.LOAD_COMPLETE, onColladaLoaded); startRendering(); } override protected function onRenderTick(event:Event=null):void { collada.rotationY += 2; super.onRenderTick(event); } } } |
If you have created a box named “box1″ and you want to interact with it, you will need to delete a node tag id called “node-Scene_Root” in collada file so collada.getChildByName(“Box1″) won’t throw an error. So you get like:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 | package { import flash.display.Sprite; import flash.events.Event; import flash.events.MouseEvent; import org.papervision3d.cameras.CameraType; import org.papervision3d.core.proto.MaterialObject3D; import org.papervision3d.events.FileLoadEvent; import org.papervision3d.events.InteractiveScene3DEvent; import org.papervision3d.objects.DisplayObject3D; import org.papervision3d.objects.parsers.Collada; import org.papervision3d.render.BasicRenderEngine; import org.papervision3d.scenes.Scene3D; import org.papervision3d.view.BasicView; import org.papervision3d.view.Viewport3D; [SWF(width="640", height="480", frameRate="30", backgroundColor="#000000")] public class ColladaExample extends BasicView { private var collada:Collada; private var myObj3d:DisplayObject3D ; private var myMaterial:MaterialObject3D; public function ColladaExample () { super(0, 0, true, true, CameraType.FREE); init(); } private function init():void { camera.z = -1500; camera.focus = 200; camera.zoom = 2; addCollada(); } private function addCollada():void { collada = new Collada(); collada.load("box.dae"); collada.addEventListener(FileLoadEvent.LOAD_COMPLETE, onColladaLoaded); scene.addChild(collada); } private function onColladaLoaded(e:FileLoadEvent):void { collada.removeEventListener(FileLoadEvent.LOAD_COMPLETE, onColladaLoaded); myObj3d = collada.getChildByName("box1", true) myObj3d.addEventListener(InteractiveScene3DEvent.OBJECT_OVER, on3dOver); myObj3d.addEventListener(InteractiveScene3DEvent.OBJECT_OUT, on3dOut); myObj3d.addEventListener(InteractiveScene3DEvent.OBJECT_CLICK, on3dClick); // You can find out your material name by collada.materialsList() myMaterial = myObj3d.materials.getMaterialByName("m1"); myMaterial.interactive = true; myMaterial.smooth = true; startRendering(); } override protected function onRenderTick(event:Event=null):void { collada.rotationY += 2; super.onRenderTick(event); } private function on3dOver(e:InteractiveScene3DEvent):void { viewport.buttonMode = true; trace("OVER"); } private function on3dOut(e:InteractiveScene3DEvent):void { viewport.buttonMode = false; trace("OUT"); } private function on3dClick(e:InteractiveScene3DEvent):void { trace("CLICK"); } } } |
8 users commented in " PV3D – Loading Collada from 3ds max 2010 "
Follow-up comment rss or Leave a Trackbackhey Ed, thank you for the post.
I’ve been banging my head trying to figure out why my Max .dae’s were not working in PV3D.
BTW, this post refers Max 2010 – I assume Max 2009′s native collada exporter has the same issue? (that’s the version I’m using).
For Max 2009, you will need to download COLLADAMax 1.4.1 plug-ins on the same link page.
already on it, thanks again for the tip. Rss’d your blog – good stuff. happy coding
Hi ED, I was looking for resources, and your site seems great.
I’m new using PV3D, and I wanted to ask you, if you know why, flashCS4 shows an error, “Collada material ‘collada_png’ not found.”
I’m using your code, but I’m implementing an example that I found in gotoAndLearn.com -> Papervision3D Collada Basics. It is an incompatibility of flashplayer10? They recommend the use “Bender,” but I prefer to use “3DS MAX”, this is more and more complicated. One final request: would be possible for someone to upload a sample file, from a Collada 3DSMax2010?. Your help is appreciated! ty
Hi,
I am using the ColladaMax_FREE_3.05C.exe plugin for exporting the collada file form Max 2010 but while exporing it doesn’t show me an option to export in this format..am i using the wrong plugin?
Thanks
I believe they have taken down the “nextgen” plugin…, but you can try http://opencollada.org/download.html
thanks for the great article!!
I used “nextgen” plugin to export .dae from max 2010.
flashCS4 shows an error, “Collada material ‘collada_png’ not found.”
My object is loaded but I cannot see anything. The mouse over and mouse out works.
Any ideas why this is happening?
thanks
I recommend using Away3d instead as it can import .3ds and .obj formats to AS3 data class.
Leave A Reply