📄 oasismovable.cpp
字号:
/******************************************************************************
* 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 : oasisMovable.cpp
* DESCRIPTION : If it moves, kick it
* AUTHOR : Zephie Greyvenstein
*****************************************************************************/
#include "oasisMovable.h"
#include "OgreMath.h"
namespace Oasis {
movable::movable( ) {
position = vector3::ZERO;
orientation = quaternion::IDENTITY;
}
movable::~movable( ) {
}
void movable::setPosition( real x, real y, real z ) {
setPosition( vector3( x, y, z ) );
}
void movable::setPosition( const vector3 &newPosition ) {
position = newPosition;
_updatePosition( );
}
const vector3 &movable::getPosition( void ) const {
return position;
}
void movable::move( real x, real y, real z ) {
move( vector3( x, y, z ) );
}
void movable::move( const vector3 &moveVector ) {
setPosition( position + moveVector );
}
void movable::moveRelative( real x, real y, real z ) {
moveRelative( vector3( x, y, z ) );
}
void movable::moveRelative( const vector3 &moveVector ) {
setPosition( position + ( orientation * moveVector ) );
}
void movable::rotate( real x, real y, real z, real degrees ) {
quaternion quat;
quat.fromAxisAndAngle( vector3( x, y, z ),
Ogre::Math::DegreesToRadians( degrees ) );
rotate( quat );
}
void movable::rotate( const vector3 &axis, real degrees ) {
quaternion quat;
quat.fromAxisAndAngle( axis, Ogre::Math::DegreesToRadians( degrees ) );
rotate( quat );
}
void movable::rotate( const quaternion &rotation ) {
setOrientation( orientation * rotation );
}
void movable::setOrientation( const quaternion &newOrientation ) {
orientation = newOrientation;
_updateOrientation( );
}
const quaternion &movable::getOrientation( void ) const {
return orientation;
}
vector3 movable::getDirection( void ) const {
return orientation * -vector3::UNITZ;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -