Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/OgreMain/include/OgreRotationalSpline.h @ 5

Last change on this file since 5 was 5, checked in by anonymous, 17 years ago

=hoffentlich gehts jetzt

File size: 5.4 KB
Line 
1/*
2-----------------------------------------------------------------------------
3This source file is part of OGRE
4    (Object-oriented Graphics Rendering Engine)
5For the latest info, see http://www.ogre3d.org/
6
7Copyright (c) 2000-2006 Torus Knot Software Ltd
8Also see acknowledgements in Readme.html
9
10This program is free software; you can redistribute it and/or modify it under
11the terms of the GNU Lesser General Public License as published by the Free Software
12Foundation; either version 2 of the License, or (at your option) any later
13version.
14
15This program is distributed in the hope that it will be useful, but WITHOUT
16ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
18
19You should have received a copy of the GNU Lesser General Public License along with
20this program; if not, write to the Free Software Foundation, Inc., 59 Temple
21Place - Suite 330, Boston, MA 02111-1307, USA, or go to
22http://www.gnu.org/copyleft/lesser.txt.
23
24You may alternatively use this source under the terms of a specific version of
25the OGRE Unrestricted License provided you have obtained such a license from
26Torus Knot Software Ltd.
27-----------------------------------------------------------------------------
28*/
29#ifndef __RotationalSpline_H__
30#define __RotationalSpline_H__
31
32#include "OgrePrerequisites.h"
33#include "OgreQuaternion.h"
34
35namespace Ogre {
36
37    /** This class interpolates orientations (rotations) along a spline using
38        derivatives of quaternions.
39    @remarks
40        Like the SimpleSpline class, this class is about interpolating values
41        smoothly over a spline. Whilst SimpleSpline deals with positions (the normal
42        sense we think about splines), this class interpolates orientations. The
43        theory is identical, except we're now in 4-dimensional space instead of 3.
44    @par
45        In positional splines, we use the points and tangents on those points to generate
46        control points for the spline. In this case, we use quaternions and derivatives
47        of the quaternions (i.e. the rate and direction of change at each point). This is the
48        same as SimpleSpline since a tangent is a derivative of a position. We effectively
49        generate an extra quaternion in between each actual quaternion which when take with
50        the original quaternion forms the 'tangent' of that quaternion.
51    */
52    class _OgreExport RotationalSpline
53    {
54    public:
55        RotationalSpline();
56        ~RotationalSpline();
57
58        /** Adds a control point to the end of the spline. */
59        void addPoint(const Quaternion& p);
60
61        /** Gets the detail of one of the control points of the spline. */
62        const Quaternion& getPoint(unsigned short index) const;
63
64        /** Gets the number of control points in the spline. */
65        unsigned short getNumPoints(void) const;
66
67        /** Clears all the points in the spline. */
68        void clear(void);
69
70        /** Updates a single point in the spline.
71        @remarks
72            This point must already exist in the spline.
73        */
74        void updatePoint(unsigned short index, const Quaternion& value);
75
76        /** Returns an interpolated point based on a parametric value over the whole series.
77        @remarks
78            Given a t value between 0 and 1 representing the parametric distance along the
79            whole length of the spline, this method returns an interpolated point.
80        @param t Parametric value.
81                @param useShortestPath Defines if rotation should take the shortest possible path
82        */
83        Quaternion interpolate(Real t, bool useShortestPath=true);
84
85        /** Interpolates a single segment of the spline given a parametric value.
86        @param fromIndex The point index to treat as t=0. fromIndex + 1 is deemed to be t=1
87        @param t Parametric value
88                @param useShortestPath Defines if rotation should take the shortest possible path
89        */
90        Quaternion interpolate(unsigned int fromIndex, Real t, bool useShortestPath=true);
91
92        /** Tells the spline whether it should automatically calculate tangents on demand
93            as points are added.
94        @remarks
95            The spline calculates tangents at each point automatically based on the input points.
96            Normally it does this every time a point changes. However, if you have a lot of points
97            to add in one go, you probably don't want to incur this overhead and would prefer to
98            defer the calculation until you are finished setting all the points. You can do this
99            by calling this method with a parameter of 'false'. Just remember to manually call
100            the recalcTangents method when you are done.
101        @param autoCalc If true, tangents are calculated for you whenever a point changes. If false,
102            you must call reclacTangents to recalculate them when it best suits.
103        */
104        void setAutoCalculate(bool autoCalc);
105
106        /** Recalculates the tangents associated with this spline.
107        @remarks
108            If you tell the spline not to update on demand by calling setAutoCalculate(false)
109            then you must call this after completing your updates to the spline points.
110        */
111        void recalcTangents(void);
112
113    protected:
114
115        bool mAutoCalc;
116
117
118
119        std::vector<Quaternion> mPoints;
120        std::vector<Quaternion> mTangents;
121
122    };
123
124
125}
126
127
128#endif
129
Note: See TracBrowser for help on using the repository browser.