O'Reilly logo

Professional Papervision3D by Michael Lively

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Appendix A. Pocket Reference

This appendix is a listing by chapter of important code snippets and formulas. It's meant to be a reference for the code snippets. The electronic form is on the book's companion website so you can arrange it into any format that you'd like.

Chapter 1: Understanding Flash3D

Summary: Flash 3D is one of the fastest-moving areas in web technology. In this chapter, you learned how to build a simple 3D engine in both CS3 and CS4. Using what you learned about 3D engines you created a torus worm, carousel, and image ball. Finally, you examined Disney's rules for creating realistic animation, and converted a timeline animation into ActionScript.

Helpful Links

http://www.mathworld.wolfram.com

http://www.sebleedelisle.com

http://flintparticles.org

http://www.flashandmath.com

Perspective Scaling

T = scale = focal length/(focal length + z)
scale=focal length/(focal length + z);
x=x*scale;
y=y*scale;

Generating Random Colors

Math.random()*0xffffff

3D Engine in 13 Lines of Code

import flash.display.Sprite;//imports sprite class var myAngle:Number =0;//Angle of ball var ball:Sprite = new Sprite();//instantiates ball sprite ball.graphics.beginFill(0xFF0000);//Assign a ball color ball.graphics.drawCircle(0, 0, 40);//draws your ball at 0,0 ball.graphics.endFill();//ends the fill addChild(ball);//adds the ball to the stage addEventListener(Event.ENTER_FRAME, myonEnterFrame);//loops equations function myonEnterFrame(event:Event):void{ myAngle=myAngle+.1;//iterates angle ball.x = 300*Math.sin(myAngle); ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required