DefaultCamera2D and DefaultCamera3D
Synopsis
define a Graphics Display Kit camera
GDcamera_notify_templ
group+OPort GDcamera_notify_templ
{
int update;
enum type {choices = {"3D", "2D"}; };
enum mode { choices = {"Manual", "Automatic"}; };
enum auto_norm { choices = {"None", "Data Change", "Object Attach",
"Data and Object"}; };
float norm_scale;
enum extents { choices = {"Compute", "Window"}; };
enum mapping { choices = {"World", "Pixel"}; };
int image_pass;
int pickable;
int nobjs;
GDobject_templ+IPort2 *objects[]; // Objects to render
float xmin; // Viewport specification
float ymin;
float xmax;
float ymax;
float from[3]; // Camera orientation
float up[3];
float at[3];
float scale;
GDxform_templ+IPort2 &xform;
int perspec; // Camera projection
int hither;
float front
float back;
float fov;
float wsize;
int depth_cue; // Depth cue information
float depth_front;
float depth_back;
float depth_scale;
float jitter_scale;
int+write dep;
method+notify_val upd_func = "GDcamera_update";
method+notify_deinst del_func = "GDcamera_delete";
};
GDcamera_templ
GDcamera_notify_templ+OPort GDcamera_templ;
GDcamera
GDcamera_templ GDcamera
<NEiconName="camera"> {
nobjs => array_size(objects);
ptr+nonotify+nosave local_ptr;
};
DefaultCamera
GDcamera DefaultCamera
{
mode = GD_CAMERA_AUTO_UPDATE;
pickable = 1;
auto_norm = GD_CAMERA_AUTO_NORM_NONE;
norm_scale = GD_DEFAULT_NORM_SCALE;
extents = GD_CAMERA_COMPUTE_EXTENT;
mapping = GD_CAMERA_MAP_WORLD;
xmin = 0.0;
ymin = 0.0;
xmax = 1.0;
ymax = 1.0;
from = {0.0, 0.0, 12.0};
up = {0.0, 1.0, 0.0};
at = {0.0, 0.0, 0.0};
scale = 1.0;
perspec = 0;
hither = 0;
front = GD_DEFAULT_FRONT_PAR;
back = GD_DEFAULT_BACK;
fov = GD_DEFAULT_VIEW_ANGLE
wsize = GD_DEFAULT_WSIZE;
depth_cue = 0;
depth_front = GD_DEFAULT_DEPTH_FRONT;
depth_back = GD_DEFAULT_DEPTH_BACK;
depth_scale = GD_DEFAULT_DEFAULT_SCALE;
jitter_scale = 1.0;
};
DefaultCamera2D
DefaultCamera DefaultCamera2D
{
type = GD_CAMERA_2D;
image_pass = 1;
};
DefaultCamera3D
DefaultCamera DefaultCamera3D
{
type = GD_CAMERA_3D;
image_pass = 0;
};
Description
These templates define a Graphics Display Kit camera. GDcamera_notify_templ defines the elements that cause the camera's methods to execute. GDcamera is used to define a camera without default values. DefaultCamera2D define a 2D camera with default values; in other words, Graphics Display Kit objects connected to DefaultCamera2D are rendered in 2D. DefaultCamera3D defines a 3D camera with default values; in other words, Graphics Display Kit objects connected to DefaultCamera3D are rendered in 3D.
Input Ports
objects
One or more objects to be rendered. This input port is an array of connections to objects matching type GDobject_templ.
xform
A transformation that represents the camera's orientation. xform is a connection to an object that matches type GDxform_templ. The subelements from, at, up and scale are used to calculate the transformation.
Parameters
update
When the mode parameter (see below) is set to 0, determines whether the view is updated: 0 means no; 1 means yes.
type
This parameter controls the camera's type:
Value |
Meaning | |
0 |
3D camera |
GD_CAMERA_3D |
1 |
2D camera |
GD_CAMERA_2D |
mode
This parameter controls the camera's update mode:
Value |
Meaning |
Symbolic constant |
0 |
Update the camera only when the camera's update element has been set to 1 |
GD_CAMERA_MANUAL_UPDATE |
1 |
Update the camera automatically |
GD_CAMERA_AUTO_UPDATE |
auto_norm
This parameter controls if and when the objects in the camera are normalized to fit in the view.
Value |
Meaning |
Symbolic constant |
0 |
No auto- normalization. |
GD_CAMERA_AUTO_NORM_NONE |
1 |
Auto-normalize when the data's extents become larger. |
GD_CAMERA_AUTO_NORM_DATA |
2 |
Auto-normalize when an object is attached to the camera. |
GD_CAMERA_AUTO_NORM_ATTACH |
3 |
Auto-normalize when either the data's extents become larger or an object is attached to the camera |
GD_CAMERA_AUTO_NORM_ALL |
norm_scale
This parameter applies a scale to normalization. By default, norm_scale is set to 0.8, indicating that when normalization takes place, any objects will be scaled to fill 80% of the camera.
extents
This parameter controls how the extents of the objects connected to the camera are computed when doing normalization:
Value |
Meaning |
Symbolic constant |
0 |
Compute the extents from the objects' data |
GD_CAMERA_COMPUTE_EXTENT |
1 |
Compute the extents using the object's window |
GD_CAMERA_USE_WINDOW |
mapping
This parameter controls the mapping of the camera:
Value |
Meaning |
Symbolic constant |
0 |
Map data to world space |
GD_CAMERA_MAP_WORLD |
1 |
Map data to pixel space. This effectively sets the camera's wsize parameter to the camera's number of pixels divided by 2. This is useful for image data. |
GD_CAMERA_MAP_PIXELS |
image_pass
This parameter controls if there is a separate pass to render the images in 2D cameras. A value of 1 means all images are rendered in a separate pass prior to all other objects in the 2D camera. A value of 0 means that images are rendered in the same pass as all other objects. When a separate image pass is enabled, images are rendered "behind" the other objects in the camera. Otherwise, all objects in the camera are rendered in the order that they were attached to the camera.
pickable
This parameter controls if the camera is pickable: 0 means the camera is not pickable; 1 means the camera is pickable. When the camera is not pickable, all the objects in that camera are also unpickable. Use this subelement if objects in the view, such as annotation or legends, should not be transformed.
nobjs
The number of Graphics Display Kit objects connected to the camera. nobjs is updated automatically when the size of the array changes.
xmin
ymin
xmax
ymax
The camera's viewport; that is, the region it occupies in the view. For the purposes of specifying a viewport, point (0,0) is the top-left corner of the view and point (1,1) is the bottom-right corner. The viewport specification is not currently supported by the camera.
from
The X, Y, and Z position in world coordinates of the camera.
up
An X, Y, and Z direction vector indicating the vertical axis of the camera.
at
The X, Y, and Z position in world coordinates at which the camera is pointed.
scale
The scale term that is applied to the camera.
perspec
The camera type: 0 means parallel; 1 means perspective.
hither
Whether front and back clipping is in effect: 0 means no; 1 means yes.
front
The distance in world coordinates from the camera's origin (from) to the front clip plane. The distance is measured along the front-at line.
The valid values of front depends on the type of camera. If the camera's type is parallel, then front can be any value, positive or negative. If the camera's type is perspective, then front can be any positive value.
back
The distance in world coordinates from the camera's origin (from) to the back clip plane. The distance is measured along the front-at line.
back must be greater than front for both parallel and perspective cameras.
fov
For perspective cameras only, the angle in degrees formed by the edges of the field of view volume. fov must be a value between 0 and 180.
wsize
For parallel cameras only, a scale factor in world coordinates that determines the range of viewing.
depth_cue
Whether depth cueing is in effect: 0 means no; 1 means yes.
depth_front
The distance in world coordinates from the camera's origin (from) to where depth cueing begins. The distance is measured along the front-at line.
depth_back
The distance in world coordinates from the camera's origin (from) to where the maximum depth scale is applied. The distance is measured along the front-at line.
depth_scale
The maximum depth scale.
Specify a value between 0 and 1. For example, 0.1 means that a factor of 0.1 is applied to locations at and further than depth_back.
jitter_scale
This parameter is used to scale the jitter offset that can be applied to any of the objects in the camera. Jitter offset is used to move objects either positively or negatively in the camera in order to resolve the ambiguity in rendering objects at the same depth. Jitter_scale is useful for adjusting the amount of the jitter offset in order to reduce artifacts that may be introduced in cases where the objects are very thin geometries. Note that when an object is locked, its coordinates are not transformed, thus they are not jittered.
Example
Libraries.Graphics_Display.Views.View2D
Libraries.Graphics_Display.Views.View3D
File
v/gd.v