#include <zoompancontroller.h>
Public Member Functions | |
| ZoomPanControllerInstance (EntityInstance &entity, Component &resource) | |
| virtual bool | init (utility::ErrorState &errorState) override |
| virtual void | update (double deltaTime) override |
| void | frameTexture (const Texture2D &texture, nap::TransformComponentInstance &ioTextureTransform, float scale=1.0f) |
| void | frameTexture (const glm::vec2 &textureSize, nap::TransformComponentInstance &ioTextureTransform, float scale=1.0f) |
| void | reset () |
| float | getZoomLevel () const |
| nap::OrthoCameraComponentInstance & | getCamera () |
Public Member Functions inherited from ComponentInstance | |
| ComponentInstance (EntityInstance &entity, Component &resource) | |
| nap::EntityInstance * | getEntityInstance () const |
| nap::Component * | getComponent () const |
| template<typename T > | |
| T * | getComponent () const |
| virtual bool | init (utility::ErrorState &errorState) |
Public Member Functions inherited from Object | |
| Object () | |
| virtual | ~Object () |
| virtual void | onDestroy () |
| Object (Object &)=delete | |
| Object & | operator= (const Object &)=delete |
| Object (Object &&)=delete | |
| Object & | operator= (Object &&)=delete |
Additional Inherited Members | |
Static Public Member Functions inherited from Object | |
| static bool | isIDProperty (rtti::Instance &object, const rtti::Property &property) |
Public Attributes inherited from Object | |
| std::string | mID |
| Property: 'mID' unique name of the object. Used as an identifier by the system. More... | |
2D texture zoom and pan camera controller.
Allows for freely moving around and zooming into a 2D texture using an orthographic camera. Use the 'frameTexture' function to adjust the scale and position of your texture, ensuring it fits perfectly in the viewport.
This component updates the projection and transform matrix of an orthographic camera, based on pointer input events. It therefore requires the following components to be present on the same entity.
After calling 'frameTexture':
Not calling 'frameTexture' allows you to use your own texture scale and orthographic camera settings. Note that for the component to work properly it can't have any parent transform, if it does the the result is undefined.
| ZoomPanControllerInstance | ( | EntityInstance & | entity, |
| Component & | resource | ||
| ) |
| void frameTexture | ( | const glm::vec2 & | textureSize, |
| nap::TransformComponentInstance & | ioTextureTransform, | ||
| float | scale = 1.0f |
||
| ) |
Scales and positions a texture to perfectly fit in the viewport. The adjusted transform can be applied to a uniform 1m2 (default) plane to position it correctly in this frame. The current zoom and pan levels are reset and the camera position, viewport, and clipping planes are adjusted to capture the texture:
- The texture is placed at a depth of (z)0, with dimensions adjusted to fit in the current viewport. - The camera is placed at (xy)0 at a depth of (z)5. - The camera planes will match the size of the viewport. - The near and far clipping planes are setup to include the framed texture.
Avoid calling this function if you need to manually control the orthographic camera.
| textureSize | size of the texture |
| ioTextureTransform | the texture transform to update |
| scale | multiplication factor, defaults to 1 (perfect fit) |
| void frameTexture | ( | const Texture2D & | texture, |
| nap::TransformComponentInstance & | ioTextureTransform, | ||
| float | scale = 1.0f |
||
| ) |
Scales and positions a texture to perfectly fit in the viewport. The adjusted transform can be applied to a uniform 1m2 (default) plane to position it correctly in this frame. The current zoom and pan levels are reset and the camera position, viewport, and clipping planes are adjusted to capture the texture:
- The texture is placed at a depth of (z)0, with dimensions adjusted to fit in the current viewport. - The camera is placed at (xy)0 at a depth of (z)5. - The camera planes will match the size of the viewport. - The near and far clipping planes are setup to include the framed texture.
Avoid calling this function if you need to manually control the orthographic camera.
| textureSize | size of the texture |
| ioTextureTransform | the texture transform to update |
| scale | multiplication factor, defaults to 1 (perfect fit) |
| nap::OrthoCameraComponentInstance& getCamera | ( | ) |
| float getZoomLevel | ( | ) | const |
Returns the current zoom level, where 0 = completely zoomed in, 1 = framed in window and anything higher is zoomed out.
|
overridevirtual |
Initializes the component based on the resource.
| errorState | the error message when initialization fails |
Reimplemented from ComponentInstance.
| void reset | ( | ) |
Updates the camera planes to match size of the viewport.
|
overridevirtual |
update pancontrollerInstance. This is called by NAP core automatically
| deltaTime | time in between frames in seconds |
Reimplemented from ComponentInstance.