Close Show/hide page

A Papervision 2.0 alpha example

Thumbnail - Click me

I drew up this example a few weeks ago to learn about the new features in Papervision 2.0 alpha. If you’re thinking of looking into the new version, then hopefully you’ll find the supplied source code below of some use. I used the code from this screencast on unitzeroone.com as a starting point.

The source code has example usage of the following things…

  • Setting up and rendering a simple 3d scene
  • Materials that take a light source, found in the org.papervision3d.materials.shadematerials package (GouraudMaterial, PhongMaterial, CellMaterial, FlatShadeMaterial, EnvMapMaterial). And CompositeMaterial, too, which is pretty useful as well.
  • Shaders (EnvMapShader)
  • Multiple viewports (used here to create the reflection on the floor)
  • Simple user interaction using InteractiveSceneManager (clicking on a ball makes it bounce)

I wanted to throw all the example materials into the scene at the same time in order to compare their appearance, etc., so you may find the demo to run quite slowly…

Source code

Please note this source targeted the Papervision 2.0 alpha, and won’t compile on more up-to-date versions without making a few adjustments…

Licensed under a Creative Commons Attribution 3.0 License.

16 Responses to “A Papervision 2.0 alpha example”

  1. Ahmet:

    Demo is running smoothly :)
    Thanks for the source !

  2. xero / fontvir.us:

    very cool lee!
    thanx for posting the source!

    the only new feature i see missing is culling.
    you could zoom the cam and show a ploy count
    so ppl can see when an object is off screen pv3d
    dounst wait resources rendering unnecessary stuff…

    just a thought.
    thanx again!

  3. Boris:

    Hi Lee,
    cool Demo, but this line of code doesnt function

    // Make sphere bounce…
    Tweener.addTween(e.target, { y:100, bezier:{ y:600 }, time:3, transition:”easeoutbounce”} );

    There will be an error dropped that Sphere has no _bezier property – what is wrong

  4. Betty:

    I argued, Thornfield will, probably, be a good way from the town. satellite street map views A new servitude. There is something in that, I soliloquised

  5. hierro:

    Hello, what if i have a texturized plane and i wanna get the pixel color of a given 3d coordinates ? Just dunno enough about matrix and inverseMatrix, any hints ?

    thank u for help, hierro.

  6. nurah:

    thanks

  7. Justin:

    looks like the newest version of great white (pv2 beta) doesnt have “FreeCamera3D” but you can use find and replace to change the 3 instances to “Camera3D” and get the same results.

  8. charles:

    I have a question about ShadedMaterial, why is there some black lines on the top of the sphere?
    Can we remove it, how?

  9. Rake girl:

    thanks for sharing the code…i’m a java programmer and
    i definitively have to take a look of that. i saw you imported a lot
    of cool objets i’ve never used or seen in my life

  10. Edz Hye:

    thanks for the ideas, im beginning to learn codes

  11. Marcel van Duijn:

    Hi,

    I have been experimenting with this example and noticed something weird. The spheres with materials attached that are based on EnvMapMaterial have their lighting / material mirrored on their surface (as if there is a light source opposite the actual light source). The Flat- and Gouraud spheres behave as expected, but materials based on EnvMapMaterial show this fenomenon.

    Papervisions’ EnvMapMaterial has a property .backenvmap. This property is utilized in EnvMapMaterial.drawTriangle but the implementation seems incorrect so that the backenvmap is actually never used???

    The method seems to choose between the map to draw from (lightMap / backenvmap) based on the angle of the face with the light source. For angles > 90 or 0){
    useMap = _lightMap;
    }else{
    useMap = backenvmap;
    }
    graphics.beginBitmapFill( _lightMap, transformMatrix, false, false);
    [/code]

    Would this be an explanation for the fact that materials based on EnvMapMaterial show this 'undesired', at least by me, side effect? As Im kind of a novice to PV I cant image that this wouldnt have been noticed yet...

    Coudl someone confirm, or deny and explain?

    Chrs

  12. Lee:

    Having only played with EnvMapMaterial superficially, I’d also like some elaboration on this. :D

    Lee

  13. matt:

    hmm, when I publish, I only see a gray screen,
    any ideas?

    thx
    !m

  14. shuping:

    Thanks for thw source!

  15. Mateusz:

    The source is a 404 could you please publish it again?

  16. admin:

    @Mateusz, Thanks for letting me know. I’ve updated the link. -Lee

Leave a Reply