|
Blender
V2.59
|
00001 /* 00002 * $Id: BL_DeformableGameObject.h 36523 2011-05-06 20:18:42Z blendix $ 00003 * 00004 * ***** BEGIN GPL LICENSE BLOCK ***** 00005 * 00006 * This program is free software; you can redistribute it and/or 00007 * modify it under the terms of the GNU General Public License 00008 * as published by the Free Software Foundation; either version 2 00009 * of the License, or (at your option) any later version. 00010 * 00011 * This program is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 * GNU General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU General Public License 00017 * along with this program; if not, write to the Free Software Foundation, 00018 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00019 * 00020 * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. 00021 * All rights reserved. 00022 * 00023 * The Original Code is: all of this file. 00024 * 00025 * Contributor(s): none yet. 00026 * 00027 * ***** END GPL LICENSE BLOCK ***** 00028 */ 00029 00034 #ifndef BL_DEFORMABLEGAMEOBJECT 00035 #define BL_DEFORMABLEGAMEOBJECT 00036 00037 #if defined(WIN32) && !defined(FREE_WINDOWS) 00038 #pragma warning (disable:4786) // get rid of stupid stl-visual compiler debug warning 00039 #endif //WIN32 00040 00041 #include "DNA_mesh_types.h" 00042 #include "KX_GameObject.h" 00043 #include "BL_MeshDeformer.h" 00044 #include "KX_SoftBodyDeformer.h" 00045 #include <vector> 00046 00047 class BL_ShapeActionActuator; 00048 struct Key; 00049 00050 class BL_DeformableGameObject : public KX_GameObject 00051 { 00052 public: 00053 CValue* GetReplica(); 00054 00055 double GetLastFrame () 00056 { 00057 return m_lastframe; 00058 } 00059 Object* GetBlendObject() 00060 { 00061 return m_blendobj; 00062 } 00063 virtual void Relink(CTR_Map<CTR_HashedPtr, void*>*map) 00064 { 00065 if (m_pDeformer) 00066 m_pDeformer->Relink (map); 00067 KX_GameObject::Relink(map); 00068 }; 00069 void ProcessReplica(); 00070 00071 BL_DeformableGameObject(Object* blendobj, void* sgReplicationInfo, SG_Callbacks callbacks) : 00072 KX_GameObject(sgReplicationInfo,callbacks), 00073 m_pDeformer(NULL), 00074 m_activeAct(NULL), 00075 m_lastframe(0.), 00076 m_blendobj(blendobj), 00077 m_activePriority(9999) 00078 { 00079 m_isDeformable = true; 00080 }; 00081 virtual ~BL_DeformableGameObject(); 00082 bool SetActiveAction(class BL_ShapeActionActuator *act, short priority, double curtime); 00083 00084 bool GetShape(vector<float> &shape); 00085 Key* GetKey() 00086 { 00087 if(m_pDeformer) { 00088 BL_MeshDeformer *deformer= dynamic_cast<BL_MeshDeformer *>(m_pDeformer); // incase its not a MeshDeformer 00089 if(deformer) { 00090 return deformer->GetMesh()->key; 00091 } 00092 00093 #if 0 // TODO. shape keys for softbody, currently they dont store a mesh. 00094 KX_SoftBodyDeformer *deformer_soft= dynamic_cast<KX_SoftBodyDeformer *>(m_pDeformer); 00095 if(deformer) { 00096 return deformer->GetMesh()->key; 00097 } 00098 #endif 00099 } 00100 return NULL; 00101 } 00102 00103 virtual void SetDeformer(class RAS_Deformer* deformer); 00104 virtual class RAS_Deformer* GetDeformer() 00105 { 00106 return m_pDeformer; 00107 } 00108 00109 public: 00110 00111 protected: 00112 00113 RAS_Deformer *m_pDeformer; 00114 00115 class BL_ShapeActionActuator *m_activeAct; 00116 double m_lastframe; 00117 Object* m_blendobj; 00118 short m_activePriority; 00119 00120 00121 #ifdef WITH_CXX_GUARDEDALLOC 00122 public: 00123 void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:BL_DeformableGameObject"); } 00124 void operator delete( void *mem ) { MEM_freeN(mem); } 00125 #endif 00126 }; 00127 00128 #endif 00129