6. Loading Complex Models


Hi, Today we're going to modify the "Creating Objects" project again, this time to load a Collada Model file.

Loading Collada files is the fastest and easiest way in Papervision 3d to get a complex model into your scene. By changing a few lines in your code, we can quickly load a model of a cow and make it spin! The result will be this:

All that, in just a few lines of code!

Let's show you how to spin cows..

We'll need to use the org.papervision3d.objects.DisplayObject3D package to store our model in. This will store the geometry, materials and everything like the position and rotation. We'll also need the Collada file parser.. Change your import lines so they look like this:

import PaperBase;
import org.papervision3d.objects.DisplayObject3D;
import org.papervision3d.objects.parsers.Collada;

They're the only three imports needed!

Now, instead of making a cone, this time we're making a cow, so we change the "public var cone" line to this:

public var cow:DisplayObject3D;

So, that line tells our program that we want to store a DisplayObject3D in a variable called cow.

Now, in the init3d() function code we'll load the Collada file. I have the file stored on my server. You can download it if you want but this example will refer to the model on my server so it will work wherever. Change all of the code in "init3d" to this:

cow = new Collada("http://papervision2.com/wp-content/downloads/dae/cow.dae");
cow.moveDown(100);
cow.scale = 3;
cow.pitch(-30);
default_scene.addChild(cow);

Most of that code is just positioning the cow in the scene!
The first line of that code makes the cow variable load the Collada model file from my server. All of the parsing, getting the material and everything like that is done by the Collada package which is pretty neat!

We then move the cow down a bit, tilt her towards the camera, and add her to the scene.

All that's needed now is to rotate the cow each time the frame is processed. Simple! Change the code under "processFrame" so that it reads:

cow.yaw(5);

and you're all done!

My final code is here:

Actionscript:
  1. package {
  2.     
  3.     import PaperBase;
  4.     import org.papervision3d.objects.DisplayObject3D;
  5.     import org.papervision3d.objects.parsers.Collada;
  6.     
  7.     public class Main extends PaperBase {
  8.       
  9.        public var cow:DisplayObject3D;
  10.       
  11.        public function Main() {
  12.          init();
  13.        }
  14.       
  15.        override protected function init3d():void {
  16.          cow = new Collada("http://papervision2.com/wp-content/downloads/dae/cow.dae");
  17.          cow.moveDown(100);
  18.          cow.scale = 3;
  19.          cow.pitch( -30);
  20.          default_scene.addChild(cow);
  21.        }
  22.       
  23.        override protected function processFrame():void {
  24.          cow.yaw(5);
  25.        }
  26.       
  27.     }
  28.     
  29. }

If you enjoyed this post, feel free to Buy Me a Beer!

