1 // Copyright (c) 2019 OPEN CASCADE SAS
3 // This file is part of Open CASCADE Technology software library.
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.
11 // Alternatively, this file may be used under the terms of Open CASCADE
12 // commercial license or contractual agreement.
14 #ifndef _AIS_WalkDelta_HeaderFile
15 #define _AIS_WalkDelta_HeaderFile
17 #include <Standard_Real.hxx>
19 //! Walking translation components.
20 enum AIS_WalkTranslation
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
27 //! Walking rotation components.
30 AIS_WalkRotation_Yaw = 0, //!< yaw rotation angle
31 AIS_WalkRotation_Pitch, //!< pitch rotation angle
32 AIS_WalkRotation_Roll, //!< roll rotation angle
38 Standard_Real Value; //!< value
39 Standard_Real Pressure; //!< key pressure
40 Standard_Real Duration; //!< duration
42 //! Return TRUE if delta is empty.
43 bool IsEmpty() const { return Abs (Value) <= RealSmall(); }
45 //! Empty constructor.
46 AIS_WalkPart() : Value (0.0), Pressure (1.0), Duration (0.0) {}
52 //! Empty constructor.
54 : myIsDefined (false), myIsJumping (false), myIsCrouching (false), myIsRunning (false) {}
56 //! Return translation component.
57 const AIS_WalkPart& operator[] (AIS_WalkTranslation thePart) const { return myTranslation[thePart]; }
59 //! Return translation component.
60 AIS_WalkPart& operator[] (AIS_WalkTranslation thePart) { return myTranslation[thePart]; }
62 //! Return rotation component.
63 const AIS_WalkPart& operator[] (AIS_WalkRotation thePart) const { return myRotation[thePart]; }
65 //! Return rotation component.
66 AIS_WalkPart& operator[] (AIS_WalkRotation thePart) { return myRotation[thePart]; }
68 //! Return jumping state.
69 bool IsJumping() const { return myIsJumping; }
71 //! Set jumping state.
72 void SetJumping (bool theIsJumping) { myIsJumping = theIsJumping; }
74 //! Return crouching state.
75 bool IsCrouching() const { return myIsCrouching; }
77 //! Set crouching state.
78 void SetCrouching (bool theIsCrouching) { myIsCrouching = theIsCrouching; }
80 //! Return running state.
81 bool IsRunning() const { return myIsRunning; }
83 //! Set running state.
84 void SetRunning (bool theIsRunning) { myIsRunning = theIsRunning; }
86 //! Return TRUE if navigation keys are pressed even if delta from the previous frame is empty.
87 bool IsDefined() const { return myIsDefined || !IsEmpty(); }
89 //! Set if any navigation key is pressed.
90 void SetDefined (bool theIsDefined) { myIsDefined = theIsDefined; }
92 //! Return TRUE when both Rotation and Translation deltas are empty.
93 bool IsEmpty() const { return !ToMove() && !ToRotate(); }
95 //! Return TRUE if translation delta is defined.
98 return !myTranslation[AIS_WalkTranslation_Forward].IsEmpty()
99 || !myTranslation[AIS_WalkTranslation_Side].IsEmpty()
100 || !myTranslation[AIS_WalkTranslation_Up].IsEmpty();
103 //! Return TRUE if rotation delta is defined.
104 bool ToRotate() const
106 return !myRotation[AIS_WalkRotation_Yaw].IsEmpty()
107 || !myRotation[AIS_WalkRotation_Pitch].IsEmpty()
108 || !myRotation[AIS_WalkRotation_Roll].IsEmpty();
113 AIS_WalkPart myTranslation[3];
114 AIS_WalkPart myRotation[3];
122 #endif // _AIS_WalkDelta_HeaderFile