Tactics: Western Philosophers Vs. Musicians  0.12
A turn-based tactical game combining rules and gameplay elements inspired by Final Fantasy Tactics and the Mayfair Exponential Game System. Unlike most games of this type, motion is in full, grid-less 3D.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GUtils.h
Go to the documentation of this file.
1 // Copyright (C) 2004-2011 Dylan Blair
3 //
4 // email: dblair@alumni.cs.utexas.edu
5 //
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
10 //
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 
21 #ifndef GUTILS_H
22 #define GUTILS_H
23 
24 #include "../Math_LIB/MMatrix3x3.h"
25 
26 #ifdef _WIN32
27 #pragma warning(push)
28 //Get rid of MSVC++ warning - "decorated name length exceeded, name was truncated"
29 //One situation where this warning will be issued is when your code contains
30 //templates specialized on templates repeatedly. For example, a map of maps (from
31 //the Standard C++ Library). In this situation, you can make your typedefs a type
32 //(struct, for example) that contains the map.
33 //You might, however, decide to not restructure your code. It is possible to ship
34 //an application that generates C4503, but if you get link time errors on a
35 //truncated symbol, it will be more difficult to determine the type of the symbol
36 //in the error. Debugging will also be more difficult; the debugger will also have
37 //difficultly mapping symbol name to type name. The correctness of the program,
38 //however, is unaffected by the truncated name.
39 #pragma warning(disable:4503)
40 #endif
41 
42 #include <Ogre.h>
43 
44 #ifdef _WIN32
45 #pragma warning(pop)
46 #endif
47 
48 namespace OpenSkyNet {
51  namespace Graphics {
52  inline void Vector3ToMPoint(const Ogre::Vector3& v_, Math::Point<>& p_) {
53  p_.x() = v_.x; p_.y() = v_.y; p_.z() = v_.z;
54  }
55 
56  inline Math::Point<> GetMPointFromVector3(const Ogre::Vector3& v_) {
57  return Math::Point<>(v_.x,v_.y,v_.z);
58  }
59 
60  template<class T>
61  inline Ogre::Vector3 GetVector3FromMPoint(const Math::Point<T>& p_) {
62  return Ogre::Vector3(p_.x(),p_.y(),p_.z());
63  }
64 
65  inline Math::Matrix3x3 GetMMatrix3x3FromMatrix3(const Ogre::Matrix3& rot_) {
66  return Math::Matrix3x3(GetMPointFromVector3(rot_.GetColumn(0)),
67  GetMPointFromVector3(rot_.GetColumn(1)),
68  GetMPointFromVector3(rot_.GetColumn(2)));
69  }
70 
71  inline void MMatrix3x3ToMatrix3(const Math::Matrix3x3& rot_, Ogre::Matrix3& mat_) {
72  mat_[0][0] = rot_.col(0)[0];
73  mat_[0][1] = rot_.col(1)[0];
74  mat_[0][2] = rot_.col(2)[0];
75  mat_[1][0] = rot_.col(0)[1];
76  mat_[1][1] = rot_.col(1)[1];
77  mat_[1][2] = rot_.col(2)[1];
78  mat_[2][0] = rot_.col(0)[2];
79  mat_[2][1] = rot_.col(1)[2];
80  mat_[2][2] = rot_.col(2)[2];
81  }
82 
83  inline Ogre::Matrix3 GetMatrix3FromMMatrix3x3(const Math::Matrix3x3& rot_) {
84  return Ogre::Matrix3(rot_.col(0)[0],rot_.col(1)[0],rot_.col(2)[0],
85  rot_.col(0)[1],rot_.col(1)[1],rot_.col(2)[1],
86  rot_.col(0)[2],rot_.col(1)[2],rot_.col(2)[2]);
87  }
88  }
89 }
90 
91 #endif //GUTILS_H
Ogre::Vector3 GetVector3FromMPoint(const Math::Point< T > &p_)
Definition: GUtils.h:61
void MMatrix3x3ToMatrix3(const Math::Matrix3x3 &rot_, Ogre::Matrix3 &mat_)
Definition: GUtils.h:71
Math::Point GetMPointFromVector3(const Ogre::Vector3 &v_)
Definition: GUtils.h:56
T & y()
Definition: MPoint.h:65
Ogre::Matrix3 GetMatrix3FromMMatrix3x3(const Math::Matrix3x3 &rot_)
Definition: GUtils.h:83
T & x()
Definition: MPoint.h:64
T & z()
Definition: MPoint.h:66
Definition: MPoint.h:33
Definition: MMatrix3x3.h:32
Math::Matrix3x3 GetMMatrix3x3FromMatrix3(const Ogre::Matrix3 &rot_)
Definition: GUtils.h:65
float float rot_[3]
Definition: ViewerApp.h:31
Math::Point & col(int i_)
Definition: MMatrix3x3.h:49
void Vector3ToMPoint(const Ogre::Vector3 &v_, Math::Point<> &p_)
Definition: GUtils.h:52