Peter Elst

Flash Platform Consultant
  • Home
  • About me
  • Articles
  • Downloads
  • Contact me

Papervision3D in 5 minutes

7 07 2007

Having had Ralph over to our user group last Thursday was a real inspiration to get experimenting with Papervision3D again. Last night I decided to try out John Grdn’s new PV3D components for the Flash IDE — I was stunned.

Its been ages since I last played around with the API but its ridiculously quick and easy to get a Collada model loaded in and apply your custom materials. Just a couple of lines of code and you get it animating. Thought I’d share my little experiment here, if you’ve got a couple of minutes to spare during a coffee break be sure to give it a try.

 

1. Download and install PV3DComponents_v1.0.mxp from the following URL:
http://www.rockonflash.com/blog/?p=54

2. Launch Flash CS3 and create a blank FLA

3. Drag an instance of the Collada Scene component from the components panel to the stage, resize it to fit the stage and give it the instance name “scene3D”

4. Download cube.dae (created by Alessandro Crugnola for this experiment)

5. Go to Window > Other Panels > PV3D Panel

6. In the PV3D Panel point to your working folder and specify cube.dae you just downloaded as its Collada source file

7. In the model tab of the PV3D Panel set up the zoom and rotation of the 3D object

 

Notice the live preview in the component on stage. Now, lets add a material to this cube —

 

8. Import an image file into you’d like to use as a material, set up its linkage ID in the Library panel to “cubeSkin”

9. In the Parameters panel click on Materials list and set it up to read as the screenshot below:

Papervision3D component material dialog

 

The materialName property refers to the name of the material as specified in the Collada file, in this case its “CubeMaterial”. Interesting to know if you’re not sure what material names where used in a specific file you can just open it with your favourite text editor and look for the library_materials node — Collada files are XML based so easily readable.

The materialLinkageID property is set to the Linkage ID we gave that bitmap image that was imported i.e. “cubeSkin”

 

10. Add a new layer to your timeline and add the following code (if you feel dirty doing this, simply create an AS3 class and set it as the document class for the FLA).

 

import flash.events.Event;
  
function rotateCube(evt:Event):void {
  scene3D.collada.rotationX += 1;
  scene3D.collada.rotationY += 1;
  scene3D.collada.rotationZ += 1;
}
  
addEventListener(Event.ENTER_FRAME, rotateCube);

Pretty easy, right? It just increments the x, y and z rotation of the 3D object by 1 every frame. Now save this FLA in your working folder and run Control > Test Movie which should give you a result something like this:

[flash]/blog/wp-content/uploads/2007/07/pv3d.swf,350,300[/flash]

Download the source files

« OOP with ActionScript 3.0 article And now for something completely different… »



Actions

  • rss Comments rss
  • trackback Trackback

Informations

  • Date : 7 July 2007
  • Categories : Flash, Flex, Open Source

29 responses to “Papervision3D in 5 minutes”

7 07 2007
Sean Moore (16:34:55) :

Nice article Peter! I want to try this out. Looks like it takes some of the work out of loading the model and mapping the material in code… (Rock on John!)

Sean

7 07 2007
reintroducing.com Blogging Receptacle » Blog Archive » PE Does PV3D In 5 (17:46:09) :

[...] Elst posted a quick blog about his experience with Papervision3D in five minutes.  Pretty cool that it only took him that long to get back into the swing of things.  Once I pick [...]

7 07 2007
Hebi Flash Blog » Et encore Papervision... (18:01:25) :

[...] bouge décidément de ce côté. Peter Elst vient de nous faire un petit tutorial avec Papervision en 5 minutes, histoire de faire mumuse avec le composant Papervision pour Flash CS3. Plutôt rapide [...]

8 07 2007
John Grden (05:33:59) :

Thanks for posting about this Peter!

I thought it worth mentioning that you could also use yaw(), pitch() and roll() methods to do the incremental rotation

scene3d.collada.yaw(1)
is the same as:
scene3d.collada.rotationY += 1;

Thanks again, this looks great!

John

25 07 2007
Andrew Paul Simmons (00:25:30) :

Very cool!!

24 08 2007
Jeff (02:23:10) :

Wish I could get this working right. I’m fine until step 9 where it says “In the Parameters panel click on Materials list and set it up to read as the screenshot below:” When I click on the Materials list it is totally blank. When I hit the “+” icon nothing happens, so I’m not sure how to populate the list with data. I have installed all of the AS3 classes and can’t figure out what the problem is. Any help is appreciated.

Thanks,
Jeff

24 08 2007
Peter (13:29:19) :

If you click the + icon you should see the dialog getting populated with values like animated, singleSided etc. (see screenshot). Then you just click the space on the right of each value and type in its value.

Hope this helps!

