Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Sep 12, 2010, 12:47:30 AM (14 years ago)
Author:
rgrieder
Message:

Basic stuff up and running for the Qt sandbox.
No GUI support yet.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sandbox_qt/src/libraries/util/Math.h

    r7401 r7421  
    3535    @file
    3636    @ingroup Math
    37     @brief Declaration and implementation of several math-functions, typedefs of some Ogre::Math classes to the orxonox namespace.
     37    @brief Declaration and implementation of several math-functions.
    3838*/
    3939
     
    4545#include <string>
    4646#include <cmath>
    47 
    48 #include <OgreMath.h>
    49 #include <OgreVector2.h>
    50 #include <OgreVector3.h>
    51 #include <OgreVector4.h>
    52 #include <OgreQuaternion.h>
    53 #include <OgreColourValue.h>
    5447
    5548// Certain headers might define unwanted macros...
     
    8376    }
    8477
    85 #if OGRE_VERSION < 0x010603
    86     _UtilExport std::ostream& operator<<(std::ostream& out, const orxonox::Radian& radian);
    87     _UtilExport std::ostream& operator<<(std::ostream& out, const orxonox::Degree& degree);
    88 #endif
    89     _UtilExport std::istream& operator>>(std::istream& in, orxonox::Radian& radian);
    90     _UtilExport std::istream& operator>>(std::istream& in, orxonox::Degree& degree);
    91 
    92     _UtilExport float getAngle(const orxonox::Vector3& myposition, const orxonox::Vector3& mydirection, const orxonox::Vector3& otherposition);
    93     _UtilExport orxonox::Vector2 get2DViewdirection(const orxonox::Vector3& myposition, const orxonox::Vector3& mydirection, const orxonox::Vector3& myorthonormal, const orxonox::Vector3& otherposition);
    94     _UtilExport orxonox::Vector2 get2DViewcoordinates(const orxonox::Vector3& myposition, const orxonox::Vector3& mydirection, const orxonox::Vector3& myorthonormal, const orxonox::Vector3& otherposition);
    95     _UtilExport orxonox::Vector3 getPredictedPosition(const orxonox::Vector3& myposition, float projectilespeed, const orxonox::Vector3& targetposition, const orxonox::Vector3& targetvelocity);
    96 
    9778    /**
    9879        @brief Returns the sign of the given value.
     
    177158            return ((x % max) + max);
    178159    }
    179 
    180     /**
    181         @brief Returns a "zero" value for the given type.
    182         @note This is the default template of the zeroise() function. The template is spezialized for each supported type.
    183 
    184         The exact return value of the function depends on the type. For @c int this is 0,
    185         for @c float it's 0.0f. For a @c std::string the function returns "" and for
    186         @c Vector3 you get <tt>Vector3(0, 0, 0)</tt>.
    187     */
    188     template <typename T>
    189     inline T zeroise()
    190     {
    191         // Default, raise a compiler error without including large boost header cascade.
    192         T temp();
    193         *********temp; // If you reach this code, you abused zeroise()!
    194         return temp;
    195     }
    196 
    197     template <> inline char                 zeroise<char>()                 { return 0; }
    198     template <> inline unsigned char        zeroise<unsigned char>()        { return 0; }
    199     template <> inline short                zeroise<short>()                { return 0; }
    200     template <> inline unsigned short       zeroise<unsigned short>()       { return 0; }
    201     template <> inline int                  zeroise<int>()                  { return 0; }
    202     template <> inline unsigned int         zeroise<unsigned int>()         { return 0; }
    203     template <> inline long                 zeroise<long>()                 { return 0; }
    204     template <> inline unsigned long        zeroise<unsigned long>()        { return 0; }
    205     template <> inline long long            zeroise<long long>()            { return 0; }
    206     template <> inline unsigned long long   zeroise<unsigned long long>()   { return 0; }
    207     template <> inline float                zeroise<float>()                { return 0; }
    208     template <> inline double               zeroise<double>()               { return 0; }
    209     template <> inline long double          zeroise<long double>()          { return 0; }
    210     template <> inline bool                 zeroise<bool>()                 { return 0; }
    211     template <> inline void*                zeroise<void*>()                { return 0; }
    212     template <> inline std::string          zeroise<std::string>()          { return std::string(); }
    213     template <> inline orxonox::Radian      zeroise<orxonox::Radian>()      { return orxonox::Radian(0.0f); }
    214     template <> inline orxonox::Degree      zeroise<orxonox::Degree>()      { return orxonox::Degree(0.0f); }
    215     template <> inline orxonox::Vector2     zeroise<orxonox::Vector2>()     { return orxonox::Vector2    (0, 0)      ; }
    216     template <> inline orxonox::Vector3     zeroise<orxonox::Vector3>()     { return orxonox::Vector3    (0, 0, 0)   ; }
    217     template <> inline orxonox::Vector4     zeroise<orxonox::Vector4>()     { return orxonox::Vector4    (0, 0, 0, 0); }
    218     template <> inline orxonox::ColourValue zeroise<orxonox::ColourValue>() { return orxonox::ColourValue(0, 0, 0, 0); }
    219     template <> inline orxonox::Quaternion  zeroise<orxonox::Quaternion>()  { return orxonox::Quaternion (0, 0, 0, 0); }
    220 
    221     /**
    222         @brief Provides zero value symbols that can be returned as reference
    223         @see zeroise()
    224     */
    225     template <typename T>
    226     struct NilValue
    227     {
    228         inline operator const T&() const
    229         {
    230             return value;
    231         }
    232         static T value;
    233     };
    234     template <typename T>
    235     T NilValue<T>::value = zeroise<T>();
    236160
    237161    /**
     
    297221
    298222    _UtilExport unsigned long getUniqueNumber();
    299 
    300     /**
    301         @brief A Vector class containing two integers @a x and @a y.
    302     */
    303     class IntVector2
    304     {
    305     public:
    306         IntVector2() : x(0), y(0) { }
    307         IntVector2(int _x, int _y) : x(_x), y(_y) { }
    308         int x;
    309         int y;
    310     };
    311 
    312     /**
    313         @brief A Vector class containing three integers @a x, @a y, and @a z.
    314     */
    315     class IntVector3
    316     {
    317     public:
    318         IntVector3() : x(0), y(0), z(0) { }
    319         IntVector3(int _x, int _y, int _z) : x(_x), y(_y), z(_z) { }
    320         int x;
    321         int y;
    322         int z;
    323     };
    324223}
    325224
Note: See TracChangeset for help on using the changeset viewer.