ilag.h

Go to the documentation of this file.
00001 //**************************************************************************/
00002 // Copyright (c) 1998-2006 Autodesk, Inc.
00003 // All rights reserved.
00004 //
00005 // These coded instructions, statements, and computer programs contain
00006 // unpublished proprietary information written by Autodesk, Inc., and are
00007 // protected by Federal copyright law. They may not be disclosed to third
00008 // parties or copied or duplicated in any form, in whole or in part, without
00009 // the prior written consent of Autodesk, Inc.
00010 //**************************************************************************/
00011 //
00012 // \TODO Consider these classes for a move to maxsdk/samples/modifiers/flex/...
00013 //
00014 #pragma once
00015 
00016 #include "maxheap.h"
00017 #include "iFnPub.h"
00018 #include "object.h"
00019 
00020 #define LAZYID 0xDE17A34f, 0x8A41E2B0
00021 
00022 
00023 class SpringClass: public MaxHeapOperators
00024 {
00025 public:
00026     Point3 vel, pos, init_pos;
00027     float InheritVel;
00028     BOOL modified;
00029     Point3 LocalPt;
00030 
00031     Point3 tempVel[6];
00032     Point3 tempPos[6];
00033     float dist;
00034     float mass;
00035 };
00036 
00037 class EdgeBondage: public MaxHeapOperators
00038 {
00039 public:
00040     float dist;
00041     int v1,v2;
00042     int flags;
00043 };
00044 
00045 
00046 class CacheClass: public MaxHeapOperators
00047 {
00048 public:
00049 Point3 vel, pos;
00050 
00051 };
00052 
00053 
00054 class LagModData : public LocalModData {
00055     public:
00056 
00057         Tab<EdgeBondage> edgeSprings;
00058 
00059         int id;
00060         INode *SelfNode;
00061         Tab<SpringClass> SpringList;
00062         Tab<CacheClass> WholeFrameCache;
00063 
00064         Tab<BYTE> esel;  //selection for edges vertices
00065         Tab<BYTE> wsel;     //vertex weight selection
00066         Tab<BYTE> psel;     
00067         Matrix3 InverseTM;
00068 
00069 
00070         BOOL isMesh;
00071         BOOL isPatch;
00072 
00073         BOOL addSprings;
00074         BOOL removeSprings;
00075         BOOL computeEdges;
00076         BOOL ignoreInteriorHandles;
00077         BOOL simpleSoft;
00078 
00079         Point3 hitPoint;
00080         BOOL isHit;
00081         TimeValue lastFrame;
00082         BOOL nukeRenderCache;
00083         Tab<Point3> pointCache;
00084 
00085         LagModData()
00086             {
00087             SelfNode = NULL;
00088             id = -1;
00089             computeEdges = TRUE;
00090             isMesh = FALSE;
00091             isPatch = FALSE;
00092             lastFrame = 999999999;
00093             nukeRenderCache = TRUE;
00094             addSprings = FALSE;
00095             removeSprings = FALSE;
00096             simpleSoft = FALSE;
00097 
00098             }
00099         LagModData(int i, INode *n)
00100             {
00101             id = i;
00102             SelfNode = n;
00103             isMesh = FALSE;
00104             isPatch = FALSE;
00105             lastFrame = 999999999;
00106             nukeRenderCache = TRUE;
00107             computeEdges = TRUE;
00108             addSprings = FALSE;
00109             removeSprings = FALSE;
00110             simpleSoft = FALSE;
00111 
00112             }
00113         ~LagModData()
00114             {
00115             SelfNode = NULL;
00116             }   
00117         LocalModData*   Clone();                        
00118 
00119 
00120     };
00121 
00122 
00123 class ILagMod;
00124 
00125 
00126 // block IDs
00127 enum { lag_params };
00128 // lag_param param IDs
00129 enum { lag_flex, lag_strength, lag_sway, lag_referenceframe, lag_paint_strength,
00130         lag_paint_radius,lag_paint_feather,lag_paint_backface, lag_force_node, lag_absolute,
00131         lag_solver, lag_samples,
00132         lag_chase, lag_center,
00133         lag_endframeon, lag_endframe,
00134         lag_collider_node,
00135         lag_stretch_str, lag_stretch_sway,
00136         lag_torque_str, lag_torque_sway,
00137         lag_extra_str, lag_extra_sway,
00138         lag_hold_radius,
00139         lag_add_mode,
00140         lag_displaysprings,
00141         lag_holdlength,
00142         lag_holdlengthpercent,
00143         lag_lazyeval,
00144         lag_stretch,
00145         lag_stiffness,
00146         lag_enable_advance_springs,
00147         lag_springcolors,
00148         lag_customspringdisplay,
00149         lag_affectall,
00150 
00151         lag_createspringdepth,
00152         lag_createspringmult,
00153         
00154 
00155 
00156  };
00157 
00158 
00159 
00160 //***************************************************************
00161 //Function Publishing System stuff   
00162 //****************************************************************
00163 #define LAG_INTERFACE Interface_ID(0xDE17A34f, 0x8A41E3C1)
00164 
00165 #define GetILagInterface(cd) \
00166             (ILagMod *)(cd)->GetInterface(LAG_INTERFACE)
00167 
00168 enum {  lag_paint, lag_setreference, lag_reset,
00169         lag_addforce, lag_removeforce, 
00170         lag_numbervertices,
00171         lag_selectvertices,lag_getselectedvertices,
00172         lag_getvertexweight,lag_setvertexweight,
00173         lag_setedgelist,lag_getedgelist,
00174         lag_addspringselection,
00175         lag_addspring,
00176         lag_removeallsprings,
00177         lag_addspring_button,
00178         lag_removespring_button,
00179         lag_option_button,
00180         lag_simplesoft_button,
00181 
00182         lag_removespring_by_end,
00183         lag_removespring_by_both_ends,
00184         lag_removespringbyindex,
00185         lag_numbersprings,
00186         lag_getspringgroup,
00187         lag_setspringgroup,
00188 
00189         lag_getspringlength,
00190         lag_setspringlength,
00191         lag_getindex
00192 
00193 
00194         };
00195 //****************************************************************
00196 
00197 
00198 class ILagMod : public FPMixinInterface 
00199     {
00200     public:
00201 
00202         //Function Publishing System
00203         //Function Map For Mixin Interface
00204         //*************************************************
00205         BEGIN_FUNCTION_MAP
00206 
00207             VFN_0(lag_paint, fnPaint);
00208             VFN_0(lag_setreference, fnSetReference);
00209             VFN_0(lag_reset, fnReset);
00210             VFN_1(lag_addforce, fnAddForce,TYPE_INODE);
00211             VFN_1(lag_removeforce, fnRemoveForce,TYPE_INT);
00212             FN_0(lag_numbervertices,TYPE_INT, fnNumberVertices);
00213 
00214             VFN_2(lag_selectvertices, fnSelectVertices, TYPE_BITARRAY, TYPE_BOOL);
00215             FN_0(lag_getselectedvertices, TYPE_BITARRAY, fnGetSelectedVertices);
00216 
00217             FN_1(lag_getvertexweight, TYPE_FLOAT, fnGetVertexWeight, TYPE_INT);
00218             VFN_2(lag_setvertexweight, fnSetVertexWeight, TYPE_INT_TAB,TYPE_FLOAT_TAB);
00219 
00220             VFN_2(lag_setedgelist, fnSetEdgeList, TYPE_BITARRAY, TYPE_BOOL);
00221             FN_0(lag_getedgelist, TYPE_BITARRAY, fnGetEdgeList);
00222 
00223             VFN_2(lag_addspringselection, fnAddSingleSpringFromSelection,TYPE_INT,TYPE_BOOL);
00224             VFN_4(lag_addspring, fnAddSpring,TYPE_INT,TYPE_INT,TYPE_INT,TYPE_BOOL);
00225             VFN_0(lag_removeallsprings, fnRemoveAllSprings);
00226 
00227             VFN_0(lag_addspring_button, fnAddSpringButton);
00228             VFN_0(lag_removespring_button, fnRemoveSpringButton);
00229             VFN_0(lag_option_button, fnOptionButton);
00230             VFN_0(lag_simplesoft_button, fnSimpleSoftButton);
00231 
00232             VFN_1(lag_removespring_by_end,fnRemoveSpring,TYPE_INT);
00233             VFN_2(lag_removespring_by_both_ends,fnRemoveSpring,TYPE_INT,TYPE_INT);
00234             VFN_1(lag_removespringbyindex,fnRemoveSpringByIndex,TYPE_INT);
00235 
00236             FN_0(lag_numbersprings,TYPE_INT,fnNumberSprings);
00237             FN_1(lag_getspringgroup,TYPE_FLOAT,fnGetSpringGroup,TYPE_INT);
00238             VFN_2(lag_setspringgroup,fnSetSpringGroup,TYPE_INT,TYPE_INT);
00239 
00240             FN_1(lag_getspringlength,TYPE_FLOAT,fnGetSpringLength,TYPE_INT);
00241             VFN_2(lag_setspringlength,fnSetSpringLength,TYPE_INT,TYPE_FLOAT);
00242 
00243             FN_2(lag_getindex,TYPE_INT,fnGetIndex,TYPE_INT,TYPE_INT);
00244 
00245 
00246         END_FUNCTION_MAP
00247 
00248 
00249         FPInterfaceDesc* GetDesc();    // <-- must implement 
00250 //note functions that start with fn are to be used with maxscript since these expect 1 based indices
00251         BitArray        tempBitArray;
00252         virtual void    fnPaint()=0;
00253         virtual void    fnSetReference()=0;
00254         virtual void    fnReset()=0;
00255         virtual void    fnAddForce(INode *node)=0;
00256         virtual void    fnRemoveForce(int whichNode)=0;
00257         virtual int     fnNumberVertices()=0;
00258         virtual void    fnSelectVertices(BitArray *selList, BOOL updateViews)=0;
00259         virtual BitArray *fnGetSelectedVertices()=0;
00260 
00261         virtual float   fnGetVertexWeight(int index)=0;
00262         virtual void    fnSetVertexWeight(Tab<int> *indexList, Tab<float> *values)=0;
00263 
00264         virtual void    fnSetEdgeList(BitArray *selList, BOOL updateViews)=0;
00265         virtual BitArray *fnGetEdgeList()=0;
00266 
00267         virtual void    fnAddSingleSpringFromSelection(int flag,BOOL addDupes)=0;
00268         virtual void    AddSingleSpringFromSelection(LagModData *lmd, int flag,BOOL addDupes)=0;
00269 
00270         virtual void    fnAddSpring(int a, int b, int flag,BOOL addDupes)=0;
00271         virtual void    AddSpring(LagModData *lmd, int a, int b, int flag,BOOL addDupes)=0;
00272 
00273 
00274         virtual void    fnRemoveAllSprings()=0;
00275         virtual void    RemoveAllSprings(LagModData *lmd)=0;
00276         
00277 /*      virtual void    fnDeleteSpring(int a, int b)=0;
00278         virtual void    fnDeleteSpring(int index)=0;
00279         virtual void    DeleteSpring(LagModData *lmd, int a, int b)=0;
00280         virtual void    DeleteSpring(LagModData *lmd, int index)=0;
00281 
00282         virtual void    fnSetSpringFlag(int index, int flag)=0;
00283         virtual void    SetSpringFlag(LagModData *lmd,int index, int flag)=0;
00284         virtual int     fnGetSpringFlag(int index)=0;
00285         virtual int     GetSpringFlag(LagModData *lmd,int index)=0;
00286 */
00287 
00288         virtual void    fnAddSpringButton()=0;
00289         virtual void    fnRemoveSpringButton()=0;
00290         virtual void    fnOptionButton()=0;
00291         virtual void    fnSimpleSoftButton()=0;
00292 
00293         virtual void    fnRemoveSpring(int a) = 0;
00294         virtual void    RemoveSpring(LagModData *lmd,int a) = 0;
00295         virtual void    fnRemoveSpring(int a,int b) = 0;
00296         virtual void    RemoveSpring(LagModData *lmd,int a,int b)=0;
00297         virtual void    fnRemoveSpringByIndex(int index) = 0;
00298         virtual void    RemoveSpringByIndex(LagModData *lmd,int index) = 0;
00299 
00300         virtual int     fnNumberSprings()=0;
00301         virtual int     NumberSprings(LagModData *lmd)=0;
00302 
00303         virtual int     fnGetSpringGroup(int index) = 0;
00304         virtual int     GetSpringGroup(LagModData *lmd,int index)=0;
00305         virtual void    fnSetSpringGroup(int index, int group)=0;
00306         virtual void    SetSpringGroup(LagModData *lmd,int index, int group)=0;
00307 
00308         virtual float   fnGetSpringLength(int index)=0;
00309         virtual float   GetSpringLength(LagModData *lmd,int index) = 0;
00310         virtual void    fnSetSpringLength(int index,float dist)=0;
00311         virtual void    SetSpringLength(LagModData *lmd,int index,float dist) = 0;
00312 
00313         virtual int     fnGetIndex(int a, int b)=0;
00314         virtual int     GetIndex(LagModData *lmd,int a, int b)=0;
00315     };
00316 
00317 
00318 
00319 
00320