XMLAnimTreeEntry.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 // FILE:        XMLAnimTreeEntry.h
00012 // DESCRIPTION: Interface to Load Save Animation Interfaces
00013 // AUTHOR:      Michael Zyracki 
00014 // HISTORY:     created 2005
00015 //***************************************************************************/
00016 #pragma once
00017 
00018 #include "export.h"
00019 #include "ifnpub.h"
00020 #include "ref.h"
00021 
00023 
00024 
00025 
00028 #define EXPOSE_WORLD_TRANSFORM_SCLASS_ID 0x7f765e27
00029 
00030 
00033 #define EXPOSE_WORLD_TRANSFORM_CLASS_ID Class_ID(0x7f765e27, 0x13e613a0) 
00034 
00035 
00036  
00037 
00038 class XMLAnimTreeEntryList;
00039 class XMLAnimLabelWindow;
00040 class XMLAnimMapDlg;
00041 class AnimFileLoader;
00042 class XMLAnim;
00043 class AnimFileCreator;
00044 
00046 #define XMLANIMTREEENTRY_INTERFACE  Interface_ID(0x5d25abd, 0x36934bff)
00047 
00049 
00053 class XMLAnimTreeEntry : public FPMixinInterface
00054 {
00056     friend class XMLAnimTreeEntryList;
00058     friend class XMLAnimLabelWindow;
00060     friend class XMLAnimMapDlg;
00062     friend class AnimFileLoader;
00064     friend class AnimFileCreator;
00066     friend class XMLAnim;
00068     friend class XMLTreeListEnum;
00070     friend class XMLAnimTreeEntryImp;
00071 
00072 public:
00074     
00090     enum Type {eNone = 0x0, eTransform = 0x1, eBaseObject = 0x2, eModObject = 0x4, eNoteTracks = 0x8, 
00091     eVisTracks = 0x10, eMatMaps = 0x20, eMatParams = 0x40, eCustomAttributes = 0x80, 
00092     eIK = 0x100, ePos = 0x200,eRot =0x400, eScale = 0x800, ePosX = 0x1000,
00093     ePosY = 0x2000, ePosZ = 0x4000,eList = 0x8000,eKeyable = 0x10000,eRotX = 0x20000,eRotY = 0x40000,eRotZ = 0x80000,
00094     eScaleX = 0x100000,eScaleY = 0x200000,eScaleZ = 0x400000,eExposeWorldTransform = 0x800000,eLayer = 0x1000000};
00095 
00098     DllExport Animatable *GetAnim()const {return anim;}
00099     
00102     DllExport Animatable *GetClient() const{return client;}
00103     
00106     DllExport int GetSubNum()const{return subNum;}
00107     
00110     DllExport const MCHAR *GetName()const {return name.data();}
00111     
00114     DllExport int GetUnique()const {return unique;}
00115     
00118     DllExport const MCHAR *GetMapName()const{return  mapName.data();}
00119     
00122     DllExport int GetMapUnique()const {return mapUnique;}
00123 
00127     DllExport bool IsType(int type) const;
00128     
00130     
00133     DllExport unsigned int GetType()const{return type;}
00134 
00136     enum { getAnim,getClient,getSubNum,getName,getUnique,getMapName,getMapUnique,isType};
00137     // Function Map
00139     BEGIN_FUNCTION_MAP
00141         RO_PROP_FN(getAnim, GetAnimRef, TYPE_REFTARG);
00143         RO_PROP_FN(getClient, GetClientRef, TYPE_REFTARG);
00145         RO_PROP_FN(getSubNum, GetSubNum, TYPE_INT);
00147         RO_PROP_FN(getName, GetName, TYPE_STRING);
00149         RO_PROP_FN(getUnique, GetUnique, TYPE_INT);
00151         RO_PROP_FN(getMapName, GetMapName, TYPE_STRING);
00153         RO_PROP_FN(getMapUnique, GetMapUnique, TYPE_INT);
00155         FN_1(isType, TYPE_bool, IsType,TYPE_ENUM);  
00156     
00157     END_FUNCTION_MAP
00158 
00159     //for FP 
00161     DllExport FPInterfaceDesc* GetDesc();
00163     LifetimeType LifetimeControl() { return wantsRelease; }
00165     BaseInterface* AcquireInterface() { return this; }
00167     DllExport void ReleaseInterface();
00168 
00169 private:
00170     
00171     DllExport   XMLAnimTreeEntry(Animatable *a, Animatable *c,int s, int d);
00172     DllExport   XMLAnimTreeEntry(const XMLAnimTreeEntry &entry);
00173 
00174     Animatable *anim;
00175     Animatable *client;
00176     int subNum;
00177     int depth;
00178     MSTR name; 
00179     int unique;
00180     MSTR mapName;
00181     int mapUnique;
00182     unsigned int type;
00183     DWORD flags;
00184     BOOL selected,mapped; //used in XMLAnimWindow
00185     int location; //used to specify where it came from the original list, in XMLAnimWindow
00186     BOOL loadable;//used when loaded in and a child is being loaded, we need to set all the parent/anims, as unloadable
00187     MSTR className; //name of it's class
00188     SClass_ID superClassID;
00189     Class_ID classID;
00190     MSTR mapClassName;
00191     MSTR nodeParentName; //only used for nodes!!!!
00192     MSTR IKBeginNode; //only used for IKControlChain Nodes.
00193     MSTR IKEndNode;
00194     MSTR IKSplineNode; //only used by nodes that are dummies that control a spline IK. This is the IKChainControl node
00195     float distanceToParent;//only fo nodes.
00196     int numChildren; //subanims or node children
00197 
00198 
00199     DllExport int GetParentIndex(XMLAnimTreeEntryList *list, int listIndex);
00200     DllExport unsigned int GetLocalType();
00201     DllExport unsigned int IsXYZ();
00202     DllExport BOOL IsList();
00203     DllExport bool IsParentOpen(XMLAnimTreeEntryList *list, int listIndex);
00204     DllExport MSTR StripNodeFromName(); //TODO make sure we handle nodeless entries
00205 
00206 
00207     //FP functions and info
00208     DllExport ReferenceTarget* GetAnimRef() {return dynamic_cast<ReferenceTarget*>(anim);} // This needs to be deinlined.
00209     DllExport ReferenceTarget* GetClientRef() {return dynamic_cast<ReferenceTarget*>(client);} // This needs to be deinlined.
00210 
00211 };
00212 
00213 
00214 
00216 #define XMLANIMTREEENTRYLIST_INTERFACE  Interface_ID(0x34d56bf5, 0x1b2a7c80)
00217 
00218 
00220 
00225 class XMLAnimTreeEntryList : private Tab<XMLAnimTreeEntry*>,public FPMixinInterface     
00226 {
00228     friend class XMLAnimTreeEntry;
00230     friend class XMLAnimLabelWindow;
00232     friend class XMLAnimMapDlg;
00234     friend class AnimFileLoader;
00236     friend class AnimFileCreator;
00238     friend class XMLAnim;   
00240     friend class XMLTreeListEnum;
00242     friend class XMLAnimTreeEntryListImp;
00243 public: 
00244 
00246     DllExport XMLAnimTreeEntryList();
00248     DllExport ~XMLAnimTreeEntryList();
00249 
00250 
00252     
00255     DllExport XMLAnimTreeEntry* operator[](const int index);
00256 
00259     DllExport int Count() const;
00260     
00262     DllExport void ZeroCount();
00263     
00265     DllExport void Shrink();
00266     
00268 
00272     DllExport int Delete(int start,int num) ;
00273     
00275     DllExport void DeleteData();
00276 
00278 
00282     DllExport int FindAnim(Animatable *anim,int start=0);
00283 
00285     
00286     // !\param[in] which XMLAnimTreeEntry you want to find
00287     // !\return The index where the entry is, -1 if not found
00288     DllExport int Find(XMLAnimTreeEntry *which);
00289 
00290     // \brief Find this particular XMLAnimTreeEntry based off it's name and unique id.
00291     
00292     // !param[in] name The name of the track you want to find
00293     // !param[in] unique Whether or not the track is unique
00294     // !\return The index where the entry is, -1 if not found
00295     DllExport int Find(MSTR &name, int unique);
00296 
00297     // !\brief Find the subAnim parents of the specified item.
00298 
00301     DllExport void FindParents(int index,Tab<int> &parentIndices);
00302 
00304 
00307     DllExport void FindChildren(int index,Tab<int> &childIndices);
00308 
00309 
00310     //FP stuff
00312     enum { getEntry,count,zeroCount,shrink,deleteItems,findAnim,findName};
00313     // Function Map
00315     BEGIN_FUNCTION_MAP  
00317         FN_1(getEntry, TYPE_INTERFACE, GetEntry,TYPE_INT);
00319         FN_0(count,TYPE_INT,Count);
00321         VFN_0(zeroCount,ZeroCount);
00323         VFN_0(shrink,Shrink);
00325         FN_2(deleteItems,TYPE_INT,Delete,TYPE_INT,TYPE_INT);
00327         FN_2(findAnim,TYPE_INT,FindAnimFP,TYPE_REFTARG,TYPE_INT);
00329         FN_2(findName,TYPE_INT,FindNameFP,TYPE_STRING,TYPE_INT);
00330     
00331     END_FUNCTION_MAP
00332 
00333     //for 
00335     DllExport FPInterfaceDesc* GetDesc();
00337     LifetimeType LifetimeControl() { return wantsRelease; }
00339     BaseInterface* AcquireInterface() { return this; }
00341     DllExport void ReleaseInterface();
00342 
00343     
00344 private:
00345     //fp stuff
00346     FPInterface* GetEntry(const int index);
00347     int FindAnimFP(ReferenceTarget *anim,int start);
00348     int FindNameFP(MCHAR *name,int unique);
00349 
00350     int curSel;
00351     DllExport void Build(   Animatable *root);
00352     DllExport MSTR GetName(XMLAnimTreeEntry *entry, int listIndex);
00353     DllExport void SetNameTypeUnique(XMLAnimTreeEntry* entry,int index);
00354 
00355     DllExport void DeleteSubtree(int index);
00356     DllExport void RecalcSubtree(int index,DWORD flags=0);
00357 
00358     DllExport void AppendEntry(XMLAnimTreeEntry &entry);
00359     DllExport void InsertEntry(int where,XMLAnimTreeEntry &entry);
00360 
00361     DllExport BOOL IsTextSelected(int index);
00362     DllExport void ClearSelectText();
00363 
00364     DllExport void GetSelected(Tab<XMLAnimTreeEntry*> &selected);
00365     DllExport void GetAll(Tab<XMLAnimTreeEntry*>&all);
00366     DllExport void SelectByWildCard(MCHAR *buf);
00367     DllExport void SelectText(int index,BOOL sel,BOOL range=FALSE,BOOL column=FALSE);
00368     DllExport int FindSelectText();
00369     DllExport void SelectItemText(int index);
00370     DllExport void SelectAllText();
00371     DllExport void SelectInvertText();
00372     DllExport void SelectChildrenText(int index);
00373 
00374     DllExport void AddWorldTransformEntry(MSTR &nodeName,int where);
00375 
00376     DllExport int LineCount();
00377     DllExport int MaxDepth();
00378 
00379     DllExport int EntryRealDepth(int i);
00380     DllExport int RealMaxDepth();
00381     DllExport void MarkParentsFromListAsUnloadable(int index);
00382     DllExport void MarkParentsAndChildrenAsMapped(BOOL mapped,int index);
00383     DllExport void MarkParentsAndParentsChildrenAsMapped(BOOL mapped,int index);
00384     DllExport bool AreAnyChildrenMapped(int index);
00385 
00386     DllExport void FindAllParentNodes(int index,Tab<int> &nodeParents); //find all of the parent nodes
00387     DllExport void FindAllChildNodes(int index,Tab<int> &nodeChildren); //find all of the child nodes
00388     DllExport void FindChildNodes(int index,Tab<int> &nodeChildren); //find just the direct child nodes
00389     DllExport void SetMapInfo(BOOL mapped,int which, MSTR &mapName, int mapUnique);
00390 
00391 };
00392 
00394 #define NODEANDANIMS_INTERFACE  Interface_ID(0x4ad13c9b, 0x3ca97bec)
00395 
00398 
00407 
00408 class NodeAndAnims : public FPMixinInterface
00409 {
00411     friend class XMLAnimLabelWindow;
00413     friend class XMLAnimMapDlg;
00415     friend class AnimFileLoader;
00417     friend class AnimFileCreator;
00419     friend class XMLAnim;   
00421     friend class NodeAndAnimsImp;
00423     friend class ILoadSaveAnimation_Imp;
00424 public:
00425     NodeAndAnims():node(NULL),IKNodeName(NULL),list(NULL){};
00426 
00428     DllExport NodeAndAnims(const NodeAndAnims &);
00429     
00432     DllExport XMLAnimTreeEntryList *GetList()const {return list;}
00433     
00436     DllExport INode *GetNode()const {return node;}
00437     
00439     DllExport void DeleteThis();
00440 
00442     enum { getList,getNode};
00444     #pragma warning(push)
00445     #pragma warning(disable:4100)
00446     BEGIN_FUNCTION_MAP  
00448         FN_0(getList, TYPE_INTERFACE,GetListFP);
00450         FN_0(getNode,TYPE_INODE,GetNode);
00451     END_FUNCTION_MAP
00452     #pragma warning(pop)
00453     // function map use
00455     DllExport FPInterfaceDesc* GetDesc();
00457     LifetimeType LifetimeControl() { return wantsRelease; }
00459     BaseInterface* AcquireInterface() { return this; }
00461     DllExport void ReleaseInterface();
00462 
00463 private:
00464 
00465     INode *node; //node may be NULL!
00466     MSTR *IKNodeName;//name of the IK Node that this node may implicitly control, e.g a spline IK helper
00467     //node would have the name of the .. may be NULL!
00468     XMLAnimTreeEntryList *list;
00469 
00470     DllExport FPInterface *GetListFP();
00471 };
00472 
00473 
00474