Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/libraries/util/MathConvert.h @ 11928

Last change on this file since 11928 was 8351, checked in by rgrieder, 14 years ago

Merged kicklib2 branch back to trunk (includes former branches ois_update, mac_osx and kicklib).

Notes for updating

Linux:
You don't need an extra package for CEGUILua and Tolua, it's already shipped with CEGUI.
However you do need to make sure that the OgreRenderer is installed too with CEGUI 0.7 (may be a separate package).
Also, Orxonox now recognises if you install the CgProgramManager (a separate package available on newer Ubuntu on Debian systems).

Windows:
Download the new dependency packages versioned 6.0 and use these. If you have problems with that or if you don't like the in game console problem mentioned below, you can download the new 4.3 version of the packages (only available for Visual Studio 2005/2008).

Key new features:

  • *Support for Mac OS X*
  • Visual Studio 2010 support
  • Bullet library update to 2.77
  • OIS library update to 1.3
  • Support for CEGUI 0.7 —> Support for Arch Linux and even SuSE
  • Improved install target
  • Compiles now with GCC 4.6
  • Ogre Cg Shader plugin activated for Linux if available
  • And of course lots of bug fixes

There are also some regressions:

  • No support for CEGUI 0.5, Ogre 1.4 and boost 1.35 - 1.39 any more
  • In game console is not working in main menu for CEGUI 0.7
  • Tolua (just the C lib, not the application) and CEGUILua libraries are no longer in our repository. —> You will need to get these as well when compiling Orxonox
  • And of course lots of new bugs we don't yet know about
  • Property svn:eol-style set to native
