IBM Visualization Data Explorer Programmer's Reference

[ Bottom of Page | Previous Page | Next Page | Table of Contents | Partial Table of Contents | Index ]

DXNewCamera

Function

Creates a new Camera.

Syntax

#include <dx/dx.h>

Camera DXNewCamera()

Functional Details

Creates a new Camera. A camera defines the position and orientation of the viewer, the volume of interest of the object being viewed, and the size of the image to contain the resulting view.

A summary of how to interpret a camera follows.

The position and orientation of the view are defined by where the viewer is standing, from, where the viewer is looking, to, and the tilt of the viewer's head, up.

The volume of interest of the object being viewed depends on the type of camera. An orthographic camera defines a box that is centered on the to point and has an infinite z axis lying along the to-from vector. The y axis is perpendicular to the to-from vector in the direction of the up vector. The x- and y-dimensions of the box are given by the width and aspect parameters of the camera, where aspect is defined as the ratio of the height to width.

In orthographic projection, objects do not appear smaller as they get more distant, and in fact, distance between the object and the viewer has no effect on the appearance of the object. The distance between the to and from points is irrelevant; only the direction is important.

The volume of interest defined by a perspective camera is a pyramid with an apex at the from position, and a base at the to point perpendicular to the to-from vector. The width of the base is defined by the angle formed by the sides of the pyramid at the apex and the distance between the to and from points. The angle formed by the sides of the pyramid is also known as the "field of view" and is the fov parameter.

The fov is defined as twice the tangent of half the angle (e.g., for a 90-degree sweep, the fov is 2 * tan(45 degrees), or 2.0). The fov can also be thought as the ratio of the width of the base to the distance to the viewer (e.g., for a 20-meter wide area from a distance of 10 meters , set the fov to 20/10, or 2.0). The base height is defined by the resulting width times the aspect.

With a perspective camera, objects appear smaller with increasing distance. When the perspective pyramid is projected onto the image, the sides of the pyramid are made parallel, with a cross-section equal to the base dimensions. This has the effect of widening (in x and y) the objects in front of the pyramid base and compressing (in x and y) the objects behind the pyramid base.

The Camera created can be deleted with DXDelete. See 4.2 , "Memory Management".

The horizontal size of the image containing the resulting view is defined as the resolution in pixels, and the vertical size is determined by the resolution * aspect. The same aspect ratio is used for both the size of the image and the volume of interest to prevent the object from being stretched in one of the dimensions. The background color of the image is also a parameter to the camera.

By default, the camera is orthographic, looking from the positive z axis toward the origin; x and y each range from -1 to +1. The image is 640 by 480 pixels, with the origin at the center of the image.

Return Value

Returns the Camera or returns NULL and sets an error code.

See Also

DXGetCameraMatrix, DXGetCameraRotation, DXGetCameraMatrixWithFuzz, DXRender, DXSetBackgroundColor, DXGetBackgroundColor, DXSetOrthographic, DXGetOrthographic, DXSetPerspective, DXGetPerspective, DXSetResolution, DXGetCameraResolution, DXSetView, DXGetView

16.7 , "Camera Class".


[ Top of Page | Previous Page | Next Page | Table of Contents | Partial Table of Contents | Index ]
[Data Explorer Documentation | QuickStart Guide | User's Guide | User's Reference | Programmer's Reference | Installation and Configuration Guide ]

[Data Explorer Home Page | Contact Data Explorer | Same document on Data Explorer Home Page ]


[IBM Home Page | Order | Search | Contact IBM | Legal ]