IProjectionMod.h

Go to the documentation of this file.
00001 /**********************************************************************
00002  *<
00003     FILE: IProjectionMod.h
00004 
00005     DESCRIPTION: Interface for Projection Modifier
00006 
00007     CREATED BY:  Michael Russo
00008 
00009     HISTORY:     02-23-2004
00010 
00011  *> Copyright (c) 2004, All Rights Reserved.
00012  **********************************************************************/
00013 
00014 #pragma once
00015 
00016 #include "maxheap.h"
00017 #include "ObjectWrapper.h"
00018 // forward declarations
00019 class IProjectionModData;
00020 
00021 #pragma warning(push)
00022 #pragma warning(disable:4100)
00023 
00024 #define PROJECTIONMOD_CLASS_ID          Class_ID(0x166c301c, 0x19f90c49)
00025 #define IPROJECTIONMOD_INTERFACE_ID     Interface_ID(0x6b231b96, 0xb26a72)
00026 #define IPROJECTIONMOD10_INTERFACE_ID   Interface_ID(0x5a9803fa, 0x40216bb5)
00027 #define IPROJECTIONMODDATA_INTERFACE_ID Interface_ID(0x341e47bc, 0x1f923a2f)
00028 
00029 //=============================================================================
00030 //
00031 //  Class IProjectionMod
00037 //=============================================================================
00038 class IProjectionMod : public FPMixinInterface
00039 {
00040 public:
00041     // IProjectionMod
00042 
00043     // Geometry Selection Methods
00044     enum { PM_SL_OBJECT, PM_SL_VERT, PM_SL_FACE, PM_SL_ELEM };
00045 
00046     // Access to Geom Selections by Node/Object Index
00047 
00050     virtual int                 NumObjects() = 0;
00051 
00054     virtual INode*              GetObjectNode(int iIndex) = 0;
00055 
00058     virtual const MCHAR*        GetObjectName(int iIndex) = 0;
00059 
00063     virtual int                 GetObjectSelLevel(int iIndex) = 0;
00064 
00067     virtual void                DeleteObjectNode(int iIndex) = 0;
00068 
00069     // Access to Geom Selections by Geom Selections
00070 
00073     virtual int                 NumGeomSels() = 0;
00074 
00077     virtual const MCHAR*        GetGeomSelName( int iSelIndex ) = 0;
00078 
00082     virtual int                 GetGeomSelSelLevel( int iSelIndex ) = 0;
00083 
00087     virtual int                 NumGeomSelNodes( int iSelIndex ) = 0;
00088 
00092     virtual INode*              GetGeomSelNode( int iSelIndex, int iNodeIndex ) = 0;
00093 
00098     virtual void                SetGeomSelMapProportion( int iSelIndex, float fProportion ) = 0;
00099 
00103     virtual float               GetGeomSelMapProportion( int iSelIndex ) = 0;
00104 
00107     virtual void                DeleteGeomSel( int iSelIndex ) = 0;
00108 
00112     virtual void                DeleteGeomSelNode( int iSelIndex, int iNodeIndex ) = 0;
00113 
00117     virtual IProjectionModData* GetProjectionModData(INode *pNode) = 0;
00118 
00119     // Modifier Access
00120 
00124     virtual bool                IsValidObject( INode *pNode ) = 0;
00125 
00129     virtual bool                AddObjectNode( INode *pNode ) = 0;
00130 
00132     virtual void                DeleteAll() = 0;
00133 
00136     virtual void                SetGeomSelNodesVisibility( bool bVisible ) = 0;
00137 
00141     virtual bool                GetGeomSelNodesVisibility() = 0;
00142 
00144     virtual void                UpdateProjectionTypeList() = 0;
00145 
00148     virtual void                AutoWrapCage() = 0;
00149 
00152     virtual void                ResetCage() = 0;
00153 
00157     virtual void                PushCage(float fAmount) = 0;
00158 
00164     virtual int                 fpGetObjectSelMtlIDs(INode *pNode, int iIndex, Tab<int> &mtlIDs) = 0;
00165 
00171     virtual int                 fpGetGeomSelMtlIDs(INode *pNode, int iSelIndex, Tab<int> &mtlIDs) = 0;
00172 
00177     virtual float               fpGetGeomSelFaceArea(INode *pNode, int iSelIndex) = 0;
00178 
00184     virtual int                 fpCheckDuplicateMatIDs( INode *pNode, BitArray &bitFaceDups ) = 0;
00185 
00191     virtual int                 fpCheckDuplicateSels( INode *pNode, BitArray &bitFaceDups ) = 0;
00192 
00195     virtual void                fpSelectByMtlID( int iMtlID ) = 0;
00198     virtual void                fpSelectBySG( int iSG ) = 0;
00199 
00205     virtual int                 fpGetNumProjectionTypes() = 0;
00206 
00210     virtual ReferenceTarget*    fpGetProjectionType(int iIndex) = 0;
00211 
00214     virtual void                fpRemoveProjectionType(int iIndex) = 0;
00215 
00219     virtual void                fpProject(int iIndex) = 0;
00220 
00222     virtual void                fpProjectAll() = 0;
00223 
00228     virtual int                 fpGetNumRegisteredProjectionTypes() = 0;
00229 
00232     virtual void                fpAddRegisteredProjectionType(int iIndex) = 0;
00233 
00237     virtual void                fpGetRegisteredProjectionTypeClassID(int iIndex, Tab<int> &classid) = 0;
00238 
00240     virtual void                fpShowAlignment() = 0;
00241 
00243     virtual void                fpClearAlignment() = 0;
00244 };
00245 
00246 //=============================================================================
00247 //
00248 //  Class IProjectionMod10
00249 //
00250 //=============================================================================
00251 
00252 class IProjectionMod10 : public FPMixinInterface
00253 {
00254 public:
00255     virtual bool                ImportCageMesh( INode* importNode ) = 0;
00256     virtual bool                ExportCageMesh( MCHAR* exportNodeName ) = 0;
00257 };
00258 
00259 //=============================================================================
00260 //
00261 //  Class IProjectionModData
00266 //=============================================================================
00267 class IProjectionModData : public BaseInterface
00268 {
00269 public:
00270 
00271     // GenericInterface
00272     virtual Interface_ID    GetID() { return IPROJECTIONMODDATA_INTERFACE_ID; }
00273 
00274     // IProjectionModData
00275 
00279     virtual ObjectWrapper &GetBaseObject() = 0; // Object with Projection Modifier
00280 
00283     virtual ObjectWrapper &GetCage() = 0;       // Cage mesh
00284 
00285     // Access to Geom Selections by Node/Object Index
00286 
00291     virtual bool        GetObjectSel(int iIndex, BitArray& sel) = 0;
00292 
00297     virtual int         GetObjectSelMtlIDs(int iIndex, Tab<int> &mtlIDs) = 0;
00298 
00299     // Access to Geom Selections by Geom Selections
00300 
00305     virtual bool        GetGeomSel(int iSelIndex, BitArray& sel) = 0;
00306 
00311     virtual int         GetGeomSelMtlIDs(int iSelIndex, Tab<int> &mtlIDs) = 0;
00312 
00316     virtual float       GetGeomSelFaceArea(int iSelIndex) = 0;
00317 
00322     virtual int         CheckDuplicateMatIDs( BitArray &bitFaceDups ) = 0;
00323 
00328     virtual int         CheckDuplicateSels( BitArray &bitFaceDups ) = 0;
00329 
00330 };
00331 
00332 
00333 //=============================================================================
00334 //
00335 //  Class IProjectionModType
00336 //
00337 //  Class Category: ProjectionModType
00347 //=============================================================================
00348 class IProjectionModType : public ReferenceTarget
00349 {
00350 public:
00351 
00355     virtual void SetIProjectionMod( IProjectionMod *pPMod ) {}
00356 
00365     virtual bool CanProject(Tab<INode*> &tabSourceNodes, int iSelIndex, int iNodeIndex) { return false; }
00366     
00372     virtual void Project(Tab<INode*> &tabSourceNodes, int iSelIndex, int iNodeIndex) {}
00373 
00376     virtual void SetInitialName(int iIndex) {}
00377 
00380     virtual const MCHAR *GetName(){return NULL;}
00381 
00384     virtual void SetName(const MCHAR *name) {}
00385     // deprecated method - implement SetName(const MCHAR *name)
00386     virtual void SetName(MCHAR *name) { SetName(const_cast<const MCHAR*>(name)); }
00387 
00391     virtual void Enable(bool enable) {}
00392 
00395     virtual bool IsEditing() { return false; }
00396 
00398     virtual void EndEditing() {}
00399 
00403     virtual void EnableEditing(bool enable) {}
00404 
00408     virtual RefResult NotifyRefChanged( Interval changeInt,RefTargetHandle hTarget, PartID& partID, RefMessage message )    
00409         { return REF_SUCCEED; }
00410 
00414     virtual IOResult Load(ILoad *iload) {return IO_OK;}
00418     virtual IOResult Save(ISave *isave) {return IO_OK;}
00419 
00424     virtual void ModifyObject(TimeValue t, ModContext &mc, ObjectState * os, INode *inode, IProjectionModData *pPModData) {}
00425 
00429     virtual void BeginEditParams(IObjParam  *ip, ULONG flags,Animatable *prev) {}
00433     virtual void EndEditParams(IObjParam *ip,ULONG flags,Animatable *next) {}         
00434 
00439     virtual void NotifyInputChanged(Interval changeInt, PartID partID, RefMessage message, ModContext *mc, IProjectionModData *pPModData) {}
00440 
00444     virtual void GetWorldBoundBox(TimeValue t,INode* inode, ViewExp *vpt, Box3& box, ModContext *mc){}
00445 
00449     virtual int Display(TimeValue t, GraphicsWindow *gw, Matrix3 tm ) { return 1;}
00450 
00454     virtual int HitTest(TimeValue t, INode* inode, int type, int crossing, int flags, IPoint2 *p, ViewExp *vpt, ModContext* mc, Matrix3 tm) {return 0;}
00455 
00459     virtual void SelectSubComponent(HitRecord *hitRec, BOOL selected, BOOL all, BOOL invert=FALSE) {}
00460 
00464     virtual void Move( TimeValue t, Matrix3& partm, Matrix3& tmAxis, Point3& val, Matrix3 tm, BOOL localOrigin=FALSE ) {}
00465 
00469     virtual void GetSubObjectCenters(SubObjAxisCallback *cb,TimeValue t,INode *node, Matrix3 tm) {}
00470 
00474     virtual void GetSubObjectTMs(SubObjAxisCallback *cb,TimeValue t,INode *node, Matrix3 tm) {}
00475 
00479     virtual void ClearSelection(int selLevel) {}
00480 
00484     virtual void SelectAll(int selLevel) {}
00485 
00489     virtual void InvertSelection(int selLevel) {}
00490     
00491 };
00492 
00493 //=============================================================================
00494 //
00495 //  Class IProjectionIntersector
00496 //
00497 //  Ray-intersection for projection mapping
00501 //=============================================================================
00502 class IProjectionIntersector: public MaxHeapOperators {
00503     public:
00504         IProjectionIntersector() {}
00505         virtual         ~IProjectionIntersector() {}
00506         virtual void    DeleteThis() {}
00507 
00511         virtual BOOL    InitRoot( MNMesh* root,         MNMesh* cage,           Matrix3& objectToWorldTM ) = 0;
00515         virtual BOOL    InitRoot( ObjectWrapper& root,  ObjectWrapper& cage,    Matrix3& objectToWorldTM ) = 0;
00516 
00518         virtual BOOL    RootValid() = 0;
00519 
00521         virtual BOOL    InitLeaf( MNMesh* leaf,         Matrix3& objectToWorldTM ) = 0;
00523         virtual BOOL    InitLeaf( ObjectWrapper& leaf,  Matrix3& objectToWorldTM ) = 0;
00525         virtual BOOL    LeafValid() = 0;
00526 
00528         virtual void    Free() = 0;
00529 
00530         enum {FINDCLOSEST_CAGED=1, FINDCLOSEST_IGNOREBACKFACING=2};
00534         virtual BOOL    RootClosestFace( Ray& pointAndNormal, int flags, float& dist, DWORD& rootFaceIndex, Tab<float>& rootFaceBary ) = 0;
00535 
00538         virtual BOOL    LeafIntersectRay( Ray& ray, float& dist, DWORD& leafFaceIndex, Tab<float>& leafFaceBary ) = 0;
00539 
00542         virtual BOOL    LeafIntersectRay( DWORD rootFaceIndex, Point3& rootFaceBary, float& dist, DWORD& leafFaceIndex, Tab<float>& leafFaceBary ) = 0;
00543 };
00544 
00545 // Manager class, creates instances of IProjectionIntersector
00546 class IProjectionIntersectorMgr : public FPStaticInterface {
00547     public:
00548         virtual IProjectionIntersector* CreateProjectionIntersector() = 0;
00549 };
00550 
00551 #define IPROJECTIONINTERSECTORMGR_INTERFACE_ID Interface_ID(0x457d402d, 0x36e81f43)
00552 #define GetIProjectionIntersectorMgr() \
00553     ((IProjectionIntersectorMgr*)GetCOREInterface(IPROJECTIONINTERSECTORMGR_INTERFACE_ID))
00554 
00555 #pragma warning(pop)
00556 
00557