Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Sep 8, 2008, 11:17:20 PM (16 years ago)
Author:
rgrieder
Message:
  • Extended convert a little bit support template specialisations as well.
  • Converted conversion function with Math and std::string to Math.h and .cc
File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/core3/src/util/Math.h

    r1566 r1745  
    4141#include <OgreQuaternion.h>
    4242#include <OgreColourValue.h>
     43#include "SubString.h"
    4344
    4445namespace orxonox
     
    6465_UtilExport orxonox::Vector3 getPredictedPosition(const orxonox::Vector3& myposition, float projectilespeed, const orxonox::Vector3& targetposition, const orxonox::Vector3& targetvelocity);
    6566
     67/////////////////////////////////////
     68// Conversion Functions of our own //
     69/////////////////////////////////////
     70
     71// Vector2 to std::string
     72inline bool explicitConversion(std::string* output, const orxonox::Vector2& input)
     73{
     74    std::ostringstream ostream;
     75    if (ostream << input.x << "," << input.y)
     76    {
     77        (*output) = ostream.str();
     78        return true;
     79    }
     80    return false;
     81}
     82
     83// Vector3 to std::string
     84inline bool explicitConversion(std::string* output, const orxonox::Vector3& input)
     85{
     86    std::ostringstream ostream;
     87    if (ostream << input.x << "," << input.y << "," << input.z)
     88    {
     89        (*output) = ostream.str();
     90        return true;
     91    }
     92    return false;
     93}
     94
     95// Vector4 to std::string
     96inline bool explicitConversion(std::string* output, const orxonox::Vector4& input)
     97{
     98    std::ostringstream ostream;
     99    if (ostream << input.x << "," << input.y << "," << input.z << "," << input.w)
     100    {
     101        (*output) = ostream.str();
     102        return true;
     103    }
     104    return false;
     105}
     106
     107// Quaternion to std::string
     108inline bool explicitConversion(std::string* output, const orxonox::Quaternion& input)
     109{
     110    std::ostringstream ostream;
     111    if (ostream << input.w << "," << input.x << "," << input.y << "," << input.z)
     112    {
     113        (*output) = ostream.str();
     114        return true;
     115    }
     116    return false;
     117}
     118
     119// ColourValue to std::string
     120inline bool explicitConversion(std::string* output, const orxonox::ColourValue& input)
     121{
     122    std::ostringstream ostream;
     123    if (ostream << input.r << "," << input.g << "," << input.b << "," << input.a)
     124    {
     125        (*output) = ostream.str();
     126        return true;
     127    }
     128    return false;
     129}
     130
     131// std::string to Vector2
     132_UtilExport bool explicitConversion(orxonox::Vector2* output, const std::string& input);
     133// std::string to Vector3
     134_UtilExport bool explicitConversion(orxonox::Vector3* output, const std::string& input);
     135// std::string to Vector4
     136_UtilExport bool explicitConversion(orxonox::Vector4* output, const std::string& input);
     137// std::string to Quaternion
     138_UtilExport bool explicitConversion(orxonox::Quaternion* output, const std::string& input);
     139// std::string to ColourValue
     140_UtilExport bool explicitConversion(orxonox::ColourValue* output, const std::string& input);
     141
    66142template <typename T>
    67143inline T sgn(T x)
Note: See TracChangeset for help on using the changeset viewer.