dehash »  AS3 Papervision3D GreatWhite example code «

Some AS3 code examples that use Papervision3D GreatWhite from SVN. Made with FlashDevelop and Flex3 SDK but as they are pure AS3 examples they should work mostly the same in Flash 9 too. Some examples are clean and basic but others are less so and some are just ideas for things to explore later when more examples are added. Will try to put build/revision number in each post but note when using SVN it is inevitable that if some time has passed parts of these they may not work without tweaking in later builds. The source code text is released as open source under the BSD License which is a very open license with few restrictions. Any external media used however (bitmaps, flv, sound etc) is not covered by this license. If you notice mistakes please email dehash_at_gmail_dot_com.

 

Title: DAE EnvMapMaterial

Embedded Blender Collada DAE with EnvMapMaterial using BasicView - revision 702 - The Collada DAE is the monkey object 'Suzanne' exported without a material from current Blender with a EnvMapMaterial added to it.

Actionscript:
  1. /**
  2. * v0.1 code by dehash.com 2008
  3. * Released as open source under the BSD License
  4. * http://www.opensource.org/licenses/bsd-license.php
  5. */
  6. package com.dehash.pv3d.examples.materials{
  7.  
  8. import flash.display.Bitmap;
  9. import org.papervision3d.lights.PointLight3D;
  10. import org.papervision3d.materials.shadematerials.EnvMapMaterial;
  11. import org.papervision3d.objects.DisplayObject3D;
  12. import org.papervision3d.objects.parsers.DAE;
  13. import org.papervision3d.view.BasicView;
  14. import flash.events.Event;
  15.  
  16. [SWF(width="800", height="600", backgroundColor="0x000000")]
  17.  
  18. public class DaeEnvMapMaterial extends BasicView {
  19.  
  20. [Embed(source='ml2.jpg')]
  21. private var ml2:Class;
  22.  
  23. [Embed(source='monkey2.dae', mimeType='application/octet-stream' )]
  24. private var monkey2:Class;
  25.  
  26. private var do3d:DisplayObject3D;
  27. private var envMapMaterial:EnvMapMaterial;
  28. private var light:PointLight3D;
  29. private var dae:DAE;
  30.  
  31. public function DaeEnvMapMaterial (viewportWidth:Number = 800, viewportHeight:Number = 600,
  32. scaleToStage:Boolean=true, interactive:Boolean=false, cameraType:String="CAMERA3D")
  33. {
  34. super(viewportWidth, viewportHeight, scaleToStage, interactive, cameraType);
  35.  
  36. stage.quality = "low";
  37.  
  38. light = new PointLight3D(false, false);
  39. scene.addChild(light);
  40.  
  41. var data:Bitmap = new ml2() as Bitmap;
  42. envMapMaterial = new EnvMapMaterial(light, data.bitmapData, data.bitmapData, 0xFFCCDD);
  43.  
  44. dae = new DAE();
  45. dae.load(new monkey2());
  46. dae.getChildByName( "Suzanne", true ).material = envMapMaterial;
  47. dae.scale = 300;
  48. dae.rotationX = -90;
  49. scene.addChild(dae);
  50.  
  51. renderer.renderScene(scene, camera, viewport);
  52. this.startRendering();
  53. }
  54.  
  55. protected override function onRenderTick(event:Event = null):void {
  56. dae.roll(0.01);
  57. renderer.renderScene(scene, camera, viewport)
  58. }
  59.  
  60. }
  61. }