File size: 6.7 KB
RevLine 
[1777]1/*
2 *   ORXONOX - the hottest 3D action shooter ever to exist
3 *                    > www.orxonox.net <
4 *
5 *
6 *   License notice:
7 *
8 *   This program is free software; you can redistribute it and/or
9 *   modify it under the terms of the GNU General Public License
10 *   as published by the Free Software Foundation; either version 2
11 *   of the License, or (at your option) any later version.
12 *
13 *   This program is distributed in the hope that it will be useful,
14 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
15 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 *   GNU General Public License for more details.
17 *
18 *   You should have received a copy of the GNU General Public License
19 *   along with this program; if not, write to the Free Software
20 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
21 *
22 *   Author:
23 *      Fabian 'x3n' Landau
24 *      Reto Grieder
25 *   Co-authors:
26 *      ...
27 */
28
[1778]29/**
[7401]30@file
31@ingroup Convert
32@brief
33    Conversion functions for Math types like Ogre::Vector3 (definitions are in Math.cc)
[1777]34*/
35
36#ifndef _MathConvert_H__
37#define _MathConvert_H__
38
39#include "UtilPrereqs.h"
[2014]40#include "Math.h"
[1777]41#include "Convert.h"
42
[2171]43namespace orxonox
44{
45    ////////////////////
46    // Math to string //
47    ////////////////////
[1777]48
[7401]49    /// Ogre::Vector2 to std::string conversion
[2171]50    template <>
51    struct ConverterExplicit<orxonox::Vector2, std::string>
[1777]52    {
[8351]53        ORX_FORCEINLINE static bool convert(std::string* output, const orxonox::Vector2& input)
[1779]54        {
[2171]55            std::ostringstream ostream;
[6417]56            if (ostream << input.x << ',' << input.y)
[2171]57            {
58                (*output) = ostream.str();
59                return true;
60            }
61            return false;
[1779]62        }
[2171]63    };
[1777]64
[7401]65    /// Ogre::Vector3 to std::string conversion
[2171]66    template <>
67    struct ConverterExplicit<orxonox::Vector3, std::string>
[1777]68    {
[8351]69        ORX_FORCEINLINE static bool convert(std::string* output, const orxonox::Vector3& input)
[1779]70        {
[2171]71            std::ostringstream ostream;
[6417]72            if (ostream << input.x << ',' << input.y << ',' << input.z)
[2171]73            {
74                (*output) = ostream.str();
75                return true;
76            }
77            return false;
[1779]78        }
[2171]79    };
[1777]80
[7401]81    /// Ogre::Vector4 to std::string conversion
[2171]82    template <>
83    struct ConverterExplicit<orxonox::Vector4, std::string>
[1777]84    {
[8351]85        ORX_FORCEINLINE static bool convert(std::string* output, const orxonox::Vector4& input)
[1779]86        {
[2171]87            std::ostringstream ostream;
[6417]88            if (ostream << input.x << ',' << input.y << ',' << input.z << ',' << input.w)
[2171]89            {
90                (*output) = ostream.str();
91                return true;
92            }
93            return false;
[1779]94        }
[2171]95    };
[1777]96
[7401]97    /// Ogre::Quaternion to std::string conversion
[2171]98    template <>
99    struct ConverterExplicit<orxonox::Quaternion, std::string>
[1777]100    {
[8351]101        ORX_FORCEINLINE static bool convert(std::string* output, const orxonox::Quaternion& input)
[1779]102        {
[2171]103            std::ostringstream ostream;
[6417]104            if (ostream << input.w << ',' << input.x << ',' << input.y << ',' << input.z)
[2171]105            {
106                (*output) = ostream.str();
107                return true;
108            }
109            return false;
[1779]110        }
[2171]111    };
[1777]112
[7401]113    /// Ogre::ColourValue to std::string conversion
[2171]114    template <>
115    struct ConverterExplicit<orxonox::ColourValue, std::string>
[1777]116    {
[8351]117        ORX_FORCEINLINE static bool convert(std::string* output, const orxonox::ColourValue& input)
[1779]118        {
[2171]119            std::ostringstream ostream;
[6417]120            if (ostream << input.r << ',' << input.g << ',' << input.b << ',' << input.a)
[2171]121            {
122                (*output) = ostream.str();
123                return true;
124            }
125            return false;
[1779]126        }
[2171]127    };
[1777]128
129
[2171]130    ////////////////////
131    // string to Math //
132    ////////////////////
[1777]133
[7401]134    /// std::string to Ogre::Vector2 conversion
[2171]135    template <> struct _UtilExport ConverterFallback<std::string, orxonox::Vector2>
136    { static bool convert(orxonox::Vector2*     output, const std::string& input); };
[7401]137    /// std::string to Ogre::Vector3 conversion
[2171]138    template <> struct _UtilExport ConverterFallback<std::string, orxonox::Vector3>
139    { static bool convert(orxonox::Vector3*     output, const std::string& input); };
[7401]140    /// std::string to Ogre::Vector4 conversion
[2171]141    template <> struct _UtilExport ConverterFallback<std::string, orxonox::Vector4>
142    { static bool convert(orxonox::Vector4*     output, const std::string& input); };
[7401]143    /// std::string to Ogre::Quaternion conversion
[2171]144    template <> struct _UtilExport ConverterFallback<std::string, orxonox::Quaternion>
145    { static bool convert(orxonox::Quaternion*  output, const std::string& input); };
[7401]146    /// std::string to Ogre::ColourValue conversion
[2171]147    template <> struct _UtilExport ConverterFallback<std::string, orxonox::ColourValue>
148    { static bool convert(orxonox::ColourValue* output, const std::string& input); };
[1777]149
150
[2171]151    ///////////////////////////////
152    // From and to Radian/Degree //
153    ///////////////////////////////
[1777]154
[7401]155    /// Delegates conversions from Radian to conversions from float
[2171]156    template <class ToType>
157    struct ConverterFallback<orxonox::Radian, ToType>
[2014]158    {
[8351]159        ORX_FORCEINLINE static bool convert(ToType* output, const orxonox::Radian& input)
[2171]160        {
161            return convertValue<Ogre::Real, ToType>(output, input.valueRadians());
162        }
163    };
[1777]164
[7401]165    /// Delegates conversions from Degree to conversions from float
[2171]166    template <class ToType>
167    struct ConverterFallback<orxonox::Degree, ToType>
[2014]168    {
[8351]169        ORX_FORCEINLINE static bool convert(ToType* output, const orxonox::Degree& input)
[2171]170        {
171            return convertValue<Ogre::Real, ToType>(output, input.valueDegrees());
172        }
173    };
[1777]174
[7401]175    /// Delegates conversions to Radian to conversions to float
[2171]176    template <class FromType>
177    struct ConverterFallback<FromType, orxonox::Radian>
[1777]178    {
[8351]179        ORX_FORCEINLINE static bool convert(orxonox::Radian* output, const FromType& input)
[2014]180        {
[2171]181            float temp;
182            if (convertValue(&temp, input))
183            {
184                *output = temp;
185                return true;
186            }
187            else
188                return false;
[2014]189        }
[2171]190    };
[1777]191
[7401]192    /// Delegates conversions to Degree to conversions to float
[2171]193    template <class FromType>
194    struct ConverterFallback<FromType, orxonox::Degree>
[1777]195    {
[8351]196        ORX_FORCEINLINE static bool convert(orxonox::Degree* output, const FromType& input)
[2014]197        {
[2171]198            float temp;
199            if (convertValue(&temp, input))
200            {
201                *output = temp;
202                return true;
203            }
204            else
205                return false;
[2014]206        }
[2171]207    };
208}
[1777]209
210#endif /* _MathConvert_H__ */
Note: See TracBrowser for help on using the repository browser.