33#include <NDEVR/Model.h>
34#include <NDEVR/SelectionInfo.h>
35#include <NDEVR/SnapLocation.h>
36#include <NDEVR/CameraBackground.h>
37#include <NDEVR/AutoZoomFocus.h>
38#include <NDEVR/CameraAnimation.h>
39#include <NDEVR/Resource.h>
40#include <NDEVR/Time.h>
41#include <NDEVR/TimeSpan.h>
42#include <NDEVR/BaseValues.h>
43#include <NDEVR/Vector.h>
44#include <NDEVR/Angle.h>
46#include <NDEVR/BasicResourceListener.h>
161 void move(
const Ray<3, fltp08>& distance);
627 void _setupListeners();
632 void executeAnimations(
Time current_time);
641 Ray<2, uint04> m_window_size;
647 Ray<3, fltp08> m_lookat;
648 Ray<3, fltp08> m_up_direction;
653 fltp08 m_goto_initial_ortho_bounds;
654 fltp08 m_goto_initial_zoom_extent_mult;
661 bool m_use_reference_size =
true;
662 bool m_refresh_background =
false;
Stores an angle in an optimized internal format with support for efficient trigonometric operations.
Simple version of ResourceListener which allows for a simple function callback that will be executed ...
A specification of upper and lower bounds in N-dimensions.
The equivelent of std::vector but with a bit more control.
Logic for rendering the background to a 3D user view.
void setFarPlaneBounds(const Bounds< 1, fltp08 > &near_plane_bounds)
Sets the allowable range for the far clipping plane distance.
const CameraBackground & cameraBackground() const
Gets the camera background settings (const).
void moveHorizontalPercent(fltp08 percent)
Moves the camera horizontally by a normalized percentage of the viewport width.
Resource< String > camera_format
Format descriptor for the camera source (e.g., resolution, codec).
Bounds< 2, Angle< fltp08 > > getPerspectiveBounds() const
Computes the angular bounds visible in perspective mode.
void lookHorizontal(fltp08 percent)
Rotates the camera horizontally by a normalized percentage of the view.
Resource< fltp08 > default_zoom_delta
The default incremental change applied during zoom operations.
void setupFromFormat(const ViewportFormat &format)
Configures this camera from the given viewport format settings.
Resource< fltp08 > near_plane
The distance from the camera to the near clipping plane.
void refreshFocusBounds(const DesignObjectLookup *lookup, TimeSpan animation_time)
Recomputes the auto-zoom focus bounds based on the current scene state.
void setReferenceSize(fltp08 size)
Sets the reference size used for scaling calculations.
void look(fltp08 horz_percent, fltp08 vert_percent, const CameraAnimation &original)
Rotates the camera by normalized horizontal and vertical percentages with animation parameters.
void addLookatAnimation(Vector< 3, fltp08 > lookat, const TimeSpan &time, bool clear_animations=true)
Adds an animation that transitions the camera to look at the specified direction.
Resource< fltp08 > zoom_extent_mult
Multiplier applied to the zoom extents calculation.
fltp04 pixelThickness() const
Gets the current pixel thickness for rendering lines and points.
CameraBackground & cameraBackground()
Gets the camera background settings (mutable).
bool isObjectPotentiallyVisibleToCamera(const UUID &id) const
Checks whether the given object is potentially visible from this camera's viewpoint.
Resource< fltp04 > pixel_thickness
The thickness of rendered lines and points in pixels.
void updateSelectionInfo(const Vector< 2, fltp04 > &pixel_location, SelectionInfo &info) const
Updates the given SelectionInfo with a point-based selection at the specified pixel location.
void setProjectionTransform(const Matrix< fltp08 > &transform)
Sets a custom projection transform matrix, overriding the computed one.
void setUseReferenceSize(bool use_reference_size)
Sets whether the camera should use a reference size for scaling calculations.
void postUpdateBackground()
Signals that the camera background needs to be updated.
Vector< 3, Angle< fltp08 > > gotoOrientation() const
Gets the target orientation for a pending goto animation.
Resource< bool > rotation_lock
Whether the camera rotation is locked and cannot be changed.
void addObjectToVisible(const Model &model)
Adds the given model to the set of objects visible to this camera.
Resource< Vertex< 3, fltp08 > > offset
The positional offset of the camera in 3D world space.
void moveHorizontal(fltp08 distance)
Moves the camera horizontally (left/right) relative to its view direction.
Resource< String > camera_source
Identifier of the source providing the camera feed (e.g., device name).
void moveVerticalPercent(fltp08 percent)
Moves the camera vertically by a normalized percentage of the viewport height.
Resource< Vector< 2, Angle< fltp08 > > > perspective_fov
The horizontal and vertical field of view angles for perspective projection.
Resource< fltp08 > orthographic_perspective_ratio
The blend ratio between orthographic and perspective projection modes.
Resource< fltp08 > orthographic_fov
The field of view size used for orthographic projection.
Bounds< 3, fltp08 > getFocusBounds() const
Gets the current auto-zoom focus bounds.
DynamicPointer< Set< UUID > > visible_items
Set of object UUIDs explicitly marked as visible to this camera.
bool hasWorldGridAlignment() const
Checks whether the camera grid is aligned with the world coordinate system.
Camera(const Camera &camera)
Copy constructor.
fltp08 calculatedReferenceSize() const
Gets the calculated reference size based on the current viewport dimensions.
bool isUserCamera() const
Checks whether this camera represents a user-interactive viewport camera.
Matrix< fltp08 > projectionMatrix() const
Gets the current projection matrix, which may be custom or calculated.
Vertex< 2, fltp08 > toScreenSpace(const Vector< 2, fltp04 > &pixel_location) const
Converts a pixel location to normalized screen space in the range -1.0 to 1.0.
void addObjectsToVisible(const Buffer< UUID > &models, DesignObjectLookup *lookup)
Adds multiple objects to the set of objects visible to this camera.
void updateGridSpacing()
Recalculates the grid spacing based on the current zoom level and view parameters.
void updateSelectionInfo(const Polygon< fltp04 > &pixel_location, SelectionInfo &info) const
Updates the given SelectionInfo with a polygon-based selection at the specified pixel polygon.
Vector< 2, uint04 > windowSize() const
Gets the current window size in pixels.
void zoom(fltp08 distance_mult, const CameraAnimation &original)
Zooms the camera by a distance multiplier with animation parameters.
SnapLocation preferredSnapLocation() const
Gets the preferred snap location for this camera.
void move(const Ray< 3, fltp08 > &distance)
Moves the camera by a ray-defined offset and direction.
void setNearPlaneBounds(const Bounds< 1, fltp08 > &near_plane_bounds)
Sets the allowable range for the near clipping plane distance.
void moveForward(fltp08 distance)
Moves the camera forward or backward along its look direction.
void move(const Ray< 3, fltp08 > &distance, const CameraAnimation &original)
Moves the camera by a ray-defined offset and direction with animation parameters.
void copyFrom(const Camera &object)
Copies all camera settings from the given camera into this one.
void moveVertical(fltp08 distance)
Moves the camera vertically (up/down) relative to its view direction.
fltp08 widthToHeightRatio() const
Computes the width-to-height ratio of the viewport.
Resource< bool > is_exposed
Whether the camera viewport is currently exposed and visible to the user.
Resource< ScreenshotRequest > screenshot_request
The current pending screenshot request, if any.
void setFocusBounds(const Bounds< 3, fltp08 > &bounds)
Sets the auto-zoom focus bounds directly.
Vector< 2, fltp08 > activeOrthoSize() const
Gets the active orthographic view size in world units.
void addOrbitAnimation(Vector< 3, fltp08 > target, Vector< 3, Angle< fltp08 > > orient, fltp08 zoom, bool face_target, const TimeSpan &time, bool clear_animations=true)
Adds an orbit animation around a target point.
Matrix< fltp08 > viewMatrix() const
Gets the view matrix (camera transformation matrix).
Resource< bool > is_orthographic
Whether the camera uses orthographic projection instead of perspective.
Vector< 2, Angle< fltp08 > > getRotateAroundPoint(const Vector< 3, fltp04 > &vCenter) const
Computes the rotation angles needed to rotate the camera around a given center point.
Resource< bool > location_lock
Whether the camera position is locked and cannot be moved.
bool hasFullAutoFocus() const
Checks whether the camera has full auto-focus enabled on all axes.
Resource< SelectionInfo > selection_info
The current selection state associated with this camera view.
void setAutoZoomFocus(AutoZoomFocus focus)
Sets the auto-zoom focus configuration for this camera.
Vertex< 3, fltp08 > toWorldSpaceFromPixelSpace(const Vector< 2, fltp04 > &pixel_location, fltp08 depth_percent) const
Converts a pixel-space location and depth to a 3D world-space position.
Vector< 2, Angle< fltp08 > > activeFOV() const
Gets the currently active field of view, accounting for projection mode.
void clearAutozoomFocus()
Clears the current auto-zoom focus settings.
fltp08 heightToWidthRatio() const
Computes the height-to-width ratio of the viewport.
Vertex< 3, fltp08 > computedOffset() const
Gets the computed camera offset in world space, accounting for animations.
void addZoomMultiplierAnimation(fltp08 multiplier, const TimeSpan &time, bool clear_animations=true)
Adds an animation that scales the zoom level by a multiplier over the specified time.
SelectionInfo createSelectionInfo() const
Creates a new SelectionInfo based on the current camera state.
Matrix< fltp08 > viewToWorldSpace() const
Computes the transformation matrix from view space to world space.
DynamicPointer< Set< UUID > > hidden_items
Set of object UUIDs explicitly marked as hidden from this camera.
Resource< Vector< 3, Angle< fltp08 > > > orientation
The rotational orientation of the camera as Euler angles.
SnapLocation currentSnapLocation() const
Gets the current snap location that the camera is aligned to.
const Bounds< 1, fltp08 > & nearPlaneBounds() const
Gets the allowable range for the near clipping plane distance.
Bounds< 3, fltp08 > getOrthographicBounds() const
Computes the 3D axis-aligned bounds visible in orthographic mode.
void clearAnimations()
Removes all queued camera animations.
Resource< fltp08 > plane_intercept_value
The depth value at which a cutting plane intercepts the view.
void panPercent(fltp08 horizontal_percent, fltp08 vertical_percent, const CameraAnimation &original)
Pans the camera by normalized percentages, keeping the target point fixed while moving the offset.
Vector< 3, fltp08 > gotoLocation() const
Gets the target location for a pending goto animation.
void addZoomToExtentsAnimation(SnapLocation location, Bounds< 3, fltp08 > object, const TimeSpan &time, bool use_true_extents=true, bool clear_animations=true, Vector< 3, Angle< fltp08 > > angle_offsets=Vector< 3, Angle< fltp08 > >(Angle< fltp08 >(0)))
Adds an animation that zooms to fit the given bounds at a specific snap location.
void move(fltp08 horizontal_distance, fltp08 vertical_distance)
Moves the camera by the specified horizontal and vertical distances.
Matrix< fltp08 > worldToViewSpace() const
Computes the transformation matrix from world space to view space.
Resource< Vertex< 3, fltp08 > > target
The point in 3D world space the camera is looking at.
bool refreshMovement(const Time ¤t_time, const DesignObjectLookup *lookup=nullptr, const TimeSpan &time_out=TimeSpan(0.2))
Advances any active camera animations and updates the camera position and orientation.
void writeMetaData()
Writes the current camera metadata to the underlying design object storage.
void lookVertical(fltp08 percent)
Rotates the camera vertically by a normalized percentage of the view.
void readMetaData()
Reads camera metadata from the underlying design object storage.
const Bounds< 1, fltp08 > & farPlaneBounds() const
Gets the allowable range for the far clipping plane distance.
Vertex< 3, fltp08 > toWorldSpaceFromViewSpace(const Vector< 2, fltp08 > &view_location, fltp08 depth_percent) const
Converts a view-space location and depth to a 3D world-space position.
ViewportFormat format() const
Gets the viewport format descriptor for this camera.
const Ray< 3, fltp08 > & getLookat() const
Gets the current look-at ray describing the camera view direction and position.
Resource< bool > is_valid
Whether the camera is in a valid, usable state.
static constexpr StringView TypeName()
Gets the type name identifier for Camera objects.
Resource< fltp08 > far_plane
The distance from the camera to the far clipping plane.
void addZoomToExtentsAnimation(Bounds< 3, fltp08 > object, const TimeSpan &time, bool use_true_extents=true, bool clear_animations=true, Vector< 3, Angle< fltp08 > > angle_offsets=Vector< 3, Angle< fltp08 > >(Angle< fltp08 >(0)))
Adds an animation that zooms to fit the given bounds using the current orientation.
Resource< Vertex< 2, fltp08 > > cross_hairs
The 2D position of the crosshair overlay on screen.
void addAnimation(CameraAnimation animation, bool clear_current_animations=true)
Adds a camera animation to the queue.
void movePercent(fltp08 horizontal_percent, fltp08 vertical_percent)
Moves the camera by normalized horizontal and vertical percentages of the viewport.
void look(fltp08 horz_percent, fltp08 vert_percent)
Rotates the camera by normalized horizontal and vertical percentages.
void addIsOrthographicAnimation(bool is_orthographic, const TimeSpan &time, bool clear_animations=true)
Adds an animation that transitions between orthographic and perspective projection.
void move(fltp08 horizontal_distance, fltp08 vertical_distance, const CameraAnimation &original)
Moves the camera by the specified horizontal and vertical distances with animation parameters.
Matrix< fltp08 > calculateProjectionMatrix() const
Calculates the projection matrix from current camera parameters.
Resource< Time > last_visible_update_time
Timestamp of the last update to visible content.
void addZoomAnimation(fltp08 distance_mult, const TimeSpan &time, bool clear_animations=true)
Adds a zoom animation that scales the view over the specified time.
void setWindowSize(const Vector< 2, uint04 > &size)
Sets the window size for this camera viewport.
void updateSelectionInfo(const Bounds< 2, fltp04 > &pixel_location, SelectionInfo &info) const
Updates the given SelectionInfo with a rectangle-based selection at the specified pixel bounds.
void addZoomToExtentsAnimation(Vector< 3, Angle< fltp08 > > orientation, Bounds< 3, fltp08 > object, const TimeSpan &time, bool use_true_extents=true, bool clear_animations=true)
Adds an animation that zooms to fit the given bounds at a specified orientation.
void movePercent(fltp08 horizontal_percent, fltp08 vertical_percent, const CameraAnimation &original)
Moves the camera by normalized horizontal and vertical percentages with animation parameters.
Camera(const Model &camera)
Constructs a Camera from an existing Model.
A core class where all Design Objects including models, materials, and geometries are stored.
Provides a modifiable pointer that has shared ownership of a dynamically allocated object.
Templated logic for doing matrix multiplication.
Vector< 3, fltp08 > size() const
Returns the size (extents) of the model's bounding box.
Model()
Default constructor. Creates an uninitialized Model.
A core part of the engine, stores variables that can be listened to with ResourceListener which will ...
Responsible for turning a user interaction into a selection within a DesignObjectLookup.
The core String View class for the NDEVR API.
Stores a time span, or difference between two times, with an optional start time.
Represents a timestamp with utilities for manipulation and conversion.
A universally unique identifier (UUID) is a 128-bit number used to identify information in computer s...
A fixed-size array with N dimensions used as the basis for geometric and mathematical types.
A point in N-dimensional space, used primarily for spatial location information.
The primary namespace for the NDEVR SDK.
float fltp04
Defines an alias representing a 4 byte floating-point number Bit layout is as follows: -Sign: 1 bit a...
double fltp08
Defines an alias representing an 8 byte floating-point number.
SnapLocation
A list of directions that a view can be pointed relative to an object or scene.
@ e_no_snap
No snap applied; free camera orientation.
Logic for automatically zooming a Camera or Viewport to a certain location or having certain objects ...
A container for information relating to a Camera 3D animation such as zooming or rotating around a ta...
Defines for a given type (such as sint04, fltp08, UUID, etc) a maximum, minimum, and reserved 'invali...
std::function< void(const StringView &image_id)> callback
Callback invoked with the screenshot image identifier upon completion.
bool operator!=(const ScreenshotRequest &) const
Inequality operator.
bool operator==(const ScreenshotRequest &) const
Equality operator.
ScreenshotRequest(std::function< void(const StringView &image_id)> callback)
Constructs a ScreenshotRequest with the given completion callback.
ScreenshotRequest()
Default constructor.