Class Camera
Represents a camera that can be used to control the view of a GraphicControl.
Inherited Members
Namespace: ABB.Robotics.RobotStudio.Stations
Assembly: ABB.Robotics.RobotStudio.Stations.dll
Syntax
sistent("Camera")]
public sealed class Camera : ProjectObject, IGfxObject
Examples
Camera Collection.
Project.UndoContext.BeginUndoStep("CameraProperties");
try
{
Station station = Station.ActiveStation;
// Create a Camera.
Camera myCam = new Camera();
// Set the camera to look at a specific point.
myCam.LookAt = new Vector3(0, 0, 0);
// Set the camera to view from a specific point.
myCam.LookFrom = new Vector3(10, 10, 10);
// Fix the camera to this point.
myCam.LockRotate = 0.0;
myCam.LockTranslate = 0.0;
myCam.LockZoom = 0.0;
// Add it to the stations camera collection.
station.Cameras.Add(myCam);
// Sync the current view to the camera view.
GraphicControl.ActiveGraphicControl.SyncCamera(myCam, true, 0);
// Use the camera as the true camera.
// This make sure that the constraints on the movement kicks in.
GraphicControl.ActiveGraphicControl.Camera = myCam;
// Unlock the view (negative values removes the locks).
myCam.LockRotate = -1.0;
myCam.LockTranslate = -1.0;
myCam.LockZoom = -1.0;
// Create a solid box to follow.
Part myPart = new Part();
station.GraphicComponents.Add(myPart);
Body box = Body.CreateSolidBox(new Matrix4(Vector3.XVector, 0.0), new Vector3(0.1, 0.1, 0.1));
myPart.Bodies.Add(box);
// Keep the direction in which the view of the box fixed.
myCam.FollowBehavior = FollowObjectBehavior.FixDirection;
// Follow the box.
myCam.FollowObject = myPart;
// Move the part in the GUI.
// Observe how the part moves relative the floor,
// but how the camera follows the part.
}
catch
{
Project.UndoContext.CancelUndoStep(CancelUndoStepType.Rollback);
throw;
}
finally
{
Project.UndoContext.EndUndoStep();
}
Constructors
Camera()
Initializes a new instance of the Camera class.
Declaration
public Camera()
Examples
New Camera.
Project.UndoContext.BeginUndoStep("CameraProperties");
try
{
Station station = Station.ActiveStation;
// Create a Camera.
Camera myCam = new Camera();
// Set the camera to look at a specific point.
myCam.LookAt = new Vector3(0, 0, 0);
// Set the camera to view from a specific point.
myCam.LookFrom = new Vector3(10, 10, 10);
// Fix the camera to this point.
myCam.LockRotate = 0.0;
myCam.LockTranslate = 0.0;
myCam.LockZoom = 0.0;
// Add it to the stations camera collection.
station.Cameras.Add(myCam);
// Sync the current view to the camera view.
GraphicControl.ActiveGraphicControl.SyncCamera(myCam, true, 0);
// Use the camera as the true camera.
// This make sure that the constraints on the movement kicks in.
GraphicControl.ActiveGraphicControl.Camera = myCam;
// Unlock the view (negative values removes the locks).
myCam.LockRotate = -1.0;
myCam.LockTranslate = -1.0;
myCam.LockZoom = -1.0;
// Create a solid box to follow.
Part myPart = new Part();
station.GraphicComponents.Add(myPart);
Body box = Body.CreateSolidBox(new Matrix4(Vector3.XVector, 0.0), new Vector3(0.1, 0.1, 0.1));
myPart.Bodies.Add(box);
// Keep the direction in which the view of the box fixed.
myCam.FollowBehavior = FollowObjectBehavior.FixDirection;
// Follow the box.
myCam.FollowObject = myPart;
// Move the part in the GUI.
// Observe how the part moves relative the floor,
// but how the camera follows the part.
}
catch
{
Project.UndoContext.CancelUndoStep(CancelUndoStepType.Rollback);
throw;
}
finally
{
Project.UndoContext.EndUndoStep();
}
Properties
FieldOfView
Gets or sets the field of view, in degrees
Declaration
public double FieldOfView { get; set; }
Property Value
Type | Description |
---|---|
Double |
Remarks
Only used for perspective cameras
FollowBehavior
Gets or sets a value indicating how the camera will behave when it follows an object.
Declaration
public FollowObjectBehavior FollowBehavior { get; set; }
Property Value
Type | Description |
---|---|
FollowObjectBehavior |
Examples
Camera Collection.
Project.UndoContext.BeginUndoStep("CameraProperties");
try
{
Station station = Station.ActiveStation;
// Create a Camera.
Camera myCam = new Camera();
// Set the camera to look at a specific point.
myCam.LookAt = new Vector3(0, 0, 0);
// Set the camera to view from a specific point.
myCam.LookFrom = new Vector3(10, 10, 10);
// Fix the camera to this point.
myCam.LockRotate = 0.0;
myCam.LockTranslate = 0.0;
myCam.LockZoom = 0.0;
// Add it to the stations camera collection.
station.Cameras.Add(myCam);
// Sync the current view to the camera view.
GraphicControl.ActiveGraphicControl.SyncCamera(myCam, true, 0);
// Use the camera as the true camera.
// This make sure that the constraints on the movement kicks in.
GraphicControl.ActiveGraphicControl.Camera = myCam;
// Unlock the view (negative values removes the locks).
myCam.LockRotate = -1.0;
myCam.LockTranslate = -1.0;
myCam.LockZoom = -1.0;
// Create a solid box to follow.
Part myPart = new Part();
station.GraphicComponents.Add(myPart);
Body box = Body.CreateSolidBox(new Matrix4(Vector3.XVector, 0.0), new Vector3(0.1, 0.1, 0.1));
myPart.Bodies.Add(box);
// Keep the direction in which the view of the box fixed.
myCam.FollowBehavior = FollowObjectBehavior.FixDirection;
// Follow the box.
myCam.FollowObject = myPart;
// Move the part in the GUI.
// Observe how the part moves relative the floor,
// but how the camera follows the part.
}
catch
{
Project.UndoContext.CancelUndoStep(CancelUndoStepType.Rollback);
throw;
}
finally
{
Project.UndoContext.EndUndoStep();
}
FollowObject
Gets or sets an object that the camera will follow.
Declaration
public GraphicComponent FollowObject { get; set; }
Property Value
Type | Description |
---|---|
GraphicComponent |
Examples
Camera Collection.
Project.UndoContext.BeginUndoStep("CameraProperties");
try
{
Station station = Station.ActiveStation;
// Create a Camera.
Camera myCam = new Camera();
// Set the camera to look at a specific point.
myCam.LookAt = new Vector3(0, 0, 0);
// Set the camera to view from a specific point.
myCam.LookFrom = new Vector3(10, 10, 10);
// Fix the camera to this point.
myCam.LockRotate = 0.0;
myCam.LockTranslate = 0.0;
myCam.LockZoom = 0.0;
// Add it to the stations camera collection.
station.Cameras.Add(myCam);
// Sync the current view to the camera view.
GraphicControl.ActiveGraphicControl.SyncCamera(myCam, true, 0);
// Use the camera as the true camera.
// This make sure that the constraints on the movement kicks in.
GraphicControl.ActiveGraphicControl.Camera = myCam;
// Unlock the view (negative values removes the locks).
myCam.LockRotate = -1.0;
myCam.LockTranslate = -1.0;
myCam.LockZoom = -1.0;
// Create a solid box to follow.
Part myPart = new Part();
station.GraphicComponents.Add(myPart);
Body box = Body.CreateSolidBox(new Matrix4(Vector3.XVector, 0.0), new Vector3(0.1, 0.1, 0.1));
myPart.Bodies.Add(box);
// Keep the direction in which the view of the box fixed.
myCam.FollowBehavior = FollowObjectBehavior.FixDirection;
// Follow the box.
myCam.FollowObject = myPart;
// Move the part in the GUI.
// Observe how the part moves relative the floor,
// but how the camera follows the part.
}
catch
{
Project.UndoContext.CancelUndoStep(CancelUndoStepType.Rollback);
throw;
}
finally
{
Project.UndoContext.EndUndoStep();
}
LockRotate
Gets or sets a value (in radians) indicating how much the user is allowed to rotate the view. A negative value disables rotate lock.
Declaration
public double LockRotate { get; set; }
Property Value
Type | Description |
---|---|
Double |
Examples
Camera Collection.
Project.UndoContext.BeginUndoStep("CameraProperties");
try
{
Station station = Station.ActiveStation;
// Create a Camera.
Camera myCam = new Camera();
// Set the camera to look at a specific point.
myCam.LookAt = new Vector3(0, 0, 0);
// Set the camera to view from a specific point.
myCam.LookFrom = new Vector3(10, 10, 10);
// Fix the camera to this point.
myCam.LockRotate = 0.0;
myCam.LockTranslate = 0.0;
myCam.LockZoom = 0.0;
// Add it to the stations camera collection.
station.Cameras.Add(myCam);
// Sync the current view to the camera view.
GraphicControl.ActiveGraphicControl.SyncCamera(myCam, true, 0);
// Use the camera as the true camera.
// This make sure that the constraints on the movement kicks in.
GraphicControl.ActiveGraphicControl.Camera = myCam;
// Unlock the view (negative values removes the locks).
myCam.LockRotate = -1.0;
myCam.LockTranslate = -1.0;
myCam.LockZoom = -1.0;
// Create a solid box to follow.
Part myPart = new Part();
station.GraphicComponents.Add(myPart);
Body box = Body.CreateSolidBox(new Matrix4(Vector3.XVector, 0.0), new Vector3(0.1, 0.1, 0.1));
myPart.Bodies.Add(box);
// Keep the direction in which the view of the box fixed.
myCam.FollowBehavior = FollowObjectBehavior.FixDirection;
// Follow the box.
myCam.FollowObject = myPart;
// Move the part in the GUI.
// Observe how the part moves relative the floor,
// but how the camera follows the part.
}
catch
{
Project.UndoContext.CancelUndoStep(CancelUndoStepType.Rollback);
throw;
}
finally
{
Project.UndoContext.EndUndoStep();
}
LockTranslate
Gets or sets a value (in meters) indicating how much the user is allowed to translate (pan) the view. A negative value disables translate lock.
Declaration
public double LockTranslate { get; set; }
Property Value
Type | Description |
---|---|
Double |
Examples
Camera Collection.
Project.UndoContext.BeginUndoStep("CameraProperties");
try
{
Station station = Station.ActiveStation;
// Create a Camera.
Camera myCam = new Camera();
// Set the camera to look at a specific point.
myCam.LookAt = new Vector3(0, 0, 0);
// Set the camera to view from a specific point.
myCam.LookFrom = new Vector3(10, 10, 10);
// Fix the camera to this point.
myCam.LockRotate = 0.0;
myCam.LockTranslate = 0.0;
myCam.LockZoom = 0.0;
// Add it to the stations camera collection.
station.Cameras.Add(myCam);
// Sync the current view to the camera view.
GraphicControl.ActiveGraphicControl.SyncCamera(myCam, true, 0);
// Use the camera as the true camera.
// This make sure that the constraints on the movement kicks in.
GraphicControl.ActiveGraphicControl.Camera = myCam;
// Unlock the view (negative values removes the locks).
myCam.LockRotate = -1.0;
myCam.LockTranslate = -1.0;
myCam.LockZoom = -1.0;
// Create a solid box to follow.
Part myPart = new Part();
station.GraphicComponents.Add(myPart);
Body box = Body.CreateSolidBox(new Matrix4(Vector3.XVector, 0.0), new Vector3(0.1, 0.1, 0.1));
myPart.Bodies.Add(box);
// Keep the direction in which the view of the box fixed.
myCam.FollowBehavior = FollowObjectBehavior.FixDirection;
// Follow the box.
myCam.FollowObject = myPart;
// Move the part in the GUI.
// Observe how the part moves relative the floor,
// but how the camera follows the part.
}
catch
{
Project.UndoContext.CancelUndoStep(CancelUndoStepType.Rollback);
throw;
}
finally
{
Project.UndoContext.EndUndoStep();
}
LockZoom
Gets or sets a value (in meters) indicating how much the user is allowed to zoom the view. A negative value disables zoom lock.
Declaration
public double LockZoom { get; set; }
Property Value
Type | Description |
---|---|
Double |
Examples
Camera Collection.
Project.UndoContext.BeginUndoStep("CameraProperties");
try
{
Station station = Station.ActiveStation;
// Create a Camera.
Camera myCam = new Camera();
// Set the camera to look at a specific point.
myCam.LookAt = new Vector3(0, 0, 0);
// Set the camera to view from a specific point.
myCam.LookFrom = new Vector3(10, 10, 10);
// Fix the camera to this point.
myCam.LockRotate = 0.0;
myCam.LockTranslate = 0.0;
myCam.LockZoom = 0.0;
// Add it to the stations camera collection.
station.Cameras.Add(myCam);
// Sync the current view to the camera view.
GraphicControl.ActiveGraphicControl.SyncCamera(myCam, true, 0);
// Use the camera as the true camera.
// This make sure that the constraints on the movement kicks in.
GraphicControl.ActiveGraphicControl.Camera = myCam;
// Unlock the view (negative values removes the locks).
myCam.LockRotate = -1.0;
myCam.LockTranslate = -1.0;
myCam.LockZoom = -1.0;
// Create a solid box to follow.
Part myPart = new Part();
station.GraphicComponents.Add(myPart);
Body box = Body.CreateSolidBox(new Matrix4(Vector3.XVector, 0.0), new Vector3(0.1, 0.1, 0.1));
myPart.Bodies.Add(box);
// Keep the direction in which the view of the box fixed.
myCam.FollowBehavior = FollowObjectBehavior.FixDirection;
// Follow the box.
myCam.FollowObject = myPart;
// Move the part in the GUI.
// Observe how the part moves relative the floor,
// but how the camera follows the part.
}
catch
{
Project.UndoContext.CancelUndoStep(CancelUndoStepType.Rollback);
throw;
}
finally
{
Project.UndoContext.EndUndoStep();
}
LookAt
Gets or sets the point which will act as the center of the camera view.
Declaration
public Vector3 LookAt { get; set; }
Property Value
Type | Description |
---|---|
Vector3 |
Examples
Camera Collection.
Project.UndoContext.BeginUndoStep("CameraProperties");
try
{
Station station = Station.ActiveStation;
// Create a Camera.
Camera myCam = new Camera();
// Set the camera to look at a specific point.
myCam.LookAt = new Vector3(0, 0, 0);
// Set the camera to view from a specific point.
myCam.LookFrom = new Vector3(10, 10, 10);
// Fix the camera to this point.
myCam.LockRotate = 0.0;
myCam.LockTranslate = 0.0;
myCam.LockZoom = 0.0;
// Add it to the stations camera collection.
station.Cameras.Add(myCam);
// Sync the current view to the camera view.
GraphicControl.ActiveGraphicControl.SyncCamera(myCam, true, 0);
// Use the camera as the true camera.
// This make sure that the constraints on the movement kicks in.
GraphicControl.ActiveGraphicControl.Camera = myCam;
// Unlock the view (negative values removes the locks).
myCam.LockRotate = -1.0;
myCam.LockTranslate = -1.0;
myCam.LockZoom = -1.0;
// Create a solid box to follow.
Part myPart = new Part();
station.GraphicComponents.Add(myPart);
Body box = Body.CreateSolidBox(new Matrix4(Vector3.XVector, 0.0), new Vector3(0.1, 0.1, 0.1));
myPart.Bodies.Add(box);
// Keep the direction in which the view of the box fixed.
myCam.FollowBehavior = FollowObjectBehavior.FixDirection;
// Follow the box.
myCam.FollowObject = myPart;
// Move the part in the GUI.
// Observe how the part moves relative the floor,
// but how the camera follows the part.
}
catch
{
Project.UndoContext.CancelUndoStep(CancelUndoStepType.Rollback);
throw;
}
finally
{
Project.UndoContext.EndUndoStep();
}
LookFrom
Gets or sets the point of view of the camera.
Declaration
public Vector3 LookFrom { get; set; }
Property Value
Type | Description |
---|---|
Vector3 |
Examples
Camera Example.
Project.UndoContext.BeginUndoStep("CameraProperties");
try
{
Station station = Station.ActiveStation;
// Create a Camera.
Camera myCam = new Camera();
// Set the camera to look at a specific point.
myCam.LookAt = new Vector3(0, 0, 0);
// Set the camera to view from a specific point.
myCam.LookFrom = new Vector3(10, 10, 10);
// Fix the camera to this point.
myCam.LockRotate = 0.0;
myCam.LockTranslate = 0.0;
myCam.LockZoom = 0.0;
// Add it to the stations camera collection.
station.Cameras.Add(myCam);
// Sync the current view to the camera view.
GraphicControl.ActiveGraphicControl.SyncCamera(myCam, true, 0);
// Use the camera as the true camera.
// This make sure that the constraints on the movement kicks in.
GraphicControl.ActiveGraphicControl.Camera = myCam;
// Unlock the view (negative values removes the locks).
myCam.LockRotate = -1.0;
myCam.LockTranslate = -1.0;
myCam.LockZoom = -1.0;
// Create a solid box to follow.
Part myPart = new Part();
station.GraphicComponents.Add(myPart);
Body box = Body.CreateSolidBox(new Matrix4(Vector3.XVector, 0.0), new Vector3(0.1, 0.1, 0.1));
myPart.Bodies.Add(box);
// Keep the direction in which the view of the box fixed.
myCam.FollowBehavior = FollowObjectBehavior.FixDirection;
// Follow the box.
myCam.FollowObject = myPart;
// Move the part in the GUI.
// Observe how the part moves relative the floor,
// but how the camera follows the part.
}
catch
{
Project.UndoContext.CancelUndoStep(CancelUndoStepType.Rollback);
throw;
}
finally
{
Project.UndoContext.EndUndoStep();
}
Parent
Declaration
public override ProjectObject Parent { get; }
Property Value
Type | Description |
---|---|
ProjectObject |
Overrides
Projection
Gets or sets a value indicating how 3D objects are projected.
Declaration
public GraphicProjection Projection { get; set; }
Property Value
Type | Description |
---|---|
GraphicProjection |
Examples
Camera Collection.
Project.UndoContext.BeginUndoStep("CameraProperties");
try
{
Station station = Station.ActiveStation;
// Create a Camera.
Camera myCam = new Camera();
// Set the camera to look at a specific point.
myCam.LookAt = new Vector3(0, 0, 0);
// Set the camera to view from a specific point.
myCam.LookFrom = new Vector3(10, 10, 10);
// Fix the camera to this point.
myCam.LockRotate = 0.0;
myCam.LockTranslate = 0.0;
myCam.LockZoom = 0.0;
// Add it to the stations camera collection.
station.Cameras.Add(myCam);
// Sync the current view to the camera view.
GraphicControl.ActiveGraphicControl.SyncCamera(myCam, true, 0);
// Use the camera as the true camera.
// This make sure that the constraints on the movement kicks in.
GraphicControl.ActiveGraphicControl.Camera = myCam;
// Unlock the view (negative values removes the locks).
myCam.LockRotate = -1.0;
myCam.LockTranslate = -1.0;
myCam.LockZoom = -1.0;
// Create a solid box to follow.
Part myPart = new Part();
station.GraphicComponents.Add(myPart);
Body box = Body.CreateSolidBox(new Matrix4(Vector3.XVector, 0.0), new Vector3(0.1, 0.1, 0.1));
myPart.Bodies.Add(box);
// Keep the direction in which the view of the box fixed.
myCam.FollowBehavior = FollowObjectBehavior.FixDirection;
// Follow the box.
myCam.FollowObject = myPart;
// Move the part in the GUI.
// Observe how the part moves relative the floor,
// but how the camera follows the part.
}
catch
{
Project.UndoContext.CancelUndoStep(CancelUndoStepType.Rollback);
throw;
}
finally
{
Project.UndoContext.EndUndoStep();
}
UpDirection
Gets or sets the direction that corresponds to up on the screen.
Declaration
public Vector3 UpDirection { get; set; }
Property Value
Type | Description |
---|---|
Vector3 |
Remarks
This is normally equal to ZVector.
Visible
Gets or sets a value indicating whether the camera will be displayed in the graphics.
Declaration
public bool Visible { get; set; }
Property Value
Type | Description |
---|---|
Boolean |
Examples
Camera Collection.
Project.UndoContext.BeginUndoStep("CameraProperties");
try
{
Station station = Station.ActiveStation;
// Create a Camera.
Camera myCam = new Camera();
// Set the camera to look at a specific point.
myCam.LookAt = new Vector3(0, 0, 0);
// Set the camera to view from a specific point.
myCam.LookFrom = new Vector3(10, 10, 10);
// Fix the camera to this point.
myCam.LockRotate = 0.0;
myCam.LockTranslate = 0.0;
myCam.LockZoom = 0.0;
// Add it to the stations camera collection.
station.Cameras.Add(myCam);
// Sync the current view to the camera view.
GraphicControl.ActiveGraphicControl.SyncCamera(myCam, true, 0);
// Use the camera as the true camera.
// This make sure that the constraints on the movement kicks in.
GraphicControl.ActiveGraphicControl.Camera = myCam;
// Unlock the view (negative values removes the locks).
myCam.LockRotate = -1.0;
myCam.LockTranslate = -1.0;
myCam.LockZoom = -1.0;
// Create a solid box to follow.
Part myPart = new Part();
station.GraphicComponents.Add(myPart);
Body box = Body.CreateSolidBox(new Matrix4(Vector3.XVector, 0.0), new Vector3(0.1, 0.1, 0.1));
myPart.Bodies.Add(box);
// Keep the direction in which the view of the box fixed.
myCam.FollowBehavior = FollowObjectBehavior.FixDirection;
// Follow the box.
myCam.FollowObject = myPart;
// Move the part in the GUI.
// Observe how the part moves relative the floor,
// but how the camera follows the part.
}
catch
{
Project.UndoContext.CancelUndoStep(CancelUndoStepType.Rollback);
throw;
}
finally
{
Project.UndoContext.EndUndoStep();
}
Methods
AfterLoad(PimDocument)
Declaration
protected override void AfterLoad(PimDocument doc)
Parameters
Type | Name | Description |
---|---|---|
RobotStudio.API.Persistence.PimDocument | doc |
Overrides
SetView(Vector3, Vector3, Vector3)
Sets LookAt, LookFrom and UpDirection in one operation.
Declaration
public void SetView(Vector3 lookAt, Vector3 lookFrom, Vector3 upVec)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | lookAt | |
Vector3 | lookFrom | |
Vector3 | upVec |