0033661: Data Exchange, Step Import - Tessellated GDTs are not imported
[occt.git] / src / AIS / AIS_WalkDelta.hxx
1 // Copyright (c) 2019 OPEN CASCADE SAS
2 //
3 // This file is part of Open CASCADE Technology software library.
4 //
5 // This library is free software; you can redistribute it and/or modify it under
6 // the terms of the GNU Lesser General Public License version 2.1 as published
7 // by the Free Software Foundation, with special exception defined in the file
8 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
9 // distribution for complete text of the license and disclaimer of any warranty.
10 //
11 // Alternatively, this file may be used under the terms of Open CASCADE
12 // commercial license or contractual agreement.
13
14 #ifndef _AIS_WalkDelta_HeaderFile
15 #define _AIS_WalkDelta_HeaderFile
16
17 #include <Standard_Real.hxx>
18
19 //! Walking translation components.
20 enum AIS_WalkTranslation
21 {
22   AIS_WalkTranslation_Forward = 0, //!< translation delta, Forward walk
23   AIS_WalkTranslation_Side,        //!< translation delta, Side walk
24   AIS_WalkTranslation_Up,          //!< translation delta, Up walk
25 };
26
27 //! Walking rotation components.
28 enum AIS_WalkRotation
29 {
30   AIS_WalkRotation_Yaw = 0,  //!< yaw   rotation angle
31   AIS_WalkRotation_Pitch,    //!< pitch rotation angle
32   AIS_WalkRotation_Roll,     //!< roll  rotation angle
33 };
34
35 //! Walking value.
36 struct AIS_WalkPart
37 {
38   Standard_Real Value;    //!< value
39   Standard_Real Pressure; //!< key pressure
40   Standard_Real Duration; //!< duration
41
42   //! Return TRUE if delta is empty.
43   bool IsEmpty() const { return Abs (Value) <= RealSmall(); }
44
45   //! Empty constructor.
46   AIS_WalkPart() : Value (0.0), Pressure (1.0), Duration (0.0) {}
47 };
48
49 //! Walking values.
50 struct AIS_WalkDelta
51 {
52   //! Empty constructor.
53   AIS_WalkDelta()
54   : myIsDefined (false), myIsJumping (false), myIsCrouching (false), myIsRunning (false) {}
55
56   //! Return translation component.
57   const AIS_WalkPart& operator[] (AIS_WalkTranslation thePart) const { return myTranslation[thePart]; }
58
59   //! Return translation component.
60   AIS_WalkPart&       operator[] (AIS_WalkTranslation thePart)       { return myTranslation[thePart]; }
61
62   //! Return rotation component.
63   const AIS_WalkPart& operator[] (AIS_WalkRotation thePart) const { return myRotation[thePart]; }
64
65   //! Return rotation component.
66   AIS_WalkPart&       operator[] (AIS_WalkRotation thePart)       { return myRotation[thePart]; }
67
68   //! Return jumping state.
69   bool IsJumping() const { return myIsJumping; }
70
71   //! Set jumping state.
72   void SetJumping (bool theIsJumping) { myIsJumping = theIsJumping; }
73
74   //! Return crouching state.
75   bool IsCrouching() const { return myIsCrouching; }
76
77   //! Set crouching state.
78   void SetCrouching (bool theIsCrouching) { myIsCrouching = theIsCrouching; }
79
80   //! Return running state.
81   bool IsRunning() const { return myIsRunning; }
82
83   //! Set running state.
84   void SetRunning (bool theIsRunning) { myIsRunning = theIsRunning; }
85
86   //! Return TRUE if navigation keys are pressed even if delta from the previous frame is empty.
87   bool IsDefined() const { return myIsDefined || !IsEmpty(); }
88
89   //! Set if any navigation key is pressed.
90   void SetDefined (bool theIsDefined) { myIsDefined = theIsDefined; }
91
92   //! Return TRUE when both Rotation and Translation deltas are empty.
93   bool IsEmpty() const { return !ToMove() && !ToRotate(); }
94
95   //! Return TRUE if translation delta is defined.
96   bool ToMove() const
97   {
98     return !myTranslation[AIS_WalkTranslation_Forward].IsEmpty()
99         || !myTranslation[AIS_WalkTranslation_Side].IsEmpty()
100         || !myTranslation[AIS_WalkTranslation_Up].IsEmpty();
101   }
102
103   //! Return TRUE if rotation delta is defined.
104   bool ToRotate() const
105   {
106     return !myRotation[AIS_WalkRotation_Yaw].IsEmpty()
107         || !myRotation[AIS_WalkRotation_Pitch].IsEmpty()
108         || !myRotation[AIS_WalkRotation_Roll].IsEmpty();
109   }
110
111 private:
112
113   AIS_WalkPart myTranslation[3];
114   AIS_WalkPart myRotation[3];
115   bool myIsDefined;
116   bool myIsJumping;
117   bool myIsCrouching;
118   bool myIsRunning;
119
120 };
121
122 #endif // _AIS_WalkDelta_HeaderFile