Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 853


Ignore:
Timestamp:
Mar 5, 2008, 6:38:09 PM (17 years ago)
Author:
landauf
Message:

sync with notebook, there are some changes in the MultiTypes, XMLPort and the WorldEntity, but there's still a bug in some of the Converter-specializations

Location:
code/branches/core
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • code/branches/core/bin/levels/sample.oxw

    r851 r853  
    3535<NPC position="100,0,400" scale="1" mesh="razor.mesh"/>
    3636
    37 <Model name="starship" position="200,0,500" scale="10" mesh="starship.mesh" yaw="-90" pitch="-90" />
     37<Model name="starship" position="(200,0,500)" scale="10" mesh="starship.mesh" yaw="-90" pitch="-90" />
    3838<Model name="drone" position="-200,0,500" scale="10" mesh="drone.mesh" yaw="-90" pitch="-90" />
    39 
     39<!--
    4040<Model position="-200,1000,500" scale="10" mesh="hoover_body.mesh" yaw="-90" pitch="-90" />
    4141<Model position="-200,1000,500" scale="10" mesh="hoover_gear0.mesh" yaw="-90" pitch="-90" />
     
    4848<Model position="12893,-1583,-17939" scale="48" mesh="ast1.mesh" rotationAxis="0.0597998,0.923364,0" rotationRate="36" />
    4949<Model position="-2107,259,-19814" scale="29" mesh="ast4.mesh" rotationAxis="0.298639,0.96907,0" rotationRate="32" />
    50 
     50-->
    5151<!-- Unused at the moment -->
    5252<!--  <SpaceshipSteeringObject node="OgreHeadNode" forward="500" rotateupdown="200" rotaterightleft="200" looprightleft="200" /> -->
  • code/branches/core/src/orxonox/core/BaseObject.cc

    r852 r853  
    7979    Element& BaseObject::XMLPort(Element& xmlelement, bool loading)
    8080    {
     81        std::cout << "1_1: " << this->getName() << std::endl;
    8182        XMLPortParam(BaseObject, "name", setName, getName, xmlelement, loading);
    82 
     83std::cout << "1_2: " << this->getName() << std::endl;
    8384        return xmlelement;
    8485    }
  • code/branches/core/src/orxonox/core/XMLPort.h

    r850 r853  
    4848    xmlcontainer##loadfunction##savefunction->port(this, xmlelement, loading)
    4949
     50#define XMLPortParamLoadOnly(classname, paramname, loadfunction, xmlelement, loading) \
     51    orxonox::XMLPortClassParamContainer<classname>* xmlcontainer##loadfunction##savefunction = (orxonox::XMLPortClassParamContainer<classname>*)(this->getIdentifier()->getXMLPortParamContainer(paramname)); \
     52    if (!xmlcontainer##loadfunction##savefunction) \
     53    { \
     54        xmlcontainer##loadfunction##savefunction = new orxonox::XMLPortClassParamContainer<classname>(this->getIdentifier()->getName(), std::string(paramname), createFunctor(&classname::loadfunction), 0); \
     55        this->getIdentifier()->addXMLPortParamContainer(paramname, xmlcontainer##loadfunction##savefunction); \
     56    } \
     57    xmlcontainer##loadfunction##savefunction->port(this, xmlelement, loading)
    5058
    5159namespace orxonox
     
    100108                if (loading)
    101109                {
     110std::cout << "3_1: load param " << this->paramname_ << std::endl;
    102111                    std::string attribute = xmlelement.GetAttribute(this->paramname_);
     112std::cout << "3_2: attribute " << attribute << std::endl;
    103113                    if (attribute.size() > 0)
    104114                    {
    105115                        SubString tokens(attribute, ",", SubString::WhiteSpaces, false, '\\', '"', '(', ')', '\0');
     116std::cout << "3_3: tokens: " << tokens.size() << " params: " << this->loadfunction_->getParamCount() << std::endl;
    106117                        if ((unsigned int)tokens.size() >= (unsigned int)this->loadfunction_->getParamCount())
    107118                        {
    108                             MultiTypeMath param1, param2, param3, param4, param5;
    109                             if (tokens.size() >= 1) param1 = tokens[0];
    110                             if (tokens.size() >= 2) param1 = tokens[1];
    111                             if (tokens.size() >= 3) param1 = tokens[2];
    112                             if (tokens.size() >= 4) param1 = tokens[3];
    113                             if (tokens.size() >= 5) param1 = tokens[4];
     119                            if (this->loadfunction_->getParamCount() == 1)
     120                            {
     121std::cout << "3_4 start: load with whole attribute as input" << std::endl;
     122                                (*this->loadfunction_)(object, MultiTypeMath(attribute));
     123std::cout << "3_5 end" << std::endl;
     124                            }
     125                            else
     126                            {
     127std::cout << "3_4: load with tokens as input" << std::endl;
     128                                MultiTypeMath param1, param2, param3, param4, param5;
     129                                if (tokens.size() >= 1) param1 = tokens[0];
     130                                if (tokens.size() >= 2) param1 = tokens[1];
     131                                if (tokens.size() >= 3) param1 = tokens[2];
     132                                if (tokens.size() >= 4) param1 = tokens[3];
     133                                if (tokens.size() >= 5) param1 = tokens[4];
    114134
    115                             (*this->loadfunction_)(object, param1, param2, param3, param4, param5);
     135                                (*this->loadfunction_)(object, param1, param2, param3, param4, param5);
     136                            }
    116137                        }
    117138                        else
     
    123144                else
    124145                {
    125 //                    xmlelement.SetAttribute(this->paramname_, "...");
     146                    if (this->savefunction_)
     147                    {
     148//                        xmlelement.SetAttribute(this->paramname_, "...");
     149                    }
    126150                }
    127151
  • code/branches/core/src/orxonox/objects/WorldEntity.cc

    r850 r853  
    172172        XMLPortParam(WorldEntity, "position", setPosition, getPosition, xmlelement, loading);
    173173//        XMLPortParam(WorldEntity, "direction", setDirection, getDirection, xmlelement, loading);
    174 //        XMLPortParam(WorldEntity, "yaw", yaw, getYaw, xmlelement, loading);
    175 //        XMLPortParam(WorldEntity, "pitch", pitch, getPitch, xmlelement, loading);
    176 //        XMLPortParam(WorldEntity, "roll", roll, getRoll, xmlelement, loading);
    177         XMLPortParam(WorldEntity, "scale", setScale, getScale, xmlelement, loading);
     174        XMLPortParamLoadOnly(WorldEntity, "yaw", setYaw, xmlelement, loading);
     175        XMLPortParamLoadOnly(WorldEntity, "pitch", setPitch, xmlelement, loading);
     176        XMLPortParamLoadOnly(WorldEntity, "roll", setRoll, xmlelement, loading);
     177        XMLPortParam(WorldEntity, "scale", setTotalScale, getScale, xmlelement, loading);
    178178        XMLPortParam(WorldEntity, "rotationAxis", setRotationAxis, getRotationAxis, xmlelement, loading);
    179179        XMLPortParam(WorldEntity, "rotationRate", setRotationRate, getRotationRate, xmlelement, loading);
  • code/branches/core/src/orxonox/objects/WorldEntity.h

    r852 r853  
    5757                { this->node_->roll(angle, relativeTo); }
    5858
     59            inline void setYaw(const Degree &angle)
     60                { this->node_->yaw(angle, Ogre::Node::TS_LOCAL); }
     61            inline void setPitch(const Degree &angle)
     62                { this->node_->pitch(angle, Ogre::Node::TS_LOCAL); }
     63            inline void setRoll(const Degree &angle)
     64                { this->node_->roll(angle, Ogre::Node::TS_LOCAL); }
     65
    5966            inline const Ogre::Quaternion& getOrientation()
    6067              { return this->node_->getOrientation(); }
     
    7582              { this->node_->setScale(x, y, z); }
    7683            inline void setScale(Real scale)
     84              { this->node_->setScale(scale, scale, scale); }
     85            inline void setTotalScale(Real scale)
    7786              { this->node_->setScale(scale, scale, scale); }
    7887            inline const Vector3& getScale(void) const
  • code/branches/core/src/util/Convert.h

    r848 r853  
    397397    bool operator()(orxonox::Vector2* output, const std::string& input) const
    398398    {
    399       SubString tokens(input, ",", SubString::WhiteSpaces, false, '\\', '"', '(', ')', '\0');
     399      SubString tokens(input, ",", SubString::WhiteSpaces, false, '\\', '"', '\0', '\0', '\0');
    400400
    401401      if (tokens.size() >= 2)
     
    420420    bool operator()(orxonox::Vector3* output, const std::string& input) const
    421421    {
    422       SubString tokens(input, ",", SubString::WhiteSpaces, false, '\\', '"', '(', ')', '\0');
     422      SubString tokens(input, ",", SubString::WhiteSpaces, false, '\\', '"', '\0', '\0', '\0');
    423423
    424424      if (tokens.size() >= 3)
     
    445445    bool operator()(orxonox::Vector4* output, const std::string& input) const
    446446    {
    447       SubString tokens(input, ",", SubString::WhiteSpaces, false, '\\', '"', '(', ')', '\0');
     447      SubString tokens(input, ",", SubString::WhiteSpaces, false, '\\', '"', '\0', '\0', '\0');
    448448
    449449      if (tokens.size() >= 4)
     
    472472    bool operator()(orxonox::Quaternion* output, const std::string& input) const
    473473    {
    474       SubString tokens(input, ",", SubString::WhiteSpaces, false, '\\', '"', '(', ')', '\0');
     474      SubString tokens(input, ",", SubString::WhiteSpaces, false, '\\', '"', '\0', '\0', '\0');
    475475
    476476      if (tokens.size() >= 4)
     
    499499    bool operator()(orxonox::ColourValue* output, const std::string& input) const
    500500    {
    501       SubString tokens(input, ",", SubString::WhiteSpaces, false, '\\', '"', '(', ')', '\0');
     501      SubString tokens(input, ",", SubString::WhiteSpaces, false, '\\', '"', '\0', '\0', '\0');
    502502
    503503      if (tokens.size() >= 4)
  • code/branches/core/src/util/MultiTypeMath.cc

    r848 r853  
    4444    else if (type == MT_degree)
    4545        this->degree_ = orxonox::Degree(0);
    46 }
    47 
    48 MultiTypeMath::MultiTypeMath(const MultiTypeMath& mtm) : MultiTypeString(mtm)
    49 {
    50     this->type_ = mtm.type_;
    51     this->value_ = mtm.value_;
    52 }
    53 
    54 MultiTypeMath& MultiTypeMath::operator=(const MultiTypeMath& mtm)
    55 {
    56     this->type_ = mtm.type_;
    57     this->value_ = mtm.value_;
    58     return *this;
    5946}
    6047
     
    10390MultiTypeMath::operator orxonox::Vector2() const
    10491{
    105     return (this->type_ == MT_vector2) ? this->vector2_ : ConvertValueAndReturn<MultiTypePrimitive, orxonox::Vector2>(*this);
     92    return (this->type_ == MT_vector2) ? this->vector2_ : ConvertValueAndReturn<MultiTypeMath, orxonox::Vector2>(*this);
    10693}
    10794
    10895MultiTypeMath::operator orxonox::Vector3() const
    10996{
    110     return (this->type_ == MT_vector3) ? this->vector3_ : ConvertValueAndReturn<MultiTypePrimitive, orxonox::Vector3>(*this);
     97std::cout << "4_2: Convert MultiTypeMath to Vector3:" << std::endl;
     98std::cout << "     MultiTypeMath has type " << this->getType() << std::endl;
     99std::cout << MT_vector3 << std::endl;
     100std::cout << MT_string << std::endl;
     101std::cout << MT_vector2 << std::endl;
     102std::cout << MT_int << std::endl;
     103std::cout << MT_uint << std::endl;
     104std::cout << MT_null << std::endl;
     105if (this->type_ == MT_vector3)
     106{
     107    std::cout << "     MultiTypeMath contains already a Vector3" << std::endl;
     108    std::cout << "     Returnvalue is " << this->vector3_ << std::endl;
     109}
     110else
     111{
     112    std::cout << "     MultiTypeMath doesn't contain a Vector3" << std::endl;
     113    std::cout << "     Returnvalue is " << ConvertValueAndReturn<MultiTypeMath, orxonox::Vector3>(*this) << std::endl;
     114    std::cout << "     Returnvalue was " << ConvertValueAndReturn<MultiTypePrimitive, orxonox::Vector3>(*this) << std::endl;
     115}
     116    return (this->type_ == MT_vector3) ? this->vector3_ : ConvertValueAndReturn<MultiTypeMath, orxonox::Vector3>(*this);
    111117}
    112118
    113119MultiTypeMath::operator orxonox::Quaternion() const
    114120{
    115     return (this->type_ == MT_quaternion) ? this->quaternion_ : ConvertValueAndReturn<MultiTypePrimitive, orxonox::Quaternion>(*this);
     121    return (this->type_ == MT_quaternion) ? this->quaternion_ : ConvertValueAndReturn<MultiTypeMath, orxonox::Quaternion>(*this);
    116122}
    117123
    118124MultiTypeMath::operator orxonox::ColourValue() const
    119125{
    120     return (this->type_ == MT_colourvalue) ? this->colourvalue_ : ConvertValueAndReturn<MultiTypePrimitive, orxonox::ColourValue>(*this);
     126    return (this->type_ == MT_colourvalue) ? this->colourvalue_ : ConvertValueAndReturn<MultiTypeMath, orxonox::ColourValue>(*this);
    121127}
    122128
    123129MultiTypeMath::operator orxonox::Radian() const
    124130{
    125     return (this->type_ == MT_radian) ? this->radian_ : ConvertValueAndReturn<MultiTypePrimitive, orxonox::Radian>(*this);
     131    return (this->type_ == MT_radian) ? this->radian_ : ConvertValueAndReturn<MultiTypeMath, orxonox::Radian>(*this);
    126132}
    127133
    128134MultiTypeMath::operator orxonox::Degree() const
    129135{
    130     return (this->type_ == MT_degree) ? this->degree_ : ConvertValueAndReturn<MultiTypePrimitive, orxonox::Degree>(*this);
     136    return (this->type_ == MT_degree) ? this->degree_ : ConvertValueAndReturn<MultiTypeMath, orxonox::Degree>(*this);
    131137}
    132138
    133139void MultiTypeMath::setValue(const MultiTypeMath& mtm)
    134140{
    135     this->type_ = mtm.type_;
    136     this->value_ = mtm.value_;
     141    std::cout << "4_3: setValue in MultiTypeMath with other Multitype as parameter: " << mtm << std::endl;
     142
     143    MultiTypeString::setValue(mtm);
     144    this->vector2_ = mtm.vector2_;
     145    this->vector3_ = mtm.vector3_;
     146    this->quaternion_ = mtm.quaternion_;
     147    this->colourvalue_ = mtm.colourvalue_;
     148    this->radian_ = mtm.radian_;
     149    this->degree_ = mtm.degree_;
    137150}
    138151
  • code/branches/core/src/util/MultiTypeMath.h

    r848 r853  
    5959        inline MultiTypeMath(const orxonox::Radian&      value) { this->setValue(value); }
    6060        inline MultiTypeMath(const orxonox::Degree&      value) { this->setValue(value); }
    61         MultiTypeMath(const MultiTypeMath& mtm);
     61        inline MultiTypeMath(const MultiTypeMath& mtm)          { this->setValue(mtm);   }
    6262
    6363        using MultiTypeString::operator=;
     
    6868        inline MultiTypeMath& operator=(const orxonox::Radian&      value) { this->setValue(value); return *this; }
    6969        inline MultiTypeMath& operator=(const orxonox::Degree&      value) { this->setValue(value); return *this; }
    70         MultiTypeMath& operator=(const MultiTypeMath& mtm);
     70        inline MultiTypeMath& operator=(const MultiTypeMath& mtm)          { this->setValue(mtm);   return *this; }
    7171
    7272        using MultiTypeString::operator==;
     
    9797        using MultiTypeString::setValue;
    9898        inline void setValue(const orxonox::Vector2&     value) { this->type_ = MT_vector2;     this->vector2_     = value; }
    99         inline void setValue(const orxonox::Vector3&     value) { this->type_ = MT_vector3;     this->vector3_     = value; }
     99        inline void setValue(const orxonox::Vector3&     value) { std::cout << "4_4: setValue Vector3: " << value << std::endl; this->type_ = MT_vector3;     this->vector3_     = value; }
    100100        inline void setValue(const orxonox::ColourValue& value) { this->type_ = MT_colourvalue; this->colourvalue_ = value; }
    101101        inline void setValue(const orxonox::Quaternion&  value) { this->type_ = MT_quaternion;  this->quaternion_  = value; }
  • code/branches/core/src/util/MultiTypePrimitive.cc

    r848 r853  
    3232MultiTypePrimitive::MultiTypePrimitive(MultiType type)
    3333{
     34std::cout << "4_5: Created MultiTypePrimitive with type " << type << std::endl;
    3435    this->type_ = type;
    3536
     
    6061    else
    6162        this->value_.int_ = 0;
    62 }
    63 
    64 MultiTypePrimitive::MultiTypePrimitive(const MultiTypePrimitive& mtp)
    65 {
    66     this->type_ = mtp.type_;
    67     this->value_ = mtp.value_;
    68 }
    69 
    70 MultiTypePrimitive& MultiTypePrimitive::operator=(const MultiTypePrimitive& mtp)
    71 {
    72     this->type_ = mtp.type_;
    73     this->value_ = mtp.value_;
    74     return *this;
    7563}
    7664
     
    203191void MultiTypePrimitive::setValue(const MultiTypePrimitive& mtp)
    204192{
     193    std::cout << "4_3: setValue in MultiTypePrimitive with other Multitype as parameter: " << mtp << std::endl;
    205194    this->type_ = mtp.type_;
    206195    this->value_ = mtp.value_;
  • code/branches/core/src/util/MultiTypePrimitive.h

    r848 r853  
    5252        inline MultiTypePrimitive(long double    value) { this->setValue(value); }
    5353        inline MultiTypePrimitive(bool           value) { this->setValue(value); }
    54         MultiTypePrimitive(const MultiTypePrimitive& mtp);
     54        inline MultiTypePrimitive(const MultiTypePrimitive& mtp) { this->setValue(mtp); }
    5555
    5656        inline MultiTypePrimitive& operator=(MultiType      value) { this->type_ = MT_null; return *this; }
     
    6767        inline MultiTypePrimitive& operator=(long double    value) { this->setValue(value); return *this; }
    6868        inline MultiTypePrimitive& operator=(bool           value) { this->setValue(value); return *this; }
    69         MultiTypePrimitive& operator=(const MultiTypePrimitive& mtp);
     69        inline MultiTypePrimitive& operator=(const MultiTypePrimitive& mtp) { this->setValue(mtp); return *this; }
    7070
    7171        inline bool operator==(int            value) const { return (this->value_.int_        == value); }
  • code/branches/core/src/util/MultiTypeString.cc

    r848 r853  
    3838}
    3939
    40 MultiTypeString::MultiTypeString(const MultiTypeString& mts) : MultiTypePrimitive(mts)
    41 {
    42     this->type_ = mts.type_;
    43     this->value_ = mts.value_;
    44 }
    45 
    46 MultiTypeString& MultiTypeString::operator=(const MultiTypeString& mts)
    47 {
    48     this->type_ = mts.type_;
    49     this->value_ = mts.value_;
    50     return *this;
    51 }
    52 
    5340bool MultiTypeString::operator==(const MultiTypeString& mts) const
    5441{
     
    7966MultiTypeString::operator std::string() const
    8067{
    81     return (this->type_ == MT_string) ? this->string_ : ConvertValueAndReturn<MultiTypePrimitive, std::string>(*this);
     68    return (this->type_ == MT_string) ? this->string_ : ConvertValueAndReturn<MultiTypeString, std::string>(*this);
    8269}
    8370
    8471MultiTypeString::operator const char*() const
    8572{
    86     return (this->type_ == MT_constchar) ? this->string_.c_str() : ConvertValueAndReturn<MultiTypePrimitive, const char*>(*this);
     73    return ((this->type_ == MT_constchar) ? this->string_ : ConvertValueAndReturn<MultiTypeString, std::string>(*this)).c_str();
    8774}
    8875
    8976void MultiTypeString::setValue(const MultiTypeString& mts)
    9077{
    91     this->type_ = mts.type_;
    92     this->value_ = mts.value_;
     78    MultiTypePrimitive::setValue(mts);
     79    this->string_ = mts.string_;
    9380}
    9481
  • code/branches/core/src/util/MultiTypeString.h

    r848 r853  
    3131
    3232#include <string>
    33 
     33#include <iostream>
    3434#include "UtilPrereqs.h"
    3535
     
    5252        inline MultiTypeString(long double    value) : MultiTypePrimitive(value) {}
    5353        inline MultiTypeString(bool           value) : MultiTypePrimitive(value) {}
    54         inline MultiTypeString(const char*        value) { this->setValue(value); }
    55         inline MultiTypeString(const std::string& value) { this->setValue(value); }
    56         MultiTypeString(const MultiTypeString& mtp);
     54        inline MultiTypeString(const char*        value)   { this->setValue(value); }
     55        inline MultiTypeString(const std::string& value)   { this->setValue(value); std::cout << "4_1: Created MultiTypeString with value " << value << " and type " << this->getType() << std::endl; }
     56        inline MultiTypeString(const MultiTypeString& mts) { this->setValue(mts);   }
    5757
    5858        using MultiTypePrimitive::operator=;
    59         inline MultiTypeString& operator=(const char*        value) { this->setValue(value); return *this; }
    60         inline MultiTypeString& operator=(const std::string& value) { this->setValue(value); return *this; }
    61         MultiTypeString& operator=(const MultiTypeString& mtp);
     59        inline MultiTypeString& operator=(const char*        value)   { this->setValue(value); return *this; }
     60        inline MultiTypeString& operator=(const std::string& value)   { this->setValue(value); return *this; }
     61        inline MultiTypeString& operator=(const MultiTypeString& mts) { this->setValue(mts);   return *this; }
    6262
    6363        using MultiTypePrimitive::operator==;
    6464        inline bool operator==(const char*        value) const { return (this->string_ == std::string(value)); }
    6565        inline bool operator==(const std::string& value) const { return (this->string_ == value);              }
    66         bool operator==(const MultiTypeString& mtp) const;
     66        bool operator==(const MultiTypeString& mts) const;
    6767
    6868        using MultiTypePrimitive::operator!=;
    6969        inline bool operator!=(const char*        value) const { return (this->string_ != std::string(value)); }
    7070        inline bool operator!=(const std::string& value) const { return (this->string_ != value);              }
    71         bool operator!=(const MultiTypeString& mtp) const;
     71        bool operator!=(const MultiTypeString& mts) const;
    7272
    7373        operator std::string() const;
     
    7777        inline void setValue(const char*        value) { this->type_ = MT_string; this->string_ = std::string(value); }
    7878        inline void setValue(const std::string& value) { this->type_ = MT_string; this->string_ = value;              }
    79         void setValue(const MultiTypeString& mtp);
     79        void setValue(const MultiTypeString& mts);
    8080
    8181        inline const std::string getString() const { return this->string_;         }
Note: See TracChangeset for help on using the changeset viewer.