📄 oasisconvert.h
字号:
/******************************************************************************
* This source file is part of Bad Camel Gaming
* Copyright (C) 2003 Zephie Greyvenstein
* See Readme.html for acknowledgements
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*****************************************************************************/
/******************************************************************************
* FILENAME : oasisConvert.h
* DESCRIPTION : Tools for converting between various libs data types
* AUTHOR : Zephie Greyvenstein
*****************************************************************************/
/// Avoid double inclusion
#ifndef __CONVERT_H__
#define __CONVERT_H__
/// Include common stuff
#include "oasisCommon.h"
#include "oasisVector3.h"
#include "oasisQuaternion.h"
#include "oasisColour.h"
#include "oasisPhysicsCommon.h"
/// Include Ogre stuff
#include "OgreVector3.h"
#include "OgreQuaternion.h"
#include "OgreColourValue.h"
namespace Oasis {
/// A helper class to convert between the various library's data types
class convert {
public:
/// Convert an Ogre vector to a standard vector
static inline vector3 parseVector3( const Ogre::Vector3 &vec ) {
return vector3( vec.x, vec.y, vec.z );
}
/// Convert an Ogre quaternion to a standard quaternion
static inline quaternion parseQuaternion( const Ogre::Quaternion &quat ) {
return quaternion( quat.w, quat.x, quat.y, quat.z );
}
/// Convert an ODE vector3 to a standard vector3
static inline vector3 parseVector3( const dReal *vec ) {
return vector3( ( real )vec[ 0 ],
( real )vec[ 1 ],
( real )vec[ 2 ] );
}
/// Convert an ODE quaternion to a standard quaternion
static inline quaternion parseQuaternion( const dQuaternion quat ) {
return quaternion( ( real )quat[ 0 ],
( real )quat[ 1 ],
( real )quat[ 2 ],
( real )quat[ 3 ] );
}
/// Convert an Ogre colour to a standard colour
static inline colour parseColour( const Ogre::ColourValue &col ) {
return colour( col.r, col.g, col.b, col.a );
}
/// Convert a standard vector to an Ogre vector
static inline Ogre::Vector3 toOgreVector3( const vector3 &vec ) {
return Ogre::Vector3( vec.x, vec.y, vec.z );
}
/// Convert a standard quaternion to an Ogre quaternion
static inline Ogre::Quaternion toOgreQuaternion( const quaternion &quat ) {
return Ogre::Quaternion( quat.w, quat.x, quat.y, quat.z );
}
/// Convert a standard colour to an Ogre colour
static inline Ogre::ColourValue toOgreColour( const colour &col ) {
return Ogre::ColourValue( col.red, col.green, col.blue, col.alpha );
}
/// Convert a standard quaternion to an ODE quaternion
static inline void toODEQuaternion( dQuaternion &odeQuat,
const quaternion &quat ) {
odeQuat[ 0 ] = quat.w;
odeQuat[ 1 ] = quat.x;
odeQuat[ 2 ] = quat.y;
odeQuat[ 3 ] = quat.z;
}
};
};
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -