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 "K3dLineMove.h" 00034 00035 K3dLineMove::K3dLineMove() 00036 { 00037 m_pPosition = NULL; 00038 m_pRotation = NULL; 00039 m_pRelOrigin = NULL; 00040 m_pRelDirection = NULL; 00041 m_pMatrix = NULL; 00042 m_pRotMatrix = NULL; 00043 } 00044 K3dLineMove::~K3dLineMove() 00045 { 00046 } 00047 00048 K3dLineMove& K3dLineMove::operator= (K3dLineMove& _rkLineMove) 00049 { 00050 *this->GetOrigin() = *_rkLineMove.GetOrigin(); 00051 *this->GetDirection() = *_rkLineMove.GetDirection(); 00052 *this->GetColor() = *_rkLineMove.GetColor(); 00053 this->GetWidth() = _rkLineMove.GetWidth(); 00054 *this->GetPosition() = *_rkLineMove.GetPosition(); 00055 *this->GetRotation() = *_rkLineMove.GetRotation(); 00056 *this->GetRelOrigin() = *_rkLineMove.GetRelOrigin(); 00057 *this->GetRelDirection() = *_rkLineMove.GetRelDirection(); 00058 *this->GetMatrix() = *_rkLineMove.GetMatrix(); 00059 *this->GetRotMatrix() = *_rkLineMove.GetRotMatrix(); 00060 return *this; 00061 } 00062 00064 void K3dLineMove::Init() 00065 { 00066 *GetRelOrigin() = *GetOrigin(); 00067 *GetRelDirection() = *GetDirection(); 00068 } 00069 00071 void K3dLineMove::UpdateMatrix() 00072 { 00073 m_pMatrix->GetTranslation(*GetPosition()); 00074 // Set rotation matrix 00075 *m_pRotMatrix = *m_pMatrix; 00076 m_pRotMatrix->ResetTranslation(); 00077 K3dVector3Obj kRelOrigin, kRelDirection; 00078 kRelOrigin = *m_pRelOrigin; 00079 kRelDirection = *m_pRelDirection; 00080 // Change relative vertices by rotation matrix 00081 m_pRotMatrix->ChangeVectorGL(kRelOrigin); 00082 m_pRotMatrix->ChangeVectorGL(kRelDirection); 00083 // Set world vertex positions for drawing 00084 *GetOrigin() = kRelOrigin + *m_pPosition; 00085 *GetDirection() = kRelDirection + *m_pPosition; 00086 } 00087 00089 void K3dLineMove::SetRenderMatrix() 00090 { 00091 *m_pMatrix = *m_pRotMatrix; 00092 // Set position from matrix 00093 m_pMatrix->Translation(*GetPosition()); 00094 } 00095 00096 00097