H3D API  2.4.1
Public Member Functions | Public Attributes | List of all members
H3D::Viewpoint Class Reference

The Viewpoint node defines a viewpoint that provides a perspective view of the scene. More...

#include <H3D/Viewpoint.h>

Inheritance diagram for H3D::Viewpoint:
Inheritance graph

Public Member Functions

 Viewpoint (Inst< SFSetBind > _set_bind=0, Inst< SFVec3f > _centerOfRotation=0, Inst< SFString > _description=0, Inst< SFFloat > _fieldOfView=0, Inst< SFBool > _jump=0, Inst< SFNode > _metadata=0, Inst< SFOrientation > _orientation=0, Inst< SFPosition > _position=0, Inst< SFBool > _retainUserOffsets=0, Inst< SFTime > _bindTime=0, Inst< SFBool > _isBound=0, Inst< SFMatrix4f > _accForwardMatrix=0, Inst< SFMatrix4f > _accInverseMatrix=0)
 Constructor.
 
virtual bool windowFromfieldOfView (H3DFloat width, H3DFloat height, H3DFloat clip_near, H3DFloat &top, H3DFloat &bottom, H3DFloat &right, H3DFloat &left)
 Calculates the top, bottom, right and left clipping values for the view frustum at the near plane. More...
 
virtual void setupProjection (EyeMode eye_mode, H3DFloat width, H3DFloat height, H3DFloat clip_near, H3DFloat clip_far, StereoInfo *stereo_info=0, bool update_stereo_proj_shift=false)
 Set up perspective projection matrix. More...
 
- Public Member Functions inherited from H3D::X3DViewpointNode
 X3DViewpointNode (Inst< SFSetBind > _set_bind=0, Inst< SFVec3f > _centerOfRotation=0, Inst< SFString > _description=0, Inst< SFBool > _jump=0, Inst< SFNode > _metadata=0, Inst< SFOrientation > _orientation=0, Inst< SFPosition > _position=0, Inst< SFBool > _retainUserOffsets=0, Inst< SFTime > _bindTime=0, Inst< SFBool > _isBound=0, Inst< SFMatrix4f > _accForwardMatrix=0, Inst< SFMatrix4f > _accInverseMatrix=0, Inst< SFSumVec3f > _totalPosition=0, Inst< SFSumRotation > _totalOrientation=0)
 Constructor.
 
virtual ~X3DViewpointNode ()
 Destructor.
 
virtual void traverseSG (TraverseInfo &ti)
 Traverse the scenegraph. More...
 
virtual void toStackTop ()
 Move this instance to the stack top.
 
virtual void removeFromStack ()
 Remove the bindable node from the stack.
 
virtual void rotateAround (Rotation rotation, bool collision, Vec3f rotation_center)
 Function for rotating the viewpoint around rotation_center without changing the position or orientation fields. More...
 
virtual void rotateAroundSelf (Rotation rotation)
 without changing the position or orientation fields.
 
virtual void translate (Vec3f direction, bool collision, const vector< H3DFloat > &avatar_size, X3DChildNode *topNode)
 Function for translating the viewpoint with direction without changing the position or orientation fields. More...
 
virtual void moveTo (Vec3f new_pos)
 Function for moving the viewpoint to the new_pos without changing the position or orientation fields.
 
virtual bool detectCollision (const vector< H3DFloat > &avatar_size, X3DChildNode *topNode)
 Function for detecting collision between avatar and objects.
 
virtual Matrix4f getProjectionMatrix (EyeMode eye_mode, H3DFloat width, H3DFloat height, H3DFloat clip_near, H3DFloat clip_far, StereoInfo *stereo_info=0, bool mirrored_in_y=false)
 Gets the projectionMatrix for this viewpoint, i.e. More...
 
virtual void setupViewMatrix (EyeMode eye_mode, StereoInfo *stereo_info=0, bool update_stereo_view_shift=false)
 Adds a view matrix to the current OpenGL matrix to transform from view coordinates (camera/viewpoint space) to world space. More...
 
virtual Matrix4f getViewMatrix (EyeMode eye_mode, StereoInfo *stereo_info=0)
 Gets the viewMatrix for this viewpoint, i.e. More...
 
bool isTopLevel ()
 True if this viewpoint node exists outside a ViewpointGroup.
 
bool inSceneGraph ()
 True if this viewpoint node exists in scene graph.
 
