H3D API
2.4.1
|
The base class for all window nodes. More...
#include <H3D/H3DWindowNode.h>
Classes | |
class | RenderMode |
The mode for rendering specified as a string. More... | |
class | WindowSizeChanged |
Class which handles the windows resizing related operations. More... | |
Public Member Functions | |
H3DWindowNode (Inst< SFInt32 > _width=0, Inst< SFInt32 > _height=0, Inst< SFBool > _fullscreen=0, Inst< SFBool > _mirrored=0, Inst< RenderMode > _renderMode=0, Inst< SFViewpoint > _viewpoint=0, Inst< SFInt32 > _posX=0, Inst< SFInt32 > _posY=0, Inst< SFBool > _manualCursorControl=0, Inst< SFString > _cursorType=0, Inst< SFNavigationInfo > _navigationInfo=0, Inst< SFBool > _useFullscreenAntiAliasing=0, Inst< SFVec2f > _clipDistances=0, Inst< SFBool > _singlePassStereo=0, Inst< SFString > _pointingDeviceRefreshMode=0, Inst< SFBool > _resetViewPoint=0, Inst< SFInt32 > _numSamples=0) | |
Constructor. | |
~H3DWindowNode () | |
Destructor. | |
virtual void | swapBuffers ()=0 |
Virtual function to swap buffers. | |
virtual void | initWindow ()=0 |
Virtual function that should create a new window and set its properties depending on the fields. More... | |
virtual void | deinitWindow () |
Virtual function to clean up all that was created in initWindow. | |
virtual void | initWindowHandler ()=0 |
Virtual function to initialize the window handler if needed. More... | |
virtual void | setFullscreen (bool fullscreen)=0 |
Virtual function to set whether the window should be fullscreen or not. | |
virtual void | makeWindowActive ()=0 |
Virtual function to make the current window active, i.e. More... | |
virtual void | initialize () |
Initialize the window node. | |
virtual void | render (X3DChildNode *child_to_render) |
This function renders the X3DChildNode given into the window of the H3DWindowNode. | |
virtual void | reshape (int w, int h) |
This function will be called when the window size has changed. | |
virtual void | display () |
This function is called when the window has to redraw itself. | |
virtual void | onKeyDown (int key, bool special) |
This function should be called by a window when a key is pressed. More... | |
virtual void | onKeyUp (int key, bool special) |
This function should be called by a window when a key is released. More... | |
virtual void | onMouseButtonAction (int button, int state) |
This function should be called by a window when a mouse button is pressed or released. More... | |
virtual void | onMouseMotionAction (int x, int y) |
This function should be called by a window when a mouse sends a motion event. More... | |
virtual void | onMouseWheelAction (int direction) |
This function should be called by a window when a mouse wheel is scrolled either from or towards the user For values of direction see MouseSensor.h. | |
virtual void | shareRenderingContext (H3DWindowNode *w) |
This function shares the rendering context between this H3DWindowNode and the one given as an argument. More... | |
operator HWND () | |
Class Conversion Operator For Window Handle (H3DWindowNode Can Be Used As A Window Handle) | |
![]() | |
Node () | |
Constructor. | |
virtual Node * | clone (bool deepCopy=true, DeepCopyMap *deepCopyMap=NULL) |
Returns a new instance of this node type with the same state as this one. More... | |
virtual | ~Node () |
Destructor. | |
X3DPrototypeInstance * | getProtoInstanceParent () |
If this node is the root node in the proto body of a X3DPrototypeInstance then this will return that node. More... | |
void | setProtoInstanceParent (X3DPrototypeInstance *p) |
Set the X3DPrototypeInstance this node is the the root node if applicaple. | |
virtual void | render () |
the render() function is used for the depth-first rendering traversal of the scene-graph. More... | |
virtual void | traverseSG (TraverseInfo &ti) |
traverseSG is called once per scenegraph loop on the scene in order to traverse the scenegraph. More... | |
virtual bool | lineIntersect (const Vec3f &from, const Vec3f &to, LineIntersectResult &result) |
Detect intersection between a line segment and the Node. More... | |
virtual void | closestPoint (const Vec3f &p, NodeIntersectResult &result) |
Find closest point on Node to p. More... | |
virtual bool | movingSphereIntersect (H3DFloat radius, const Vec3f &from, const Vec3f &to, NodeIntersectResult &result) |
Detect collision between a moving sphere and the Node. More... | |
virtual string | defaultXMLContainerField () |
Returns the default xml containerField attribute value. More... | |
virtual Field * | getField (const string &_name) const |
return a pointer to the field specified by name within this instance | |
int | addDestructCallback (void(*func)(Node *, void *), void *args) |
Add a callback function to be run on destruction of node. More... | |
int | removeDestructCallback (void(*func)(Node *, void *), void *args) |
Add a callback function to be run on destruction of node. More... | |
Static Public Member Functions | |
static bool | calculateFarAndNearPlane (H3DFloat &far, H3DFloat &near, X3DChildNode *child, X3DViewpointNode *vp, bool include_stylus) |
Calculate the far and near clipping planes from the bounding box of a X3DChildNode. More... | |
static string | takeScreenShot (const string &url) |
static string | takeScreenshot (const string &url) |
Saves the currently rendered buffer to file. More... | |
![]() | |
static unsigned int | nrNodesAlive () |
Returns the nr of nodes currently alive, i.e. nodes created but not destructed. | |
static int | nrNodesCreated () |
Returns the number of nodes created in total since the start of the program. | |
Public Attributes | |
H3DUniquePtr< SFInt32 > | posX |
The x coordinate in pixels of the window in screen coordinates. More... | |
H3DUniquePtr< SFInt32 > | posY |
The y coordinate in pixels of the window in screen coordinates. More... | |
H3DUniquePtr< SFInt32 > | width |
The width in pixels of the window. More... | |
H3DUniquePtr< SFInt32 > | height |
The height in pixels of the window. More... | |
H3DUniquePtr< SFBool > | fullscreen |
Determines if the window should be in fullscreen or not. More... | |
H3DUniquePtr< SFBool > | mirrored |
Determines if the scene rendered should be mirrored or not. More... | |
H3DUniquePtr< RenderMode > | renderMode |
The mode to render the scene in the window in. More... | |
H3DUniquePtr< SFViewpoint > | viewpoint |
If the viewpoint field is specified, that viewpoint is used by the rendering in H3DWindowNode instead of the stack top of the Viewpoint bindable stack. More... | |
H3DUniquePtr< SFBool > | manualCursorControl |
If set to true changes of cursor is totally up to the user of the window by changing the cursorType. More... | |
H3DUniquePtr< SFString > | cursorType |
The cursorType field specifies the look of the mouse pointer. More... | |
H3DUniquePtr< SFNavigationInfo > | navigationInfo |
If the navigationInfo field is specified, that NavigationInfo is used for rendering in H3DWindowNode instead of the stack top of the NavigationInfo bindable stack. More... | |
H3DUniquePtr< SFVec2f > | clipDistances |
The distance (in meters) used for the far and near clip plane. More... | |
H3DUniquePtr< SFBool > | useFullscreenAntiAliasing |
If set to true fullscreen anti-aliasing is used for this window. More... | |
H3DUniquePtr< SFInt32 > | viewportWidth |
The width of the viewport being used for this window Access type: outputOnly . | |
H3DUniquePtr< SFInt32 > | projectionWidth |
The width of the projection width, mostly of the time it is the same as the viewport width. More... | |
H3DUniquePtr< SFInt32 > | viewportHeight |
The height of the viewport being used for this window Access type: outputOnly . | |
H3DUniquePtr< SFInt32 > | projectionHeight |
The height of the projection height, mostly of the time it is the same as the viewport height. More... | |
H3DUniquePtr< SFBool > | singlePassStereo |
Flag for whether singlePassStereo is enabled or not. More... | |
H3DUniquePtr< SFString > | pointingDeviceRefreshMode |
Determines how often the X3DPointingDeviceSensorNode's in the scene will be checked for intersection. More... | |
H3DUniquePtr< SFBool > | resetViewPoint |
Reset viewpoint Access type: inputOutput Default value: false . | |
H3DUniquePtr< SFInt32 > | numSamples |
Number of samples used by this window. More... | |
Static Public Attributes | |
static H3DNodeDatabase | database |
The H3DNodeDatabase for this node. | |
Protected Member Functions | |
void | initWindowWithContext () |
internal help function to initialize the window and check if success. More... | |
LRESULT | Message (HWND _hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) |
Handles messages. Called by WindowProc. | |
void | renderChild (X3DChildNode *child_to_render, bool render_fbo_only) |
Help function for renderChild. | |
virtual int | setCursorType (const std::string &) |
Set the cursor to the given cursor type. More... | |
virtual string | getCursorForMode (const string &) |
Return the cursor type to use for given modes. More... | |
![]() | |
void | cloneFieldValue (Field &_from, Field &_to, bool deepCopy, DeepCopyMap &deepCopyMap) |
A helper function for the clone() method. More... | |
Static Protected Member Functions | |
static LRESULT CALLBACK | WindowProc (HWND _hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) |
Whenever a subclass to H3DWindowNode is created this callback is a subclass callback. More... | |
static void | setMultiPassTransparency (bool b) |
If multi pass transparency is set to true the scene will be rendered three times graphically, once for all solid objects, once for the back side of transparent objects and once for the front face of transparent objects. More... | |
![]() | |
static Node * | getClonedInstance (Node *original, bool deepCopy, DeepCopyMap &deepCopyMap) |
A helper function for nodes that implement clone() More... | |
Protected Attributes | |
RenderMode::Mode | last_render_mode |
The render mode used in the last render loop. | |
X3DViewpointNode::EyeMode | eye_mode |
Current eye mode. | |
string | current_cursor |
The cursor currently in use. | |
H3DUniquePtr< WindowSizeChanged > | windowSizeChanged |
Field handles necessary operations needed when window size actually changes. | |
Additional Inherited Members | |
![]() | |
typedef std::map< Node *, Node * > | DeepCopyMap |
A map type used during a deep copy clone() to map from original nodes to cloned nodes. | |
The base class for all window nodes.
A H3DWindowNode handles creation of windows and window properties for looking into a Scene. To implement a new window class the following functions have to be specified: swapBuffers(), initWindow(), initWindowHandler(), setFullscreen( bool fullscreen ) makeWindowActive(), setCursorType( const std::string & cursor_mode ) and getCursorForMode. For example implementation see GLUTWindow.
|
static |
Calculate the far and near clipping planes from the bounding box of a X3DChildNode.
The far and near planes will be calculated on contain the node but nothing else. Requires the bounding box type to be BoxBound.
far | Return param for the far plane. |
near | Return param for the near plane. |
child | The child node we want to be visible. |
vp | The Viewpoint in the scene. |
include_stylus | if true the stylus from each HapticsDevice in DeviceInfo will also be included in the calculations of the planes. The bounding box we will use is then the union of the stylus fields and the child parameter. |
References H3D::X3DViewpointNode::accForwardMatrix, H3D::X3DViewpointNode::accInverseMatrix, H3D::H3DBoundedObject::bound, H3D::Bound::boundUnion(), H3D::TransformedBoxBound::boxBound, H3D::BoxBound::center, H3D::DeviceInfo::device, H3D::DeviceInfo::getActive(), H3D::TransformedBoxBound::matrix, Rotation(), H3D::BoxBound::size, H3D::H3DHapticsDevice::stylus, H3D::X3DViewpointNode::totalOrientation, H3D::X3DViewpointNode::totalPosition, H3D::H3DHapticsDevice::trackerOrientation, H3D::MatrixTransform::transformedBound, and H3D::H3DHapticsDevice::weightedProxyPosition.
Referenced by H3D::FrameBufferTextureGenerator::render(), and render().
|
inlineprotectedvirtual |
Return the cursor type to use for given modes.
This should be implemented for each subclass to choose appropriate cursors. The standard modes are: "DEFAULT" - normal mode "ON_SENSOR_OVER" - when mouse pointer is over a pointing device sensor. "ON_SENSOR_ACTIVE" - when a sensor node is active "ON_NAV_LOOKAT" - when lookat mode is chosen
Reimplemented in H3D::GLUTWindow.
Referenced by render().
|
pure virtual |
Virtual function that should create a new window and set its properties depending on the fields.
This function should set window_is_made_active to true if window is made active at initialization.
Implemented in H3D::GLUTWindow.
Referenced by initWindowWithContext().
|
pure virtual |
Virtual function to initialize the window handler if needed.
E.g. glutInit().
Implemented in H3D::GLUTWindow.
Referenced by initialize().
|
protected |
internal help function to initialize the window and check if success.
it will call the initWindow function to initialize the window.
References initWindow(), H3D::H3DWindowNode::RenderMode::MONO, and renderMode.
Referenced by initialize(), and render().
|
pure virtual |
Virtual function to make the current window active, i.e.
make subsequent OpenGL calls draw in the context of this window. This function should set window_is_made_activeto true if window is made active.
Implemented in H3D::GLUTWindow.
Referenced by render().
|
virtual |
This function should be called by a window when a key is pressed.
When special is true the key is a special key enumerated in X3DKeyDeviceSensorNode.h The window handles the translation from its internal behaviour to ASCII and the special numbers.
key | Specifies the key that is pressed. |
special | True when the key is a special key, and false when it is not. |
References H3D::X3DKeyDeviceSensorNode::keyboardDownCallback(), and H3D::X3DKeyDeviceSensorNode::keyboardSpecialDownCallback().
Referenced by H3D::GLUTWindow::glutKeyboardDownCallback(), H3D::GLUTWindow::glutSpecialDownCallback(), and Message().
|
virtual |
This function should be called by a window when a key is released.
When special is true the key is a special key enumerated in X3DKeyDeviceSensorNode.h The window handles the translation from its internal behaviour to ASCII and the special numbers.
key | Specifies the key that is released |
special | True when the key is a special key, and false when it is not. |
References H3D::X3DKeyDeviceSensorNode::keyboardSpecialUpCallback(), and H3D::X3DKeyDeviceSensorNode::keyboardUpCallback().
Referenced by H3D::GLUTWindow::glutKeyboardUpCallback(), H3D::GLUTWindow::glutSpecialUpCallback(), and Message().
|
virtual |
This function should be called by a window when a mouse button is pressed or released.
For values of button and state see MouseSensor.h
button | specifies the mouse button pressed or released |
state | shows that the button is pressed or released |
References H3D::MouseSensor::buttonCallback(), and H3D::H3DNavigation::leftButtonUpdate().
Referenced by H3D::GLUTWindow::glutMouseCallback(), and Message().
|
virtual |
This function should be called by a window when a mouse sends a motion event.
x, y are window relative coordinates
References H3D::MouseSensor::motionCallback(), H3D::H3DNavigation::motionUpdate(), and x.
Referenced by H3D::GLUTWindow::glutMotionCallback(), and Message().
|
inlineprotectedvirtual |
Set the cursor to the given cursor type.
See cursorType field for valid values. Returns 0 on success. -1 if the cursor_type is not supported.
Reimplemented in H3D::GLUTWindow.
Referenced by render().
|
inlinestaticprotected |
If multi pass transparency is set to true the scene will be rendered three times graphically, once for all solid objects, once for the back side of transparent objects and once for the front face of transparent objects.
This is in order to avoid artifacts for transparent objects when rendered in the wrong order.
Referenced by H3D::Scene::idle().
|
virtual |
This function shares the rendering context between this H3DWindowNode and the one given as an argument.
This means that the two windows after the call can share display lists and textures. When several H3DWindowNode instances are created this function will always be called to share the rendering context between them, i.e. all H3DWindowNode instances share rendering context by default.
References H3D_FULL_LOCATION.
Referenced by initialize().
|
static |
References takeScreenshot().
|
static |
Saves the currently rendered buffer to file.
That is, a screenshot of the openGL window.
References H3DUtil::saveFreeImagePNG().
Referenced by takeScreenShot().
|
staticprotected |
Whenever a subclass to H3DWindowNode is created this callback is a subclass callback.
The only function of this callback is to send the right events to KeySensor. When the events are processed it calls the Window Procedure stored in wpOrigProc.
References Message().
H3DUniquePtr< SFVec2f > H3D::H3DWindowNode::clipDistances |
The distance (in meters) used for the far and near clip plane.
Near plane is x, far plane is y. A value of -1 for far plane means that far plane is at infinity.
Access type: outputOnly
Referenced by H3DWindowNode(), and render().
H3DUniquePtr< SFString > H3D::H3DWindowNode::cursorType |
The cursorType field specifies the look of the mouse pointer.
For the user to be in control of what cursorType should be shown the manualCursorControl field must be set to true. The valid values depend on the underlying window system so query the valid values before setting a cursor type. See implementations of H3DWindowNode such as GLUTWindow or wxWindowNode to see that cursors they support.
Access type: inputOutput
Default value: "DEFAULT"
Valid values: Different depending on implementation.
Referenced by H3D::GLUTWindow::GLUTWindow(), H3DWindowNode(), and render().
H3DUniquePtr< SFBool > H3D::H3DWindowNode::fullscreen |
Determines if the window should be in fullscreen or not.
Access type: inputOutput
Default value: FALSE
Referenced by H3D::GLUTWindow::GLUTWindow(), H3DWindowNode(), H3D::GLUTWindow::initWindow(), and render().
H3DUniquePtr< SFInt32 > H3D::H3DWindowNode::height |
The height in pixels of the window.
Access type: inputOutput
Default value: 600
Referenced by H3DWindowNode(), H3D::GLUTWindow::initWindow(), render(), reshape(), and H3D::GLUTWindow::setFullscreen().
H3DUniquePtr< SFBool > H3D::H3DWindowNode::manualCursorControl |
If set to true changes of cursor is totally up to the user of the window by changing the cursorType.
If false, H3D API will control which cursor to show, changing cursor when e.g. a X3DPointingDeviceSensorNode is being pointed at.
Access type: inputOutput
Default value: false
Referenced by H3DWindowNode(), and render().
H3DUniquePtr< SFBool > H3D::H3DWindowNode::mirrored |
Determines if the scene rendered should be mirrored or not.
Access type: inputOutput
Default value: FALSE
Referenced by H3DWindowNode(), and render().
H3DUniquePtr< SFNavigationInfo > H3D::H3DWindowNode::navigationInfo |
If the navigationInfo field is specified, that NavigationInfo is used for rendering in H3DWindowNode instead of the stack top of the NavigationInfo bindable stack.
This is so that multiple windows with different NavigationInfos can be specified.
Access type: inputOutput
Default value: NULL
Referenced by render().
H3DUniquePtr< SFInt32 > H3D::H3DWindowNode::numSamples |
Number of samples used by this window.
Access type: outputOnly
Default value: 0
Referenced by H3DWindowNode(), and H3D::FrameBufferTextureGenerator::preProcessFBO().
H3DUniquePtr< SFString > H3D::H3DWindowNode::pointingDeviceRefreshMode |
Determines how often the X3DPointingDeviceSensorNode's in the scene will be checked for intersection.
Access type: inputOutput
Default value: "MOUSE_MOVE"
Referenced by H3DWindowNode(), and render().
H3DUniquePtr< SFInt32 > H3D::H3DWindowNode::posX |
The x coordinate in pixels of the window in screen coordinates.
Access type: inputOutput
Default value: -1 meaning let the window manager choose
Referenced by H3DWindowNode(), and H3D::GLUTWindow::initWindow().
H3DUniquePtr< SFInt32 > H3D::H3DWindowNode::posY |
The y coordinate in pixels of the window in screen coordinates.
Access type: inputOutput
Default value: -1 meaning let the window manager choose
Referenced by H3DWindowNode(), and H3D::GLUTWindow::initWindow().
H3DUniquePtr< SFInt32 > H3D::H3DWindowNode::projectionHeight |
The height of the projection height, mostly of the time it is the same as the viewport height.
This value is used to define the projection frustum height Access type: outputOnly
Referenced by H3D::FrameBufferTextureGenerator::render(), and render().
H3DUniquePtr< SFInt32 > H3D::H3DWindowNode::projectionWidth |
The width of the projection width, mostly of the time it is the same as the viewport width.
This value is used to define the projection frustum width
Referenced by H3D::FrameBufferTextureGenerator::render(), and render().
H3DUniquePtr< RenderMode > H3D::H3DWindowNode::renderMode |
The mode to render the scene in the window in.
See RenderMode::Mode for valid values. Values are specified as a string with the same name as the enum value of the mode you want.
Access type: inputOutput
Default value: "MONO"
Referenced by H3D::FrameBufferTextureGenerator::blitColorBuffer(), H3DWindowNode(), initialize(), H3D::GLUTWindow::initWindow(), initWindowWithContext(), H3D::FrameBufferTextureGenerator::render(), render(), and H3D::H3DWindowNode::WindowSizeChanged::update().
H3DUniquePtr< SFBool > H3D::H3DWindowNode::singlePassStereo |
Flag for whether singlePassStereo is enabled or not.
A change in this flag should trigger shader rebuilds.
Access type: outputOnly
Default value: false
Referenced by H3DWindowNode(), and render().
H3DUniquePtr< SFBool > H3D::H3DWindowNode::useFullscreenAntiAliasing |
If set to true fullscreen anti-aliasing is used for this window.
This will smooth the appearance of objects and reduce jaggedness of the rendering.
Access type: initializeOnly
Default value: true
Referenced by H3DWindowNode(), and H3D::GLUTWindow::initWindow().
H3DUniquePtr< SFViewpoint > H3D::H3DWindowNode::viewpoint |
If the viewpoint field is specified, that viewpoint is used by the rendering in H3DWindowNode instead of the stack top of the Viewpoint bindable stack.
This is so that multiple windows with different viewpoints can be specified.
Access type: inputOutput
Default value: NULL
Referenced by render().
H3DUniquePtr< SFInt32 > H3D::H3DWindowNode::width |
The width in pixels of the window.
Access type: inputOutput
Default value: 800
Referenced by H3DWindowNode(), H3D::GLUTWindow::initWindow(), render(), reshape(), and H3D::GLUTWindow::setFullscreen().