Blender  V2.59
BL_MeshDeformer.h
Go to the documentation of this file.
00001 /*
00002  * $Id: BL_MeshDeformer.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_MESHDEFORMER
00035 #define BL_MESHDEFORMER
00036 
00037 #include "RAS_Deformer.h"
00038 #include "DNA_object_types.h"
00039 #include "DNA_key_types.h"
00040 #include "MT_Point3.h"
00041 #include <stdlib.h>
00042 
00043 #if defined(WIN32) && !defined(FREE_WINDOWS)
00044 #pragma warning (disable:4786) // get rid of stupid stl-visual compiler debug warning
00045 #endif //WIN32
00046 
00047 class BL_DeformableGameObject;
00048 
00049 class BL_MeshDeformer : public RAS_Deformer
00050 {
00051 public:
00052         void VerifyStorage();
00053         void RecalcNormals();
00054         virtual void Relink(CTR_Map<class CTR_HashedPtr, void*>*map);
00055         BL_MeshDeformer(BL_DeformableGameObject *gameobj,
00056                                         struct Object* obj,
00057                                         class RAS_MeshObject *meshobj ):
00058                 m_pMeshObject(meshobj),
00059                 m_bmesh((struct Mesh*)(obj->data)),
00060                 m_transverts(0),
00061                 m_transnors(0),
00062                 m_objMesh(obj),
00063                 m_tvtot(0),
00064                 m_gameobj(gameobj),
00065                 m_lastDeformUpdate(-1)
00066         {};
00067         virtual ~BL_MeshDeformer();
00068         virtual void SetSimulatedTime(double time){};
00069         virtual bool Apply(class RAS_IPolyMaterial *mat);
00070         virtual bool Update(void){ return false; };
00071         virtual bool UpdateBuckets(void){ return false; };
00072         virtual RAS_Deformer*   GetReplica(){return NULL;};
00073         virtual void ProcessReplica();
00074         struct Mesh* GetMesh() { return m_bmesh; };
00075         virtual class RAS_MeshObject* GetRasMesh() { return (RAS_MeshObject*)m_pMeshObject; };
00076         virtual float (* GetTransVerts(int *tot))[3]    {       *tot= m_tvtot; return m_transverts; }
00077         //      virtual void InitDeform(double time){};
00078 
00079 protected:
00080         class RAS_MeshObject*           m_pMeshObject;
00081         struct Mesh*                            m_bmesh;
00082         
00083         // this is so m_transverts doesn't need to be converted
00084         // before deformation
00085         float                                           (*m_transverts)[3];
00086         float                                           (*m_transnors)[3];
00087         struct Object*                          m_objMesh; 
00088         // --
00089         int                                                     m_tvtot;
00090         BL_DeformableGameObject*        m_gameobj;
00091         double                                          m_lastDeformUpdate;
00092 
00093 
00094 #ifdef WITH_CXX_GUARDEDALLOC
00095 public:
00096         void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:BL_MeshDeformer"); }
00097         void operator delete( void *mem ) { MEM_freeN(mem); }
00098 #endif
00099 };
00100 
00101 #endif
00102