Monthly Archive for June, 2008

Papervision Popup Book : The source – Just the elements on the stage

Sorry for putting this up so late. This code is only used to arrange the items on the stage. Much work and re-working will need to be done to even start to achieve the effect of the  ecodazoo website.  Anyways, perhaps this will get someones brain moving in the right direction and help lead us in the path to re-creating this effect fully. As soon as I get some free time I will post a version that is a true popup book in papervision.

If anyone gets a chance sooner to do some cool things with the code please shoot me an email or a blog post and I would love to share it, with myself and with everyone else. :-D

Download : FLA - AS & SOURCE

Don't forget the other code you will need to compile:

1) Papervision 2.0

2) Tweener

Actionscript:
  1. package {
  2. import caurina.transitions.Tweener;
  3. import org.papervision3d.cameras.FreeCamera3D;
  4. import org.papervision3d.core.data.qTree.QuadTree;
  5. import org.papervision3d.objects.DisplayObject3D;
  6. import com.foomonger.utils.Later;
  7. import flash.display.*;
  8. import flash.events.Event;
  9. import flash.events.MouseEvent;
  10. import org.papervision3d.cameras.Camera3D;
  11. import org.papervision3d.materials.ColorMaterial;
  12. import org.papervision3d.materials.MovieMaterial;
  13. import org.papervision3d.objects.primitives.Cube;
  14. import org.papervision3d.objects.primitives.Plane;
  15. import org.papervision3d.render.BasicRenderEngine;
  16. import org.papervision3d.scenes.Scene3D;
  17. import org.papervision3d.view.Viewport3D;
  18. public class Main extends Sprite
  19. {
  20. private var __camera                :FreeCamera3D;
  21. private var __scene  :Scene3D;
  22. private var __viewport    :Viewport3D;
  23. private var __renderer    :BasicRenderEngine;
  24. private var __width  :Number;
  25. private var __height                :Number;
  26. private var __background            :Shape;
  27. protected var __wallLeft            :D isplayObject;
  28. protected var __wallRight       :D isplayObject;
  29. protected var __wallBack            :D isplayObject;
  30. protected var __floor         :DisplayObject;
  31. protected var __tree                :D isplayObject;
  32. protected var __monster :DisplayObject;
  33. protected var __moveMatWallLeft  :MovieMaterial;
  34. protected var __moveMatRightWall    :MovieMaterial;
  35. protected var __moveMatWallBack  :MovieMaterial;
  36. protected var __moveMatFloor        :MovieMaterial;
  37. protected var __moveMatTree   :MovieMaterial;
  38. protected var __moveMatMonster  :MovieMaterial;
  39. protected var __plane_wallLeft  :P lane;
  40. protected var __plane_rightWall  :P lane;
  41. protected var __plane_wallBack  :P lane;
  42. protected var __floorPlane    :Plane;
  43. protected var __treePlane       :P lane;
  44. protected var __monsterPlane        :P lane;
  45. protected var __rotation            :Number;
  46. public function Main():void
  47. {
  48. init();
  49. }
  50. protected function init():void
  51. {
  52. __rotation = 0;
  53. setDefaultWidthHeight();
  54. createChildren();
  55. initPapervision();
  56. initMaterials();
  57. initObjects();
  58. initEvents();
  59. }
  60. protected function setDefaultWidthHeight():void
  61. {
  62. __width = 1000;
  63. __height = 600;
  64. }
  65. protected function initPapervision():void
  66. {
  67. __scene = new Scene3D();
  68. __camera = new FreeCamera3D();
  69. __camera.zoom = 11;
  70. __camera.z = -2000;
  71. __camera.y = 20;
  72. __viewport = new Viewport3D(__width,__height,false,true,true);
  73. __renderer = new BasicRenderEngine();
  74. addChild(__viewport);
  75. }
  76. protected function initMaterials():void
  77. {
  78. __moveMatRightWall = new MovieMaterial(__wallRight, true)
  79. __moveMatWallLeft = new MovieMaterial(__wallLeft, true);
  80. __moveMatWallBack = new MovieMaterial(__wallBack)
  81. __moveMatFloor = new MovieMaterial(__floor);
  82. __moveMatTree = new MovieMaterial(__tree, true );
  83. __moveMatMonster = new MovieMaterial(__monster, true);
  84. __moveMatRightWall.doubleSided = true;
  85. __moveMatWallLeft.doubleSided = true;
  86. __moveMatWallBack.doubleSided = true;
  87. __moveMatTree.doubleSided = true;
  88. __moveMatFloor.doubleSided = true;
  89. __moveMatTree.doubleSided = true;
  90. __moveMatMonster.doubleSided = true;
  91. }
  92. protected function initObjects():void
  93. {
  94. __monsterPlane   = new Plane(__moveMatMonster, 184, 237, 4, 4);
  95. __plane_rightWall   = new Plane(__moveMatRightWall, 386, 239, 4,4)
  96. __plane_wallBack    = new Plane(__moveMatWallBack, 734, 240, 4,4);
  97. __plane_wallLeft    = new Plane(__moveMatWallLeft,386,239,4,4)
  98. __floorPlane       = new Plane(__moveMatFloor, 800, 800, 14,14);
  99. __treePlane   = new Plane(__moveMatTree, 79, 112, 4, 4);
  100. __scene.addChild(__floorPlane);
  101. __scene.addChild(__plane_wallBack);
  102. __scene.addChild(__treePlane);
  103. __scene.addChild(__plane_wallLeft);
  104. __scene.addChild(__plane_rightWall);
  105. __scene.addChild(__monsterPlane);
  106. __floorPlane.y = -120;
  107. __treePlane.y = -69;
  108. __floorPlane.pitch(90);
  109. __monsterPlane.z = -300;
  110. __monsterPlane.x = 150;
  111. __monsterPlane.y = -10;
  112. __plane_wallBack.z += 340
  113. __treePlane.z = 300;
  114. __treePlane.x = -220;
  115. __plane_wallLeft.x = -155;
  116. __plane_rightWall.x = 155;
  117. __plane_wallLeft.rotationY = -35;
  118. __plane_rightWall.rotationY = 35
  119. }
  120. protected function initEvents():void
  121. {
  122. this.addEventListener(Event.ENTER_FRAME,render);
  123. }
  124. protected function render(e:Event):void
  125. {
  126. __renderer.renderScene(__scene, __camera, __viewport, true);
  127. var moveXAmount:Number = (mouseX - 1000 / 2) * 4
  128. var moveYAmount:Number = (mouseY - 600 / 2) * 2
  129. if (moveYAmount <0)
  130. {
  131. moveYAmount = 0;
  132. }
  133. __camera.x = moveXAmount;
  134. __camera.y = moveYAmount;
  135. __camera.lookAt(__floorPlane)
  136. }
  137. protected function createChildren():void
  138. {
  139. //Movieclips with Export for AS in Library
  140. __wallBack   = new Wall_back();
  141. __wallLeft   = new Wall_left();
  142. __wallRight  = new Wall_right();
  143. __floor   = new Floor();
  144. __tree  = new Tree();
  145. __monster    = new Monster();
  146. }
  147. }
  148. }

Papervision Popup Book : Source Code To Follow Shortly

Papervision Popup Book

While talking with Mike Britton this evening he sent me this link - http://www.ecodazoo.com/ If you surf around a bit you will eventually make your way to a Popup Book which was created with a custom engine (Sharikura 3D) written by Roxik. I decided to take a try at creating it in Papervision. So far I have some of the elements in place which in itself was kinda fun to put together. I would still need to get it to fold into a book but thought this was neat in itself to post.

Download : FLA - AS & SOURCE

Don't forget the other code you will need to compile:

1) Papervision 2.0

2) Tweener

Here is a link to my quick version


Follow papervision2 on Twitter

RSS Feed