Blender  V2.59
BL_ModifierDeformer.h
Go to the documentation of this file.
00001 /*
00002  * $Id: BL_ModifierDeformer.h 35063 2011-02-22 10:33:14Z jesterking $
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_MODIFIERDEFORMER
00035 #define BL_MODIFIERDEFORMER
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 "BL_ShapeDeformer.h"
00042 #include "BL_DeformableGameObject.h"
00043 #include <vector>
00044 
00045 struct DerivedMesh;
00046 struct Object;
00047 
00048 class BL_ModifierDeformer : public BL_ShapeDeformer  
00049 {
00050 public:
00051         static bool HasCompatibleDeformer(Object *ob);
00052         static bool HasArmatureDeformer(Object *ob);
00053 
00054 
00055         BL_ModifierDeformer(BL_DeformableGameObject *gameobj,
00056                                                 Scene *scene,
00057                                                 Object *bmeshobj,
00058                                                 RAS_MeshObject *mesh)
00059                                                 :       
00060                                                 BL_ShapeDeformer(gameobj,bmeshobj, mesh),
00061                                                 m_lastModifierUpdate(-1),
00062                                                 m_scene(scene),
00063                                                 m_dm(NULL)
00064         {
00065                 m_recalcNormal = false;
00066         };
00067 
00068         /* this second constructor is needed for making a mesh deformable on the fly. */
00069         BL_ModifierDeformer(BL_DeformableGameObject *gameobj,
00070                                                 struct Scene *scene,
00071                                                 struct Object *bmeshobj_old,
00072                                                 struct Object *bmeshobj_new,
00073                                                 class RAS_MeshObject *mesh,
00074                                                 bool release_object,
00075                                                 BL_ArmatureObject* arma = NULL)
00076                                                 :
00077                                                 BL_ShapeDeformer(gameobj, bmeshobj_old, bmeshobj_new, mesh, release_object, false, arma),
00078                                                 m_lastModifierUpdate(-1),
00079                                                 m_scene(scene),
00080                                                 m_dm(NULL)
00081         {
00082         };
00083 
00084         virtual void ProcessReplica();
00085         virtual RAS_Deformer *GetReplica();
00086         virtual ~BL_ModifierDeformer();
00087         virtual bool UseVertexArray()
00088         {
00089                 return false;
00090         }
00091 
00092         bool Update (void);
00093         bool Apply(RAS_IPolyMaterial *mat);
00094         void ForceUpdate()
00095         {
00096                 m_lastModifierUpdate = -1.0;
00097         };
00098         virtual struct DerivedMesh* GetFinalMesh()
00099         {
00100                 return m_dm;
00101         }
00102         // The derived mesh returned by this function must be released!
00103         virtual struct DerivedMesh* GetPhysicsMesh();
00104 
00105 protected:
00106         double                                   m_lastModifierUpdate;
00107         Scene                                   *m_scene;
00108         DerivedMesh                             *m_dm;
00109 
00110 
00111 #ifdef WITH_CXX_GUARDEDALLOC
00112 public:
00113         void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:BL_ModifierDeformer"); }
00114         void operator delete( void *mem ) { MEM_freeN(mem); }
00115 #endif
00116 };
00117 
00118 #endif
00119