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_LightIpoSGController.h" 00034 #include "KX_ScalarInterpolator.h" 00035 #include "KX_Light.h" 00036 #include "RAS_LightObject.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_LightIpoSGController::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);//currentTime); 00051 } 00052 00053 RAS_LightObject *lightobj; 00054 00055 SG_Spatial* ob = (SG_Spatial*)m_pObject; 00056 KX_LightObject* kxlight = (KX_LightObject*) ob->GetSGClientObject(); 00057 lightobj = kxlight->GetLightData(); 00058 //lightobj = (KX_Light*) 00059 00060 if (m_modify_energy) { 00061 lightobj->m_energy = m_energy; 00062 } 00063 00064 if (m_modify_color) { 00065 lightobj->m_red = m_col_rgb[0]; 00066 lightobj->m_green = m_col_rgb[1]; 00067 lightobj->m_blue = m_col_rgb[2]; 00068 } 00069 00070 if (m_modify_dist) { 00071 lightobj->m_distance = m_dist; 00072 } 00073 00074 m_modified=false; 00075 } 00076 return false; 00077 } 00078 00079 00080 void KX_LightIpoSGController::AddInterpolator(KX_IInterpolator* interp) 00081 { 00082 this->m_interpolators.push_back(interp); 00083 } 00084 00085 SG_Controller* KX_LightIpoSGController::GetReplica(class SG_Node* destnode) 00086 { 00087 KX_LightIpoSGController* iporeplica = new KX_LightIpoSGController(*this); 00088 // clear object that ipo acts on 00089 iporeplica->ClearObject(); 00090 00091 // dirty hack, ask Gino for a better solution in the ipo implementation 00092 // hacken en zagen, in what we call datahiding, not written for replication :( 00093 00094 T_InterpolatorList oldlist = m_interpolators; 00095 iporeplica->m_interpolators.clear(); 00096 00097 T_InterpolatorList::iterator i; 00098 for (i = oldlist.begin(); !(i == oldlist.end()); ++i) { 00099 KX_ScalarInterpolator* copyipo = new KX_ScalarInterpolator(*((KX_ScalarInterpolator*)*i)); 00100 iporeplica->AddInterpolator(copyipo); 00101 00102 MT_Scalar* scaal = ((KX_ScalarInterpolator*)*i)->GetTarget(); 00103 uint_ptr orgbase = (uint_ptr)this; 00104 uint_ptr orgloc = (uint_ptr)scaal; 00105 uint_ptr offset = orgloc-orgbase; 00106 uint_ptr newaddrbase = (uint_ptr)iporeplica + offset; 00107 MT_Scalar* blaptr = (MT_Scalar*) newaddrbase; 00108 copyipo->SetNewTarget((MT_Scalar*)blaptr); 00109 } 00110 00111 return iporeplica; 00112 } 00113 00114 KX_LightIpoSGController::~KX_LightIpoSGController() 00115 { 00116 00117 T_InterpolatorList::iterator i; 00118 for (i = m_interpolators.begin(); !(i == m_interpolators.end()); ++i) { 00119 delete (*i); 00120 } 00121 00122 }