Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 19, 2008, 12:55:41 AM (16 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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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
Note: See TracChangeset for help on using the changeset viewer.