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