Main Page   Class Hierarchy   Compound List   All functions   Search  

ManipulatedCameraFrame Class Reference

A Camera Frame that can be rotated and translated with the mouse. More...

Inherits ManipulatedFrame.

List of all members.

Mode

Mode mode () const
float flySpeed () const
void setMode (const Mode mode)
void toggleMode ()
void setFlySpeed (const float s)

Current state

Vec flyUpVector () const

XML representation

virtual QDomElement domElement (const QString &name, QDomDocument &doc) const
virtual void initFromDOMElement (const QDomElement &de)

Mouse event handlers

virtual void mousePressEvent (QMouseEvent *const, Camera *const)
virtual void mouseDoubleClickEvent (QMouseEvent *const, Camera *const)
virtual void mouseReleaseEvent (QMouseEvent *const, Camera *const)
virtual void mouseMoveEvent (QMouseEvent *const, const Camera *const)

Public Types

enum  Mode { REVOLVE, FLY }

Public Methods

 ManipulatedCameraFrame ()
virtual ~ManipulatedCameraFrame ()

Protected Slots

void updateFrameInFlyMode ()

Protected Methods

void updateFlyUpVector ()
Quaternion quaternionFromThetaPhi (const int x, const int y, const Camera *const camera)


Detailed Description

A Camera Frame that can be rotated and translated with the mouse.

A ManipulatedCameraFrame is a specialization of a ManipulatedFrame, designed for associated Camera frames. All mouse motions are basically interpreted in a negated way: when the mouse goes to the right, the ManipulatedFrame translation goes to the right, while the ManipulatedCameraFrame has to go to the left, so that the scene seems to move to the right.

A ManipulatedCameraFrame has two different mode() (defined by the Mode() enum):

See the mouse page for a description of the mouse button bindings for these two modes.

You can switch between the two camera modes using the CAMERA_MODE QGLViewer::shortcutKey() (space by default). The flySpeed() (same as Camera::flySpeed()) of the Camera is determined from the QGLViewer::sceneRadius() of the scene (see QGLViewer::setSceneRadius()). Use the + and - keys to modify this value.

In FLY mode(), the camera is rotated around the camera X-axis (vertical mouse motion) or the flyUpVector() (horizontal mouse motion). This flyUpVector() determines the horizon of the scene, which will remain horizontal during the walkthrough. Use Camera::setUpVector() or the mouse (see the mouse page) to change the flyUpVector().

The ManipulatedFrame::isManipulated() function is used to call QGLViewer::fastDraw() instead of QGLViewer::draw() for interactive scene displays when the camera is manipulated (see the fastDraw example).


Member Enumeration Documentation

enum Mode
 

Mode() describes the different modes of the ManipulatedCameraFrame, set by setMode():

  • In REVOLVE mode, the frame revolves around the Camera::revolveAroundPoint().
  • The FLY mode is designed for walkthrough applications. The camera can move forward or backward in the scene, as if it was flying.
Enumeration values:
REVOLVE 
FLY 


Constructor & Destructor Documentation

ManipulatedCameraFrame  
 

Creates a default ManipulatedCameraFrame. mode is set to REVOLVE. Created object is removeFromMouseGrabberPool().

virtual ~ManipulatedCameraFrame   [inline, virtual]
 

Virtual destructor. Empty.


Member Function Documentation

QDomElement domElement const QString &    name,
QDomDocument &    doc
const [virtual]
 

Creates an XML QDomElement that represents the ManipulatedCameraFrame. Add to ManipulatedFrame::domElement() the ManipulatedCameraFrame specific informations. name is the name of the QDomElement tag. You need to provide the QDomDocument doc that will hold the resulting element.

Use initFromDOMElement() to restore the ManipulatedCameraFrame state from the resulting domElement.

Reimplemented from ManipulatedFrame.

float flySpeed   const [inline]
 

Returns the current fly speed (used when mode() is FLY). Set with setFlySpeed(). Set according to the QGLViewer::sceneRadius() in QGLViewer::setSceneRadius().

Vec flyUpVector   const [inline]
 

Return the up vector used in FLY mode. The vector is orthogonal to the horizontal plane. Horizontal displacement of the mouse rotates the frame around this vector. It is expressed in the world coordinate system.

void initFromDOMElement const QDomElement &    de [virtual]
 

Restore the ManipulatedCameraFrame state from a QDomElement created by domElement(). See also Frame::initFromDOMElement().

Reimplemented from ManipulatedFrame.

Mode mode   const [inline]
 

Returns the current ManipulatedCameraFrame mode. Mode is set by setMode(). Returned values are defined by the Mode() enum.

void mouseDoubleClickEvent QMouseEvent *    const,
Camera   const
[protected, virtual]
 

When the user double clicks on the mouse (see QGLViewer::mouseDoubleClickEvent()):

Reimplemented from ManipulatedFrame.

void mouseMoveEvent QMouseEvent *    const,
const Camera   const
[protected, virtual]
 

Move the camera frame according to the mouse motion. The camera is given as an argument so that its parameters (width and height of the window, fieldOfView) are available in order to fit the mouse motion and the display. Emits manipulated().

Reimplemented from ManipulatedFrame.

void mousePressEvent QMouseEvent *    const,
Camera   const
[protected, virtual]
 

The mouse behavior depends on mode(). In REVOLVE, it behaves essentially like a ManipulatedFrame, while FLY mode() is designed for walkthrough applications. See the QGLViewer mouse page for details.

Reimplemented from ManipulatedFrame.

void mouseReleaseEvent QMouseEvent *    const,
Camera   const
[protected, virtual]
 

When the user releases the mouse button, the manipulatedFrame action is stopped.

If the action was a rotation (REVOLVE mode()), a continuous spinning is possible if the speed of the cursor is larger than spinningSensitivity() when the button is released. Press the rotate button again to stop the spinning.

Reimplemented from ManipulatedFrame.

Quaternion quaternionFromThetaPhi const int    x,
const int    y,
const Camera *const    camera
[protected]
 

Set lastQuat according to the mouse motion. Simple Theta-Phi inferred from the X-flyUpVector() axis.

void setFlySpeed const float    s [inline, slot]
 

When ManipulatedCameraFrame is in FLY mode(), this value tunes the speed of the displacement. Current value is given by flySpeed().

void setMode const Mode    m [slot]
 

Defines the ManipulatedCameraFrame mode(). Supported modes are defined by the Mode() enum. Use toggleMode() and setMode() to change mode (or directly use the CAMERA_MODE QGLViewer::shortcutKey(), space by default):

camera()->setMode(qglviewer::ManipulatedCameraFrame::FLY); 
qglviewer:: is not necessary if you "use namespace qglviewer;".

void toggleMode   [slot]
 

Change manipulatedFrame mode (defined by the Mode() enum), see mode().

void updateFlyUpVector   [protected]
 

This function will be called by the camera when the camera orientation is changed, so that the flyUpVector (private) is changed accordingly. You should not need to call this function.

void updateFrameInFlyMode   [protected, slot]
 

Called for continuous frame motion in FLY mode. Emits manipulated().


Generated on Fri Jun 27 18:34:04 2003 for libQGLViewer by doxygen1.3-rc2