[792] | 1 | /* |
---|
| 2 | * ORXONOX - the hottest 3D action shooter ever to exist |
---|
| 3 | * |
---|
| 4 | * |
---|
| 5 | * License notice: |
---|
| 6 | * |
---|
| 7 | * This program is free software; you can redistribute it and/or |
---|
| 8 | * modify it under the terms of the GNU General Public License |
---|
| 9 | * as published by the Free Software Foundation; either version 2 |
---|
| 10 | * of the License, or (at your option) any later version. |
---|
| 11 | * |
---|
| 12 | * This program is distributed in the hope that it will be useful, |
---|
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 15 | * GNU General Public License for more details. |
---|
| 16 | * |
---|
| 17 | * You should have received a copy of the GNU General Public License |
---|
| 18 | * along with this program; if not, write to the Free Software |
---|
| 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
---|
| 20 | * |
---|
| 21 | * Author: |
---|
| 22 | * Fabian 'x3n' Landau |
---|
| 23 | * Co-authors: |
---|
| 24 | * ... |
---|
| 25 | * |
---|
| 26 | * Inspiration: MultiType by Benjamin Grauer |
---|
| 27 | */ |
---|
| 28 | |
---|
| 29 | #include "MultiTypeMath.h" |
---|
| 30 | |
---|
| 31 | MultiTypeMath::MultiTypeMath(MultiType type) : MultiTypeString(type) |
---|
| 32 | { |
---|
| 33 | if (type == MT_vector2) |
---|
| 34 | this->vector2_ = orxonox::Vector2(0, 0); |
---|
| 35 | else if (type == MT_vector3) |
---|
| 36 | this->vector3_ = orxonox::Vector3(0, 0, 0); |
---|
| 37 | else if (type == MT_colourvalue) |
---|
| 38 | this->colourvalue_ = orxonox::ColourValue(0, 0, 0, 0); |
---|
| 39 | else if (type == MT_quaternion) |
---|
| 40 | this->quaternion_ = orxonox::Quaternion(1, 0, 0, 0); |
---|
| 41 | else if (type == MT_radian) |
---|
| 42 | this->radian_ = orxonox::Radian(0); |
---|
| 43 | else if (type == MT_degree) |
---|
| 44 | this->degree_ = orxonox::Degree(0); |
---|
| 45 | } |
---|
| 46 | |
---|
[794] | 47 | MultiTypeMath::MultiTypeMath(const MultiTypeMath& mtm) : MultiTypeString(mtm) |
---|
[792] | 48 | { |
---|
| 49 | this->type_ = mtm.type_; |
---|
| 50 | this->value_ = mtm.value_; |
---|
| 51 | } |
---|
| 52 | |
---|
| 53 | MultiTypeMath& MultiTypeMath::operator=(const MultiTypeMath& mtm) |
---|
| 54 | { |
---|
| 55 | this->type_ = mtm.type_; |
---|
| 56 | this->value_ = mtm.value_; |
---|
| 57 | return *this; |
---|
| 58 | } |
---|
| 59 | |
---|
| 60 | bool MultiTypeMath::operator==(const MultiTypeMath& mtm) const |
---|
| 61 | { |
---|
| 62 | if (!MultiTypeString::operator==(mtm) && this->type_ == mtm.type_) |
---|
| 63 | { |
---|
| 64 | if (this->type_ == MT_vector2) |
---|
| 65 | return (this->vector2_ == mtm.vector2_); |
---|
| 66 | else if (this->type_ == MT_vector3) |
---|
| 67 | return (this->vector3_ == mtm.vector3_); |
---|
| 68 | else if (this->type_ == MT_colourvalue) |
---|
| 69 | return (this->colourvalue_ == mtm.colourvalue_); |
---|
| 70 | else if (this->type_ == MT_quaternion) |
---|
| 71 | return (this->quaternion_ == mtm.quaternion_); |
---|
| 72 | else if (this->type_ == MT_radian) |
---|
| 73 | return (this->radian_ == mtm.radian_); |
---|
| 74 | else if (this->type_ == MT_degree) |
---|
| 75 | return (this->degree_ == mtm.degree_); |
---|
| 76 | } |
---|
| 77 | |
---|
| 78 | return false; |
---|
| 79 | } |
---|
| 80 | |
---|
| 81 | bool MultiTypeMath::operator!=(const MultiTypeMath& mtm) const |
---|
| 82 | { |
---|
| 83 | if (MultiTypeString::operator==(mtm) && this->type_ == mtm.type_) |
---|
| 84 | { |
---|
| 85 | if (this->type_ == MT_vector2) |
---|
| 86 | return (this->vector2_ != mtm.vector2_); |
---|
| 87 | else if (this->type_ == MT_vector3) |
---|
| 88 | return (this->vector3_ != mtm.vector3_); |
---|
| 89 | else if (this->type_ == MT_colourvalue) |
---|
| 90 | return (this->colourvalue_ != mtm.colourvalue_); |
---|
| 91 | else if (this->type_ == MT_quaternion) |
---|
| 92 | return (this->quaternion_ != mtm.quaternion_); |
---|
| 93 | else if (this->type_ == MT_radian) |
---|
| 94 | return (this->radian_ != mtm.radian_); |
---|
| 95 | else if (this->type_ == MT_degree) |
---|
| 96 | return (this->degree_ != mtm.degree_); |
---|
| 97 | } |
---|
| 98 | |
---|
| 99 | return true; |
---|
| 100 | } |
---|
| 101 | |
---|
| 102 | void MultiTypeMath::setValue(const MultiTypeMath& mtm) |
---|
| 103 | { |
---|
| 104 | this->type_ = mtm.type_; |
---|
| 105 | this->value_ = mtm.value_; |
---|
| 106 | } |
---|