Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 1319


Ignore:
Timestamp:
May 19, 2008, 12:55:41 AM (17 years ago)
Author:
landauf
Message:

added support for Vector4 to MultiTypeMath and added a new function called 'assimilate' that converts the stored value of a given MultiType to it's own type and assigns it.

Location:
code/branches/console/src/util
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • code/branches/console/src/util/Convert.h

    r1064 r1319  
    384384        else if (input.getType() == MT_vector3)
    385385            return ConvertValue(output, input.getVector3());
     386        else if (input.getType() == MT_vector4)
     387            return ConvertValue(output, input.getVector4());
    386388        else if (input.getType() == MT_quaternion)
    387389            return ConvertValue(output, input.getQuaternion());
  • code/branches/console/src/util/MultiType.h

    r1056 r1319  
    5454    MT_vector2,
    5555    MT_vector3,
     56    MT_vector4,
    5657    MT_colourvalue,
    5758    MT_quaternion,
  • code/branches/console/src/util/MultiTypeMath.cc

    r1056 r1319  
    3737    else if (type == MT_vector3)
    3838        this->vector3_ = orxonox::Vector3(0, 0, 0);
     39    else if (type == MT_vector4)
     40        this->vector4_ = orxonox::Vector4(0, 0, 0, 0);
    3941    else if (type == MT_colourvalue)
    4042        this->colourvalue_ = orxonox::ColourValue(0, 0, 0, 0);
     
    5557        else if (this->type_ == MT_vector3)
    5658            return (this->vector3_ == mtm.vector3_);
     59        else if (this->type_ == MT_vector4)
     60            return (this->vector4_ == mtm.vector4_);
    5761        else if (this->type_ == MT_colourvalue)
    5862            return (this->colourvalue_ == mtm.colourvalue_);
     
    7680        else if (this->type_ == MT_vector3)
    7781            return (this->vector3_ != mtm.vector3_);
     82        else if (this->type_ == MT_vector4)
     83            return (this->vector4_ != mtm.vector4_);
    7884        else if (this->type_ == MT_colourvalue)
    7985            return (this->colourvalue_ != mtm.colourvalue_);
     
    123129MultiTypeMath::operator orxonox::Vector3() const
    124130{ return (this->type_ == MT_vector3) ? this->vector3_ : getConvertedValue<MultiTypeMath, orxonox::Vector3>(*this); }
     131MultiTypeMath::operator orxonox::Vector4() const
     132{ return (this->type_ == MT_vector4) ? this->vector4_ : getConvertedValue<MultiTypeMath, orxonox::Vector4>(*this); }
    125133MultiTypeMath::operator orxonox::Quaternion() const
    126134{ return (this->type_ == MT_quaternion) ? this->quaternion_ : getConvertedValue<MultiTypeMath, orxonox::Quaternion>(*this); }
     
    137145    this->vector2_ = mtm.vector2_;
    138146    this->vector3_ = mtm.vector3_;
     147    this->vector4_ = mtm.vector4_;
    139148    this->quaternion_ = mtm.quaternion_;
    140149    this->colourvalue_ = mtm.colourvalue_;
     
    149158    else if (this->type_ == MT_vector3)
    150159        return "Vector3";
     160    else if (this->type_ == MT_vector4)
     161        return "Vector4";
    151162    else if (this->type_ == MT_colourvalue)
    152163        return "ColourValue";
     
    169180    else if (this->type_ == MT_vector3)
    170181        ConvertValue(&output, this->vector3_);
     182    else if (this->type_ == MT_vector4)
     183        ConvertValue(&output, this->vector4_);
    171184    else if (this->type_ == MT_colourvalue)
    172185        ConvertValue(&output, this->colourvalue_);
     
    189202    else if (this->type_ == MT_vector3)
    190203        return ConvertValue(&this->vector3_, value, orxonox::Vector3(0, 0, 0));
     204    else if (this->type_ == MT_vector4)
     205        return ConvertValue(&this->vector4_, value, orxonox::Vector4(0, 0, 0, 0));
    191206    else if (this->type_ == MT_colourvalue)
    192207        return ConvertValue(&this->colourvalue_, value, orxonox::ColourValue(0, 0, 0, 0));
     
    199214    else
    200215        return MultiTypeString::fromString(value);
     216}
     217
     218void MultiTypeMath::assimilate(const MultiTypeMath& mtm)
     219{
     220    if (this->type_ == MT_vector2)
     221        this->vector2_ = mtm.operator orxonox::Vector2();
     222    else if (this->type_ == MT_vector3)
     223        this->vector3_ = mtm.operator orxonox::Vector3();
     224    else if (this->type_ == MT_vector4)
     225        this->vector4_ = mtm.operator orxonox::Vector4();
     226    else if (this->type_ == MT_colourvalue)
     227        this->colourvalue_ = mtm;
     228    else if (this->type_ == MT_quaternion)
     229        this->quaternion_ = mtm;
     230    else if (this->type_ == MT_radian)
     231        this->radian_ = mtm.operator orxonox::Radian();
     232    else if (this->type_ == MT_degree)
     233        this->degree_ = mtm.operator orxonox::Degree();
     234    else
     235        MultiTypeString::assimilate(mtm);
    201236}
    202237
  • code/branches/console/src/util/MultiTypeMath.h

    r1064 r1319  
    6363        inline MultiTypeMath(const orxonox::Vector2&     value) { this->setValue(value); }
    6464        inline MultiTypeMath(const orxonox::Vector3&     value) { this->setValue(value); }
     65        inline MultiTypeMath(const orxonox::Vector4&     value) { this->setValue(value); }
    6566        inline MultiTypeMath(const orxonox::ColourValue& value) { this->setValue(value); }
    6667        inline MultiTypeMath(const orxonox::Quaternion&  value) { this->setValue(value); }
     
    7374        inline MultiTypeMath& operator=(const orxonox::Vector2&     value) { this->setValue(value); return *this; }
    7475        inline MultiTypeMath& operator=(const orxonox::Vector3&     value) { this->setValue(value); return *this; }
     76        inline MultiTypeMath& operator=(const orxonox::Vector4&     value) { this->setValue(value); return *this; }
    7577        inline MultiTypeMath& operator=(const orxonox::ColourValue& value) { this->setValue(value); return *this; }
    7678        inline MultiTypeMath& operator=(const orxonox::Quaternion&  value) { this->setValue(value); return *this; }
     
    8284        inline bool operator==(const orxonox::Vector2&     value) const { return (this->vector2_     == value); }
    8385        inline bool operator==(const orxonox::Vector3&     value) const { return (this->vector3_     == value); }
     86        inline bool operator==(const orxonox::Vector4&     value) const { return (this->vector4_     == value); }
    8487        inline bool operator==(const orxonox::ColourValue& value) const { return (this->colourvalue_ == value); }
    8588        inline bool operator==(const orxonox::Quaternion&  value) const { return (this->quaternion_  == value); }
     
    9194        inline bool operator!=(const orxonox::Vector2&     value) const { return (this->vector2_     != value); }
    9295        inline bool operator!=(const orxonox::Vector3&     value) const { return (this->vector3_     != value); }
     96        inline bool operator!=(const orxonox::Vector4&     value) const { return (this->vector4_     != value); }
    9397        inline bool operator!=(const orxonox::ColourValue& value) const { return (this->colourvalue_ != value); }
    9498        inline bool operator!=(const orxonox::Quaternion&  value) const { return (this->quaternion_  != value); }
     
    114118        virtual operator orxonox::Vector2()     const;
    115119        virtual operator orxonox::Vector3()     const;
     120        virtual operator orxonox::Vector4()     const;
    116121        virtual operator orxonox::ColourValue() const;
    117122        virtual operator orxonox::Quaternion()  const;
     
    122127        inline void setValue(const orxonox::Vector2&     value) { this->type_ = MT_vector2;     this->vector2_     = value; }
    123128        inline void setValue(const orxonox::Vector3&     value) { this->type_ = MT_vector3;     this->vector3_     = value; }
     129        inline void setValue(const orxonox::Vector4&     value) { this->type_ = MT_vector4;     this->vector4_     = value; }
    124130        inline void setValue(const orxonox::ColourValue& value) { this->type_ = MT_colourvalue; this->colourvalue_ = value; }
    125131        inline void setValue(const orxonox::Quaternion&  value) { this->type_ = MT_quaternion;  this->quaternion_  = value; }
     
    130136        inline orxonox::Vector2     getVector2()     const { return this->vector2_;     }
    131137        inline orxonox::Vector3     getVector3()     const { return this->vector3_;     }
     138        inline orxonox::Vector4     getVector4()     const { return this->vector4_;     }
    132139        inline orxonox::ColourValue getColourValue() const { return this->colourvalue_; }
    133140        inline orxonox::Quaternion  getQuaternion()  const { return this->quaternion_;  }
     
    137144        inline orxonox::Vector2&     getVector2()     { return this->vector2_;     }
    138145        inline orxonox::Vector3&     getVector3()     { return this->vector3_;     }
     146        inline orxonox::Vector4&     getVector4()     { return this->vector4_;     }
    139147        inline orxonox::ColourValue& getColourValue() { return this->colourvalue_; }
    140148        inline orxonox::Quaternion&  getQuaternion()  { return this->quaternion_;  }
     
    145153        inline void getValue(orxonox::Vector2*     variable) const { (*variable) = orxonox::Vector2     (this->vector2_);     }
    146154        inline void getValue(orxonox::Vector3*     variable) const { (*variable) = orxonox::Vector3     (this->vector3_);     }
     155        inline void getValue(orxonox::Vector4*     variable) const { (*variable) = orxonox::Vector4     (this->vector4_);     }
    147156        inline void getValue(orxonox::ColourValue* variable) const { (*variable) = orxonox::ColourValue (this->colourvalue_); }
    148157        inline void getValue(orxonox::Quaternion*  variable) const { (*variable) = orxonox::Quaternion  (this->quaternion_);  }
     
    155164        virtual bool fromString(const std::string value);
    156165
     166        virtual void assimilate(const MultiTypeMath& mtm);
     167
    157168    protected:
    158169        orxonox::Vector2      vector2_;
    159170        orxonox::Vector3      vector3_;
     171        orxonox::Vector4      vector4_;
    160172        orxonox::ColourValue  colourvalue_;
    161173        orxonox::Quaternion   quaternion_;
  • code/branches/console/src/util/MultiTypePrimitive.cc

    r1056 r1319  
    266266}
    267267
     268void MultiTypePrimitive::assimilate(const MultiTypePrimitive& mtp)
     269{
     270    if (this->type_ == MT_void)
     271        this->value_.void_ = mtp;
     272    else if (this->type_ == MT_int)
     273        this->value_.int_ = mtp;
     274    else if (this->type_ == MT_uint)
     275        this->value_.uint_ = mtp;
     276    else if (this->type_ == MT_char)
     277        this->value_.char_ = mtp;
     278    else if (this->type_ == MT_uchar)
     279        this->value_.uchar_ = mtp;
     280    else if (this->type_ == MT_short)
     281        this->value_.short_ = mtp;
     282    else if (this->type_ == MT_ushort)
     283        this->value_.ushort_ = mtp;
     284    else if (this->type_ == MT_long)
     285        this->value_.long_ = mtp;
     286    else if (this->type_ == MT_ulong)
     287        this->value_.ulong_ = mtp;
     288    else if (this->type_ == MT_float)
     289        this->value_.float_ = mtp;
     290    else if (this->type_ == MT_double)
     291        this->value_.double_ = mtp;
     292    else if (this->type_ == MT_longdouble)
     293        this->value_.longdouble_ = mtp;
     294    else if (this->type_ == MT_bool)
     295        this->value_.bool_ = mtp;
     296}
     297
    268298std::ostream& operator<<(std::ostream& out, const MultiTypePrimitive& mtp)
    269299{
  • code/branches/console/src/util/MultiTypePrimitive.h

    r1062 r1319  
    187187        virtual bool fromString(const std::string value);
    188188
     189        virtual void assimilate(const MultiTypePrimitive& mtp);
     190
    189191    protected:
    190192        MultiTypeValue  value_;
  • code/branches/console/src/util/MultiTypeString.cc

    r1064 r1319  
    136136}
    137137
     138void MultiTypeString::assimilate(const MultiTypeString& mts)
     139{
     140    if (this->type_ == MT_constchar)
     141        this->string_ = mts.toString();
     142    else if (this->type_ == MT_string)
     143        this->string_ = mts.toString();
     144    else
     145        MultiTypePrimitive::assimilate(mts);
     146}
     147
    138148std::ostream& operator<<(std::ostream& out, MultiTypeString& mts)
    139149{
  • code/branches/console/src/util/MultiTypeString.h

    r1064 r1319  
    117117        virtual bool fromString(const std::string value);
    118118
     119        virtual void assimilate(const MultiTypeString& mts);
     120
    119121    protected:
    120122        std::string      string_;
Note: See TracChangeset for help on using the changeset viewer.