- Public Member Functions inherited from H3D::X3DBindableNode
 X3DBindableNode (const string &_bindable_stack_name, Inst< SFSetBind > _set_bind=0, Inst< SFNode > _metadata=0, Inst< SFTime > _bindTime=0, Inst< SFBool > _isBound=0)
 Constructor.
 
virtual ~X3DBindableNode ()
 Destructor.
 
virtual void initialize ()
 Initialize this bindable stack, toStackTop is done.
 
bool isStackTop ()
 Is this node at the top of the stack.
 
- Public Member Functions inherited from H3D::X3DChildNode
 X3DChildNode (Inst< SFNode > _metadata=0)
 Constructor.
 
- Public Member Functions inherited from H3D::X3DNode
 X3DNode (Inst< SFNode > _metadata=0)
 Constructor.
 
X3DMetadataObjectgetMetadataByName (const string &_name)
 Given a name, the first X3DMetadataObject in the metadata field that matches that name is returned. More...
 
- Public Member Functions inherited from H3D::Node
 Node ()
 Constructor.
 
virtual Nodeclone (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.
 
X3DPrototypeInstancegetProtoInstanceParent ()
 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 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 FieldgetField (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...
 

Public Attributes

H3DUniquePtr< SFFloatfieldOfView
 The fieldOfView field specifies a preferred minimum viewing angle from this viewpoint in radians. More...
 
- Public Attributes inherited from H3D::X3DViewpointNode
H3DUniquePtr< SFVec3fcenterOfRotation
 The centerOfRotation field specifies a center about which to rotate the user's eyepoint when in EXAMINE mode. More...
 
H3DUniquePtr< SFStringdescription
 The description field specifies a textual description of the X3DViewpointNode node. More...
 
H3DUniquePtr< SFBooljump
 The jump field specifies whether the user's view "jumps" to the position and orientation of a bound X3DViewpointNode node or remains unchanged. More...
 
H3DUniquePtr< SFOrientationorientation
 Specifies the orientation of the X3DViewpointNode relative to the default orientation. More...
 
H3DUniquePtr< SFPositionposition
 Specifies the position of the X3DViewpointNode the local coordinate system. More...
 
H3DUniquePtr< SFBoolretainUserOffsets
 The retainUserOffsets field indicates whether a viewpoint needs to retain (TRUE) or reset to zero (FALSE) any prior user navigation offsets from defined viewpoint position, orientation. More...
 
H3DUniquePtr< SFMatrix4faccForwardMatrix
 The matrix from local space to global space. More...
 
H3DUniquePtr< SFMatrix4faccInverseMatrix
 The matrix from global space to the local space the X3DViewpointNode resides in. More...
 
H3DUniquePtr< SFSumVec3ftotalPosition
 Returns the sum of the field position and the internal field relPos used for navigation. More...
 
H3DUniquePtr< SFSumRotationtotalOrientation
 Returns the sum of the field orientation and the internal field relOrn used for navigation. More...
 
H3DUniquePtr< SFVec3frelPos
 Internal field that stores the relative offset from the position set by the user. More...
 
H3DUniquePtr< SFRotationrelOrn
 Internal field that stores the relative offset from the orientation set by the user. More...
 
- Public Attributes inherited from H3D::X3DBindableNode
H3DUniquePtr< SFSetBindset_bind
 Input field to bind or unbind the node. More...
 
H3DUniquePtr< SFTimebindTime
 The bindTime field is the time at which the Viewpoint node is bound or unbound. More...
 
H3DUniquePtr< SFBoolisBound
 Output field telling if this node is bound or not. More...
 
- Public Attributes inherited from H3D::X3DNode
H3DUniquePtr< SFNodemetadata
 Meta data about the node. More...
 

Additional Inherited Members

- Public Types inherited from H3D::X3DViewpointNode
enum  EyeMode { MONO = 0 , LEFT_EYE = 1 , RIGHT_EYE = 2 , BOTH_EYE = 3 }
 Used with setupProjection function to indicate for which eye the frustum should be calculated. More...
 
- Public Types inherited from H3D::Node
typedef std::map< Node *, Node * > DeepCopyMap
 A map type used during a deep copy clone() to map from original nodes to cloned nodes.
 
- Static Public Member Functions inherited from H3D::X3DViewpointNode
static X3DViewpointNodegetActive ()
 Convenience function to get the top of the X3DViewpointNode stack.
 
static const ViewpointList & getAllViewpoints ()
 Returns a list of all current X3DViewpointNode instances.
 
static bool viewpointsChanged ()
 True on any addition/deletion/in_scene_graph status change of viewpoints, reset once inquired.
 
- Static Public Member Functions inherited from H3D::X3DBindableNode
static X3DBindableNodegetActive (const string &bindable_stack_name)
 Returns the active bindable instance, i.e. More...
 
static const StackType & getStack (const string &bindable_stack_name)
 Get the stack for a given name.
 
static const StackMapType & getStackMap ()
 Return the map of all bindable nodes available.
 
- Static Public Member Functions inherited from H3D::Node
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.
 
- Static Public Attributes inherited from H3D::X3DBindableNode
static H3DNodeDatabase database
 The H3DNodedatabase for this node.
 
- Static Public Attributes inherited from H3D::X3DNode
static H3DNodeDatabase database
 The H3DNodeDatabase for this node.
 
- Protected Member Functions inherited from H3D::Node
void cloneFieldValue (Field &_from, Field &_to, bool deepCopy, DeepCopyMap &deepCopyMap)
 A helper function for the clone() method. More...
 
- Static Protected Member Functions inherited from H3D::Node
static NodegetClonedInstance (Node *original, bool deepCopy, DeepCopyMap &deepCopyMap)
 A helper function for nodes that implement clone() More...
 
- Protected Attributes inherited from H3D::X3DViewpointNode
bool is_top_level
 True if the viewpooint exists outside a ViewpointGroup.
 
bool in_scene_graph
 True is the viewpoint exists in scene graph.
 
- Static Protected Attributes inherited from H3D::X3DBindableNode
static StackMapType stack
 The bindable stack.
 

Detailed Description

The Viewpoint node defines a viewpoint that provides a perspective view of the scene.

A perspective view is one in which all projectors are coalesce at position.

The fieldOfView field specifies a preferred minimum viewing angle from this viewpoint in radians. A small field of view roughly corresponds to a telephoto lens; a large field of view roughly corresponds to a wide-angle lens. The field of view shall be greater than zero and smaller than pi. The value of fieldOfView represents the minimum viewing angle in any direction axis perpendicular to the view. A browser with a rectangular viewing projection has the following relationship: display width tan(FOVhorizontal/2)
-----------— = ----------------—
display height tan(FOVvertical/2)
where the smaller of display width or display height determines which angle equals the fieldOfView (the larger angle is computed using the relationship described above). The larger angle shall not exceed pi and may force the smaller angle to be less than fieldOfView in order to sustain the aspect ratio.

Examples:

Member Function Documentation

◆ setupProjection()

void Viewpoint::setupProjection ( EyeMode  eye_mode,
H3DFloat  width,
H3DFloat  height,
H3DFloat  clip_near,
H3DFloat  clip_far,
StereoInfo stereo_info = 0,
bool  update_stereo_proj_shift = false 
)
virtual

Set up perspective projection matrix.

clip_far = -1 means far plane at infinity.

Implements H3D::X3DViewpointNode.

◆ windowFromfieldOfView()

bool Viewpoint::windowFromfieldOfView ( H3DFloat  width,
H3DFloat  height,
H3DFloat  clip_near,
H3DFloat top,
H3DFloat bottom,
H3DFloat right,
H3DFloat left 
)
virtual

Calculates the top, bottom, right and left clipping values for the view frustum at the near plane.

Must be implemented by all subclasses.

Parameters
[in]widthWidth of window in number of pixels.
[in]heightHeight of window in number of pixels.
[in]clip_nearDistance to near plane from viewpoint in meters.
[out]topThe top clipping value.
[out]bottomThe bottom clipping value.
[out]rightThe right clipping value.
[out]leftThe left clipping value.

Implements H3D::X3DViewpointNode.

References fieldOfView.

Member Data Documentation

◆ fieldOfView

H3DUniquePtr< SFFloat > H3D::Viewpoint::fieldOfView

The fieldOfView field specifies a preferred minimum viewing angle from this viewpoint in radians.

Access type: inputOutput
Default value: pi/4
Value range: (0,pi)

Referenced by Viewpoint(), and windowFromfieldOfView().


The documentation for this class was generated from the following files: