Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:02:56

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   Standard_Real Value;    //!< value
0039   Standard_Real Pressure; //!< key pressure
0040   Standard_Real Duration; //!< duration
0041 
0042   //! Return TRUE if delta is empty.
0043   bool IsEmpty() const { return Abs (Value) <= RealSmall(); }
0044 
0045   //! Empty constructor.
0046   AIS_WalkPart() : Value (0.0), Pressure (1.0), Duration (0.0) {}
0047 };
0048 
0049 //! Walking values.
0050 struct AIS_WalkDelta
0051 {
0052   //! Empty constructor.
0053   AIS_WalkDelta()
0054   : myIsDefined (false), myIsJumping (false), myIsCrouching (false), myIsRunning (false) {}
0055 
0056   //! Return translation component.
0057   const AIS_WalkPart& operator[] (AIS_WalkTranslation thePart) const { return myTranslation[thePart]; }
0058 
0059   //! Return translation component.
0060   AIS_WalkPart&       operator[] (AIS_WalkTranslation thePart)       { return myTranslation[thePart]; }
0061 
0062   //! Return rotation component.
0063   const AIS_WalkPart& operator[] (AIS_WalkRotation thePart) const { return myRotation[thePart]; }
0064 
0065   //! Return rotation component.
0066   AIS_WalkPart&       operator[] (AIS_WalkRotation thePart)       { return myRotation[thePart]; }
0067 
0068   //! Return jumping state.
0069   bool IsJumping() const { return myIsJumping; }
0070 
0071   //! Set jumping state.
0072   void SetJumping (bool theIsJumping) { myIsJumping = theIsJumping; }
0073 
0074   //! Return crouching state.
0075   bool IsCrouching() const { return myIsCrouching; }
0076 
0077   //! Set crouching state.
0078   void SetCrouching (bool theIsCrouching) { myIsCrouching = theIsCrouching; }
0079 
0080   //! Return running state.
0081   bool IsRunning() const { return myIsRunning; }
0082 
0083   //! Set running state.
0084   void SetRunning (bool theIsRunning) { myIsRunning = theIsRunning; }
0085 
0086   //! Return TRUE if navigation keys are pressed even if delta from the previous frame is empty.
0087   bool IsDefined() const { return myIsDefined || !IsEmpty(); }
0088 
0089   //! Set if any navigation key is pressed.
0090   void SetDefined (bool theIsDefined) { myIsDefined = theIsDefined; }
0091 
0092   //! Return TRUE when both Rotation and Translation deltas are empty.
0093   bool IsEmpty() const { return !ToMove() && !ToRotate(); }
0094 
0095   //! Return TRUE if translation delta is defined.
0096   bool ToMove() const
0097   {
0098     return !myTranslation[AIS_WalkTranslation_Forward].IsEmpty()
0099         || !myTranslation[AIS_WalkTranslation_Side].IsEmpty()
0100         || !myTranslation[AIS_WalkTranslation_Up].IsEmpty();
0101   }
0102 
0103   //! Return TRUE if rotation delta is defined.
0104   bool ToRotate() const
0105   {
0106     return !myRotation[AIS_WalkRotation_Yaw].IsEmpty()
0107         || !myRotation[AIS_WalkRotation_Pitch].IsEmpty()
0108         || !myRotation[AIS_WalkRotation_Roll].IsEmpty();
0109   }
0110 
0111 private:
0112 
0113   AIS_WalkPart myTranslation[3];
0114   AIS_WalkPart myRotation[3];
0115   bool myIsDefined;
0116   bool myIsJumping;
0117   bool myIsCrouching;
0118   bool myIsRunning;
0119 
0120 };
0121 
0122 #endif // _AIS_WalkDelta_HeaderFile