1 | #ifndef Trackball_H
|
---|
2 | #define Trackball_H
|
---|
3 |
|
---|
4 | class Trackball {
|
---|
5 |
|
---|
6 | public:
|
---|
7 | Trackball();
|
---|
8 | ~Trackball();
|
---|
9 |
|
---|
10 | void start(float x, float y);
|
---|
11 |
|
---|
12 | // Pass the x and y coordinates of the last and current positions of
|
---|
13 | // the mouse, scaled so they are from (-1.0 ... 1.0).
|
---|
14 | //
|
---|
15 | // The resulting rotation is returned as a quaternion rotation in the
|
---|
16 | // first paramater.
|
---|
17 | void update(float x, float y);
|
---|
18 |
|
---|
19 | // This function was added by joe kniss to facilitate a home key!
|
---|
20 | void clear();
|
---|
21 |
|
---|
22 | // A useful function, builds a rotation matrix in Matrix based on
|
---|
23 | // given quaternion.
|
---|
24 | void buildRotMatrix(float m[4][4]);
|
---|
25 |
|
---|
26 | // This function computes a quaternion based on an axis (defined by
|
---|
27 | // the given vector) and an angle about which to rotate. The angle is
|
---|
28 | // expressed in radians. The result is put into the third argument.
|
---|
29 | void reapply();
|
---|
30 |
|
---|
31 | // This funciton was also written by joe to allow arbitary views
|
---|
32 | void setMatrix(float rot[16]);
|
---|
33 | void getAxisAngle(float& angle, float axis[3]);
|
---|
34 |
|
---|
35 | private:
|
---|
36 | static float trackballSize;
|
---|
37 | static int renormCount;
|
---|
38 |
|
---|
39 | float curQuat[4];
|
---|
40 | float lastQuat[4];
|
---|
41 | float lastX;
|
---|
42 | float lastY;
|
---|
43 | float a[3]; /* Axis of rotation */
|
---|
44 | float phi; /* how much to rotate about axis */
|
---|
45 |
|
---|
46 | float projectToSphere(float, float, float);
|
---|
47 |
|
---|
48 | };
|
---|
49 |
|
---|
50 | /*
|
---|
51 | * (c) Copyright 1993, 1994, Silicon Graphics, Inc.
|
---|
52 | * ALL RIGHTS RESERVED
|
---|
53 | * Permission to use, copy, modify, and distribute this software for
|
---|
54 | * any purpose and without fee is hereby granted, provided that the above
|
---|
55 | * copyright notice appear in all copies and that both the copyright notice
|
---|
56 | * and this permission notice appear in supporting documentation, and that
|
---|
57 | * the name of Silicon Graphics, Inc. not be used in advertising
|
---|
58 | * or publicity pertaining to distribution of the software without specific,
|
---|
59 | * written prior permission.
|
---|
60 | *
|
---|
61 | * THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
|
---|
62 | * AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
|
---|
63 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR
|
---|
64 | * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
|
---|
65 | * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT,
|
---|
66 | * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY
|
---|
67 | * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION,
|
---|
68 | * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF
|
---|
69 | * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN
|
---|
70 | * ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
|
---|
71 | * ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
|
---|
72 | * POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
|
---|
73 | *
|
---|
74 | * US Government Users Restricted Rights
|
---|
75 | * Use, duplication, or disclosure by the Government is subject to
|
---|
76 | * restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
|
---|
77 | * (c)(1)(ii) of the Rights in Technical Data and Computer Software
|
---|
78 | * clause at DFARS 252.227-7013 and/or in similar or successor
|
---|
79 | * clauses in the FAR or the DOD or NASA FAR Supplement.
|
---|
80 | * Unpublished-- rights reserved under the copyright laws of the
|
---|
81 | * United States. Contractor/manufacturer is Silicon Graphics,
|
---|
82 | * Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311.
|
---|
83 | *
|
---|
84 | * OpenGL(TM) is a trademark of Silicon Graphics, Inc.
|
---|
85 | */
|
---|
86 |
|
---|
87 | #endif
|
---|
88 |
|
---|