#include <MRViewport.h>
Classes | |
struct | LinePointImmediateRenderParams |
Rendering parameters for immediate drawing of lines and points. More... | |
struct | Parameters |
struct | PickRenderObjectParams |
struct | TriCornerColors |
Public Types | |
using | ViewportRectangle = MR::ViewportRectangle |
using | PickRenderObjectPredicate = std::function<bool ( const VisualObject*, ViewportMask )> |
using | FitMode = MR::FitMode |
using | BaseFitParams = MR::BaseFitParams |
using | FitDataParams = MR::FitDataParams |
using | FitBoxParams = MR::FitBoxParams |
Public Member Functions | |
MRVIEWER_API | Viewport () |
MRVIEWER_API | ~Viewport () |
Viewport | clone () const |
Viewport (Viewport &&) noexcept=default | |
Viewport & | operator= (Viewport &&) noexcept=default |
MRVIEWER_API void | init () |
MRVIEWER_API void | setAxesPos (const int pixelXoffset=-100, const int pixelYoffset=-100) |
MRVIEWER_API void | setAxesSize (const int axisPixSize=80) |
MRVIEWER_API void | shut () |
MRVIEWER_API void | clearFramebuffers () |
MRVIEWER_API bool | draw (const VisualObject &obj, DepthFunction depthFunc=DepthFunction::Default, RenderModelPassMask pass=RenderModelPassMask::All, bool allowAlphaSort=false) const |
MRVIEWER_API bool | draw (const VisualObject &obj, const AffineXf3f &xf, DepthFunction depthFunc=DepthFunction::Default, RenderModelPassMask pass=RenderModelPassMask::All, bool allowAlphaSort=false) const |
MRVIEWER_API bool | draw (const VisualObject &obj, const AffineXf3f &xf, const Matrix4f &projM, DepthFunction depthFunc=DepthFunction::Default, RenderModelPassMask pass=RenderModelPassMask::All, bool allowAlphaSort=false) const |
MRVIEWER_API void | drawLines (const std::vector< LineSegm3f > &lines, const std::vector< SegmEndColors > &colors, const LinePointImmediateRenderParams ¶ms) |
Draw lines immediately. | |
void | drawLines (const std::vector< LineSegm3f > &lines, const std::vector< SegmEndColors > &colors, float width=1, bool depthTest=true) |
MRVIEWER_API void | drawPoints (const std::vector< Vector3f > &points, const std::vector< Vector4f > &colors, const LinePointImmediateRenderParams ¶ms) |
Draw points immediately. | |
void | drawPoints (const std::vector< Vector3f > &points, const std::vector< Vector4f > &colors, float width=1, bool depthTest=true) |
MRVIEWER_API void | drawTris (const std::vector< Triangle3f > &tris, const std::vector< TriCornerColors > &colors, const ModelRenderParams ¶ms, bool depthTest=true) |
Draw triangles immediately (flat shaded) | |
MRVIEWER_API void | drawTris (const std::vector< Triangle3f > &tris, const std::vector< TriCornerColors > &colors, const Matrix4f &modelM={}, bool depthTest=true) |
BaseRenderParams | getBaseRenderParams () const |
Prepares base rendering parameters for this viewport. | |
BaseRenderParams | getBaseRenderParams (const Matrix4f &projM) const |
Prepares base rendering parameters for this viewport with custom projection matrix. | |
ModelRenderParams | getModelRenderParams (const Matrix4f &modelM, Matrix4f *normM, DepthFunction depthFunc=DepthFunction::Default, RenderModelPassMask pass=RenderModelPassMask::All, bool allowAlphaSort=false) const |
Prepares rendering parameters to draw a model with given transformation in this viewport. | |
MRVIEWER_API ModelRenderParams | getModelRenderParams (const Matrix4f &modelM, const Matrix4f &projM, Matrix4f *normM, DepthFunction depthFunc=DepthFunction::Default, RenderModelPassMask pass=RenderModelPassMask::All, bool allowAlphaSort=false) const |
Prepares rendering parameters to draw a model with given transformation in this viewport with custom projection matrix. | |
MRVIEWER_API ObjAndPick | pickRenderObject (const PickRenderObjectParams ¶ms=PickRenderObjectParams::defaults()) const |
MRVIEWER_API ObjAndPick | pickRenderObject (std::span< VisualObject *const > objects, const PickRenderObjectParams ¶ms=PickRenderObjectParams::defaults()) const |
MRVIEWER_API ConstObjAndPick | pickRenderObjectConst (std::span< const VisualObject *const > objects, const PickRenderObjectParams ¶ms=PickRenderObjectParams::defaults()) const |
MRVIEWER_API ObjAndPick | pick_render_object () const |
MRVIEWER_API ObjAndPick | pick_render_object (uint16_t pickRadius) const |
MRVIEWER_API ObjAndPick | pick_render_object (const std::vector< VisualObject * > &objects) const |
MRVIEWER_API ObjAndPick | pick_render_object (const std::vector< VisualObject * > &objects, uint16_t pickRadius, bool exactPickFirst=true) const |
MRVIEWER_API ObjAndPick | pick_render_object (bool exactPickFirst) const |
MRVIEWER_API ObjAndPick | pick_render_object (const Vector2f &viewportPoint) const |
MRVIEWER_API ObjAndPick | pick_render_object (const std::vector< VisualObject * > &objects, const Vector2f &viewportPoint) const |
MRVIEWER_API std::vector< ObjAndPick > | multiPickObjects (std::span< VisualObject *const > objects, const std::vector< Vector2f > &viewportPoints) const |
MRVIEWER_API std::vector< std::shared_ptr< VisualObject > > | findObjectsInRect (const Box2i &rect, int maxRenderResolutionSide=512) const |
MRVIEWER_API std::unordered_map< std::shared_ptr< ObjectMesh >, FaceBitSet > | findVisibleFaces (const BitSet &includePixBs, int maxRenderResolutionSide=512) const |
MRVIEWER_API ConstObjAndPick | const_pick_render_object () const |
MRVIEWER_API ConstObjAndPick | const_pick_render_object (const std::vector< const VisualObject * > &objects) const |
MRVIEWER_API std::vector< ConstObjAndPick > | constMultiPickObjects (const std::vector< const VisualObject * > &objects, const std::vector< Vector2f > &viewportPoints) const |
MRVIEWER_API void | transformView (const AffineXf3f &xf) |
bool | getRedrawFlag () const |
void | resetRedrawFlag () |
MRVIEWER_API void | setRotation (bool state) |
MRVIEWER_API const ViewportRectangle & | getViewportRect () const |
MRVIEWER_API float | getPixelSize () const |
MRVIEWER_API float | getPixelSizeAtPoint (const Vector3f &worldPoint) const |
MRVIEWER_API void | setViewportRect (const ViewportRectangle &rect) |
MRVIEWER_API AffineXf3f | getUnscaledViewXf () const |
returns orthonormal matrix with translation | |
AffineXf3f | getViewXf () const |
converts directly from the view matrix | |
Vector3f | getUpDirection () const |
returns unit vector in world space corresponding to up-direction in camera space | |
Vector3f | getRightDirection () const |
returns unit vector in world space corresponding to right-direction in camera space | |
Vector3f | getBackwardDirection () const |
returns unit vector in world space corresponding to direction toward camera in camera space | |
MRVIEWER_API Line3f | unprojectPixelRay (const Vector2f &viewportPoint) const |
MRVIEWER_API Vector3f | worldToCameraSpace (const Vector3f &p) const |
MRVIEWER_API std::vector< Vector3f > | worldToCameraSpace (const std::vector< Vector3f > &p) const |
MRVIEWER_API Vector3f | projectToClipSpace (const Vector3f &worldPoint) const |
MRVIEWER_API std::vector< Vector3f > | projectToClipSpace (const std::vector< Vector3f > &worldPoints) const |
MRVIEWER_API Vector3f | unprojectFromClipSpace (const Vector3f &clipPoint) const |
MRVIEWER_API std::vector< Vector3f > | unprojectFromClipSpace (const std::vector< Vector3f > &clipPoints) const |
MRVIEWER_API Vector3f | projectToViewportSpace (const Vector3f &worldPoint) const |
MRVIEWER_API std::vector< Vector3f > | projectToViewportSpace (const std::vector< Vector3f > &worldPoints) const |
MRVIEWER_API Vector3f | unprojectFromViewportSpace (const Vector3f &viewportPoint) const |
MRVIEWER_API std::vector< Vector3f > | unprojectFromViewportSpace (const std::vector< Vector3f > &viewportPoints) const |
MRVIEWER_API Vector3f | clipSpaceToViewportSpace (const Vector3f &p) const |
MRVIEWER_API std::vector< Vector3f > | clipSpaceToViewportSpace (const std::vector< Vector3f > &p) const |
MRVIEWER_API Vector3f | viewportSpaceToClipSpace (const Vector3f &p) const |
MRVIEWER_API std::vector< Vector3f > | viewportSpaceToClipSpace (const std::vector< Vector3f > &p) const |
void | setupView () |
void | preDraw () |
void | postDraw () const |
MRVIEWER_API void | fitData (float fill=1.0f, bool snapView=true) |
MRVIEWER_API void | fitBox (const Box3f &newSceneBox, float fill=1.0f, bool snapView=true) |
MRVIEWER_API void | preciseFitBoxToScreenBorder (const FitBoxParams ¶ms) |
MRVIEWER_API void | preciseFitDataToScreenBorder (const FitDataParams ¶ms={}) |
MRVIEWER_API float | getRatio () const |
MRVIEWER_API bool | allModelsInsideViewportRectangle () const |
MRVIEWER_API const Box3f & | getSceneBox () const |
const Parameters & | getParameters () const |
MRVIEWER_API Vector3f | getCameraPoint () const |
MRVIEWER_API void | setCameraPoint (const Vector3f &cameraWorldPos) |
MRVIEWER_API void | setCameraTrackballAngle (const Quaternionf &rot) |
MRVIEWER_API void | setCameraTranslation (const Vector3f &translation) |
MRVIEWER_API void | setCameraViewAngle (float newViewAngle) |
MRVIEWER_API void | setCameraZoom (float zoom) |
MRVIEWER_API void | setOrthographic (bool orthographic) |
MRVIEWER_API void | setBackgroundColor (const Color &color) |
MRVIEWER_API void | setClippingPlane (const Plane3f &plane) |
MRVIEWER_API void | setLabel (std::string s) |
void | setSelectable (bool on) |
MRVIEWER_API void | showAxes (bool on) |
MRVIEWER_API void | showClippingPlane (bool on) |
MRVIEWER_API void | showRotationCenter (bool on) |
MRVIEWER_API void | showGlobalBasis (bool on) |
MRVIEWER_API void | rotationCenterMode (Parameters::RotationCenterMode mode) |
MRVIEWER_API void | setParameters (const Viewport::Parameters ¶ms) |
MRVIEWER_API void | cameraLookAlong (const Vector3f &dir, const Vector3f &up) |
MRVIEWER_API void | cameraRotateAround (const Line3f &axis, float angle) |
MRVIEWER_API Vector3f | getRotationPivot () const |
Static Public Member Functions | |
static MRVIEWER_API Viewport & | get (ViewportId viewportId={}) |
Public Attributes | |
ViewportId | id { 1} |
using MR::Viewport::FitMode = MR::FitMode |
using MR::Viewport::PickRenderObjectPredicate = std::function<bool ( const VisualObject*, ViewportMask )> |
MRVIEWER_API MR::Viewport::Viewport | ( | ) |
MRVIEWER_API MR::Viewport::~Viewport | ( | ) |
|
defaultnoexcept |
MRVIEWER_API bool MR::Viewport::allModelsInsideViewportRectangle | ( | ) | const |
MRVIEWER_API void MR::Viewport::cameraLookAlong | ( | const Vector3f & | dir, |
const Vector3f & | up ) |
MRVIEWER_API void MR::Viewport::cameraRotateAround | ( | const Line3f & | axis, |
float | angle ) |
MRVIEWER_API void MR::Viewport::clearFramebuffers | ( | ) |
MRVIEWER_API std::vector< Vector3f > MR::Viewport::clipSpaceToViewportSpace | ( | const std::vector< Vector3f > & | p | ) | const |
MRVIEWER_API Vector3f MR::Viewport::clipSpaceToViewportSpace | ( | const Vector3f & | p | ) | const |
|
inlinenodiscard |
MRVIEWER_API ConstObjAndPick MR::Viewport::const_pick_render_object | ( | ) | const |
MRVIEWER_API ConstObjAndPick MR::Viewport::const_pick_render_object | ( | const std::vector< const VisualObject * > & | objects | ) | const |
MRVIEWER_API std::vector< ConstObjAndPick > MR::Viewport::constMultiPickObjects | ( | const std::vector< const VisualObject * > & | objects, |
const std::vector< Vector2f > & | viewportPoints ) const |
MRVIEWER_API bool MR::Viewport::draw | ( | const VisualObject & | obj, |
const AffineXf3f & | xf, | ||
const Matrix4f & | projM, | ||
DepthFunction | depthFunc = DepthFunction::Default, | ||
RenderModelPassMask | pass = RenderModelPassMask::All, | ||
bool | allowAlphaSort = false ) const |
Immediate draw of given object with given transformation to world and given projection matrix Returns true if something was drawn.
MRVIEWER_API bool MR::Viewport::draw | ( | const VisualObject & | obj, |
const AffineXf3f & | xf, | ||
DepthFunction | depthFunc = DepthFunction::Default, | ||
RenderModelPassMask | pass = RenderModelPassMask::All, | ||
bool | allowAlphaSort = false ) const |
Immediate draw of given object with given transformation to world Returns true if something was drawn.
MRVIEWER_API bool MR::Viewport::draw | ( | const VisualObject & | obj, |
DepthFunction | depthFunc = DepthFunction::Default, | ||
RenderModelPassMask | pass = RenderModelPassMask::All, | ||
bool | allowAlphaSort = false ) const |
Immediate draw of given object with transformation to world taken from object's scene Returns true if something was drawn.
MRVIEWER_API void MR::Viewport::drawLines | ( | const std::vector< LineSegm3f > & | lines, |
const std::vector< SegmEndColors > & | colors, | ||
const LinePointImmediateRenderParams & | params ) |
Draw lines immediately.
|
inline |
MRVIEWER_API void MR::Viewport::drawPoints | ( | const std::vector< Vector3f > & | points, |
const std::vector< Vector4f > & | colors, | ||
const LinePointImmediateRenderParams & | params ) |
Draw points immediately.
|
inline |
MRVIEWER_API void MR::Viewport::drawTris | ( | const std::vector< Triangle3f > & | tris, |
const std::vector< TriCornerColors > & | colors, | ||
const Matrix4f & | modelM = {}, | ||
bool | depthTest = true ) |
MRVIEWER_API void MR::Viewport::drawTris | ( | const std::vector< Triangle3f > & | tris, |
const std::vector< TriCornerColors > & | colors, | ||
const ModelRenderParams & | params, | ||
bool | depthTest = true ) |
Draw triangles immediately (flat shaded)
MRVIEWER_API std::vector< std::shared_ptr< VisualObject > > MR::Viewport::findObjectsInRect | ( | const Box2i & | rect, |
int | maxRenderResolutionSide = 512 ) const |
MRVIEWER_API std::unordered_map< std::shared_ptr< ObjectMesh >, FaceBitSet > MR::Viewport::findVisibleFaces | ( | const BitSet & | includePixBs, |
int | maxRenderResolutionSide = 512 ) const |
MRVIEWER_API void MR::Viewport::fitBox | ( | const Box3f & | newSceneBox, |
float | fill = 1.0f, | ||
bool | snapView = true ) |
MRVIEWER_API void MR::Viewport::fitData | ( | float | fill = 1.0f, |
bool | snapView = true ) |
|
static |
Return the current viewport, or the viewport corresponding to a given unique identifier from ViewerInstance()
viewportId | unique identifier corresponding to the desired viewport (current viewport if 0) |
|
inlinenodiscard |
returns unit vector in world space corresponding to direction toward camera in camera space
|
inlinenodiscard |
Prepares base rendering parameters for this viewport.
|
inlinenodiscard |
Prepares base rendering parameters for this viewport with custom projection matrix.
MRVIEWER_API Vector3f MR::Viewport::getCameraPoint | ( | ) | const |
|
nodiscard |
Prepares rendering parameters to draw a model with given transformation in this viewport with custom projection matrix.
normM | if not null, this matrix of normals transformation will be computed and referenced in the result |
allowAlphaSort | If not null and the object is semitransparent, enable alpha-sorting. |
|
inlinenodiscard |
Prepares rendering parameters to draw a model with given transformation in this viewport.
modelM | model to world transformation, this matrix will be referenced in the result |
normM | if not null, this matrix of normals transformation will be computed and referenced in the result |
allowAlphaSort | If not null and the object is semitransparent, enable alpha-sorting. |
|
inline |
MRVIEWER_API float MR::Viewport::getPixelSize | ( | ) | const |
MRVIEWER_API float MR::Viewport::getPixelSizeAtPoint | ( | const Vector3f & | worldPoint | ) | const |
MRVIEWER_API float MR::Viewport::getRatio | ( | ) | const |
|
inline |
|
inlinenodiscard |
returns unit vector in world space corresponding to right-direction in camera space
MRVIEWER_API Vector3f MR::Viewport::getRotationPivot | ( | ) | const |
MRVIEWER_API const Box3f & MR::Viewport::getSceneBox | ( | ) | const |
|
nodiscard |
returns orthonormal matrix with translation
|
inlinenodiscard |
returns unit vector in world space corresponding to up-direction in camera space
MRVIEWER_API const ViewportRectangle & MR::Viewport::getViewportRect | ( | ) | const |
|
inlinenodiscard |
converts directly from the view matrix
MRVIEWER_API void MR::Viewport::init | ( | ) |
MRVIEWER_API std::vector< ObjAndPick > MR::Viewport::multiPickObjects | ( | std::span< VisualObject *const > | objects, |
const std::vector< Vector2f > & | viewportPoints ) const |
MRVIEWER_API ObjAndPick MR::Viewport::pick_render_object | ( | ) | const |
MRVIEWER_API ObjAndPick MR::Viewport::pick_render_object | ( | bool | exactPickFirst | ) | const |
MRVIEWER_API ObjAndPick MR::Viewport::pick_render_object | ( | const std::vector< VisualObject * > & | objects | ) | const |
MRVIEWER_API ObjAndPick MR::Viewport::pick_render_object | ( | const std::vector< VisualObject * > & | objects, |
const Vector2f & | viewportPoint ) const |
MRVIEWER_API ObjAndPick MR::Viewport::pick_render_object | ( | const std::vector< VisualObject * > & | objects, |
uint16_t | pickRadius, | ||
bool | exactPickFirst = true ) const |
MRVIEWER_API ObjAndPick MR::Viewport::pick_render_object | ( | const Vector2f & | viewportPoint | ) | const |
MRVIEWER_API ObjAndPick MR::Viewport::pick_render_object | ( | uint16_t | pickRadius | ) | const |
MRVIEWER_API ObjAndPick MR::Viewport::pickRenderObject | ( | const PickRenderObjectParams & | params = PickRenderObjectParams::defaults() | ) | const |
MRVIEWER_API ObjAndPick MR::Viewport::pickRenderObject | ( | std::span< VisualObject *const > | objects, |
const PickRenderObjectParams & | params = PickRenderObjectParams::defaults() ) const |
MRVIEWER_API ConstObjAndPick MR::Viewport::pickRenderObjectConst | ( | std::span< const VisualObject *const > | objects, |
const PickRenderObjectParams & | params = PickRenderObjectParams::defaults() ) const |
void MR::Viewport::postDraw | ( | ) | const |
MRVIEWER_API void MR::Viewport::preciseFitBoxToScreenBorder | ( | const FitBoxParams & | params | ) |
MRVIEWER_API void MR::Viewport::preciseFitDataToScreenBorder | ( | const FitDataParams & | params = {} | ) |
void MR::Viewport::preDraw | ( | ) |
MRVIEWER_API std::vector< Vector3f > MR::Viewport::projectToClipSpace | ( | const std::vector< Vector3f > & | worldPoints | ) | const |
MRVIEWER_API Vector3f MR::Viewport::projectToClipSpace | ( | const Vector3f & | worldPoint | ) | const |
MRVIEWER_API std::vector< Vector3f > MR::Viewport::projectToViewportSpace | ( | const std::vector< Vector3f > & | worldPoints | ) | const |
MRVIEWER_API Vector3f MR::Viewport::projectToViewportSpace | ( | const Vector3f & | worldPoint | ) | const |
|
inline |
MRVIEWER_API void MR::Viewport::rotationCenterMode | ( | Parameters::RotationCenterMode | mode | ) |
MRVIEWER_API void MR::Viewport::setAxesPos | ( | const int | pixelXoffset = -100, |
const int | pixelYoffset = -100 ) |
MRVIEWER_API void MR::Viewport::setAxesSize | ( | const int | axisPixSize = 80 | ) |
MRVIEWER_API void MR::Viewport::setBackgroundColor | ( | const Color & | color | ) |
MRVIEWER_API void MR::Viewport::setCameraPoint | ( | const Vector3f & | cameraWorldPos | ) |
MRVIEWER_API void MR::Viewport::setCameraTrackballAngle | ( | const Quaternionf & | rot | ) |
MRVIEWER_API void MR::Viewport::setCameraTranslation | ( | const Vector3f & | translation | ) |
MRVIEWER_API void MR::Viewport::setCameraViewAngle | ( | float | newViewAngle | ) |
MRVIEWER_API void MR::Viewport::setCameraZoom | ( | float | zoom | ) |
MRVIEWER_API void MR::Viewport::setClippingPlane | ( | const Plane3f & | plane | ) |
MRVIEWER_API void MR::Viewport::setLabel | ( | std::string | s | ) |
MRVIEWER_API void MR::Viewport::setOrthographic | ( | bool | orthographic | ) |
MRVIEWER_API void MR::Viewport::setParameters | ( | const Viewport::Parameters & | params | ) |
MRVIEWER_API void MR::Viewport::setRotation | ( | bool | state | ) |
|
inline |
void MR::Viewport::setupView | ( | ) |
MRVIEWER_API void MR::Viewport::setViewportRect | ( | const ViewportRectangle & | rect | ) |
MRVIEWER_API void MR::Viewport::showAxes | ( | bool | on | ) |
MRVIEWER_API void MR::Viewport::showClippingPlane | ( | bool | on | ) |
MRVIEWER_API void MR::Viewport::showGlobalBasis | ( | bool | on | ) |
MRVIEWER_API void MR::Viewport::showRotationCenter | ( | bool | on | ) |
MRVIEWER_API void MR::Viewport::shut | ( | ) |
MRVIEWER_API void MR::Viewport::transformView | ( | const AffineXf3f & | xf | ) |
MRVIEWER_API std::vector< Vector3f > MR::Viewport::unprojectFromClipSpace | ( | const std::vector< Vector3f > & | clipPoints | ) | const |
MRVIEWER_API Vector3f MR::Viewport::unprojectFromClipSpace | ( | const Vector3f & | clipPoint | ) | const |
MRVIEWER_API std::vector< Vector3f > MR::Viewport::unprojectFromViewportSpace | ( | const std::vector< Vector3f > & | viewportPoints | ) | const |
MRVIEWER_API Vector3f MR::Viewport::unprojectFromViewportSpace | ( | const Vector3f & | viewportPoint | ) | const |
MRVIEWER_API Line3f MR::Viewport::unprojectPixelRay | ( | const Vector2f & | viewportPoint | ) | const |
MRVIEWER_API std::vector< Vector3f > MR::Viewport::viewportSpaceToClipSpace | ( | const std::vector< Vector3f > & | p | ) | const |
MRVIEWER_API Vector3f MR::Viewport::viewportSpaceToClipSpace | ( | const Vector3f & | p | ) | const |
MRVIEWER_API std::vector< Vector3f > MR::Viewport::worldToCameraSpace | ( | const std::vector< Vector3f > & | p | ) | const |
MRVIEWER_API Vector3f MR::Viewport::worldToCameraSpace | ( | const Vector3f & | p | ) | const |
ViewportId MR::Viewport::id { 1} |