Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-26 09:02:20

0001 // Copyright (c) 2019 OPEN CASCADE SAS
0002 //
0003 // This file is part of Open CASCADE Technology software library.
0004 //
0005 // This library is free software; you can redistribute it and/or modify it under
0006 // the terms of the GNU Lesser General Public License version 2.1 as published
0007 // by the Free Software Foundation, with special exception defined in the file
0008 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0009 // distribution for complete text of the license and disclaimer of any warranty.
0010 //
0011 // Alternatively, this file may be used under the terms of Open CASCADE
0012 // commercial license or contractual agreement.
0013 
0014 #ifndef _AIS_WalkDelta_HeaderFile
0015 #define _AIS_WalkDelta_HeaderFile
0016 
0017 #include <Standard_Real.hxx>
0018 
0019 //! Walking translation components.
0020 enum AIS_WalkTranslation
0021 {
0022   AIS_WalkTranslation_Forward = 0, //!< translation delta, Forward walk
0023   AIS_WalkTranslation_Side,        //!< translation delta, Side walk
0024   AIS_WalkTranslation_Up,          //!< translation delta, Up walk
0025 };
0026 
0027 //! Walking rotation components.
0028 enum AIS_WalkRotation
0029 {
0030   AIS_WalkRotation_Yaw = 0, //!< yaw   rotation angle
0031   AIS_WalkRotation_Pitch,   //!< pitch rotation angle
0032   AIS_WalkRotation_Roll,    //!< roll  rotation angle
0033 };
0034 
0035 //! Walking value.
0036 struct AIS_WalkPart
0037 {
0038   double Value;    //!< value
0039   double Pressure; //!< key pressure
0040   double Duration; //!< duration
0041 
0042   //! Return TRUE if delta is empty.
0043   bool IsEmpty() const { return std::abs(Value) <= RealSmall(); }
0044 
0045   //! Empty constructor.
0046   AIS_WalkPart()
0047       : Value(0.0),
0048         Pressure(1.0),
0049         Duration(0.0)
0050   {
0051   }
0052 };
0053 
0054 //! Walking values.
0055 struct AIS_WalkDelta
0056 {
0057   //! Empty constructor.
0058   AIS_WalkDelta()
0059       : myIsDefined(false),
0060         myIsJumping(false),
0061         myIsCrouching(false),
0062         myIsRunning(false)
0063   {
0064   }
0065 
0066   //! Return translation component.
0067   const AIS_WalkPart& operator[](AIS_WalkTranslation thePart) const
0068   {
0069     return myTranslation[thePart];
0070   }
0071 
0072   //! Return translation component.
0073   AIS_WalkPart& operator[](AIS_WalkTranslation thePart) { return myTranslation[thePart]; }
0074 
0075   //! Return rotation component.
0076   const AIS_WalkPart& operator[](AIS_WalkRotation thePart) const { return myRotation[thePart]; }
0077 
0078   //! Return rotation component.
0079   AIS_WalkPart& operator[](AIS_WalkRotation thePart) { return myRotation[thePart]; }
0080 
0081   //! Return jumping state.
0082   bool IsJumping() const { return myIsJumping; }
0083 
0084   //! Set jumping state.
0085   void SetJumping(bool theIsJumping) { myIsJumping = theIsJumping; }
0086 
0087   //! Return crouching state.
0088   bool IsCrouching() const { return myIsCrouching; }
0089 
0090   //! Set crouching state.
0091   void SetCrouching(bool theIsCrouching) { myIsCrouching = theIsCrouching; }
0092 
0093   //! Return running state.
0094   bool IsRunning() const { return myIsRunning; }
0095 
0096   //! Set running state.
0097   void SetRunning(bool theIsRunning) { myIsRunning = theIsRunning; }
0098 
0099   //! Return TRUE if navigation keys are pressed even if delta from the previous frame is empty.
0100   bool IsDefined() const { return myIsDefined || !IsEmpty(); }
0101 
0102   //! Set if any navigation key is pressed.
0103   void SetDefined(bool theIsDefined) { myIsDefined = theIsDefined; }
0104 
0105   //! Return TRUE when both Rotation and Translation deltas are empty.
0106   bool IsEmpty() const { return !ToMove() && !ToRotate(); }
0107 
0108   //! Return TRUE if translation delta is defined.
0109   bool ToMove() const
0110   {
0111     return !myTranslation[AIS_WalkTranslation_Forward].IsEmpty()
0112            || !myTranslation[AIS_WalkTranslation_Side].IsEmpty()
0113            || !myTranslation[AIS_WalkTranslation_Up].IsEmpty();
0114   }
0115 
0116   //! Return TRUE if rotation delta is defined.
0117   bool ToRotate() const
0118   {
0119     return !myRotation[AIS_WalkRotation_Yaw].IsEmpty()
0120            || !myRotation[AIS_WalkRotation_Pitch].IsEmpty()
0121            || !myRotation[AIS_WalkRotation_Roll].IsEmpty();
0122   }
0123 
0124 private:
0125   AIS_WalkPart myTranslation[3];
0126   AIS_WalkPart myRotation[3];
0127   bool         myIsDefined;
0128   bool         myIsJumping;
0129   bool         myIsCrouching;
0130   bool         myIsRunning;
0131 };
0132 
0133 #endif // _AIS_WalkDelta_HeaderFile