Blender V2.61 - r43446

BL_ModifierDeformer.h

Go to the documentation of this file.
00001 /*
00002  * ***** BEGIN GPL LICENSE BLOCK *****
00003  *
00004  * This program is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU General Public License
00006  * as published by the Free Software Foundation; either version 2
00007  * of the License, or (at your option) any later version.
00008  *
00009  * This program is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  * GNU General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program; if not, write to the Free Software Foundation,
00016  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00017  *
00018  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
00019  * All rights reserved.
00020  *
00021  * The Original Code is: all of this file.
00022  *
00023  * Contributor(s): none yet.
00024  *
00025  * ***** END GPL LICENSE BLOCK *****
00026  */
00027 
00032 #ifndef BL_MODIFIERDEFORMER
00033 #define BL_MODIFIERDEFORMER
00034 
00035 #if defined(WIN32) && !defined(FREE_WINDOWS)
00036 #pragma warning (disable:4786) // get rid of stupid stl-visual compiler debug warning
00037 #endif //WIN32
00038 
00039 #include "BL_ShapeDeformer.h"
00040 #include "BL_DeformableGameObject.h"
00041 #include <vector>
00042 
00043 struct DerivedMesh;
00044 struct Object;
00045 
00046 class BL_ModifierDeformer : public BL_ShapeDeformer  
00047 {
00048 public:
00049     static bool HasCompatibleDeformer(Object *ob);
00050     static bool HasArmatureDeformer(Object *ob);
00051 
00052 
00053     BL_ModifierDeformer(BL_DeformableGameObject *gameobj,
00054                         Scene *scene,
00055                         Object *bmeshobj,
00056                         RAS_MeshObject *mesh)
00057                         :   
00058                         BL_ShapeDeformer(gameobj,bmeshobj, mesh),
00059                         m_lastModifierUpdate(-1),
00060                         m_scene(scene),
00061                         m_dm(NULL)
00062     {
00063         m_recalcNormal = false;
00064     };
00065 
00066     /* this second constructor is needed for making a mesh deformable on the fly. */
00067     BL_ModifierDeformer(BL_DeformableGameObject *gameobj,
00068                         struct Scene *scene,
00069                         struct Object *bmeshobj_old,
00070                         struct Object *bmeshobj_new,
00071                         class RAS_MeshObject *mesh,
00072                         bool release_object,
00073                         BL_ArmatureObject* arma = NULL)
00074                         :
00075                         BL_ShapeDeformer(gameobj, bmeshobj_old, bmeshobj_new, mesh, release_object, false, arma),
00076                         m_lastModifierUpdate(-1),
00077                         m_scene(scene),
00078                         m_dm(NULL)
00079     {
00080     };
00081 
00082     virtual void ProcessReplica();
00083     virtual RAS_Deformer *GetReplica();
00084     virtual ~BL_ModifierDeformer();
00085     virtual bool UseVertexArray()
00086     {
00087         return false;
00088     }
00089 
00090     bool Update (void);
00091     bool Apply(RAS_IPolyMaterial *mat);
00092     void ForceUpdate()
00093     {
00094         m_lastModifierUpdate = -1.0;
00095     };
00096     virtual struct DerivedMesh* GetFinalMesh()
00097     {
00098         return m_dm;
00099     }
00100     // The derived mesh returned by this function must be released!
00101     virtual struct DerivedMesh* GetPhysicsMesh();
00102 
00103 protected:
00104     double                   m_lastModifierUpdate;
00105     Scene                   *m_scene;
00106     DerivedMesh             *m_dm;
00107 
00108 
00109 #ifdef WITH_CXX_GUARDEDALLOC
00110 public:
00111     void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:BL_ModifierDeformer"); }
00112     void operator delete( void *mem ) { MEM_freeN(mem); }
00113 #endif
00114 };
00115 
00116 #endif
00117