Panda3D
physxEnums.cxx
1 // Filename: physxEnums.cxx
2 // Created by: enn0x (23Sep09)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #include "physxEnums.h"
16 
17 #include "string_utils.h"
18 #include "config_util.h"
19 
20 ostream &
21 operator << (ostream &out, PhysxEnums::PhysxUpAxis axis) {
22 
23  switch (axis) {
24  case PhysxEnums::X_up:
25  return out << "x";
26 
27  case PhysxEnums::Y_up:
28  return out << "y";
29 
30  case PhysxEnums::Z_up:
31  return out << "z";
32  }
33 
34  return out << "**invalid PhysxEnums::PhysxUpAxis value: (" << (int)axis << ")**";
35 }
36 
37 istream &
38 operator >> (istream &in, PhysxEnums::PhysxUpAxis &axis) {
39 
40  string word;
41  in >> word;
42 
43  if (cmp_nocase(word, "x") == 0) {
44  axis = PhysxEnums::X_up;
45  }
46  else if (cmp_nocase(word, "y") == 0) {
47  axis = PhysxEnums::Y_up;
48  }
49  else if (cmp_nocase(word, "z") == 0) {
50  axis = PhysxEnums::Z_up;
51  }
52  else {
53  physx_cat->error()
54  << "Invalid up-axis string: " << word << "\n";
55  axis = PhysxEnums::Z_up;
56  }
57 
58  return in;
59 }
60