Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Papervision3D Essentials

You're reading from  Papervision3D Essentials

Product type Book
Published in Sep 2009
Publisher Packt
ISBN-13 9781847195722
Pages 428 pages
Edition 1st Edition
Languages

Table of Contents (18) Chapters

Papervision3D Essentials
Credits
About the Authors
About the Reviewers
1. Preface
1. Setting Up 2. Building Your First Application 3. Primitives 4. Materials 5. Cameras 6. Moving Things Around 7. Shading 8. External Models 9. Z-Sorting 10. Particles 11. Filters and Effects 12. 3D Vector Drawing and Text 13. Optimizing Performance

Chapter 8. External Models

In the previous chapter, the Utah teapot was introduced to demonstrate several shaders. Of course, we did not create the teapot by manually defining each triangle to form the shape of a teapot. Papervision3D allows us to work with models that are created and exported by a 3D modeling program, which adds many possibilities, especially when the shape of the default primitives doesn't fit your needs.

With Papervision3D we can load several types of 3D models. Some of them support animations that have been created in the 3D modeling program. There are many programs that support the model formats Papervision3D reads, more than what we can cover in this book. We will have a look at the following three:

  • Autodesk 3ds Max: One of the widely-known commercial 3D programs, which runs only on Windows

  • Sketchup: A free 3D modeling program provided by Google. Designed to be a more intuitive 3D program, which runs on Max OS X and Windows

  • Blender: An open source, platform-independent...

Modeling for Papervision3D


As mentioned in the introduction, this chapter will not describe in detail how to create models. Each tool works differently and requires a different approach for creating suitable models.

In this section, we will discuss several techniques that relate to modeling for Papervision3D. As Papervision3D is commonly used for web-based projects, modeling requires a different mindset than modeling for an animated movie, visualization, or game. Most of the techniques discussed relate to improving performance. This section is especially useful for modelers who need to create models for Papervision3D.

Note

Papervision3D Previewer

Papervision3D Previewer is a small program that should be part of every modeller's toolbox. This tool comes in handy for testing purposes. It allows a modeler to render an exported model in Papervision3D, and it displays some statistics that show how the model performs. At the time of writing, this tool was not compatible with Papervision3D 2.1...

Creating a template class to load models


In order to show an imported 3D model using Papervision3D, we will create a basic application. Remember the example in Chapter 6, in which we made the camera orbit around a grid of planes by moving the mouse? We will use the same code to rotate around the models, which we are going to create and load later in this chapter.

Based on the orbit example we create the following class. Each time we load a new model we just have to alter the init() method. First, have a look at the following base code for this example:

package {
import flash.events.Event;
import org.papervision3d.materials.WireframeMaterial;
import org.papervision3d.materials.utils.MaterialsList;
import org.papervision3d.objects.DisplayObject3D;
import org.papervision3d.objects.primitives.Cube;
import org.papervision3d.view.BasicView;
public class ExternalModelsExample extends BasicView
{
private var model:DisplayObject3D;
private var rotX:Number = 0.1;
private var rotY:Number = 0.1;
private...

Creating models in Autodesk 3ds Max and loading them into Papervision3D


Autodesk 3ds Max (also known as 3D Studio Max or 3ds Max) is one of the widely-known commercial 3D modeling and animation programs. This is a good authoring tool to start with, as it can save to two of the file formats Papervision3D can handle. These are:

  • COLLADA (extension *.dae): An open source 3D file type, which is supported by Papervision3D. This is the most advanced format and has been supported since Papervision3D's first release. It also supports animations and is actually just a plain text XML file.

  • 3D Studio (extension *.3ds): As the name suggests, this is one of the formats that 3ds Max natively supports. Generally speaking it is also one of the most common formats to save 3D models in.

As of 3ds Max version 9, there is a built-in exporter plugin available that supports exporting to COLLADA. However, you should avoid using this, as at the time of writing, the models it exports are not suitable for Papervision3D...

Creating and loading models using SketchUp


SketchUp is a free 3D modeling program, which was acquired by Google in 2006. It has been designed as a 3D modeling program that's easier to use than other 3D modelling programs. A key to its success is its easy learning curve compared to other 3D tools.

Mac OS X, Windows XP, and Windows Vista operating systems are supported by this program that can be downloaded from http://sketchup.google.com/. Although there is a commercial SketchUp Pro version available, the free version works fine in conjunction with Papervision3D.

An interesting feature for non-3D modelers is the integration with Google's 3D Warehouse. This makes it possible to search for models that have been contributed by other SketchUp users. These models are free of any rights and can be used in commercial (Papervision3D) projects.

Exporting a model from Google's 3D Warehouse for Papervision3D

There are several ways to load a model, coming from Google 3D Warehouse, into Papervision3D...

Creating and loading models using Blender


Blender is an open source, platform-independent 3D modeling tool, which was first released in 1998 as a shareware program. It went open source in 2002. Its features are similar to those in commercial tools such as 3ds Max, Maya, and Cinema4D. However, it has a reputation of having a difficult learning curve compared to other 3D modeling programs. Blender is strongly based on usage of keyboard shortcuts and not menus, which makes it hard for new users to find the options they're looking for. In the last few years, more menu-driven interfaces have been added.

It's not in the scope of this book to teach you everything about the modeling tools that can be used with Papervision3D. This also counts for Blender. There are many resources such as online tutorials and books that cover how to work with Blender.

Note

Blender 3D—architecture, buildings, and scenery

Packt Publishing has released a book called Blender 3D: Architecture, Buildings, and Scenery...

Keeping control over your materials


It is very convenient that the materials defined inside a 3D modeling tool can be used in Papervision3D. On the other hand, there are situations where you want to have control over materials. To name a few:

  • When you want to use another material type such as a movie clip or streaming video

  • When you want to change a material property such as interactive, precise, and smooth

  • When you want to apply a shader

The moment you call the load() method using any of the 3D model parsers, you can pass a material list, specifying the materials you want to use. This works in a similar way to specifying a material list at instantiation of a cube and looks as follows:

var materials:MaterialsList = new MaterialsList();
load() methodcallingmaterials.addMaterial(new ColorMaterial(0x0000FF), "materialDefinition");
var model:DAE = new DAE();
model.load("model.dae",materals);

The materialDefinition string in the materials list refers to the unique ID of a material that was automatically...

Summary


Modeling is a very broad topic as there are many 3D programs, each with numerous features. When you want to display custom objects besides the built-in primitives, you can load models created by 3D programs.

This chapter showed how to create basic models in 3ds Max, SketchUp, and Blender, and how to export them for Papervision3D. To do this we've used three different file formats:

  • COLLADA (.dae): An open source 3D model file type, which has been supported since the early releases of Papervision3D. This is the most developed file type, which also supports animation and animation clips.

  • 3D Studio (.3ds): An established 3D file format that is supported by most 3D modeling programs.

  • SketchUp (.kmz): A format that is used by Google Earth, which can be created by a free program called SketchUp.

Creating models for use in Papervision3D has some requirements and conventions to take into account:

  • Keep a low polygon count

  • Add polygons to problematic parts of your model to prevent z-sorting artifacts...

lock icon The rest of the chapter is locked
You have been reading a chapter from
Papervision3D Essentials
Published in: Sep 2009 Publisher: Packt ISBN-13: 9781847195722
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime}