DirectAnimation Animated Header --C DirectAnimation Animated Header --C* Microsoft DirectAnimation SDK
*Contents  *Index  *Topic Contents
*Previous Topic: B
*Next Topic: D

C


camera
DirectAnimation uses a camera to render a geometry (3-D image) into a 2-D image. DirectAnimation has two kinds of cameras: perspective cameras and parallel cameras. A perspective camera projects an image as if it comes from a point. A parallel camera uses parallel projection lines as if projected from an infinite distance away (the image's plane is the same as the viewing plane). Every camera consists of a projection plane (which is the xy plane), a near clip plane, and either a projection point (for a perspective camera) that lies on the z-axis, or a projection direction (for a parallel camera). The near clip plane is a cut-off point on the z-axis that makes everything on the camera side of it invisible. See Rendering Geometries into Images for a diagram.

Cameras in DirectAnimation are objects of the DACamera (or Java CameraBvr) class type. They can be constructed with the DAStatics.PerspectiveCamera (or Java Statics.perspectiveCamera)or the DAStatics.ParallelCamera (or Java Statics.parallelCamera) methods, and are operated on by methods such as DACamera.transform (or Java CameraBvr.transform).

To render 3-D geometries as 2-D images, use the DAGeometry.render (or Java GeometryBvr.render) method, which works on a geometry and returns an image.

The following Java code fragment constructs a scene from the union of lights and an imported cube, and then renders that scene into a 2-D image with a perspective camera.


      URL geomBase = buildURL(getImportBase(),"file:/c:/DxM/Media/geometry/");
      GeometryBvr cube = importGeometry(buildURL(geomBase,"cube.x"));
      GeometryBvr lights = ambientLight;
      GeometryBvr scene = union(lights, cube);
      CameraBvr camera = perspectiveCamera(1, 0);
      ImageBvr renderedGeometry = scene.render(camera);

The perspectiveCamera method's n and p parameters define, respectively, the position of the near clip plane and of the projection point on the positive z-axis.

clip
Clipping is a form of cropping where the clipped region need not be rectangular. To clip an image so that it conforms to the size of the matte, use the DAImage.Clip(matte)) function (or Java ImageBvr.clip(matte) method) where matte is a DAMatte behavior (or Java MatteBvr behavior). A DAMatte behavior (or Java MatteBvr behavior) is a behavior with operations for constructing matte (stencil) regions.

The resulting image is the portion of the original image that falls in the matte region and is otherwise transparent and undetectable.

A shortcut to clipping an image with a polygonal region is the DAImage.ClipPolygon function (or Java ImageBvr.clipPolygon method), which generates a polygonal matte and does a clip.

color
Color in DirectAnimation is represented by a DAColor (or Java ColorBvr) behavior. You can create color either by specifying hue, saturation, and lightness values with the DAStatics.ColorHsl function (or Java Statics.colorHsl method), or by specifying red-green-blue color components with the DAColor.ColorRgb function (or Java Statics.colorRgb method). As shown in the following JScript code:

thisColor = m.ColorHsl(0.5, 0.5, 0.5);
col = m.ColorRgb(1, 0, 0); //red

DirectAnimation defines the following color constants:
Java Reference Scripting Reference
aqua Aqua
black Black
blue Blue
cyan Cyan
fuchsia Fuchsia
gray Gray
green Green
lime Lime
magenta Magenta
maroon Maroon
navy Navy
olive Olive
purple Purple
red Red
silver Silver
teal Teal
white White
yellow Yellow

crop
Cropping limits the part of the image that is accessible to the user visually or for interaction. To crop an image, apply the DAImage.crop(lowLeftPt, upRightPt) function (or Java ImageBvr.crop(lowLeftPt, upRightPt) method). This defines the detectable or visible portion of the subject image as the part that falls within the two given points.

© 1998 Microsoft Corporation. All rights reserved. Terms of Use.

*Top of Page