25 08 2007
Paradox (18:25:25) :

MXP File installed correctly, I can see the PV3D Panel and all but I don’t have any new components in the components panel

Using Flash CS3 with latest Player 9 Beta on OSX 10.4.10

Any help is appreciated

Thanks

27 08 2007
werner (20:17:41) :

thx, i like ur work, bedankt alweer, ik maakte er dit van ..cubes

30 08 2007
Jeff (18:48:47) :

I’ve figured out my problem: The papervision component is not functioning properly under Mac OS X. I tried installing it on a Windows PC and all of my material list problems went away. Apparently clicking the + icon on the Materials list will only work under a Windows installation of papervision. Hope this helps.

Jeff

30 08 2007
Peter (19:06:25) :

Good to hear you’ve got it working Jeff — I’ve got no problems using it on Mac OSX though.

24 09 2007
Jase (16:50:33) :

Hi Jeff,
I was only able to reproduce that issue in Windows if the publish setting was set to ‘ActionScript 2.0′ and the ‘Identifier’ field in the linkage properties, was filled in instead of the ‘Class’ field.

Thanks Peter. Great tutorial.

24 09 2007
Papervision3D components « Change the Script (17:27:44) :

[...] got around to trying out this Papervision3d tutorial and I’m really surprised at how quickly a mapped, moving cube could be knocked up. Since the [...]

9 10 2007
Christopher M. Dickens » Papervision3d (18:35:12) :

[...] Papervision3d downloads Papervision3d Wiki Papervision3d blog Another Papervision3d blog Papervision3d in 5 mins [...]

15 10 2007
masuno (17:22:03) :

great tutorial, but i am not able to activate the linkage ID with AS3, says has to be AS2 an when publishing i get the message the papervision needs AS3.. hmmm, so what can i do??

os: mac 10.4.10

The code in the outputwindow is:

DisplayObject3D: null
Papervision3D Beta 1.7 (20.08.07)

DisplayObject3D: null
DisplayObject3D: null
Papervision3D Beta 1.7 (20.08.07)

DisplayObject3D: null
DisplayObject3D: null
DisplayObject3D: Box01
Collada material CubeMaterial not found.

1 01 2008
Warren mackenzie (00:57:54) :

hi, ive been looking for articles and source for a while,
i downloaded SVN turtle thing,set it all up and i tried variuos other ‘basic’ tutorials, including the Computer ats one which usually works, and nada!

yours did work however!!!! so thanks a lot!

do you know of any sites that have utorials that, like yours, do what they say, and start simple working up slowly, im ok at scripting and 3d, but this thing has me perplexed.

want to make an interactive 3d worldy thing for a site im on at work, this is how i gotta do it it seems, but im lost.

wish there was a clearly illustrated easy to follow book that included source files for tuts.

help me flash god.
MSN me

waz

24 02 2008
Carl (20:17:32) :

Hi Peter,

Awesome tutorial, as a person who plays around with Flash and 3DS Max (.NET developer by trade), I found all the previous tutorials ’skipped’ out important bits!

Now I finally have a base working example I can finally start playing around with my own models in PV3D (Ikept getting to the materials bit’s in other tutorials, but non explained how to setup the parameters).

Great tutorial, thanks,

Carl

7 03 2008
igregurec (20:45:45) :

hi!
i’m using flash CS3 on WinXP and when i’ve installed PV3ComponentsV1.0 there was no any new components in components panel even thou PV3Com works, well… lets say well.
same problem as “Paradox” posted few months ago.
have anybody figured it out in meanwhile?
tnx!

12 03 2008
Ahad Bokhari (20:37:59) :

I got it all done on my end…Hey i just wanted to mention to your other viewers that &nbsp didnt work in the actions of my .fla [i just deleted them] Here is how it would look like.

import flash.events.Event;
function rotateCube(evt:Event):void {
scene3D.collada.rotationX += 1;
scene3D.collada.rotationY += 1;
scene3D.collada.rotationZ += 1;
}
addEventListener(Event.ENTER_FRAME, rotateCube);

Also viewers should note to give the component (on the stage) an instance name of scene3D.

Keep up the good work Peter and thanks for the quick tutorial, to RockonFlash and to the owner of the Google code .mxp (neOriley). Yeah it was a stunner and it took just about 5 minutes!!

12 03 2008
Papervision 3D - A first for me but not the last!! (21:20:13) :

[...] thanks to Peter Elst, Rock on Flash and Google code for making this possible….There are many out there who like [...]

17 04 2008
Installing Papervision3D on Flash and Flex | fabianvercuiel.com (21:23:24) :

[...] 3D Object Basics - Papervision3D tutorial from the ground up - Papervision2: Preparing your tools - Papervision3D in 5 minutes - Content creation for Papervision3D using XSI Mod Tool - Papervision Tutorial - Papervision 3D [...]

