Camera

Namespace: Digi21.DigiNG.Cameras
Assembly: Digi21.DigiNG

Base class for drawing window cameras: name, position, rotations and clipping planes.

public abstract class Camera

Derived types: ConicCamera and OrthographicCamera.

The class has no public constructors: create a ConicCamera or an OrthographicCamera.

A Camera is a data object: changing its properties does not change the drawing window. Each read of the DigiNG class's static Camera property returns a new object containing the active drawing window's camera (a ConicCamera or an OrthographicCamera), and assignment applies the camera to that window. To modify the window's camera, read the static property, modify the returned object's properties and assign that object back to the same static property.

All three rotations are in degrees. With all three set to 0, the camera looks in the −Z direction with the +Y axis toward the top of the screen (top view with north up). The drawing window applies rotations in this order: first Pitch around the X axis, then Roll around the Y axis, and finally Yaw around the Z axis.

Properties

Property Description
string Name Camera name.
Point3D Position Camera position, in drawing file coordinates.
float Pitch Rotation around the X axis, in degrees.
float Yaw Rotation around the Z axis, in degrees.
float Roll Rotation around the Y axis, in degrees.
double Near Near clipping plane.
double Far Far clipping plane.

Methods

Method Description
Point3D WorldToViewport(Point3D world) Projects a drawing file point to OpenGL window coordinates.
Point3D ViewportToWorld(Point3D viewport) Converts an OpenGL window point to drawing file coordinates.
string ToString() Returns Name.

Example

This command displays the active drawing window's camera in the results window:

using Digi21.Digi3D;
using Digi21.DigiNG.Cameras;
using Digi21.DigiNG.Plugin.Command;

namespace Ejemplos;

[Command(Name = "INFO_CAMARA")]
public class InfoCamara : Command
{
    public InfoCamara()
    {
        Initialize += (sender, e) =>
        {
            var cámara = Digi21.DigiNG.DigiNG.Camera;

            Digi3D.OutputWindow.Show();
            Digi3D.OutputWindow.WriteLine($"Posición: {cámara.Position}");
            Digi3D.OutputWindow.WriteLine($"Pitch: {cámara.Pitch}, Yaw: {cámara.Yaw}, Roll: {cámara.Roll} (grados sexagesimales)");

            switch (cámara)
            {
                case OrthographicCamera ortográfica:
                    Digi3D.OutputWindow.WriteLine($"Ortográfica de {ortográfica.Right - ortográfica.Left} x {ortográfica.Top - ortográfica.Bottom}");
                    break;
                case ConicCamera cónica:
                    Digi3D.OutputWindow.WriteLine($"Cónica con campo de visión de {cónica.FieldOfView} grados");
                    break;
            }

            Dispose();
        };
    }
}