54 Comments

  1. Comment by rob on January 22, 2008 11:45 pm

    Cow does not have texture as pictured:

    package {

    import PaperBase;
    import org.papervision3d.objects.DisplayObject3D;
    import org.papervision3d.objects.parsers.Collada;

    public class MainCow extends PaperBase {

    public var cow:DisplayObject3D;
    [Embed(source="./cow.dae", mimeType="application/octet-stream")] private var Cow:Class;

    public function MainCow() {
    init();
    }

    override protected function init3d():void {
    cow = new Collada(XML( new Cow() ) );
    cow.moveDown(100);
    cow.scale = 3;
    cow.pitch( -30);
    default_scene.addChild(cow);
    }

    override protected function processFrame():void {
    cow.yaw(5);
    }

    }

    }

  2. Comment by Luke on January 22, 2008 11:54 pm

    Thanks rob, I personally didn't have this problem - Maybe its some kind of security issue - something stopping the flash viewer from accessing my server.

    If you want to download the model and the texture, you can get them here:
    http://papervision2.com/wp-content/downloads/dae/cow.dae
    http://papervision2.com/wp-content/downloads/dae/Cow.png

    - Luke

  3. Comment by Joshua Sullivan on January 23, 2008 2:05 am

    In the text of the tutorial, you have a typo, using "modeDown" instead of "moveDown". This mistake is not present in the final code block. Just thought you might want to know.

  4. Comment by Luke on January 23, 2008 8:35 am

    Thanks Joshua, Fixed :)

    - Luke

  5. Comment by abdel2388 on January 23, 2008 8:54 pm

    -what's the software 3d that you use to make a collada like cow.dae ?
    -because i have some problems with 3dmax i can't export collada object like you do??
    -you can give us the code to add texture(by url) to an collada object??
    thanks ;)

  6. Comment by Luke on January 23, 2008 9:12 pm

    Hi Abdel,

    Unfortunately I didn't make the Cow that I've used in the example - I'm planning on creating a Collada download section soon as one of the problems that I had when I first started with Papervision was finding good Collada files to use!

    Collada files have their texture paths defined in them. If you open up my cow Collada file you'll see the line
    "./Cow.png"

    Try changing that to a url if you want to load the image from somewhere else.

    That's the easiest way to add a texture to a Collada file by url, hope that helps!

    - Luke

  7. Comment by Lee on January 24, 2008 6:09 pm

    Great tutorials! Thanks, I really enjoy the material on this site as I'm playing with Papervision 2.
    Quick question- When using the PaperBase class, what's the "Best Practice" way to listen for key events? IE should I use event listeners, or poll for key-downs in the processFrame() function? To which function should I add the event listeners?

  8. Comment by Luke on January 24, 2008 10:13 pm

    Hi Lee,

    There's a tutorial coming shortly on handling keyboard input - I think the best way to do it would be to add the lines:

    Actionscript:
    1. stage.addEventListener(KeyboardEvent.KEY_DOWN, onKeyDown);
    2. stage.addEventListener(KeyboardEvent.KEY_UP, onKeyUp);

    Just below the "init()"; line. Then, create two functions named onKeyDown and onKeyUp, so your code will look like this:

    Actionscript:
    1. public function Main() {
    2.     init();
    3.     stage.addEventListener(KeyboardEvent.KEY_DOWN, onKeyDown);
    4.     stage.addEventListener(KeyboardEvent.KEY_UP, onKeyUp);
    5. }
    6.  
    7. public function onKeyDown( event:KeyboardEvent):void{
    8.     var keyCode:Number = event.keyCode;
    9.     // (The variable "keyCode" will now hold the value of the key which you pressed)
    10.     // Do whatever you want to here..
    11. }
    12.  
    13. public function onKeyUp( event:KeyboardEvent):void{
    14.     var keyCode:Number = event.keyCode;
    15.     // Do whatever here...
    16. }

    Using that code, the onKeyDown function will be fired when you press a key down and the onKeyUp function when you relese it.

    To work out which keycode is assigned to which key, I put the line "trace(keyCode);" into the onKeyDown function, then when you run the project in debugging mode, the output console will log the value of the key when you press it.

    Hope this helps :D

    - Luke

  9. Comment by David on January 25, 2008 4:10 pm

    Thanks Luke for the tutorial, all is working well!
    Looking forward to the next steps...
    David

  10. Comment by Parka on February 2, 2008 3:54 pm

    First, thanks for this tutorials.
    Now, I haven't tried this yet, but this seems to work as fine as collada. Is for Blender users http://rozengain.com/?postid=54
    Hope to be usefull.

  11. Comment by Francois on February 4, 2008 5:32 pm

    Hey,

    Thanks a lot for the great tutorials. Works fine.
    On another topic --> I'm trying to extend this to make morph animations. Basically, displacing the vertices of the object (probably interpolating vertex positions from two separately loaded .DAE objects). I tried doing that on the primitives like sphere and cube and it works fine, but whenever loading a Collada file, I can't access the geometry as the geometry property remains NULL whatever i do.
    I just added a 'trace(cow.geometry);' as well as the appropriate import (import org.papervision3d.core.geom.*;) but that doesn't see to work. I always get NULL for the cow geometry, although the doc says I should retrieve an array

    Any idea?

    Francois

  12. Comment by visualscoper on February 4, 2008 8:29 pm

    hi everyone
    am new, just want to say thank you to Luke for the tutorials.
    but i have a question.
    Firstly, In (Loading Complex Models) tutorial 6. the sample shows the mesh with a material.
    But for some reason i was only able to load the mesh. And with the tutorial and fixes above I still could
    not load the material with the mesh.
    Question: how do I load both the mesh and the material.
    Thanks

  13. Comment by visualscoper on February 4, 2008 9:51 pm

    hi guys
    could someone please help me
    the cow mesh only appears in black color without the material.
    please!!!

  14. Comment by blulightjr on February 22, 2008 10:00 am

    How can I change the cow texture?

  15. Comment by Carl Newman on February 23, 2008 11:24 pm

    Hello - My first post - Looks like a lot of good, helpful work here.
    My question - Would it be possible to load the name of a .dae file into the compiled flash .swf using a flash var. The flash music players work this way so you can load different songs. I guess the technical question is - is the .dae file compiled in the .swf or parded at runtime to allow changing files on the fly?

    Carl Newman

  16. Comment by Martin Dobrev on March 6, 2008 1:15 am

    Hi guys,
    you have done a really nice job with that 3D Engine :)
    I wanted to ask if somebody knows how to export the Collada models? I am using Blender and there is a collada export possibility, but there are a lot of preferences, for example export as trialngles or polygons, also the version of collada , there is 1.3 and 1.4
    Another question is if the model itself must be created in some special way ?
    Thanks in advance

    Martin Dobrev

  17. Comment by Héctor on March 7, 2008 7:16 pm

    Hi Luke

    I would like to know what is the maximum number of triangles that the collada can handle, i mean, when i translate one scene from 3dsmax to .DAE i find out that the renderer can´t work with many triangles, so is there any max number of them?

  18. Comment by andrew on March 9, 2008 7:56 pm

    Great tutorials Luke, keep up the great work. :)

    How do you apply an interactive material to an imported dae/xml model? This one has been alluding me. Thanks in advance.

    Andrew

  19. Comment by Thomas Langhagel on March 13, 2008 4:40 pm

    This tutorial gives really a very quick starting point.Thanks a lot for your well done work, Luke!

    Thomas

  20. Comment by webmaster on March 15, 2008 9:11 pm

    Thank you for all these great free tuts!

  21. Comment by Paul on March 17, 2008 12:43 pm

    Great tutorials Luke - well written, clear, concise and extremely helpful.

    Thank you.

  22. Comment by hajasmaci on March 21, 2008 4:12 pm

    Helo

    I found plugin for 3ds max to export collada file that is supported by papervision:
    http://www.feelingsoftware.com/content/view/65/79/lang,en/

    Its for free,have to register on the site. I tried it it works.

  23. Comment by Dirk on March 26, 2008 8:54 am

    Or just have a look at the product directory for collada-tools:

    http://www.collada.org/mediawiki/index.php/Portal:Products_directory

    Cheers,
    Dirk

  24. Pingback by jeppe.burchardt.com » Blog Archive » Papervision3D og Blender i flash on April 1, 2008 11:05 am

    [...] For at loade Collada filen ind i Papervision, læs denne tutorial. [...]

  25. Comment by FRACTO on April 2, 2008 7:55 am

    Hello,

    I have a question of this example and the creation of simple models. I would like to create a galaxy with his planets, sun and movements around this.

    I have initial code creating a spheres with the Sphere variable of Papervision. What is the best option: Papervision code or import a modeling with collada?

    This is the code:

    package jel.com.pv3d
    {
    import flash.display.GradientType;
    import flash.display.Sprite;
    import flash.events.Event;
    import flash.filters.GlowFilter;
    import flash.geom.Matrix;

    import jel.com.main.CanvasFlash;

    import org.papervision3d.cameras.Camera3D;
    import org.papervision3d.events.FileLoadEvent;
    import org.papervision3d.materials.BitmapFileMaterial;
    import org.papervision3d.materials.ColorMaterial;
    import org.papervision3d.objects.DisplayObject3D;
    import org.papervision3d.objects.Sphere;
    import org.papervision3d.scenes.MovieScene3D;

    public class SistemaSolar extends CanvasFlash
    {
    private var escenario3D:MovieScene3D;
    private var camara:Camera3D;
    private var dummySol:DisplayObject3D;
    private var dummyTierra:DisplayObject3D;
    private var dummySolJupiter:DisplayObject3D;
    private var sol:Sphere;
    private var tierra:Sphere;
    private var luna:Sphere;
    private var jupiter:Sphere;

    public function SistemaSolar(_width:Number, _height:Number) {
    this.width = _width;
    this.height = _height;

    //Creamos un fondo de estrellas, 400 para ser más exactos.
    creaFondoEstrellas(400);

    //creamos un sprite y se lo asignamos al escenario3D
    //hay que centrarlo en pantalla, dando la mitad del ancho y el alto de la misma.
    //de no hacer esto, los objetos aparecerían en la esquina superior izquierda de la pantalla

    var contenedor_spt:Sprite = new Sprite();
    contenedor_spt.x = 0.5*_width;
    contenedor_spt.y = 0.5*_height;
    this.addChild(contenedor_spt);
    escenario3D = new MovieScene3D(contenedor_spt);

    //creamos la cámara y definimos su zoom y la distancia a la que está el objetivo
    camara = new Camera3D(DisplayObject3D.ZERO);
    camara.zoom = 8;
    camara.focus = 100;

    //movemos la cámara hacia atrás y arriba para mirar al mundo desde un ángulo ligeramente picado

    camara.moveBackward(1750);
    camara.moveUp(1500);

    //creamos 2 objetos dummys para hacer que un astro gire sobre su eje
    //a una velocidad angular distinta que su satélite a su alrededor
    //pero si no se quiere esto, los dummys no son necesarios

    dummySol = new DisplayObject3D();
    dummySolJupiter = new DisplayObject3D();
    dummyTierra = new DisplayObject3D();

    //creamos un material con la textura de la superficie del sol, que cargamos de la carpeta imagenes
    //y una esfera para simular el Sol
    var materialSol:BitmapFileMaterial = new BitmapFileMaterial("imagenes/sol.jpg");
    //materialSol.smooth = true;
    sol = new Sphere(materialSol, 200, 20, 16);

    //idem para la tierra
    var materialTierra:BitmapFileMaterial = new BitmapFileMaterial("imagenes/mundo.jpg");
    //materialTierra.smooth = true;
    tierra = new Sphere(materialTierra, 100, 20, 16);

    //idem para la luna
    var materialLuna:BitmapFileMaterial = new BitmapFileMaterial("imagenes/luna.jpg");
    //materialLuna.smooth = false;
    luna = new Sphere(materialLuna, 30, 20, 16);

    //idem para la luna
    var materialJupiter:BitmapFileMaterial = new BitmapFileMaterial("imagenes/jupiter.jpg");
    //materialLuna.smooth = false;
    jupiter = new Sphere(materialJupiter, 120, 20, 16);
    jupiter.x = 1400;

    dummySolJupiter.addChild(jupiter);

    escenario3D.addChild(dummySol);
    escenario3D.addChild(sol);

    //la tierra la vinculamos a dummySol, para darle una velocidad de rotación en torno al sol
    //distinta de la rotación del sol sobre su eje.
    //idem para la relación de vinculación tierra/luna

    dummySol.addChild(dummyTierra);
    dummyTierra.addChild(tierra);
    dummyTierra.addChild(luna);

    escenario3D.addChild(dummySolJupiter);

    dummyTierra.x = 850; // distancia entre la Tierra y el Sol
    luna.x = 250; // distancia entre la Tierra y la Luna

    sol.container.filters = [new GlowFilter(0xFFD648, 0.5, 35, 35, 2.0, 2.0)];

    //declaramos esta clase como oyente del evento ENTER_FRAME
    //esto hace que el método onEnterFrame sea llamado 25 veces por segundo (el frameRate de reproducción de la aplicación)
    this.addEventListener(Event.ENTER_FRAME, onEnterFrame);

    }

    //método que dibuja estrellas aleatoriamente en el fondo
    private function creaFondoEstrellas(num:uint):void {
    var fondoEstrellas:Sprite = new Sprite();
    fondoEstrellas.graphics.clear();
    fondoEstrellas.graphics.beginFill(0x000000, 1.0);
    fondoEstrellas.graphics.drawRect(0,0, this.width, this.height);
    fondoEstrellas.graphics.endFill();
    var radio:Number;
    for (var i:uint=0; i<num;i++) {
    radio = 1.5*Math.random();
    fondoEstrellas.graphics.beginFill(0xffffff, 0.7);
    fondoEstrellas.graphics.drawCircle(this.width*Math.random(), this.height*Math.random(), radio);
    fondoEstrellas.graphics.endFill();
    };
    this.addChild(fondoEstrellas);
    }

    //este método es llamado cada 1/25 de segundo (cada vez que se produce un evento ENTER_FRAME)
    private function onEnterFrame(evt:Event):void {
    //rotamos 2 grados la esfera que representa al globo terráqueo y renderizamos el escenario para que se actualice la vista

    sol.rotationY -= 0.2; //rotación del Sol sobre su eje
    dummySol.rotationY -= 0.5; //rotación del resto de cuerpos sobre el Sol

    dummyTierra.rotationY -= 2; //rotación de la Luna sobre la Tierra
    tierra.rotationY -= 1.5; //rotación de la Tierra sobre su eje

    //luna.rotationY -= 1; //si quieres que la Luna tenga un mov. relativo sobre su eje, activa esta línea; aunque creo que la luna siempre nos muestra "la misma cara"

    dummySolJupiter.rotationY -= 0.3; //rotación de Júpiter
    jupiter.rotationY -= 0.75

    escenario3D.renderCamera(camara);

    }
    }
    }

    Thank you!

  26. Pingback by Mikes Blog on May 23, 2008 2:44 pm

    [...] http://papervision2.com/loading-complex-models/ [...]

  27. Pingback by What is Collada? | Flash Speaks Actionscript on May 26, 2008 2:14 pm

    [...] Simple Collada Load [...]

  28. Comment by Morf on June 3, 2008 4:52 am

    @Martin

    I really hope you've received an answer by now to your queries:

    "I wanted to ask if somebody knows how to export the Collada models? I am using Blender... there are a lot of preferences, for example export as trialngles or polygons, also the version of collada, there is 1.3 and 1.4.
    Another question is if the model itself must be created in some special way ?"

    Sorry if you've had to wait 3 months! :\

    Anyway, here's how I'm doing it with Blender:
    - Export using Collada 1.4
    - Export as Triangles (we're not supporting Polygons yet... but it'll be great when we do!)
    - Before exporting, I select all the geometry I want exported and then select the option "Only Export Selection", otherwise, the lights/lamps and cameras in your scene will be exported as well.

    I haven't tested out the "Sample Animation" option yet, but any animation your geometry has is included in the Collada file.

    As as creating a model "in a special way"... I haven't had to do anything special. Try using the steps I outline above with some simple models (like a couple cubes, and then, say two intersecting planes) to see how it works.

    Man, COLLADA and PV3D both rock!

  29. Comment by John on June 9, 2008 5:55 am

    this is amazing! please keep up your awesome tutorials!

  30. Comment by Unic on June 12, 2008 6:50 am

    Greetings from Germany :)

    I just wanted to thank you for your GREAT WORK!!! there are not much tutorials that are so easy to understand!

  31. Comment by jared on June 13, 2008 5:44 pm

    awesome tutorials, thanks so much.

    i can get the cow.dae file to load in, but i'm trying to load in my own and nothing's showing up -

    1.i make my model with Cinema 4D
    2.export as an .fbx
    3.use the Alias FBX converter, convert it to a .DAE file

    import it in and it's blank.

    if i copy the xml from the cow.dae file and paste it into the new file it works,

    i'm really puzzled. any ideas anyone?

    thanks again luke!

  32. Comment by HappyMan on June 21, 2008 8:45 am

    Alright, it's great to have such a real cow in Flash. By the way, where is the milk?

  33. Comment by HappyMan on June 21, 2008 11:39 am

    Luke, would you so kind to make us a tutorial which make the cow walking? i mean we are easy to move the cow from left to right but I don't know how to make the cow walking which we will it moves it legs while we are moving the cow???

    traditionally, i will make the cow with walking movie frames and gotoandplay it while the player is pressing the right arrow key.

    how do I make such things in paperVision?

  34. Comment by enricoB on June 22, 2008 2:55 pm

    I tried to export a model from 3D studio, using colladaMax...but no results!
    I am not able to export its texture, and i see in flash only some parts of my model.

    I think i must set some settings in 3ds exporting panel..but i dont know the right way!

    Can someone help me?

    great tutorial!

  35. Comment by luke on July 7, 2008 5:25 am

    hey luke,
    great tutorials as everyone has said, makes getting into papervision so much easier. i actually took the advice on one comment and am using Flash cs3 to export projects out of, as i'm more used to that. the only problem is it takes ages to export a scene (like 30 seconds). i've placed all the great white files in the same directory as the paperbase.as (com, org, etc). this works well but i'm wondering if i set things up differently would it speed up export of .swfs? even complex .swfs of other projects have never taken this long.

  36. Comment by Eduardo on July 9, 2008 8:52 pm

    Hi People... my OUTPUT say this:

    Papervision3D Public Alpha 2.0 - Great White (3.12.07)

    PV3D 2.0a WARNING : DO NOT USE WITH BETA 9 PLAYERS. ONLY WITH OFFICIAL TO TEST.
    CHECK YOUR VERSION!
    DisplayObject3D: null
    DisplayObject3D: null
    DisplayObject3D: null
    DisplayObject3D: vsn-mats
    BitmapFileMaterial: Loading bitmap from http://papervision2.com/wp-content/downloads/dae/Cow.png

    Whats the Problem? My COW doesnt appear !!!

  37. Comment by -YO- on July 18, 2008 5:04 pm

    Thank you for the tutorial!

    i have one problem, when i try the code with another 3D model (.dae) it doesn't appears on screen, with the cow it works perfectly, but with other it doesn't...

    hope someone could help me

    thanks

  38. Comment by -YO- on July 18, 2008 5:21 pm

    haha sorry... my 3D model was (by default) above the camera all the time...

  39. Comment by JK on July 21, 2008 11:49 pm

    Awesome tutorials!!! Thanks!

  40. Comment by pedro on July 23, 2008 12:37 pm

    i have a problem when i call the collada file from any server, this is the error in the output "Papervision3D Public Alpha 2.0 - Great White (24.03.08)

    Error opening URL 'http://pconsuegra.iespana.es/sevenListo2.dae'
    COLLADA file load error Error #2032: Error de secuencia. URL: http://pconsuegra.iespana.es/sevenListo2.dae
    "
    but if put your url ""http://papervision2.com/wp-content/downloads/dae/cow.dae"" it works, later i download your collada file "cow.dae" and i did upload to my server i flash show me the same error.
    but if i call the files in a local way all of them work, this situation is drive crazy.
    this my .as file

    ConeExample.as

    package {

    import flash.display.*;
    import flash.events.*;
    import flash.utils.Dictionary;

    import org.papervision3d.cameras.*;
    import org.papervision3d.materials.*;
    import org.papervision3d.objects.*;
    import org.papervision3d.scenes.*;
    import org.papervision3d.core.*;
    import org.papervision3d.core.proto.*;
    import org.papervision3d.events.FileLoadEvent;
    import org.papervision3d.materials.ColorMaterial;
    import org.papervision3d.materials.utils.*;
    import org.papervision3d.objects.parsers.DAE;
    import org.papervision3d.events.FileLoadEvent;

    import base.PaperBase;
    import org.papervision3d.objects.primitives.Cone;
    import org.papervision3d.materials.BitmapFileMaterial;
    import org.papervision3d.objects.DisplayObject3D;
    import org.papervision3d.objects.parsers.Collada;

    public class ConeExample extends PaperBase {

    private var w:int = new int;
    private var h:int = new int;
    private var daeFile:DAE;

    public var seven:DisplayObject3D;

    public function Main($root,w:int,h:int) {

    trace(w);
    trace(h);
    this.w=w;
    this.h=h;
    init($root, w, h);

    }

    override protected function init3d():void {
    var material:ColorMaterial = new ColorMaterial ( 0xD3C8AD, 100 );
    var material2:ColorMaterial = new ColorMaterial ( 0x007A99, 54 );
    var material3:ColorMaterial = new ColorMaterial ( 0x001E99, 54 );
    var material4:ColorMaterial = new ColorMaterial ( 0x990000, 54 );
    var material5:ColorMaterial = new ColorMaterial ( 0x99997A, 54 );
    var material6:ColorMaterial = new ColorMaterial ( 0x999999, 54 );

    var lMaterialsList:MaterialsList = new MaterialsList();
    lMaterialsList.addMaterial (material, "ERDefaultMaterial");
    lMaterialsList.addMaterial (material2, "ERTransparent08");
    lMaterialsList.addMaterial (material3, "ERTransparent11");
    lMaterialsList.addMaterial (material4, "ERTransparent46");
    lMaterialsList.addMaterial (material5, "ERTransparent51");
    lMaterialsList.addMaterial (material6, "ERTransparent06");

    /*MaterialsList.addMaterial ( new ColorMaterial ( 0xD3C8AD, 100 ), "ERDefaultMaterial");
    lMaterialsList.addMaterial ( new ColorMaterial ( 0x007A99, 54 ), "ERTransparent08");
    lMaterialsList.addMaterial ( new ColorMaterial ( 0x001E99, 54 ), "ERTransparent11");
    lMaterialsList.addMaterial ( new ColorMaterial ( 0x990000, 54 ), "ERTransparent46");
    lMaterialsList.addMaterial ( new ColorMaterial ( 0x99997A, 54 ), "ERTransparent51");
    lMaterialsList.addMaterial ( new ColorMaterial ( 0x999999, 54 ), "ERTransparent06");
    */

    //add loading listeners to your dae
    /*daeFile.addEventListener(FileLoadEvent.LOAD_COMPLETE, handleLoadComplete);
    daeFile.addEventListener(FileLoadEvent.LOAD_ERROR, handleLoadError);
    daeFile.addEventListener(FileLoadEvent.LOAD_PROGRESS, handleProgress);
    daeFile.addEventListener(FileLoadEvent.SECURITY_LOAD_ERROR, handleSecurity);
    daeFile.addEventListener(FileLoadEvent.COLLADA_MATERIALS_DONE, handleMaterialsDone);
    */
    //http://pconsuegra.iespana.es/sevenListo2.dae
    seven = new Collada("http://pconsuegra.iespana.es/sevenListo2.dae", lMaterialsList, 0.01);
    seven.moveDown(300);

    seven.x=w/2-500;
    seven.y=h/2;
    seven.scale = 1200;
    seven.pitch( 0);

    default_scene.addChild(seven);

    //default_scene.addChild(cone);

    }

    override protected function processFrame():void {

    //cone.yaw(7);
    seven.yaw(3);
    }

    }

    }

    my fla code is

    import caurina.transitions.*

    var $coneExample:ConeExample = new ConeExample();

    //this is the current root, passed to the Main - method.

    $coneExample.Main(this.root,stage.stageWidth,stage.stageHeight);

    please somebody hellppp meeee

  41. Comment by pedro on July 23, 2008 5:24 pm

    i think the reason for i can`t see my own collada files from my server, is becouse my server don`t support this kinds of file. what is the server that i need? there are some free hosting sites that support this files? please somebody help me

  42. Comment by jenny on July 30, 2008 5:11 pm

    Hi, i have done this tutorial but i can´t see anything.

    I am loading "cow.dae" from my local directory, it is exactly at the same level of cow.swf,cow.as, org and com directories,
    My question is, what am i doing wrong, why can´t i see the cow?
    My cow.fla file is 640 x 640 pixels, Might be the cow out of the canvas when i export my swf?
    There are not errors reported when i export my swf.

    Please help me!!!

    my as file looks like this:

    package {

    import PaperBase;
    import org.papervision3d.objects.DisplayObject3D;
    import org.papervision3d.objects.parsers.Collada;

    public class Main extends PaperBase {

    public var cow:DisplayObject3D;

    public function Main() {
    init();

    }

    override protected function init3d():void {
    //cow = new Collada("http://papervision2.com/wp-content/downloads/dae/cow.dae");
    //importing my model from my local directory.
    cow = new Collada("cow.dae");
    cow.moveDown(100);
    cow.scale = 3;
    cow.pitch(-30);
    default_scene.addChild(cow);
    }

    override protected function processFrame():void {
    cow.yaw(5);

    }

    }

    }

  43. Comment by Bill Brown on July 31, 2008 8:49 pm

    I think I've been able to isolate the problem with loading the Collada DAE files and textures.
    It has something to do with the server.

    Server 1 - Media Temple running Linux???
    Server 2 - MS Server 2000 running IIS 5.0

    On Server 1, I initially got an Error #2044 saying that it could not load my DAE file. I noticed that in my AS3 code I was referencing the file as "cow.dae", but on my server the file was "cow.DAE". Change the case of the file extension fixed the Error #2044; however, the textures are not loading and all I see is the mesh.

    On Server 2, everything works, including textures, without any issues.

  44. Comment by Colossus on August 5, 2008 8:17 am

    This is a great tutorial. I've been trying to use Papervision 2 with Flash though, rather than Flex and it doesn't seem to be working. Can you provide a guide on how to use Papervision 2 with Flash? I try to use your base class etc to make this cow example myself in Flash but I get nothing on screen and get the following error.

    TriangleMesh3D.as, Line 53

    1020: Method marked override must override another method.

  45. Comment by plmarcot on August 20, 2008 2:09 am

    Hi Thanks for this tutorial .

    question I have a error 1037: Packages cannot be nested.

    Somebody explain this to me?

  46. Comment by Felipe on August 20, 2008 10:12 pm

    Hi, I tried to export a DAE file from 3dMax, a real simple collada file (cone) but when a try to load, it shows Error #1009: Cannot access a property or method of a null object reference.

    What could be the problem, since the cow loads fine?

    thanks

  47. Comment by ozgur on August 21, 2008 1:18 pm

    Hello everyone, I have a problem.
    I downloaded the cow.dae and cow.png, and run the example on my machine locally.
    It works, not problem.
    I changed to another *.dae which is more detailled, (7MB)
    and I get this errors:

    any idea??

    Error: Error #1502: A script has executed for longer than the default timeout period of 15 seconds.
    at org.papervision3d.objects.parsers::Collada/org.papervision3d.objects.parsers:Collada::parseGeometry()[C:\Greatwhite\org\papervision3d\objects\parsers\Collada.as:311]
    at org.papervision3d.objects.parsers::Collada/org.papervision3d.objects.parsers:Collada::parseNode()[C:\Greatwhite\org\papervision3d\objects\parsers\Collada.as:257]
    at org.papervision3d.objects.parsers::Collada/org.papervision3d.objects.parsers:Collada::parseNode()[C:\Greatwhite\org\papervision3d\objects\parsers\Collada.as:240]
    at org.papervision3d.objects.parsers::Collada/org.papervision3d.objects.parsers:Collada::parseScene()[C:\Greatwhite\org\papervision3d\objects\parsers\Collada.as:188]
    at org.papervision3d.objects.parsers::Collada/org.papervision3d.objects.parsers:Collada::buildCollada()[C:\Greatwhite\org\papervision3d\objects\parsers\Collada.as:173]
    at org.papervision3d.objects.parsers::Collada/org.papervision3d.objects.parsers:Collada::onComplete()[C:\Greatwhite\org\papervision3d\objects\parsers\Collada.as:152]
    at flash.events::EventDispatcher/flash.events:EventDispatcher::dispatchEventFunction()
    at flash.events::EventDispatcher/dispatchEvent()
    at flash.net::URLLoader/flash.net:URLLoader::onComplete()

  48. Comment by Felipe on August 22, 2008 2:37 pm

    Hello you all!

    The error I was getting, I got around installing plugins for 3DMAX from a website listed at this site.

    Now I can export the .dae files Ok, but can´t load them on PV3D. The Cow loads fine, even when I import on 3DMAX and Export again. But a simple Box with texture (see below) does not import. If someone could please test it to see if it loads on PV3D, would be a great help for me.

    here is the collada and the texture: http://www.add-digital.com.br/collada/box.zip

    Thanks a lot!

  49. Comment by Felipe on August 22, 2008 3:33 pm

    Just discovered why the collada wasn´t showing. It was loading all right, bt the scale was too hight. just changed to make it fir the screen better. :)

  50. Comment by Magno on August 23, 2008 5:31 am

    Hey man! YOUR TUTO KICK ASS!

  51. Comment by pablow on August 26, 2008 7:22 pm

    hello, does anybody knows how this cow texture was created???
    http://papervision2.com/wp-content/downloads/dae/Cow.png
    i don´t think it was hand made.
    thank you

  52. Comment by Brice on August 29, 2008 4:39 pm

    Hi guys !
    Greetings from Paris, France
    ( I apologize for my english )

    What amazing tutorials !!! You're really 'pedagogue' ( I hope it's the same meening in English )

    I was wondering ... do you know if there's a way to modify the opacity of a Collada ?
    I managed with a Plane by modifying its Material.
    But the ".materials" property of a Collada returns nothing ...

    have you got an idea ?

    Thanks a lot
    I support you guys

    Briçou

  53. Comment by papablacksheep on September 3, 2008 4:05 am

    hello there!

    does anyone knows how can I change the MaterialsList applied to a collada at runtime ?
    Let's say I create a mycollada object with a myfirstmateriallist applied, I write:

    mycollada = new Collada("something.dae", myfirstmateriallist);

    ok, if later I want to create a function that appplies a mysecondmateriallist to this mycollada object (because of a given event or something) if I simply use a function telling:

    mycollada.material = mysecondmateriallist;

    I simply get an error :

    col: 25 Error: Contrainte implicite d'une valeur du type org.papervision3d.materials.utils:MaterialsList vers un type sans rapport org.papervision3d.core.proto:MaterialObject3D.

    (sorry I'm using french version of debugger)

    Am I doing something wrong or maybe it is not possible to change the materialsLists applied to a collada once it has been previously done?

  54. Comment by papablacksheep on September 3, 2008 4:24 am

    EDIT: sorry the right thing is:

    mycollada.materials = mysecondmateriallist;

    But it doesn't work anyway...

Comments RSS TrackBack Identifier URI

Leave a comment


Papervision 2 is proudly powered by WordPress and themed by Mukka-mu