3D Studio Max and Papervision – Or Maya and Papervision

I have been a little busy at work, and having fun with Papervision whenever I have the chance. Papervision is a 3D engine built for Flash 9 and above to allow developers and designers to create 3D objects in flash.

Papervision can be downloaded here:
http://blog.papervision3d.org/

Now this tutorial will try to help you import 3D Studio Max objects or Maya objects with Papervision.

Materials required for tutorial:
- One 3D modelling software (I use 3D Studio Max)
- DAE exporter for 3D Modelling Software. This can be found here: http://sourceforge.net/project/showfiles.php?group_id=136478
- Papervision (Download: http://blog.papervision3d.org/ )
- Flash CS3 or above
- Some time to make a cool project

I have provided a simple 3D Studio Max cone that you can download here: (You can make your own)
www.josh-ho.com/tutorials/PapervisionMAX/PapervisionMAX-Cone.zip

When you are exporting your 3D object use the Collada converter to convert your object to a DAE file. The DAE object would be read by Papervision and eventually loaded through the code provided. Also note when you are exporting make sure you are exporting the materials with a relative path to maintain materials.

First – Open Flash and create a new Actionscript 3 file
You would want to save the file in the same folder as where your papervision files are located.
Now you want to create a Base Class and link the class to the Class path in the properties tab.

In your Base class you want to import the papervision classes and some Flash classes. Your Base Class name has to be the same as the name you put in the Class path in Flash:

import flash.display.Sprite;
import flash.events.Event;
import org.papervision3d.view.Viewport3D;
import org.papervision3d.scenes.Scene3D;
import org.papervision3d.cameras.Camera3D;
import org.papervision3d.objects.parsers.DAE;
import org.papervision3d.render.BasicRenderEngine;

Create your variables:

private var viewport: Viewport3D;
private var scene: Scene3D;
private var camera: Camera3D;
private var renderer: BasicRenderEngine;
private var daeObject: DAE;

Setup Papervision:

viewport = new Viewport3D(550, 400, false, true);
addChild(viewport);
scene = new Scene3D();
camera = new Camera3D();
renderer = new BasicRenderEngine();

Now import your DAE file:

daeObject = new DAE();
daeObject.load( "Test4Max.xml" );
scene.addChild(daeObject);

It is important to maintain the render so the papervision engine would continue to render the 3D Studio Max animation. We add in an event listener to render each frame.

addEventListener(Event.ENTER_FRAME, onEnterFrameDae);
private function onEnterFrameDae( e:Event ):void {
daeObject.rotationY += 2;
renderer.renderScene( scene, camera, viewport );
}

If we run the Flash we should see the 3D Studio Max object rotating and moving on screen. And there we have it. We got a 3D Studio Max object loaded in Papervision

I have provided a simple base class for you to download
www.josh-ho.com/tutorials/PapervisionMAX/PapervisionMAX-Actionscript.zip


11 responses so far, want to say something?

  1. KrisBelucci says:

    Hi, good post. I have been wondering about this issue,so thanks for posting. I’ll definitely be coming back to your site.

  2. AndrewBoldman says:

    Hi, cool post. I have been wondering about this topic,so thanks for writing.

  3. clarklin says:

    hi there, was following your 3dmax tutorial got to the part:

    daeObject.load( “Test4Max.xml” ); //is this an .xml file??
    i followed the tutorial, dont see anything must be doing something wrong?

    my folders are like so:

    AC_RunActiveContent.js
    cone.max
    PapervisionCone.dae
    PapervisionMAX.as
    try.fla
    try.html
    try.swf

    and then i link in my .fla file to the absolute path of my papervision files:
    D:\Papervision3D_2.0.883

    and my code in the PapervisionMAX.as file looks as such http://www.pastie.org/508259

    doesnt work. what am i doin wrong?
    thanks

  4. clarklin says:

    hi in the pastie, the constructor is called PV3DCollada()
    so when i changed it to match the class name to PapervisionMAX, it compiled fine, but i still dont see anything

  5. clarklin says:

    hi Josh, no worries, i realised that the code given is not the full code,
    had to add the line

    scene.addChild(daeObject);

    and then play with the camera zoom,
    nice tutorial.

  6. admin says:

    Thanks for the update, I thought I had the right as file with all the bugs sorted out. I will update the server with the fixed as file

  7. admin says:

    Server updated with new files. Thanks for the bug report

  8. Teo Iliev says:

    This is an amazing post. I have searched through the net for such a dae loader and this seems to be the simplest and most straght on the topic. Indeed if one is going to use it with flash but not flex or smthing like this, he should consider the name of the constructor.

  9. Paulita Richel says:

    Howdy there,just found your Blog when i google something and wonder what webhosting do you use for your wordpress,the speed is more faster than my wordpress, i really need to know it.will back to check it out,i appreciate it!

  10. admin says:

    Most wordpresses are the same, it really depends on the theme you are running. Some themes run a lot of WordPress calls and those calls slows down the page load time.

  11. Javier Kear says:

    I wish I was so good!

Leave a Reply