|
Blender
V2.59
|
00001 /* 00002 * $Id: KX_WorldIpoController.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_WorldIpoController.h" 00035 #include "KX_ScalarInterpolator.h" 00036 #include "KX_WorldInfo.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_WorldIpoController::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 /* TODO, this will crash! */ 00054 KX_WorldInfo *world = NULL; 00055 00056 if (m_modify_mist_start) { 00057 world->setMistStart(m_mist_start); 00058 } 00059 00060 if (m_modify_mist_color) { 00061 world->setMistColorRed(m_mist_rgb[0]); 00062 world->setMistColorGreen(m_mist_rgb[1]); 00063 world->setMistColorBlue(m_mist_rgb[2]); 00064 } 00065 00066 if (m_modify_mist_dist) { 00067 world->setMistDistance(m_mist_dist); 00068 } 00069 00070 m_modified=false; 00071 } 00072 return false; 00073 } 00074 00075 00076 void KX_WorldIpoController::AddInterpolator(KX_IInterpolator* interp) 00077 { 00078 this->m_interpolators.push_back(interp); 00079 } 00080 00081 00082 SG_Controller* KX_WorldIpoController::GetReplica(class SG_Node* destnode) 00083 { 00084 KX_WorldIpoController* iporeplica = new KX_WorldIpoController(*this); 00085 // clear object that ipo acts on 00086 iporeplica->ClearObject(); 00087 00088 // dirty hack, ask Gino for a better solution in the ipo implementation 00089 // hacken en zagen, in what we call datahiding, not written for replication :( 00090 00091 T_InterpolatorList oldlist = m_interpolators; 00092 iporeplica->m_interpolators.clear(); 00093 00094 T_InterpolatorList::iterator i; 00095 for (i = oldlist.begin(); !(i == oldlist.end()); ++i) { 00096 KX_ScalarInterpolator* copyipo = new KX_ScalarInterpolator(*((KX_ScalarInterpolator*)*i)); 00097 iporeplica->AddInterpolator(copyipo); 00098 00099 MT_Scalar* scaal = ((KX_ScalarInterpolator*)*i)->GetTarget(); 00100 uint_ptr orgbase = (uint_ptr)this; 00101 uint_ptr orgloc = (uint_ptr)scaal; 00102 uint_ptr offset = orgloc-orgbase; 00103 uint_ptr newaddrbase = (uint_ptr)iporeplica + offset; 00104 MT_Scalar* blaptr = (MT_Scalar*) newaddrbase; 00105 copyipo->SetNewTarget((MT_Scalar*)blaptr); 00106 } 00107 00108 return iporeplica; 00109 } 00110 00111 KX_WorldIpoController::~KX_WorldIpoController() 00112 { 00113 00114 T_InterpolatorList::iterator i; 00115 for (i = m_interpolators.begin(); !(i == m_interpolators.end()); ++i) { 00116 delete (*i); 00117 } 00118 00119 }