00001 /*************************************************************************** 00002 * Copyright (C) 2006 by Benoit Chanclou,bunraku * 00003 * bchanclo@irisa.fr * 00004 * * 00005 * This program is free software; you can redistribute it and/or modify * 00006 * it under the terms of the GNU General Public License as published by * 00007 * the Free Software Foundation; either version 2 of the License, or * 00008 * (at your option) any later version. * 00009 * * 00010 * This program is distributed in the hope that it will be useful, * 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00013 * GNU General Public License for more details. * 00014 * * 00015 * You should have received a copy of the GNU General Public License * 00016 * along with this program; if not, write to the * 00017 * Free Software Foundation, Inc., * 00018 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 00019 ***************************************************************************/ 00020 #ifndef OMK_VIS_CONVERSION_H 00021 #define OMK_VIS_CONVERSION_H 00022 00023 #include "Wm4Quaternion.h" 00024 #include "OgreQuaternion.h" 00025 #include "Wm4Vector3.h" 00026 #include "OgreVector3.h" 00027 #include "Wm4Matrix3.h" 00028 #include "OgreMatrix3.h" 00029 #include "Wm4Matrix4.h" 00030 #include "OgreMatrix4.h" 00031 #include "OgreNode.h" 00032 #include "OMKTransform.h" 00033 00034 namespace OMK 00035 { 00036 namespace Vis 00037 { 00041 00042 00043 00044 inline Wm4::Quaternionf convert( const Ogre::Quaternion& q ) 00045 { 00046 return Wm4::Quaternionf( q.w, q.x, q.y, q.z ) ; 00047 } 00048 inline Ogre::Quaternion convert( const Wm4::Quaternionf& q ) 00049 { 00050 return Ogre::Quaternion( q.W(), q.X(), q.Y(), q.Z() ) ; 00051 } 00053 00054 00055 inline Wm4::Vector3f convert( const Ogre::Vector3& v ) 00056 { 00057 return Wm4::Vector3f( v.x, v.y, v.z ) ; 00058 } 00059 inline Ogre::Vector3 convert( const Wm4::Vector3f& v ) 00060 { 00061 return Ogre::Vector3( v.X(), v.Y(), v.Z() ) ; 00062 } 00064 00065 00066 inline Wm4::Matrix3f convert( const Ogre::Matrix3& m ) 00067 { 00068 return Wm4::Matrix3f( m[0][0], m[0][1], m[0][2], 00069 m[1][0], m[1][1], m[1][2], 00070 m[2][0], m[2][1], m[2][2] ) ; 00071 } 00072 inline Ogre::Matrix3 convert( const Wm4::Matrix3f& m ) 00073 { 00074 return Ogre::Matrix3( m[0][0], m[0][1], m[0][2], 00075 m[1][0], m[1][1], m[1][2], 00076 m[2][0], m[2][1], m[2][2] ) ; 00077 } 00079 00080 00081 inline Wm4::Matrix4f convert( const Ogre::Matrix4& m ) 00082 { 00083 return Wm4::Matrix4f( m[0][0], m[0][1], m[0][2], m[0][3], 00084 m[1][0], m[1][1], m[1][2], m[1][3], 00085 m[2][0], m[2][1], m[2][2], m[2][3], 00086 m[3][0], m[3][1], m[3][2], m[3][3] ) ; 00087 } 00088 inline Ogre::Matrix4 convert( const Wm4::Matrix4f& m ) 00089 { 00090 return Ogre::Matrix4( m[0][0], m[0][1], m[0][2], m[0][3], 00091 m[1][0], m[1][1], m[1][2], m[1][3], 00092 m[2][0], m[2][1], m[2][2], m[2][3], 00093 m[3][0], m[3][1], m[3][2], m[3][3] ) ; 00094 } 00096 00097 00098 00099 inline Wm4::Plane3f convert( const Ogre::Plane& p ) 00100 { 00101 return Wm4::Plane3f( convert( p.normal ), -p.d ) ; 00102 } 00103 inline Ogre::Plane convert( const Wm4::Plane3f& p ) 00104 { 00105 return Ogre::Plane( convert( p.Normal ), p.Constant ) ; 00106 } 00108 00109 00110 inline void 00111 convert( const Type::Transform& transform, Ogre::Node& node ) 00112 { 00113 const Wm4::Vector3f& translate( transform.getTranslate() ) ; 00114 node.setPosition( translate.X(), translate.Y(), translate.Z() ) ; 00115 const Wm4::Quaternionf& quaternion( transform.getQuaternionRotate() ) ; ; 00116 node.setOrientation( quaternion.W(), quaternion.X(), quaternion.Y(), quaternion.Z() ) ; 00117 const Wm4::Vector3f& scale( transform.getScale() ) ; 00118 node.setScale( scale.X(), scale.Y(), scale.Z() ) ; 00119 } 00120 inline void 00121 convert( const Ogre::Node& node, Type::Transform& transform ) 00122 { 00123 transform.setTranslate( convert( node.getPosition() ) ) ; 00124 Wm4::Quaternionf quaternion( convert( node.getOrientation() ) ) ; 00125 Wm4::Matrix3f matrix ; 00126 quaternion.ToRotationMatrix( matrix ) ; 00127 transform.setRotate( matrix ) ; 00128 transform.setScale( convert( node.getScale() ) ) ; 00129 } 00131 00132 }// namespace Vis 00133 }// namespace OMK 00134 00135 #endif // OMK_VIS_CONVERSION_H
Documentation generated on Mon Jun 9 11:45:56 2008 |
Generated with doxygen by Dimitri van Heesch , 1997-2007 |