Changeset 848 for code/branches/core/src/util/MultiTypeMath.cc
- Timestamp:
- Mar 5, 2008, 1:29:47 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/core/src/util/MultiTypeMath.cc
r797 r848 28 28 29 29 #include "MultiTypeMath.h" 30 #include "Convert.h" 30 31 31 32 MultiTypeMath::MultiTypeMath(MultiType type) : MultiTypeString(type) … … 100 101 } 101 102 103 MultiTypeMath::operator orxonox::Vector2() const 104 { 105 return (this->type_ == MT_vector2) ? this->vector2_ : ConvertValueAndReturn<MultiTypePrimitive, orxonox::Vector2>(*this); 106 } 107 108 MultiTypeMath::operator orxonox::Vector3() const 109 { 110 return (this->type_ == MT_vector3) ? this->vector3_ : ConvertValueAndReturn<MultiTypePrimitive, orxonox::Vector3>(*this); 111 } 112 113 MultiTypeMath::operator orxonox::Quaternion() const 114 { 115 return (this->type_ == MT_quaternion) ? this->quaternion_ : ConvertValueAndReturn<MultiTypePrimitive, orxonox::Quaternion>(*this); 116 } 117 118 MultiTypeMath::operator orxonox::ColourValue() const 119 { 120 return (this->type_ == MT_colourvalue) ? this->colourvalue_ : ConvertValueAndReturn<MultiTypePrimitive, orxonox::ColourValue>(*this); 121 } 122 123 MultiTypeMath::operator orxonox::Radian() const 124 { 125 return (this->type_ == MT_radian) ? this->radian_ : ConvertValueAndReturn<MultiTypePrimitive, orxonox::Radian>(*this); 126 } 127 128 MultiTypeMath::operator orxonox::Degree() const 129 { 130 return (this->type_ == MT_degree) ? this->degree_ : ConvertValueAndReturn<MultiTypePrimitive, orxonox::Degree>(*this); 131 } 132 102 133 void MultiTypeMath::setValue(const MultiTypeMath& mtm) 103 134 { 104 135 this->type_ = mtm.type_; 105 136 this->value_ = mtm.value_; 137 } 138 139 std::string MultiTypeMath::toString() const 140 { 141 std::string output; 142 143 if (this->type_ == MT_vector2) 144 ConvertValue(&output, this->vector2_); 145 else if (this->type_ == MT_vector3) 146 ConvertValue(&output, this->vector3_); 147 else if (this->type_ == MT_colourvalue) 148 ConvertValue(&output, this->colourvalue_); 149 else if (this->type_ == MT_quaternion) 150 ConvertValue(&output, this->quaternion_); 151 else if (this->type_ == MT_radian) 152 ConvertValue(&output, this->radian_); 153 else if (this->type_ == MT_degree) 154 ConvertValue(&output, this->degree_); 155 else 156 return MultiTypeString::toString(); 157 158 return output; 159 } 160 161 bool MultiTypeMath::fromString(const std::string value) 162 { 163 if (this->type_ == MT_vector2) 164 return ConvertValue(&this->vector2_, value, orxonox::Vector2(0, 0)); 165 else if (this->type_ == MT_vector3) 166 return ConvertValue(&this->vector3_, value, orxonox::Vector3(0, 0, 0)); 167 else if (this->type_ == MT_colourvalue) 168 return ConvertValue(&this->colourvalue_, value, orxonox::ColourValue(0, 0, 0, 0)); 169 else if (this->type_ == MT_quaternion) 170 return ConvertValue(&this->quaternion_, value, orxonox::Quaternion(1, 0, 0, 0)); 171 else if (this->type_ == MT_radian) 172 return ConvertValue(&this->radian_, value, orxonox::Radian(0)); 173 else if (this->type_ == MT_degree) 174 return ConvertValue(&this->degree_, value, orxonox::Degree(0)); 175 else 176 return MultiTypeString::fromString(value); 106 177 } 107 178
Note: See TracChangeset
for help on using the changeset viewer.