2004-03-25 15:55:25 +01:00
|
|
|
/****************************************************************************
|
|
|
|
* VCGLib o o *
|
|
|
|
* Visual and Computer Graphics Library o o *
|
|
|
|
* _ O _ *
|
2007-07-14 14:43:44 +02:00
|
|
|
* Copyright(C) 2004 \/)\/ *
|
2004-03-25 15:55:25 +01:00
|
|
|
* Visual Computing Lab /\/| *
|
|
|
|
* ISTI - Italian National Research Council | *
|
|
|
|
* \ *
|
|
|
|
* All rights reserved. *
|
|
|
|
* *
|
2007-07-14 14:43:44 +02:00
|
|
|
* This program is free software; you can redistribute it and/or modify *
|
2004-03-25 15:55:25 +01:00
|
|
|
* it under the terms of the GNU General Public License as published by *
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or *
|
|
|
|
* (at your option) any later version. *
|
|
|
|
* *
|
|
|
|
* This program is distributed in the hope that it will be useful, *
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
|
|
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt) *
|
|
|
|
* for more details. *
|
|
|
|
* *
|
|
|
|
****************************************************************************/
|
|
|
|
/****************************************************************************
|
|
|
|
History
|
|
|
|
|
|
|
|
$Log: not supported by cvs2svn $
|
2007-12-21 13:29:34 +01:00
|
|
|
Revision 1.16 2007/07/14 12:43:44 benedetti
|
|
|
|
Added Doxygen documentation.
|
|
|
|
|
2007-07-14 14:43:44 +02:00
|
|
|
Revision 1.15 2007/06/13 17:15:08 benedetti
|
|
|
|
Added one-level undo system and sticky trackmodes.
|
|
|
|
|
2007-06-13 19:15:09 +02:00
|
|
|
Revision 1.14 2007/05/15 15:00:47 benedetti
|
|
|
|
Moved the drawing code to trackmodes, some other minor changes
|
|
|
|
|
2007-05-15 17:00:47 +02:00
|
|
|
Revision 1.13 2007/02/26 01:30:02 cignoni
|
|
|
|
Added reflection Name
|
|
|
|
|
2007-02-26 02:30:02 +01:00
|
|
|
Revision 1.12 2007/01/15 15:04:15 tarini
|
|
|
|
added "ToAscii" and "SetFromAscii" methods to load/store current trackball status from/to ascii strings
|
|
|
|
(intended uses: clipboard operations and comments inside png snapshots!)
|
|
|
|
|
2007-01-15 16:04:15 +01:00
|
|
|
Revision 1.11 2006/08/23 15:40:57 marfr960
|
|
|
|
*** empty log message ***
|
|
|
|
|
2006-08-23 17:41:32 +02:00
|
|
|
Revision 1.10 2006/02/13 13:15:52 cignoni
|
|
|
|
Added Scale and Translate methods.
|
|
|
|
Added many drawing hints and raised the default num. of steps when drawing circles.
|
|
|
|
Added MouseDown without coords (for remembering changes of keys modifiers)
|
|
|
|
Added ZMode to the default modes under Alt+left
|
|
|
|
Added DrawPostApply (to be completed)
|
|
|
|
|
2006-02-13 14:15:52 +01:00
|
|
|
Revision 1.9 2005/10/17 01:29:46 cignoni
|
|
|
|
Main restructuring. Removed the Draw function and slightly changed the meaning of the trackball itself.
|
|
|
|
See the notes at the beginning of trackball.h
|
|
|
|
|
2005-10-17 03:29:46 +02:00
|
|
|
Revision 1.8 2004/07/11 22:06:56 cignoni
|
|
|
|
Added scaling by wheel
|
|
|
|
|
2004-07-12 00:06:56 +02:00
|
|
|
Revision 1.7 2004/06/09 14:01:13 cignoni
|
|
|
|
Heavily restructured. To be completed only rotation works...
|
|
|
|
|
2004-06-09 16:01:13 +02:00
|
|
|
Revision 1.6 2004/05/14 03:15:09 ponchio
|
|
|
|
Redesigned partial version.
|
|
|
|
|
2004-05-14 05:15:09 +02:00
|
|
|
Revision 1.5 2004/05/12 20:55:18 ponchio
|
|
|
|
*** empty log message ***
|
|
|
|
|
2004-05-12 22:55:18 +02:00
|
|
|
Revision 1.4 2004/05/07 12:46:08 cignoni
|
|
|
|
Restructured and adapted in a better way to opengl
|
|
|
|
|
2004-05-07 14:46:08 +02:00
|
|
|
Revision 1.3 2004/04/07 10:54:10 cignoni
|
|
|
|
Commented out unused parameter names and other minor warning related issues
|
|
|
|
|
2004-04-07 12:54:11 +02:00
|
|
|
Revision 1.2 2004/03/25 14:55:25 ponchio
|
|
|
|
Adding copyright.
|
|
|
|
|
2004-03-25 15:55:25 +01:00
|
|
|
|
2005-10-17 03:29:46 +02:00
|
|
|
****************************************************************************/
|
2004-03-25 15:50:08 +01:00
|
|
|
#ifndef TRACKBALL_H
|
|
|
|
#define TRACKBALL_H
|
|
|
|
|
2008-11-12 17:33:40 +01:00
|
|
|
#include <time.h>
|
2004-03-25 15:50:08 +01:00
|
|
|
#include <vcg/math/similarity.h>
|
2006-02-13 14:15:52 +01:00
|
|
|
#include <vcg/space/color4.h>
|
2004-03-25 15:50:08 +01:00
|
|
|
#include <wrap/gui/view.h>
|
|
|
|
#include <wrap/gui/trackmode.h>
|
|
|
|
#include <list>
|
2004-06-09 16:01:13 +02:00
|
|
|
#include <vector>
|
2004-03-25 15:50:08 +01:00
|
|
|
#include <map>
|
|
|
|
|
|
|
|
namespace vcg {
|
2007-07-14 14:43:44 +02:00
|
|
|
/*!
|
|
|
|
@brief The base class for Trackball.
|
|
|
|
|
|
|
|
This class is useful for using a Trackball instance in a scene graph,
|
|
|
|
as a sort of interactive transform.
|
|
|
|
*/
|
|
|
|
class Transform {
|
|
|
|
public:
|
|
|
|
/*!
|
|
|
|
@brief The constructor.
|
|
|
|
|
|
|
|
Initialize:
|
|
|
|
- track to the identity transform.
|
|
|
|
- center to origin 0,0,0.
|
|
|
|
- radius to unit size.
|
|
|
|
*/
|
|
|
|
Transform();
|
|
|
|
/// A trackball stores a transformation called 'track' that effectively rototranslate the object.
|
|
|
|
Similarityf track;
|
|
|
|
/// track position in model space.
|
|
|
|
Point3f center;
|
|
|
|
/// size of the widget in model space.
|
|
|
|
float radius;
|
|
|
|
};
|
|
|
|
|
|
|
|
/*!
|
|
|
|
@brief Computes the linear interpolation between 2 transforms.
|
|
|
|
|
|
|
|
@param a The first transform.
|
|
|
|
@param b The second transform.
|
|
|
|
@param t The interpolation value (0: just a, 0.5: middle from a to b, 1: just b).
|
|
|
|
@return The linear interpolation.
|
|
|
|
*/
|
|
|
|
Transform interpolate(const Transform &a, const Transform &b, float t);
|
|
|
|
|
|
|
|
class TrackMode;
|
|
|
|
|
|
|
|
/*!
|
|
|
|
@brief The manipulator manager system.
|
|
|
|
|
|
|
|
<em>Short usage note:</em>
|
|
|
|
|
|
|
|
- Center specify the center of rotation and scaling of the trackball and usually is set by the program and do not interactively change
|
|
|
|
- Radius specify the radius of the interactive ball shaped icon to specify rotation. It is in absolute unit.
|
|
|
|
- Like the previous one it is not changed during interaction.
|
|
|
|
|
|
|
|
When you specify a translation with the trackball the trackball center remain \b unchanged, in other words it means that the object move out of the trackball icon. Similarly when you apply a scaling the size of the manipulator icon do not change.
|
|
|
|
|
|
|
|
Typical use:
|
|
|
|
<pre>
|
|
|
|
glMatrixMode(GL_PROJECTION);
|
|
|
|
glLoadIdentity();
|
|
|
|
gluPerspective(60, float(width())/float(height()), 1, 100);
|
|
|
|
glMatrixMode(GL_MODELVIEW);
|
|
|
|
glLoadIdentity();
|
|
|
|
gluLookAt(0,0,3, 0,0,0, 0,1,0)
|
|
|
|
|
|
|
|
trackball.center=Point3f(0, 0, 0);
|
|
|
|
trackball.radius= 1;
|
|
|
|
|
|
|
|
trackball.GetView();
|
|
|
|
trackball.Apply(true); //false if you want an invisible trackball
|
|
|
|
|
|
|
|
float d=1.0f/mesh.bbox.Diag();
|
|
|
|
glScale(d);
|
|
|
|
glTranslate(-mesh.bbox.Center());
|
|
|
|
mesh->Render();
|
|
|
|
</pre>
|
|
|
|
|
|
|
|
Note on the typical use:
|
|
|
|
- Perspective and glulookat are choosed to frame the origin centered 1-radius trackball.
|
|
|
|
- The final scale and translate are just to fit a generic mesh to the 1sized origin centered where the trackball stays box.
|
|
|
|
- The trackball works also on Orthographic projections \b but that are not centered around origin (just move it back along the Z)
|
|
|
|
*/
|
|
|
|
class Trackball: public Transform {
|
|
|
|
public:
|
2004-07-12 00:06:56 +02:00
|
|
|
|
2007-07-14 14:43:44 +02:00
|
|
|
/// The componibile states of the manipulator system.
|
2008-11-12 17:33:40 +01:00
|
|
|
enum Button { BUTTON_NONE = 0x0000, ///< No button or key pressed.
|
2007-07-14 14:43:44 +02:00
|
|
|
BUTTON_LEFT = 0x0001, ///< Left mouse button pressed.
|
|
|
|
BUTTON_MIDDLE = 0x0002, ///< Middle mouse button pressed.
|
|
|
|
BUTTON_RIGHT = 0x0004, ///< Right mouse button pressed.
|
|
|
|
WHEEL = 0x0008, ///< Mouse wheel activated.
|
|
|
|
KEY_SHIFT = 0x0010, ///< Shift key pressed.
|
|
|
|
KEY_CTRL = 0x0020, ///< Ctrl key pressed.
|
|
|
|
KEY_ALT = 0x0040, ///< Alt key pressed.
|
2008-11-12 17:33:40 +01:00
|
|
|
HANDLE = 0x0080, ///< Application-defined state activated.
|
|
|
|
MODIFIER_MASK = 0x00FF, ///< (mask to get modifiers only)
|
|
|
|
KEY_UP = 0x0100, ///< Up directional key
|
|
|
|
KEY_DOWN = 0x0200, ///< Down directional key
|
|
|
|
KEY_LEFT = 0x0400, ///< Left directional key
|
|
|
|
KEY_RIGHT = 0x0800, ///< Right directional key
|
|
|
|
KEY_PGUP = 0x1000, ///< PageUp directional key
|
|
|
|
KEY_PGDOWN = 0x2000, ///< PageDown directional key
|
2007-07-14 14:43:44 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
/*!
|
|
|
|
@brief The constructor.
|
|
|
|
|
|
|
|
Initialize the internal state with default values
|
|
|
|
and call setDefaultMapping().
|
|
|
|
*/
|
|
|
|
Trackball();
|
|
|
|
/*!
|
|
|
|
@brief The destructor.
|
|
|
|
|
|
|
|
@warning The destructor <b>does not</b> deallocate the memory allocated by setDefaultMapping(), because the application can change the modes map. This can lead to small memory leaks, so please explicitally delete any manipulator in the modes map if you are going to repeatly allocate and deallocate Trackball instances.
|
|
|
|
*/
|
|
|
|
~Trackball();
|
2008-11-13 10:33:43 +01:00
|
|
|
|
|
|
|
private:
|
2008-11-28 15:55:45 +01:00
|
|
|
// Trackball must not be copied. Use Append (see vcg/complex/trimesh/append.h)
|
|
|
|
Trackball operator =(const Trackball & /*m*/){ assert(0); return *this; }
|
2008-11-13 10:33:43 +01:00
|
|
|
public:
|
2007-07-14 14:43:44 +02:00
|
|
|
/*!
|
|
|
|
@brief Reset the trackball.
|
|
|
|
|
|
|
|
Equivalent to Reset().
|
|
|
|
*/
|
|
|
|
void SetIdentity();
|
|
|
|
/*!
|
|
|
|
@brief Set the position of the trackball.
|
|
|
|
|
|
|
|
@param c The new position of the trackball.
|
|
|
|
@param millisec Currently not in use.
|
|
|
|
*/
|
|
|
|
void SetPosition(const Point3f &c, int millisec = 0);
|
|
|
|
/*!
|
|
|
|
@brief Currently not in use.
|
|
|
|
|
|
|
|
@param s Currently not in use.
|
|
|
|
*/
|
|
|
|
void SetScale(const float s) {radius=s;};
|
|
|
|
/*!
|
|
|
|
@brief Currently not in use.
|
|
|
|
|
|
|
|
@param transform Currently not in use.
|
|
|
|
@param millisec Currently not in use.
|
|
|
|
*/
|
|
|
|
void SetTransform(const Transform &transform, int millisec = 0);
|
|
|
|
/*!
|
|
|
|
@brief Apply a translation on the current transformation.
|
|
|
|
|
|
|
|
@param tr The translation vector.
|
|
|
|
*/
|
|
|
|
void Translate(Point3f tr);
|
|
|
|
/*!
|
|
|
|
@brief Apply a scaling on the current transformation.
|
|
|
|
|
|
|
|
@param f The scale factor.
|
|
|
|
*/
|
|
|
|
void Scale(const float f);
|
|
|
|
|
|
|
|
//operating
|
|
|
|
/*!
|
|
|
|
@brief Initialize the camera instance.
|
|
|
|
*/
|
|
|
|
void GetView();
|
|
|
|
|
|
|
|
/*!
|
2013-01-28 16:15:14 +01:00
|
|
|
@brief Application of the transformation.
|
|
|
|
|
|
|
|
@warning This function does \b not draw anything. You have to call DrawPostApply() after drawing everything.
|
2007-07-14 14:43:44 +02:00
|
|
|
|
|
|
|
*/
|
|
|
|
void Apply ();
|
2013-01-28 16:15:14 +01:00
|
|
|
|
2007-07-14 14:43:44 +02:00
|
|
|
/*!
|
|
|
|
@brief Draw the current manipulator.
|
|
|
|
|
|
|
|
Call the draw function of the current manipulator.
|
|
|
|
If no manipulator is selected call the draw function of the manipulator associated to inactive_mode.
|
|
|
|
|
|
|
|
@warning This function assumes that the OpenGL modelview matrix has been initialized with Apply ().
|
|
|
|
*/
|
|
|
|
void DrawPostApply();
|
2013-01-28 16:15:14 +01:00
|
|
|
|
2007-07-14 14:43:44 +02:00
|
|
|
/*!
|
|
|
|
@brief Apply the \b inverse of current transformation on the OpenGL modelview matrix.
|
|
|
|
*/
|
|
|
|
void ApplyInverse();
|
|
|
|
// DrawIcon() has been moved to trackutils.h
|
|
|
|
//void DrawIcon();
|
2009-03-31 11:03:18 +02:00
|
|
|
|
|
|
|
// T(c) S R T(t) T(-c) => S R T(S^(-1) R^(-1)(c) + t - c)
|
|
|
|
Matrix44f Matrix() const;
|
|
|
|
Matrix44f InverseMatrix() const;
|
|
|
|
|
2007-07-14 14:43:44 +02:00
|
|
|
/*!
|
|
|
|
@brief Reset the transformation and every mapped manipulator.
|
|
|
|
*/
|
|
|
|
void Reset();
|
|
|
|
|
2009-04-01 16:53:20 +02:00
|
|
|
/*!
|
|
|
|
@brief clear the modes map. Taking the right care of not doubledeleting anything.
|
|
|
|
*/
|
|
|
|
void ClearModes();
|
|
|
|
|
2007-07-14 14:43:44 +02:00
|
|
|
// DrawCircle (), DrawPlane(), DrawPlaneHandle() has been moved to trackutils.h
|
|
|
|
// the drawing code has been moved to the trackmodes
|
|
|
|
// void DrawCircle ();
|
|
|
|
// void DrawPlane();
|
|
|
|
// void DrawPlaneHandle();
|
|
|
|
|
|
|
|
//interface
|
|
|
|
/*!
|
|
|
|
@brief Interface function relative to mouse down event in QT/SDL.
|
|
|
|
|
|
|
|
@param button The new state.
|
|
|
|
*/
|
|
|
|
void MouseDown(/*Button*/ int button);
|
|
|
|
/*!
|
|
|
|
@brief Interface function relative to mouse down event in QT/SDL.
|
|
|
|
|
|
|
|
@param x The horizontal coordinate of the mouse pointer.
|
|
|
|
@param y The vertical coordinate of the mouse pointer.
|
|
|
|
@param button The new state.
|
|
|
|
*/
|
|
|
|
void MouseDown(int x, int y, /*Button*/ int button);
|
|
|
|
/*!
|
|
|
|
@brief Interface function relative to mouse down event in QT/SDL.
|
|
|
|
|
|
|
|
@param x The horizontal coordinate of the mouse pointer.
|
|
|
|
@param y The vertical coordinate of the mouse pointer.
|
|
|
|
*/
|
|
|
|
void MouseMove(int x, int y);
|
|
|
|
/*!
|
|
|
|
@brief Interface function relative to mouse down event in QT/SDL.
|
|
|
|
|
|
|
|
@param x The horizontal coordinate of the mouse pointer.
|
|
|
|
@param y The vertical coordinate of the mouse pointer.
|
|
|
|
@param button The new state.
|
|
|
|
*/
|
|
|
|
void MouseUp(int x, int y, /*Button */ int button);
|
|
|
|
/*!
|
|
|
|
@brief Old interface function relative to mouse down event in QT/SDL.
|
|
|
|
|
|
|
|
@param notch The mouse wheel notch (1: one forward step, -1: one backward step).
|
|
|
|
*/
|
|
|
|
void MouseWheel(float notch);
|
|
|
|
/*!
|
|
|
|
@brief Interface function relative to mouse down event in QT/SDL.
|
|
|
|
|
|
|
|
@param notch The mouse wheel notch (1: one forward step, -1: one backward step).
|
|
|
|
@param button The new state.
|
|
|
|
*/
|
|
|
|
void MouseWheel (float notch, /*Button */ int button);
|
|
|
|
/*!
|
|
|
|
@brief Interface function relative to key down event in QT/SDL.
|
|
|
|
|
|
|
|
@param button the new state.
|
|
|
|
*/
|
|
|
|
void ButtonUp(Button button);
|
|
|
|
/*!
|
|
|
|
@brief Interface function relative to key up event in QT/SDL.
|
|
|
|
|
|
|
|
@param button the new state.
|
|
|
|
*/
|
2008-11-12 17:33:40 +01:00
|
|
|
void ButtonDown(Button button, unsigned int msec=0);
|
2007-07-14 14:43:44 +02:00
|
|
|
/*!
|
|
|
|
@brief Undo function for manipulator system.
|
|
|
|
|
|
|
|
A call of this function restores the state before last user action.
|
|
|
|
This function calls %Undo() on every mapped manipulator.
|
|
|
|
*/
|
|
|
|
void Undo();
|
|
|
|
|
|
|
|
//default sensitivity 1
|
|
|
|
/*!
|
|
|
|
@brief Currently not in use.
|
|
|
|
|
|
|
|
@param s Currently not in use.
|
|
|
|
*/
|
|
|
|
void SetSensitivity(float s);
|
|
|
|
|
|
|
|
void SetSpinnable(bool on);
|
2008-11-12 17:33:40 +01:00
|
|
|
|
|
|
|
|
|
|
|
// returns if it is animating or not
|
|
|
|
//
|
|
|
|
bool IsAnimating(unsigned int msec=0);
|
|
|
|
|
|
|
|
// Animate: either takes an absolute time (if default not specified, then it is automeasured)
|
|
|
|
// or a fixed delta
|
|
|
|
void Animate(unsigned int msec=0);
|
|
|
|
|
2007-07-14 14:43:44 +02:00
|
|
|
/*!
|
|
|
|
@brief Currently not in use.
|
|
|
|
|
|
|
|
@return A meaningless boolean value.
|
|
|
|
*/
|
2008-11-12 17:33:40 +01:00
|
|
|
bool IsSpinnable();
|
2007-07-14 14:43:44 +02:00
|
|
|
/*!
|
|
|
|
@brief Currently not in use.
|
|
|
|
|
|
|
|
@param spin Currently not in use.
|
|
|
|
*/
|
|
|
|
void SetSpinning(Quaternionf &spin);
|
|
|
|
/*!
|
|
|
|
@brief Currently not in use.
|
|
|
|
*/
|
|
|
|
void StopSpinning();
|
|
|
|
/*!
|
|
|
|
@brief Currently not in use.
|
|
|
|
|
|
|
|
@return A meaningless boolean value.
|
|
|
|
*/
|
|
|
|
bool IsSpinning();
|
|
|
|
|
|
|
|
//interfaccia navigation:
|
|
|
|
/*!
|
|
|
|
@brief Currently not in use.
|
|
|
|
*/
|
|
|
|
void Back();
|
|
|
|
/*!
|
|
|
|
@brief Currently not in use.
|
|
|
|
*/
|
|
|
|
void Forward();
|
|
|
|
/*!
|
|
|
|
@brief Currently not in use.
|
|
|
|
*/
|
|
|
|
void Home();
|
|
|
|
/*!
|
|
|
|
@brief Currently not in use.
|
|
|
|
*/
|
|
|
|
void Store();
|
|
|
|
/*!
|
|
|
|
@brief Currently not in use.
|
|
|
|
*/
|
|
|
|
void HistorySize(int lenght);
|
2004-05-14 05:15:09 +02:00
|
|
|
|
2007-02-26 02:30:02 +01:00
|
|
|
/* //internals // commented out no more used this stuff!
|
2004-05-14 05:15:09 +02:00
|
|
|
enum Action { NONE = 0,
|
|
|
|
VIEW_ROTATE = 1,
|
|
|
|
// Axis Constrained Rotation
|
|
|
|
TRACK_ROTATE_X = 3, TRACK_ROTATE_Y = 4, TRACK_ROTATE_Z = 5,
|
|
|
|
// Drag constrained to an axis (trackball axis)
|
|
|
|
DRAG_X = 6, DRAG_Y = 7, DRAG_Z = 8,
|
|
|
|
// Drag constrained to a plane
|
|
|
|
DRAG_XY = 9, DRAG_YZ = 10, DRAG_XZ = 11,
|
|
|
|
//scale model respect to center of trackball
|
|
|
|
VIEW_SCALE = 12,
|
|
|
|
//scale trackball and model
|
|
|
|
TRACK_SCALE = 13
|
|
|
|
};
|
2007-02-26 02:30:02 +01:00
|
|
|
*/
|
2007-12-21 13:29:34 +01:00
|
|
|
// loads stores current status from/to ascii stings
|
2007-07-14 14:43:44 +02:00
|
|
|
/*!
|
2007-12-21 13:29:34 +01:00
|
|
|
@brief Stores current status into an ascii stings
|
2007-07-14 14:43:44 +02:00
|
|
|
|
2007-12-21 13:29:34 +01:00
|
|
|
Stores current status into an ascii stings. This is useful for example to implement cut-and-paste operations of trackball status, or to embed used trackball into a comment inside a screenshot, etc.
|
2010-11-15 01:06:15 +01:00
|
|
|
@param st The string where to export (must be allocated 256bytes should be enough).
|
2007-07-14 14:43:44 +02:00
|
|
|
*/
|
|
|
|
void ToAscii(char * st);
|
|
|
|
/*!
|
2007-12-21 13:29:34 +01:00
|
|
|
@brief Loads current status from an ascii stings
|
2007-07-14 14:43:44 +02:00
|
|
|
|
2007-12-21 13:29:34 +01:00
|
|
|
Loads current status from an ascii stings. This is useful for example to implement cut-and-paste operations of trackball status, or to embed used trackball into a comment inside a screenshot, etc.
|
|
|
|
@param st The string where to read from (must be allocated). Use ToAscii() method to set it.
|
|
|
|
@return True iff the trackball was successfully recovered.
|
2007-07-14 14:43:44 +02:00
|
|
|
*/
|
2007-12-21 13:29:34 +01:00
|
|
|
bool SetFromAscii(const char * st);
|
2007-07-14 14:43:44 +02:00
|
|
|
|
|
|
|
//protected:
|
|
|
|
/// The reference for point projection and unprojection from screen space to modelspace.
|
|
|
|
View<float> camera;
|
|
|
|
/*!
|
|
|
|
@brief Prepare Trackball and every mapped TrackMode for an user action.
|
|
|
|
|
|
|
|
This function is called automatically when an user action begins.
|
|
|
|
*/
|
|
|
|
void SetCurrentAction();
|
2008-11-12 17:33:40 +01:00
|
|
|
/// Current state composition. Note: mask with MODIFIERS to get modifier buttons only
|
2007-07-14 14:43:44 +02:00
|
|
|
int current_button;
|
|
|
|
/// The selected manipulator.
|
|
|
|
TrackMode *current_mode;
|
|
|
|
|
2008-11-12 17:33:40 +01:00
|
|
|
/// The inactive manipulator. It is drawn when Trackball is inactive.
|
2007-07-14 14:43:44 +02:00
|
|
|
TrackMode *inactive_mode;
|
2008-11-12 17:33:40 +01:00
|
|
|
|
|
|
|
// The manipulator to deal with timer events and key events
|
|
|
|
TrackMode *idle_and_keys_mode;
|
2007-07-14 14:43:44 +02:00
|
|
|
/*!
|
|
|
|
@brief Reset modes to default mapping.
|
|
|
|
|
|
|
|
Set the default modes mapping.
|
|
|
|
The default mapping is:
|
|
|
|
- \b LEFT : SphereMode.
|
|
|
|
- \b LEFT+CTRL or \b MIDDLE : PanMode.
|
|
|
|
- \b LEFT+SHIFT or \b WHEEL : ScaleMode.
|
|
|
|
- \b LEFT+ALT : ZMode.
|
|
|
|
|
|
|
|
@warning The memory allocated by this function <b>is not</b> automatically deallocated. see ~Trackball().
|
|
|
|
*/
|
|
|
|
void setDefaultMapping ();
|
|
|
|
|
|
|
|
/// The manipulator mapping. Needs to be explicitally managed for custom mappings.
|
|
|
|
std::map<int, TrackMode *> modes;
|
|
|
|
|
|
|
|
// undo_track and last_track have different meanings..
|
|
|
|
/// Transformation before current user action.
|
|
|
|
Similarityf last_track;
|
|
|
|
/// track after an Undo() call.
|
|
|
|
Similarityf undo_track;
|
|
|
|
/// Currently not in use.
|
|
|
|
Similarityf last_view;
|
|
|
|
/// Mouse cursor coordinates before current action.
|
|
|
|
Point3f last_point;
|
|
|
|
/// Currently not in use.
|
|
|
|
std::vector<Point3f> Hits;
|
|
|
|
/// Currently not in use.
|
|
|
|
bool dragging;
|
|
|
|
/// Currently not in use.
|
|
|
|
int button_mask;
|
|
|
|
|
2008-11-12 17:33:40 +01:00
|
|
|
unsigned int last_time;
|
|
|
|
|
2007-07-14 14:43:44 +02:00
|
|
|
/// Currently not in use.
|
|
|
|
Quaternionf spin;
|
|
|
|
/// Currently not in use.
|
|
|
|
bool spinnable;
|
|
|
|
/// Currently not in use.
|
|
|
|
bool spinning;
|
|
|
|
|
|
|
|
/// Currently not in use.
|
|
|
|
std::list<Transform> history;
|
|
|
|
/// Currently not in use.
|
|
|
|
int history_size;
|
|
|
|
|
2008-11-12 17:33:40 +01:00
|
|
|
|
|
|
|
void SetFixedTimesteps(bool mode){
|
|
|
|
fixedTimestepMode=mode;
|
|
|
|
}
|
|
|
|
|
2007-07-14 14:43:44 +02:00
|
|
|
/// Manipulators needs full access to this class.
|
|
|
|
friend class TrackMode;
|
2008-11-12 17:33:40 +01:00
|
|
|
private:
|
|
|
|
void Sync(unsigned int msec);
|
|
|
|
bool fixedTimestepMode; // if true, animations occurs at fixed time steps
|
|
|
|
|
2007-07-14 14:43:44 +02:00
|
|
|
};
|
2004-03-25 15:50:08 +01:00
|
|
|
|
|
|
|
|
|
|
|
}//namespace
|
|
|
|
|
2004-05-14 05:15:09 +02:00
|
|
|
#endif
|