Book notes in the Essential Guide [2] [Chapter 2]

Source: Internet
Author: User
Tags addchild
1. Pay attention to the z attribute of the flash native object.

In the book, "From Flash 10 onward, native display objects have positions based in a 3D coordinate system but are missing automatic Z sorting. this means display objects placed far away on the Z axis won't necessarily be drawn behind those nearby, occasionally
Resulting in unnatural overlapping. Away3D automatically executes Z sorting on objects in a scene, ensuring that all 3D objects are rendered to the view correctly ."

When a flash video is rendered, it does not decide who to cover based on the z attribute of displayObject. Instead, it relies on a "Deep Index" featuring flash ". The z attribute added by fp10 is probably displayed to a third-party 3D engine.

2, HoverCamera3D

The word "Hover" is vivid, and it is indeed a camera with a hovering angle. I made a demo, created a HoverCamera3D camera, and turned it around the green ball at a 10-degree angle. Because the camera itself is invisible, I stole a coincidence: let a cube refresh to the camera position in real time. It is still in the _ view. camera (default camera) position (0, 0,-1000 ). Check the Code:

Package {import away3d. cameras. hoverCamera3D; import away3d. cameras. targetCamera3D; import away3d. containers. view3D; import away3d. core. base. object3D; import away3d. core. base. segment; import away3d. core. base. vertex; import away3d. core. math. number3D; import away3d. materials. wireColorMaterial; import away3d. materials. wireframeMaterial; import away3d. primitives. cube; import away3d. primitives. lineSegment; import Away3d. primitives. sphere; import flash. display. sprite; import flash. events. event ;/***... * @ author wws */[SWF (width = '000000', height = '000000', backgroundColor = '0x000000')] public class TestCamera extends Sprite {private var _ view: view3D; private var _ camera: HoverCamera3D; private var _ cube: Cube; private var _ sphere: Sphere; private var _ segment1: LineSegment; public function TestCamera () {// create a green ball _ s at (0 ,) Vertex = new Sphere ({x: 0, y: 0, z: 1000, radius: 20, segmentsH: 5, segmentsW: 10, material: new WireColorMaterial (0x00cc00 )}); // create a new small cube to follow the camera position in real time _ Cube = new cube ({width: 20, height: 20, depth: 20, segmentsH: 2, segmentsW: 2, segmentsD: 2, material: new WireColorMaterial (0xcccc00)}); _ camera = new HoverCamera3D ({distance: 100, target: _ sphere, panAngle: 0, tiltAngle: 10, steps: 0}); _ segment1 = new LineSeg Ment (); _ segment1.start = new Vertex (_ sphere. x, _ sphere. y, _ sphere. z); _ segment1.material = new WireframeMaterial (0 xffffff); _ view = new View3D ({x: 275, y: 200}); _ view. camera. z = 0; _ view. camera. y = 600; // the observation point is at (0,600, 0) _ view. camera. lookAt (_ sphere. position); stage. addChild (_ view); _ view. scene. addChildren (_ cube, _ sphere, _ segment1); stage. addEventListener (Event. ENTER_FRAME, render);} private function rend Er (e: Event = null): void {_ camera. panAngle + = 1; _ camera. hover (); // The End Of _ segment1 is always connected to the cube. _ Segment1.end. setValue (_ camera. position. x, _ camera. position. y, _ camera. position. z); // set the cube to the position of _ camera. _ Cube. position = _ camera. position; _ cube. lookAt (_ sphere. position); _ view. render ();}}}

:

The HoverCamera3D camera rotates around an object at a certain angle (or elevation.

3. Rotate the camera

The original Article is extremely vivid: "the visual effect of rotating a camera appears different to rotating an object, because the camera is acting as your point of view. this means that rotating around the X axis results in a movement similar to nodding your head, rotating around
The Y axis is similar to shaking your head to say "no", and rotating around the Z axis is similar to leaning your head left or right, as you might do if you had water in your ear! ".

4, camera. zoom

Let's look at an example of gradually adjusting the zoom size.

TestCameraZoom. as [Set Document Class]

Package {import away3d. containers. view3D; import away3d. materials. material; import away3d. materials. wireColorMaterial; import away3d. primitives. cube; import flash. display. sprite; import flash. events. event ;/***... * @ author wws */[SWF (width = '000000', height = '000000', backgroundColor = '0')] public class TestCameraZoom extends Sprite {private var _ cube1: cube, _ cube2: Cube, _ cube3: Cube; private var _ view: View3D; public function TestCameraZoom () {var mat: Material = new WireColorMaterial (0xcc0000 ); // place three red cubes near the z axis + 1000 units _ cube1 = new Cube ({material: mat, x: 0, y: 0, z: 1000, width: 100, height: 100, depth: 100}); _ cube2 = new Cube ({material: mat, x:-100, y: 50, z: 1000, width: 50, height: 50, depth: 50}); _ cube3 = new Cube ({material: mat, x: 100, y:-50, z: 1000, width: 30, height: 30, depth: 30}); _ view = new View3D ({x: 275, y: 200}); // adjust the camera position and observe these cubes from the top of the corner, with (_ view. camera) {x = 400; y = 800; z = 800;} _ view. camera. lookAt (_ cube1.position); _ view. scene. addChildren (_ cube1, _ cube2, _ cube3); stage. addChild (_ view); stage. addEventListener (Event. ENTER_FRAME, render); trace (_ view. camera. zoom); // The default value is 10} private function render (e: Event = null): void {_ view. render (); _ view. camera. zoom-= 0.1 // fine-tuned focal point }}}

:

Zoom should be translated into "zoom", "zoom", or "zoom", or both... the official documentation is interpreted as "Provides an overall scale value to the view ". As shown in the preceding figure, zoom is reduced, which corresponds to the camera gradually moving away from the scene.

5, camera. focus

Description: A divisor value for the perspective depth of the view.

The book clearly states that the value of focus does not relate to the focus setting in a real life camera but represents the distance between the camera position and the viewing plane. in 3D graphics, a viewing plane is an invisible surface in space that is used as the basis
For projecting the scene to the view. if you imagine the computer screen as your viewing plane, the focus property adjusts the theoretical distance between the surface of this plane and your camera's position in front of the plane. A small focus value results
In a camera very close to the viewing plane, with an extremely wide angle of view.
I think of a picture I saw in 3D game programming masters:

The other part of this figure is not required. The focus should be the control of View Distance when the red coil is displayed.

The smaller the focus, the wider the field of view, and the smaller the object. The larger the focus, the narrower the field of view, and the larger the object.

6. The default camera of the view is not in the default position.

The default camera of view is in the Z axis-1000.

The new camera is located at 0 on the Z axis by default.

Don't ignore this. Sometimes, we can't see what we can see with a custom camera, instead of the default view camera. This is because the observation point is reduced by 1000, and the object becomes very small.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.