|
Katana Plug-in APIs 0.1
|
Interface for a layer in the Viewport. More...
#include <FnViewportLayer.h>
Public Member Functions | |
| ViewportWrapperPtr | getViewport () |
| Gets the Viewport. | |
| void | hover (bool isHovering, int x, int y) |
| Called when the mouse hovers the ViewportLayer. | |
| void | pick (unsigned int x, unsigned int y, unsigned int w, unsigned int h, bool deepPicking, PickedAttrsMap &pickedAttrs, float *singlePointDepth=NULL) |
| Picks the objects that are inside a given viewport region. | |
Interface for a layer in the Viewport.
A ViewportLayer (or layer) is an optional component of a Viewport that is responsible for a specific set of drawing and/or event processing. Examples of possible layers that can be implemented in a viewer:
The ViewportLayer allows a better code organization, but the most important reason for their existence is code reusability. Since they are independent plug-ins they can be reused on different Viewports and Viewers.
Every ViewportLayer instance has a Viewport associated with it. That Viewport can create and manage several ViewportLayers. The Viewport makes sure that the setup(), draw(), resize() and event() functions in its ViewportLayers are called for all of them.
A ViewportLayer also allows picking / selection of rendered objects in the scene inside a certain region of the viewport. This can be a deep picking (all objects inside the region, independently if they are occluded or not from the current camera point of view) or it can select only the visible objects. The Viewport provides an optional internal mechanism that makes use of an internal ID pass framebuffer. This can be used by implementing the pickerDraw() virtual function, calling addPickableObject() in it. If the rendering technology provides its own picking mechanism, then it can be used by implementing the customPick() function, which will not make use of the internal ID picking, and pickerDraw() will not be called. This mechanism also is present in the Viewport plugin type.
This is a virtual base class to be extended in your plug-in. In addition to implementing all the pure virtual functions in this class, you must also implement this static method in your derived class:
// Returns a new instance of your derived class. static ViewportLayer* create();
To indicate an error to the caller, your implementation may throw an exception derived from std::exception.
ViewerDelegate is the class that plugins should extend and implement.
ViewerDelegateWrapper is the class that allows other plugin types to access the ViewerDelegate plugin.
ViewerDelegatePluginBase is the base class that provides the common methods between ViewerDelegate and ViewerDelegateWrapper.
| ViewportWrapperPtr Foundry::Katana::ViewerAPI::ViewportLayerPluginBase::getViewport | ( | ) |
| void Foundry::Katana::ViewerAPI::ViewportLayerPluginBase::hover | ( | bool | isHovering, |
| int | x, | ||
| int | y | ||
| ) |
Called when the mouse hovers the ViewportLayer.
Layers can detect when the mouse is hovering them so that, for example, objects under the mouse pointer can be highlighted. This is called with the correct GL context so that GL based picking can be executed.
| isHovering | Flag that specifies if the mouse is hovering the layer. If false, then the mouse left the layer. In this case x and y should be ignored. |
| x | The horizontal pixel coordinate of the mouse pointer in the layer's local coordinate system. |
| y | The vertical pixel coordinate of the mouse pointer in the layer's local coordinate system. |
Reimplemented in Foundry::Katana::ViewerAPI::ViewportLayer.
| void Foundry::Katana::ViewerAPI::ViewportLayerPluginBase::pick | ( | unsigned int | x, |
| unsigned int | y, | ||
| unsigned int | w, | ||
| unsigned int | h, | ||
| bool | deepPicking, | ||
| PickedAttrsMap & | pickedAttrs, | ||
| float * | singlePointDepth = NULL |
||
| ) |
Picks the objects that are inside a given viewport region.
Allows to query the scene for objects that are visible inside a given rectangular region in the viewport. This region can be a single pixel on the screen, by setting both its width and height to 1.
The object picking can optionally be deep, meaning that all the objects viewed inside the region will be picked even if they are currently occluded by other objects. A non-deep picking means that only currently visible objects inside the region will be picked.
Picking can be implemented in two ways:
pickerDraw() and addPickableObject().customPick().This function makes use of whatever picking technique is implemented in this ViewportLayer.
This function returns a map of picking IDs to Attributes that represent the picked objects and, optionally a depth value for when the picked region is one single pixel.
| x | The region origin X component in viewport pixels. | |
| y | The region origin Y component in viewport pixels. | |
| w | The region width in viewport pixels. | |
| h | The region height in viewport pixels. | |
| deepPicking | Specifies if all objects inside the region, including occluded ones, will be picked. If set to false, only the visible objects should be picked. This should not be set to true in very frequent events, like a mouse move, since this might trigger several calls to pickerDraw(). | |
| [out] | pickedAttrs | A map top be filled with FnPickId (key) to Attribute (value) pairs that represent the picked objects. Internally, this will be either populated by customPick() or by addPickableObject() calls inside pickerDraw(). PickedAttrsMap has the same public interface as std::map<FnPickId, FnAttributes::Attribute>. |
| [out] | singlePointDepth | The value pointed by this will be set with the GL depth of a single pixel when the region with and height are both 1 and this pointer is set to something other than NULL. This can be used to solve occlusion between picked objects from the Viewport and different ViewportLayers when, for example, the user clicks on a single pixel when selecting something. |
1.7.3