ViewCamera Class

The ViewCamera class defines a camera which can be used together with a visible view. Always supply a properly orthogonalized camera up vector when rotating the camera.
Inheritance Hierarchy
SystemObject
  Tekla.Structures.Model.UIViewCamera

Namespace:  Tekla.Structures.Model.UI
Assembly:  Tekla.Structures.Model (in Tekla.Structures.Model.dll) Version: 2023.0.3
Syntax
[SerializableAttribute]
public class ViewCamera

The ViewCamera type exposes the following members.

Constructors
  NameDescription
Public methodViewCamera
Instantiates a new view camera instance with zero length vectors.
Top
Properties
  NameDescription
Public propertyDirectionVector
The camera direction (controls the camera pan and tilt).
Public propertyFieldOfView
The camera field of view as an angle (degrees) in the perspective view.
Public propertyLocation
The camera location in global coordinates (XYZ).
Public propertyUpVector
The camera up vector (controls the camera roll).
Public propertyView
The view where the camera belongs to.
Public propertyZoomFactor
The camera zoom factor (meter/pixel) in the orthogonal view.
Top
Methods
  NameDescription
Public methodModify
Updates the camera to the application view.
Public methodSelect
Updates the camera parameters from the application view.
Top
Examples
The following example shows how the ViewCamera class can be used:
using System;
using Tekla.Structures.Model.UI;
using Tekla.Structures.Geometry3d;

public class ViewCameraExample
{
    public void ViewCameraExample1()
    {
        ModelViewEnumerator ViewEnum = ViewHandler.GetVisibleViews();
        ViewEnum.MoveNext();
        View CurrentView = ViewEnum.Current;
        ViewCamera Camera = new ViewCamera();

        // Set the view to the camera
        Camera.View = CurrentView;
        if(CurrentView.IsVisible() && CurrentView.IsPerspectiveViewProjection())
        {
            // Query camera settings from the application
            Camera.Select();

            // Tilt the camera
            Vector DirectionVector = Camera.DirectionVector;
            Vector UpVector = Camera.UpVector;
            Vector CrossVector = DirectionVector.Cross(UpVector);
            Matrix RotationMatrix = new Matrix();
            RotationMatrix = MatrixFactory.Rotate(Math.PI/20.0, CrossVector);
            Tekla.Structures.Geometry3d.Point RotPoint = RotationMatrix * (Tekla.Structures.Geometry3d.Point)Camera.DirectionVector;
            DirectionVector = new Vector(RotPoint);
            DirectionVector.Normalize();
            Camera.DirectionVector = DirectionVector; 

            // Orthogonalize the camera UpVector
            UpVector = CrossVector.Cross(DirectionVector);
            UpVector.Normalize();
            Camera.UpVector = UpVector;

            // Modify the camera settings in the application
            Camera.Modify();
        }
    }
}
See Also
Was this helpful?
The feedback you give here is not visible to other users. We use your comments to improve the content.
Previous
Next