Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

panda/src/linmath/coordinateSystem.cxx

Go to the documentation of this file.
00001 // Filename: coordinateSystem.cxx
00002 // Created by:  drose (24Sep99)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) 2001, Disney Enterprises, Inc.  All rights reserved
00008 //
00009 // All use of this software is subject to the terms of the Panda 3d
00010 // Software license.  You should have received a copy of this license
00011 // along with this source code; you will also find a current copy of
00012 // the license at http://www.panda3d.org/license.txt .
00013 //
00014 // To contact the maintainers of this program write to
00015 // panda3d@yahoogroups.com .
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   // First, make sure the string is lowercase before we compare it, so
00033   // we'll be case-insensitive.
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 }

Generated on Fri May 2 00:40:03 2003 for Panda by doxygen1.3