Adding reflection with ReflectionView
Another class included in Papervision3D is ReflectionView
, which lets you add basic reflections to your scene. The download section of this chapter includes an example in which a carousel of planes is created. The example demonstrates how to work with ReflectionView
. We will briefly run through the process of adding the reflections:
The ReflectionView
class does not override the onRenderTick()
method that we have used in all our examples, so we need to change the way we call the rendering process. Replace the startRendering()
method with the following line:
And replace the onRenderTick()
method with the following:
To position the reflection of an object you set the surfaceHeight
property...
Example—creating depth of field
In film and photography depth of field is the region in the image that is sharp or in focus. A common trick in portrait photography is to focus on the subject and make the background blurred, drawing the viewer's attention to the subject. A similar effect can be achieved in Papervision3D.
Suppose you have a number of objects in your scene and you want them more in focus the closer they are to the camera. When you put each particle in a viewport layer, you can add a blur filter to each layer. Based on the screen depth of the layer, you can update the strength of the blur at every frame, which will suggest depth of field. Let's apply this idea in a simple example. We create 200 particles with a movie asset particle material and give them a random position. We also add some mouse interaction that makes the camera move. This example assumes that you have an assets
folder inside your src
folder with the glassBall.png
in it, which can be found in the code download...
This chapter discussed filters and effects. By filters we mean the Flash filters such as drop shadow, blur, and glow. The built-in Papervision3D effects allow us to create specific effects such as fire.
You don't apply a filter directly to an object, but to the viewport layer that contains the object. Viewport layers are extended sprites, so you can set their transparency and blend mode.
You can also apply a filter on viewport level, which can be approached in two ways:
Applying a filter directly to the viewport results in basic Flash filter effects, whereas working with BitmapViewport3D
allows you to create more advanced filter effects.
Papervision3D has a set of built-in effects:
An example has been given for each of...