00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #include "coordinateSystem.h"
00020 #include "config_linmath.h"
00021
00022 #include <dconfig.h>
00023 #include <notify.h>
00024
00025 #include <ctype.h>
00026 #include <string>
00027
00028 CoordinateSystem default_coordinate_system;
00029
00030 CoordinateSystem
00031 parse_coordinate_system_string(const string &str) {
00032
00033
00034 string lstr = str;
00035 for (string::iterator si = lstr.begin();
00036 si != lstr.end();
00037 ++si) {
00038 (*si) = tolower(*si);
00039 }
00040
00041 if (lstr == "default") {
00042 return CS_default;
00043
00044 } else if (lstr == "z-up" || lstr == "z-up-right") {
00045 return CS_zup_right;
00046
00047 } else if (lstr == "y-up" || lstr == "y-up-right") {
00048 return CS_yup_right;
00049
00050 } else if (lstr == "z-up-left") {
00051 return CS_zup_left;
00052
00053 } else if (lstr == "y-up-left") {
00054 return CS_yup_left;
00055 }
00056
00057 return CS_invalid;
00058 }
00059
00060 INLINE_LINMATH bool
00061 is_right_handed(CoordinateSystem cs) {
00062 if (cs == CS_default) {
00063 cs = default_coordinate_system;
00064 }
00065 switch (cs) {
00066 case CS_zup_right:
00067 case CS_yup_right:
00068 return true;
00069
00070 case CS_zup_left:
00071 case CS_yup_left:
00072 return false;
00073
00074 default:
00075 linmath_cat.error()
00076 << "Invalid coordinate system value: " << (int)cs << "\n";
00077 nassertr(false, false);
00078 return false;
00079 }
00080 }
00081
00082 ostream &
00083 operator << (ostream &out, CoordinateSystem cs) {
00084 switch (cs) {
00085 case CS_default:
00086 return out << "default";
00087
00088 case CS_zup_right:
00089 return out << "zup_right";
00090
00091 case CS_yup_right:
00092 return out << "yup_right";
00093
00094 case CS_zup_left:
00095 return out << "zup_left";
00096
00097 case CS_yup_left:
00098 return out << "yup_left";
00099
00100 case CS_invalid:
00101 return out << "invalid";
00102 }
00103
00104 linmath_cat.error()
00105 << "Invalid coordinate_system value: " << (int)cs << "\n";
00106 nassertr(false, out);
00107 return out;
00108 }