Wiley 978-0-470-74266-2 Datasheet

Browse online or download Datasheet for Software manuals Wiley 978-0-470-74266-2. Wiley Professional Papervision3D User Manual

  • Download
  • Add to my manuals
  • Print
  • Page
    / 30
  • Table of contents
  • BOOKMARKS
  • Rated. / 5. Based on customer reviews
Page view 0
Understanding Flash3D
Flash programmers have always enjoyed a freedom of expression unparalleled by other
programming platforms. And with the release of CS4, Adobe has propelled that freedom of
expression into the 3rd dimension.
But 3D didn t start with AS3. Flash developers were experimenting with 3D long before. And
applications like Papervision3D formalized these endeavors into a robust object - oriented class
structure. The acceptance and popularity of Papervision3D has become a driver of change in the
Flash developer community. But underneath the 300 classes that make up Papervision3D still beats
the original algorithms used by the early developers of Flash 3D.
Understanding how to create 3D in Flash is essential to fully grasping Papervision3D and
applications like it. As you learn how 3D engines were originally constructed, you ll gain both an
insight into Papervision3D s core architecture and an appreciation of its robust structure. Its
complexity will fade into a set of fundamental 3D algorithms.
Papervision3D, at its core, is a perspective projection engine, where projection simply means
transforming a 3D object space into 2D Flash x and y screen space. And surprisingly, the whole
process hinges on one equation: a perspective scaling equation derived from Thales Theorem:
T = scale = focal length/(focal length + z)
In the equation above, T is the perspective scale, and z is the distance from the projection plane.
The focal length (or calculated screen location) determines the amount of perspective provided
in the view. You use this equation to create an illusion of depth by scaling 2D surfaces.
In this chapter, you use Thales Theorem to create a simple 3D engine in just 19 lines of code. Then
using Flash CS4 you rebuild your engine in just 13 lines of code. You cover the big 3: translation,
rotation and scaling. And applying what you ve learned you create a 3D torus worm, carousel, and
image ball. Finally, you cover the basics of making believable animation, and how to turn a
timeline animation into pure ActionScript.
c01.indd 3c01.indd 3 12/14/09 3:03:21 PM12/14/09 3:03:21 PM
COPYRIGHTED MATERIAL
Page view 0
1 2 3 4 5 6 ... 29 30

Summary of Contents

Page 1 - COPYRIGHTED MATERIAL

Understanding Flash3D Flash programmers have always enjoyed a freedom of expression unparalleled by other programming platforms. And with

Page 2 - 3D Coordinates in Flash 10

12Part 1: Getting Startedimport flash.display.Sprite;//imports sprite classvar zposition:Number = 0;//z positionvar myAngle:Number =0;//Angle of ballv

Page 3 - Lines of Code

Chapter 1: Understanding Flash3D13 The stage class is very useful in positioning your Flash objects and will be addressed in more detail in the next c

Page 4

14Part 1: Getting Started In CS4 the perspective scaling and rotation are automatically built into Flash. It ’ s still important to know the concepts

Page 5

Chapter 1: Understanding Flash3D15 Using the Big 3 Fundamental to 3D graphics and physics are three fundamental motions: translation, rotation and s

Page 6 - Rendering to the Screen

16Part 1: Getting Started The parametric equations for a torus are: x=(c+a*cos(v))cos(u) y=(c+a*cos(v))sin(u) z=a

Page 7 - Coding Animation

Chapter 1: Understanding Flash3D17 Creating a Parametric Particle System (Torus Worm) In the previous section, you learned how to get a single eleme

Page 8

18Part 1: Getting Startedparticles_ary[i].alpha method to change the alpha of each particle based on their ith position. Center the particle system on

Page 9 - Running the Code

Chapter 1: Understanding Flash3D19var myAngle:Number =0;//Angle of ball //Add Multiple Particles function updateStage():void {

Page 10 - Part 1: Getting Started

20Part 1: Getting StartedFlint - Particle - System (at http://flintparticles.org/), a robust open source project found on Google Code, which can be us

Page 11 - Adding a Camera

Chapter 1: Understanding Flash3D21 But in CS4 there ’ s a problem with this. When using the sorting algorithm (above) you sort the elements on the z -

Page 12 - Vanishing Point

4Part 1: Getting Started But before you get started it ’ s important that you understand the coordinate system you ’ ll be rendering your objects in

Page 13 - Using the Big 3

22Part 1: Getting Started 3D Rotation To rotate x, y, z points in 3D space you use the following equations: xnew = xold*cos(angleZ) - yold*sin(

Page 14

Chapter 1: Understanding Flash3D23 The conversion between radians and degrees and vice - versa is given below: Radians = Degrees*PI/180Degrees = Radia

Page 15

24Part 1: Getting Started Finally the display container is rotated based on mouse movement using a simple mouseX displacement algorithm. function

Page 16

Chapter 1: Understanding Flash3D25plane.rotationY = -360 / numOfParticles * i + 90;plane.alpha=1;particles_ary.push(plane); numVar++;//Sta

Page 17

26Part 1: Getting Started You must orient the planes to the correct angles so that they uniformly hug the sphere as shown in Figure 1.11. plan

Page 18

Chapter 1: Understanding Flash3D27 //The vertical angle between circles.var phiStep:Number=30;var phiTilt:Vector. < Number > =new Ve

Page 19 - Rotation

28Part 1: Getting Started myDisplayObject.addChildAt(particles_ary[k] as Sprite, k); }} function particleZSort(particle1:Display

Page 20

Chapter 1: Understanding Flash3D29 Weight is the concept most forgotten in animation. Animation software doesn ’ t know how much something weighs.

Page 21 - Carousel

30Part 1: Getting Started3.0. The ActionScript is then copied to your clipboard and you can paste this code wherever you want. If you try this with th

Page 22

Chapter 1: Understanding Flash3D31 Here ’ s how the code is put together: The code starts by bringing in a number of imports that set up the animati

Page 23 - Image Ball

Chapter 1: Understanding Flash3D5 In addition, in Flash 9 the coordinate origin (0,0) is not located at the center of the screen, but at the upper lef

Page 24

32Part 1: Getting Started So what ’ s a Collada File? Essentially, it ’ s an XML document that holds the parameters of your 3D model. It ’ s design

Page 25 - (continued)

6Part 1: Getting Started Creating the illusion of depth (or 3D) using perspective scaling is sometimes referred to as 2.5D. Another term used to desc

Page 26

Chapter 1: Understanding Flash3D7 From the law of similar triangles, it follows that hflHfl  z By cross - multiplying, you get the scaling equa

Page 27 - Converting Your Animation

8Part 1: Getting Started The curve above is very similar to the gravitational or electrical potential curves found in physics. And it further suggests

Page 28

Chapter 1: Understanding Flash3D9 In Chapter 2, you ’ ll find out how to obtain the Papervision3D classes and how to drill down and examine its code.

Page 29 - Collada Files

10Part 1: Getting Started The typical flow of such a program involves first initializing the program and then using a listener to loop through a scrip

Page 30 - Summary

Chapter 1: Understanding Flash3D11 Call the method addEventListener to listen for an event Name the event you want to listen for Name the funct

Comments to this Manuals

No comments