1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 #ifndef HGVGSPRING_H_ |
|
19 #define HGVSPRING_H_ |
|
20 |
|
21 // INCLUDES |
|
22 #include <e32base.h> |
|
23 #include <e32std.h> |
|
24 |
|
25 |
|
26 NONSHARABLE_CLASS(THgVgSpring) |
|
27 { |
|
28 public: |
|
29 |
|
30 THgVgSpring(TReal aSpringK, TReal aSpringDamping, |
|
31 TReal aSpringMaxVelocity, TReal aPositionSnap, |
|
32 TReal aVelocitySnap); |
|
33 |
|
34 void SetConstants(TReal aSpringK, TReal aSpringDamping, |
|
35 TReal aSpringMaxVelocity, TReal aPositionSnap, |
|
36 TReal aVelocitySnap); |
|
37 |
|
38 void Reset(); |
|
39 void Reset(TReal aX, TReal aY); |
|
40 void SetXY(TReal aX, TReal aY); |
|
41 void SetEnd(TReal aX, TReal aY); |
|
42 void SetVelocity(TReal aVx, TReal aVy); |
|
43 TBool IntegratePhysics(TReal aDeltaTime, TBool aEndCondition); |
|
44 TReal GetX() const; |
|
45 TReal GetY() const; |
|
46 TReal GetInterpolatedX() const; |
|
47 TReal GetInterpolatedY() const; |
|
48 TReal VelX() const; |
|
49 TReal VelY() const; |
|
50 TReal EndX() const; |
|
51 TReal EndY() const; |
|
52 |
|
53 private: |
|
54 |
|
55 TReal iPrevX, iPrevY; |
|
56 TReal iX, iY; |
|
57 TReal iEndX, iEndY; |
|
58 TReal iVelX, iVelY; |
|
59 TReal iAccumulator; |
|
60 TReal iSpringK; |
|
61 TReal iSpringDamping; |
|
62 TReal iMaxSpringVelocity; |
|
63 TReal iPositionSnap; |
|
64 TReal iVelocitySnap; |
|
65 }; |
|
66 |
|
67 |
|
68 #endif /* HGVGSPRING_H */ |
|