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