Join Seb Lee-Delisle for an in-depth discussion in this video Using BasicView to render your first 3D object, part of Papervision3D 2 Essential Training.
Now we're going to look at the best way of creating Papervision projects in Flash Builder. Now, if you've ever seen any tutorials about Papervision before, you might have seen many different ways to get going and certainly a lot of the early tutorials for PV where to go through the process of making a viewport and camera and scene and setting up all of the individual items that you need separately. There actually it is much better way to do it and that's using BasicView. In fact, we don't even need to create a BasicView object. We can actually literally have our document class extending BasicView.
So let's just see quickly how to view this. Often when I'll do presentations, to show you how easy this is, I'll set myself a little challenge of doing it in 10 seconds. Now, it might take a bit longer this time, but let's see how fast I can do it. So, first of all rather than extending sprite we want to say extend the Papervision BasicView. If I hit Ctrl+Space to make sure it imports, that makes sure that we can compile that. Now, what we're going to do is add a new sphere into our scene, and then start rendering. That wasn't bad. It was probably a little longer than 10 seconds, but let's check it out. Great! So now we have our first 3D object rendering in Papervision.
So you can see how easy that was. Now as we're extending BasicView, we should really call the super and if you're used the object oriented programming practices, then you'll know what they say is. But essentially, it's just calling the constructive on the parent class for us and we're just going to make sure that the width and height of BasicView is the same as our document class. Now we're just going to look at some of the options within the Sphere constructer here. The first parameter is material. Now, by default it just uses a random wireframe material. So it could be any color. I am going to leave that as null for now. The second parameter is the radius.
I am going to leave that as well as the default at 100. Now we have the number of divisions. So, segment W has the number of divisions vertically. So that's like the segments in an orange. So we're going to up that to maybe, well, I say 15 that should be. A slightly smoother sphere. Then segment H is the number of horizontal divisions. So, we're going to up that as well to let's say 12. So let's see what a difference that makes to our sphere. You can see now it's a little bit more spherical. So that's smoother. So, the next thing I want to do is actually adjust the camera settings.
By default, the camera within BasicView has a very wide-angle lens. So I'm going to adjust its field of view using this fov property and by default I think it's something like 60. So we're just going to make it a bit more zoomed in, maybe 30. So that's 30 degrees. That defines the field of view angle for our camera. So let's just see what that looks like. So now I can see the sphere is a lot bigger. Now we haven't actually made a bigger sphere. We've just literally zoomed in the camera. So you'll find that the default very wide -angle lens for Papervision can be very useful, because when you start working in 3D in Flash, you often find that you lose the stuff that you make.
It might be behind the camera or it might be off-screen. So by having a very wide camera as the default it means that you're less likely to lose things. But of course, if you want a slightly more natural look to your 3D objects, you probably don't want such a wide-angle lens. That's why we zoomed in here. So that's brilliant! We've actually got up and running. We've put our first 3D object into our scene and we started rendering and we've also learned how to adjust the camera lens angle. So now you know how easy it is to extend BasicView in your document class and add 3D objects and render them.
Users should have a basic knowledge of Flash Builder and Actionscript 3.
- Creating 3D primitive shapes
- Controlling rotation
- Moving the camera in 3D space
- Creating a particle field with depth-of-field blur
- Importing models from external applications
- Making a simple 3D game
- Using ViewportLayers to selectively render and sort layers
- Placing a custom 3D model into an augmented reality scene
- Creating interactive carousals
- Creating interactive grids
- Working with particles and billboards
Skill Level Beginner
Q: Despite setting Mac OS X to open SWF files with the debug player, it still reverts back to other applications. What is causing this, and how can it be fixed?
A: If you are encountering this problem, check out the solution posted here:
Q: In the "About the COLLADA.dae file format" movie in the "Importing 3D Models" chapter, which version of Maya does the author use to open the included Maya files?
A: The author uses Maya 2010 to open the files.
Q: FlarToolkit.swc is no longer available to download. Where can I find a copy?
A: Download a copy of FlarToolkit here.
Q: Can I use multiple markers with FlarToolkit?
A: No, The swc version of FlarToolkit only supports one marker.