K3dSphereMove.cpp

Go to the documentation of this file.
00001 
00012 /***************************************************************************
00013  *   Copyright (C) 2007 by Jan Koci   *
00014  *   honza.koci@email.cz   *
00015  *   http://kengine.sourceforge.net/tutorial/
00016  *                                                                         *
00017  *   This program is free software; you can redistribute it and/or modify  *
00018  *   it under the terms of the GNU General Public License as published by  *
00019  *   the Free Software Foundation; either version 2 of the License, or     *
00020  *   (at your option) any later version.                                   *
00021  *                                                                         *
00022  *   This program is distributed in the hope that it will be useful,       *
00023  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00024  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00025  *   GNU General Public License for more details.                          *
00026  *                                                                         *
00027  *   You should have received a copy of the GNU General Public License     *
00028  *   along with this program; if not, write to the                         *
00029  *   Free Software Foundation, Inc.,                                       *
00030  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
00031  ***************************************************************************/
00032 
00033 #include "K3dSphereMove.h"
00034 
00035 
00036 K3dSphereMove::K3dSphereMove()
00037 {
00038         m_pRotation = NULL;
00039         m_pRelPosition = NULL;
00040         m_pMatrix = NULL;
00041         m_pRotMatrix = NULL;
00042 }
00043 
00044 K3dSphereMove::~K3dSphereMove()
00045 {}
00046 
00048 void K3dSphereMove::SetRenderMatrix()
00049 {
00050         *m_pMatrix = *m_pRotMatrix;
00051         m_pMatrix->Translation ( *GetPosition() );
00052 }
00053 
00055 void K3dSphereMove::Rotate ( const K3dVector3 &_rkAngle )
00056 {
00057         K3dVector3 kAngle = _rkAngle * K3dMath::K_DEG_TO_RAD;
00058         // Set quaternion from angle
00059         K3dQuaternion kQuat;
00060         kQuat.FromAxisAngle ( kAngle );
00061         // Set rotation matrix from quaternion
00062         kQuat.ToRotationMatrix ( *m_pRotMatrix );
00063 }
00064 
00066 void K3dSphereMove::Move ( const K3dVector3Obj &_rkPosition, const K3dVector3Obj &_rkAngle )
00067 {
00068         *GetPosition() = _rkPosition;
00069         Rotate ( _rkAngle );
00070         SetRenderMatrix();
00071 }

Generated on Thu Aug 16 23:53:26 2007 for K3dEngine by  doxygen 1.5.0