« Return to Thread: Problem with collada objects

Re: Problem with collada objects

by lunetta :: Rate this Message:

Reply to Author | View in Thread

1) Forgt about the cvs dude address, project is on google code
2) I would recommend using the trunk if you're new, Great White /Effects
have no documentation and are not finished yet...

Fausto Sgobba wrote:

> Hi everyone.
>
> First of all, I am new to Papervision and I just got the sources from
> svn. I found different links for the svn repository:
>
> http://svn1.cvsdude.com/osflash/papervision3d
> http://papervision3d.googlecode.com/svn/trunk
>
> The second one contains many dirs that seem to be the good one for my classpaths:
>
> as3\trunk\src\
> branches\Effects\src\
> branches\GreatWhite\src\
>
> I'm a bit confused... :(
>
> Now I'm using the "branches\GreatWhite\src\" classpath, which seems to work for simple tests. I've been able to create a sphere with a collada object as a child, but I can't figure out how to make the collada interactive to mouse click.
>
> Look at the following code...
>
>
>
> package  {
>    
>     import flash.display.InteractiveObject;
>     import flash.events.MouseEvent;
>     import flash.filters.GlowFilter;
>     import org.papervision3d.events.FileLoadEvent;
>     import org.papervision3d.events.InteractiveScene3DEvent;
>     import org.papervision3d.materials.BitmapFileMaterial;
>     import org.papervision3d.objects.primitives.Cone;
>     import org.papervision3d.objects.primitives.Sphere;
>     import org.papervision3d.objects.DisplayObject3D;
>     import org.papervision3d.objects.parsers.Collada;
>
>     public class Main extends PaperBase {
>        
>         // vars
>         public var cone:Cone = new Cone();
>         public var sphere:Sphere = new Sphere(
>             new BitmapFileMaterial("library/earth2.jpg"),
>             200,
>             30,
>             30
>         );
>         public var cow:DisplayObject3D;
>        
>         // const
>        
>         // events
>        
>         // getter setter
>        
>         // constructor
>         public function Main() {
>             init();
>         }
>        
>         // public
>        
>         // override
>         override protected function init3d():void {
>
>             sphere.scale = 1; // Make the cone bigger
>             default_scene.addChild(sphere); // Add it to the scene
>            
>             viewport.filters = [new GlowFilter(0x000000, 1, 10, 10, 4, 5)];
>            
>             sphere.material.smooth = true;
>            
>             sphere.scaleY = .93;
>             sphere.pitch( -15);
>            
>             default_camera.zoom = 12;
>            
>             __createCow();
>            
>         }
>        
>         private function __createCow():void {
>             cow = new
> Collada("http://papervision2.com/wp-content/downloads/dae/cow.dae");
>             cow.scale = .2;
>             cow.x = 128;
>             cow.y = 153;
>             cow.lookAt(sphere);
>             cow.addEventListener(FileLoadEvent.COLLADA_MATERIALS_DONE,
> __cowLoaded);
>             cow.pitch(-90);
>             sphere.addChild(cow);
>         }
>        
>         private function __cowLoaded(evt:FileLoadEvent):void {
>
>             trace( "Main.__cowLoaded > evt : " + evt.target );
>
>            
>         }
>        
>         private function __cowClicked(evt:InteractiveScene3DEvent):void {
>             trace( "Main.__cowClicked > evt : " + evt.target );
>             cow.scale *= 1.5;
>         }
>
>         override protected function processFrame():void {
>             //cone.yaw(5); // Rotate it a bit
>            
>             ///* sphere rotation
>             var _newYaw:Number = (stage.mouseX - (stage.width / 2)) / 20;
>             sphere.yaw(_newYaw); // Rotate it a bit
>             //*/
>
>         }
>        
>         // private
>        
>     }
>    
> }
>
> package  {
>    
>     // These lines make differant 'pieces' available in your code.
>     import flash.display.Sprite; // To extend this class
>     import flash.events.Event; // To work out when a frame is entered.
>    
>     import org.papervision3d.view.Viewport3D; // We need a viewport
>     import org.papervision3d.cameras.*; // Import all types of camera
>     import org.papervision3d.scenes.Scene3D; // We'll need at least one
> scene
>     import org.papervision3d.render.BasicRenderEngine; // And we need a
> renderer
>    
>     public class PaperBase extends Sprite { //Must be "extends Sprite"
>      
>        public var viewport:Viewport3D; // The Viewport
>        public var renderer:BasicRenderEngine; // Rendering engine
>        // -- Scenes -- //
>        public var default_scene:Scene3D; // A Scene
>        // -- Cameras --//
>        public var default_camera:Camera3D; // A Camera
>      
>        public function init(vpWidth:Number = 800, vpHeight:Number =
> 600):void {
>          initPapervision(vpWidth, vpHeight); // Initialise papervision
>          init3d(); // Initialise the 3d stuff..
>          init2d(); // Initialise the interface..
>          initEvents(); // Set up any event listeners..
>        }
>      
>        protected function initPapervision(vpWidth:Number,
> vpHeight:Number):void {
>          // Here is where we initialise everything we need to
>          // render a papervision scene.
>          viewport = new Viewport3D(vpWidth, vpHeight, false, true);
>          // The viewport is the object added to the flash scene.
>          // You 'look at' the papervision scene through the viewport
>          // window, which is placed on the flash stage.
>          addChild(viewport); // Add the viewport to the stage.
>          // Initialise the rendering engine.
>          renderer = new BasicRenderEngine();
>          // -- Initialise the Scenes -- //
>          default_scene = new Scene3D();
>          // -- Initialise the Cameras -- //
>          default_camera = new Camera3D(); // The argument passed to the
> camera
>          // is the object that it should look at. I've passed the scene
> object
>          // so that the camera is always pointing at the centre of the
> scene.
>        }
>      
>        protected function init3d():void {
>          // This function should hold all of the stages needed
>          // to initialise everything used for papervision.
>          // Models, materials, cameras etc.
>        }
>      
>        protected function init2d():void {
>          // This function should create all of the 2d items
>          // that will be overlayed on your papervision project.
>          // User interfaces, Heads up displays etc.
>        }
>      
>        protected function initEvents():void {
>          // This function makes the onFrame function get called for
>          // every frame.
>          addEventListener(Event.ENTER_FRAME, onEnterFrame);
>          // This line of code makes the onEnterFrame function get
>          // called when every frame is entered.
>        }
>      
>        protected function processFrame():void {
>          // Process any movement or animation here.
>        }
>      
>        protected function onEnterFrame( ThisEvent:Event ):void {
>          //We need to render the scene and update anything here.
>          processFrame();
>          renderer.renderScene(default_scene, default_camera, viewport);
>        }
>      
>     }
>    
> }
>
> _______________________________________________
> Papervision3D mailing list
> Papervision3D@...
> http://osflash.org/mailman/listinfo/papervision3d_osflash.org
>
>  


_______________________________________________
Papervision3D mailing list
Papervision3D@...
http://osflash.org/mailman/listinfo/papervision3d_osflash.org

 « Return to Thread: Problem with collada objects