19 04 2008
OpenRIA » Blog Archive » Papervision3D上手教程 (17:25:44) :

[...] 3D Object Basics - Papervision3D tutorial from the ground up - Papervision2: Preparing your tools - Papervision3D in 5 minutes - Content creation for Papervision3D using XSI Mod Tool - Papervision Tutorial - Papervision 3D [...]

13 05 2008
火柴工作坊 » Blog Archive » Papervision3D入门教程 (07:43:09) :

[...] and 3D Object Basics- Papervision3D tutorial from the ground up- Papervision2: Preparing your tools- Papervision3D in 5 minutes- Content creation for Papervision3D using XSI Mod Tool- Papervision Tutorial- Papervision 3D [...]

28 05 2008
samsara (07:02:39) :

Thank you for your tutorial.
I downloaded your source code, unzipped it, remedied path of the cube.dae, then published, but there were 2 compiler errors come up:
Vertices3D.as, Line 163 1000: Ambiguous reference to Vertex3D.
Vertices3D.as, Line 222 1000: Ambiguous reference to Vertex3D.

Do you have any idea why this happened?
Thanks in advance!!

28 05 2008
samsara (08:40:50) :

Oh, Sorry!
Your source file works perfectly after I re-download the Papervision3D.
Thank you for your nice tutorial!

Good day!

20 06 2008
cryzto (18:05:24) :

Hi there!
Awesome turorial, just what I was looking for…
simple but efficient…

But I have one problem:
If I place my cube.dae elsewhere before I load it in the PV3-Component…everything’s fine until I run it.
The it says “COLLADA file load Error #2032: ……”
-> it looks for the collada-file in the same place like the fla…

If now I put a copy of my collada-object in the same path like my fla, but still having the link in the PV3-Component pointing to the original one, it works…

why???… is that a PV3-Bug?

20 06 2008
cryzto (18:18:02) :

added: I think the local directory has to point to the fla-path!

PV3-localdirectory-path -> where the fla is!
PV3-collada-path -> where the collada is (+subdirectory)

then it works! but still a lil buggy… the component takes the subdirectory with the collada file as one name -> assetscube.dae

…so I think its the component which is lil buggy…

Can you confirm that?

Greetz

28 06 2008
Matt (03:57:32) :

Mine simply repeats “Please select a collada component to edit” no matter how many times i set the local path and collada path.

When I select “cube.dae” it does say “COLLADA File: cube.dae” but then continues with its complaining:

Please select a collada component to edit
Please select a collada component to edit
Please select a collada component to edit
Please select a collada component to edit
COLLADA File: cube.dae
Please select a collada component to edit
Please select a collada component to edit
Please select a collada component to edit
Please select a collada component to edit
Please select a collada component to edit

Weird.

4 07 2008
ShutterBun (06:24:31) :

I had that same problem myself, but seem to have figured it out. Basically, you have to have the “Collada Scene” that you’ve placed on your stage *selected* while you are fiddling with the controls.

Leave a comment

You can use these tags : <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>





Conferences

Flash on the Beach Speaker

Training Partners

multimediacollege

SkillsMatter

Badges

Alltop, confirmation that I kick ass

  • Categories

    • AIR RSS category feed
    • Ajax RSS category feed
    • CSS RSS category feed
    • Eclipse RSS category feed
    • Events RSS category feed
    • Flash RSS category feed
    • Flash Lite RSS category feed
    • Flex RSS category feed
    • Gadgets RSS category feed
    • General RSS category feed
    • JSFL RSS category feed
    • Mac RSS category feed
    • Open Source RSS category feed
    • PHP RSS category feed
    • Podcasts RSS category feed
    • Publications RSS category feed
    • Rants RSS category feed
    • Reviews RSS category feed
    • Thought of the Day RSS category feed
    • Training RSS category feed
    • Twitter RSS category feed
    • Video RSS category feed
  • Resources

    • Serge Jespers
    • Marco Casario
    • Keith Peters
    • Edwin van Rijkom
    • Burak Kalayci
    • Chafic Kazoun
    • LordAlex Leon
    • Aral Balkan
    • Ralf Bokelberg
    • Jesse Warden
    • Patrick Mineault
    • Josh Tynjala
    • Jonathan Kaye
    • André Michelle
    • Mario Klingemann
    • Stephen Downs
    • Robert M. Hall
    • Sas Jacobs
    • Ted Patrick
    • Rich Tretola

     
     

    Adobe Community Expert

    See my profile on LinkedIn



    Harz Ferienwohnung Suchmaschinenoptimierung Geschenkideen Harz Ferienwohnung Pagerank Webkatalog Webhosting