Hi all,

Anyone can show a 3d good successfully by using the 3D model in the
google's 3d warehouse ?
I can use the Cow.dea used by PV3D to show a cow successfully, but
when i use the 3d model got from the google 3d warehouse, the 3d model
can't be display correctly.

This is my code:

package
{
        import away3d.cameras.*;
        import away3d.containers.*;
        import away3d.core.utils.*;
        import away3d.lights.*;
        import away3d.loaders.Collada;
        import away3d.loaders.Object3DLoader;
        import away3d.materials.*;
        import away3d.primitives.*;

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

        [SWF( frameRate="30", quality="LOW", width="800", height="600")]
        public class DaeDemo extends Sprite
        {
                //engine variables
                private var scene:Scene3D;
                private var camera:Camera3D;
                private var view:View3D;

                //loader objects
                private var itemLoader:Object3DLoader;

                //scene objects
                private var objectContainer:ObjectContainer3D;

                //light objects
                private var light:DirectionalLight3D;

                //navigation variables
                private var navigate:Boolean = false;
                private var lastMouseX:Number;
                private var lastMouseY:Number;
                private var lastRotationX:Number;
                private var lastRotationY:Number;

                /**
                 * Constructor
                 */
                public function DaeDemo()
                {
                        init();
                }

                /**
                 * Global initialise function
                 */
                private function init():void
                {
                        initEngine();
                        initObjects();
                        initLights();
                        initListeners();
                }

                /**
                 * Initialise the engine
                 */
                private function initEngine():void
                {
                        scene = new Scene3D();
                        camera = new Camera3D({zoom:2, focus:10, x:0, y:0, 
z:-1000});

                        view = new View3D({scene:scene, camera:camera});
                        view.x = 400;
                        view.y = 300;
                        addChild( view );
                }


                /**
                 * Initialise the scene objects
                 */
                private function initObjects():void
                {
                        itemLoader = Collada.load("models/TV2.dae", 
{autoLoadTextures:true,
scaling:1} );
                        objectContainer = new ObjectContainer3D();
                        objectContainer.addChild(itemLoader);
                        scene.addChild( objectContainer );
                }

                /**
                 * Initialise the lights
                 */
                private function initLights():void
                {
                        light = new DirectionalLight3D({x:1, y:1, z:-1, 
ambient:0.2});
                        scene.addChild(light);
                }

                /**
                 * Initialise the listeners
                 */
                private function initListeners():void
                {
                        addEventListener( Event.ENTER_FRAME, onEnterFrame );
                        stage.addEventListener( MouseEvent.MOUSE_DOWN, 
onMouseDown );
                        stage.addEventListener( MouseEvent.MOUSE_UP, onMouseUp 
);
                        onResize(null);
                }

                /**
                 * Navigation and render loop
                 */
                private function onEnterFrame( e:Event ):void
                {
                        view.render();
                        if (navigate) {
                                objectContainer.rotationX = (mouseY - 
lastMouseY)/2 +
lastRotationX;
                                if (objectContainer.rotationX > 90)
                                        objectContainer.rotationX = 90;
                                if (objectContainer.rotationX < -90)
                                        objectContainer.rotationX = -90;
                        }
                }

                /**
                 * Mouse down listener for navigation
                 */
                private function onMouseUp(e:MouseEvent):void
                {
                        navigate = false;
                }

                /**
                 * Mouse up listener for navigation
                 */
                private function onMouseDown(e:MouseEvent):void
                {
                        lastRotationX = objectContainer.rotationX;
                        lastRotationY = objectContainer.rotationY;
                        lastMouseX = mouseX;
                        lastMouseY = mouseY;
                        navigate = true;
                }

                /**
                 * stage listener for resize events
                 */
                private function onResize(event:Event):void
                {
                        view.x = stage.stageWidth / 2;
            view.y = stage.stageHeight / 2;
                }
        }
}


This is the model that i used:
http://sketchup.google.com/3dwarehouse/details?mid=64fafdf42c5b2f1f6f23c6441c344da1&ct=mdrm


anyone can help me?

Thanks

Reply via email to