|
Blender
V2.59
|
00001 /* 00002 * $Id: KX_CameraIpoSGController.cpp 35171 2011-02-25 13:35:59Z jesterking $ 00003 * ***** BEGIN GPL LICENSE BLOCK ***** 00004 * 00005 * This program is free software; you can redistribute it and/or 00006 * modify it under the terms of the GNU General Public License 00007 * as published by the Free Software Foundation; either version 2 00008 * of the License, or (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 Free Software Foundation, 00017 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00018 * 00019 * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. 00020 * All rights reserved. 00021 * 00022 * The Original Code is: all of this file. 00023 * 00024 * Contributor(s): none yet. 00025 * 00026 * ***** END GPL LICENSE BLOCK ***** 00027 */ 00028 00034 #include "KX_CameraIpoSGController.h" 00035 #include "KX_ScalarInterpolator.h" 00036 #include "KX_Camera.h" 00037 #include "RAS_CameraData.h" 00038 00039 #if defined(_WIN64) 00040 typedef unsigned __int64 uint_ptr; 00041 #else 00042 typedef unsigned long uint_ptr; 00043 #endif 00044 00045 bool KX_CameraIpoSGController::Update(double currentTime) 00046 { 00047 if (m_modified) 00048 { 00049 T_InterpolatorList::iterator i; 00050 for (i = m_interpolators.begin(); !(i == m_interpolators.end()); ++i) { 00051 (*i)->Execute(m_ipotime); 00052 } 00053 00054 SG_Spatial* ob = (SG_Spatial*)m_pObject; 00055 KX_Camera* kxcamera = (KX_Camera*) ob->GetSGClientObject(); 00056 RAS_CameraData* camdata = kxcamera->GetCameraData(); 00057 00058 if (m_modify_lens) 00059 camdata->m_lens = m_lens; 00060 00061 if (m_modify_clipstart ) 00062 camdata->m_clipstart = m_clipstart; 00063 00064 if (m_modify_clipend) 00065 camdata->m_clipend = m_clipend; 00066 00067 if (m_modify_lens || m_modify_clipstart || m_modify_clipend) 00068 kxcamera->InvalidateProjectionMatrix(); 00069 00070 m_modified=false; 00071 } 00072 return false; 00073 } 00074 00075 00076 void KX_CameraIpoSGController::AddInterpolator(KX_IInterpolator* interp) 00077 { 00078 this->m_interpolators.push_back(interp); 00079 } 00080 00081 SG_Controller* KX_CameraIpoSGController::GetReplica(class SG_Node* destnode) 00082 { 00083 KX_CameraIpoSGController* iporeplica = new KX_CameraIpoSGController(*this); 00084 // clear object that ipo acts on 00085 iporeplica->ClearObject(); 00086 00087 // dirty hack, ask Gino for a better solution in the ipo implementation 00088 // hacken en zagen, in what we call datahiding, not written for replication :( 00089 00090 T_InterpolatorList oldlist = m_interpolators; 00091 iporeplica->m_interpolators.clear(); 00092 00093 T_InterpolatorList::iterator i; 00094 for (i = oldlist.begin(); !(i == oldlist.end()); ++i) { 00095 KX_ScalarInterpolator* copyipo = new KX_ScalarInterpolator(*((KX_ScalarInterpolator*)*i)); 00096 iporeplica->AddInterpolator(copyipo); 00097 00098 MT_Scalar* scaal = ((KX_ScalarInterpolator*)*i)->GetTarget(); 00099 uint_ptr orgbase = (uint_ptr)this; 00100 uint_ptr orgloc = (uint_ptr)scaal; 00101 uint_ptr offset = orgloc-orgbase; 00102 uint_ptr newaddrbase = (uint_ptr)iporeplica + offset; 00103 MT_Scalar* blaptr = (MT_Scalar*) newaddrbase; 00104 copyipo->SetNewTarget((MT_Scalar*)blaptr); 00105 } 00106 00107 return iporeplica; 00108 } 00109 00110 KX_CameraIpoSGController::~KX_CameraIpoSGController() 00111 { 00112 00113 T_InterpolatorList::iterator i; 00114 for (i = m_interpolators.begin(); !(i == m_interpolators.end()); ++i) { 00115 delete (*i); 00116 } 00117 00118 } 00119 00120 void 00121 KX_CameraIpoSGController::SetOption( 00122 int option, 00123 int value) 00124 { 00125 /* Setting options */ 00126 00127 }