Blender V2.61 - r43446

BL_SkinDeformer.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_SKINDEFORMER
00033 #define BL_SKINDEFORMER
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 "CTR_HashedPtr.h"
00040 #include "BL_MeshDeformer.h"
00041 #include "BL_ArmatureObject.h"
00042 
00043 #include "DNA_mesh_types.h"
00044 #include "DNA_meshdata_types.h"
00045 #include "DNA_object_types.h"
00046 #include "BKE_armature.h"
00047 
00048 #include "RAS_Deformer.h"
00049 
00050 
00051 class BL_SkinDeformer : public BL_MeshDeformer  
00052 {
00053 public:
00054 //  void SetArmatureController (BL_ArmatureController *cont);
00055     virtual void Relink(CTR_Map<class CTR_HashedPtr, void*>*map);
00056     void SetArmature (class BL_ArmatureObject *armobj);
00057 
00058     BL_SkinDeformer(BL_DeformableGameObject *gameobj,
00059                     struct Object *bmeshobj, 
00060                     class RAS_MeshObject *mesh,
00061                     BL_ArmatureObject* arma = NULL);
00062 
00063     /* this second constructor is needed for making a mesh deformable on the fly. */
00064     BL_SkinDeformer(BL_DeformableGameObject *gameobj,
00065                     struct Object *bmeshobj_old,
00066                     struct Object *bmeshobj_new,
00067                     class RAS_MeshObject *mesh,
00068                     bool release_object,
00069                     bool recalc_normal,
00070                     BL_ArmatureObject* arma = NULL);
00071 
00072     virtual RAS_Deformer *GetReplica();
00073     virtual void ProcessReplica();
00074 
00075     virtual ~BL_SkinDeformer();
00076     bool Update (void);
00077     bool UpdateInternal (bool shape_applied);
00078     bool Apply (class RAS_IPolyMaterial *polymat);
00079     bool UpdateBuckets(void) 
00080     {
00081         // update the deformer and all the mesh slots; Apply() does it well, so just call it.
00082         return Apply(NULL);
00083     }
00084     bool PoseUpdated(void)
00085         { 
00086             if (m_armobj && m_lastArmaUpdate!=m_armobj->GetLastFrame()) {
00087                 return true;
00088             }
00089             return false;
00090         }
00091 
00092     void ForceUpdate()
00093     {
00094         m_lastArmaUpdate = -1.0;
00095     };
00096     virtual bool ShareVertexArray()
00097     {
00098         return false;
00099     }
00100 
00101 protected:
00102     BL_ArmatureObject*      m_armobj;   //  Our parent object
00103     float                   m_time;
00104     double                  m_lastArmaUpdate;
00105     //ListBase*             m_defbase;
00106     float                   m_obmat[4][4];  // the reference matrix for skeleton deform
00107     bool                    m_releaseobject;
00108     bool                    m_poseApplied;
00109     bool                    m_recalcNormal;
00110     bool                    m_copyNormals; // dirty flag so we know if Apply() needs to copy normal information (used for BGEDeformVerts())
00111     struct bPoseChannel**   m_dfnrToPC;
00112 
00113     void BlenderDeformVerts();
00114     void BGEDeformVerts();
00115 
00116 
00117 #ifdef WITH_CXX_GUARDEDALLOC
00118 public:
00119     void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:BL_SkinDeformer"); }
00120     void operator delete( void *mem ) { MEM_freeN(mem); }
00121 #endif
00122 };
00123 
00124 #endif
00125