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. }

17 Responses to “Papervision Popup Book : The source – Just the elements on the stage”


  • Great work, but I can’t compile it because Papervision3D 2 and Tweener libraries are not sufficient. Error with AbstractRenderEngine. Not found IRenderEngine and other override methods errors. Any solution? Thanks.

  • Hey Isma,

    For this project I was using the Great White branch. Go to the org.papervision folder and open the file Papervision3D.as on line 34 it should say

    static public var VERSION :String = ‘Public Alpha 2.0 – Great White’;

    Let me know if this helps.

    Thanks,
    Charlie

  • Okay, okay… I had a mix of 1.5 and 2 version. With Papervision3D 2 works fine. Thanks for help.

    Congratulations for the blog. I will be kind to your experiments.

  • Please feel free to share your experiments with this project. It would be great to see it expanded upon.

  • This looks very cool!

    I am getting 5 errors in the main.as that I am not sure why.

    3 have to do with the Camera3D like this one: 1046: Type was not found or was not a compile-time constant: FreeCamera3D.

    Do I need to move the AS file, or have it point somewhere else? All the paths in the main.as look to be pointing to the right place, and I am in the Great White version.

  • Is this file located in your papervision code directory

    org\papervision3d\cameras\FreeCamera3D.as

    Let me know. If it is not I will double check and upload the code with the papervision source I used and get back to you.

  • Yes, it is.

    If it helps, I have the fla in the GreatWhite\src folder.

  • If anyone has had problems getting this to work in the newest version of Papervision here are few things I had to do.

    Change this line:
    __renderer.renderScene(__scene, __camera, __viewport, true);

    change to: __renderer.renderScene(__scene, __camera, __viewport);

    Change: FreeCamera3D to just Camera3D in all instance

    and then you have to change your camera zoom and z:

    I used:

    __camera.zoom = 20;

    __camera.z = -500;

  • Has there been any developments on this? I’d really like to participate.

  • If you are using papervision 2.1, quadtree location has been updated use:

    import org.papervision3d.core.render.data.QuadTree;

    and follow indiekid’s steps of changing the camera and rendering.

  • I have one error:

    import com.foomonger.utils.Later;

    Tested movie is blank.

  • There are a couple of other things that I had to do in addition to what indiekid mentioned.

    Download foomonger_as_package_v2.0.0b.zip from http://code.google.com/p/foomonger/
    and install the “com” folder in the same folder as the FLA folder.

    I was still getting one last error, therefore, I disabled the fourth line of the code so it looks like this:
    //import org.papervision3d.core.data.qTree.QuadTree;

    Now, it works! THANKS

  • Hey all,

    I don’t get this to work.

    1. I created a ‘project’ folder in my documents.
    2. I downloaden SVN , imported the stuff with this link (http://papervision3d.googlecode.com/svn/trunk/ ) to the ‘project’ folder with a new map called ‘papervisionstuff’.
    3. Downloaden Papervision 3d 2.0 and also extracted this into the project folder with a new map called ‘papervision2.0′.

    So my folder looks like this:
    - Papervision 2.0
    - Papervision stuff (downloaden SVN stuff)
    - Caurina (Tweener)
    - and the papervision-popup.fla and Main.as (maybe these should be placed somewhere else?)

    Then ill open the papervision-popup.fla go to preferences > as2 and add these classes links:
    D:\My Documents\papervision3dproject\Papervisionstuff\as2\trunk\src
    (too imported SVN stuff)
    and
    D:\My Documents\papervision3dproject\caurina\transitions
    (to Tweener)

    But it doesn’t work. When I open the papervisin-popup.fla all I see is a blanc canvas and when I run it I get several errors.

    Can someone help me out? Or send me an email about what to do?
    Maybe giving a .rar file with all the documents in the right places and the links that I should add in the preference>as2>classes?

    Thank you in advance,
    Patrick

  • And I also don’t have a ‘Great White’ map in my

    ‘Papervisionstuff’ folder.
    So branches > …..

    I am having cs4, so no great white there. when il go into cs4>src I do see the com,fl and org maps.

    I already tried to put the popup.fla to place there but that doesn;t work. Or well, suposingly I am doing something wrong and getting slightly frustrated :P

    Help is very much appreciated!

  • Hmm I noticed I forgot to download the source of Tweener to.

    But I did now.

    I think my problem is that I don’t know how to add the classes in Flash preferences menu

  • Hello, sorry for the quick replies.

    Which version of papervision 2.0 do I need to get the great white branche?

    In which folder do I need to place the .fla and Main.as?

    To which folders do I have to connect to connect to the classses (preferences>as2>?)

    (I downloaded the Tweener en papervision with subversion)

    Lost about what to do now! Somewhat more detailed information could help me further.

    You may email me ofcourse.

    Thank you.

  • Yeah!

    Finally I managed to get it to work.

    I found out I forgot ‘Foomonger’ :)

Leave a Reply

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word


Follow papervision2 on Twitter

RSS Feed