idatachannel.h

Go to the documentation of this file.
00001  /**********************************************************************
00002  
00003     FILE: IDataChannel.h
00004 
00005     DESCRIPTION:  Intelligent Data Channel API
00006 
00007     CREATED BY: Attila Szabo, Discreet
00008 
00009     HISTORY: [attilas|19.6.2000]
00010 
00011 
00012  *> Copyright (c) 1998-2000, All Rights Reserved.
00013  **********************************************************************/
00014 
00015 #pragma once
00016 
00017 #include "maxheap.h"
00018 #include "maxtypes.h"
00019 #include "baseinterface.h"
00020 
00021 // forward declarations
00022 class FPInterface;
00023 class BitArray;
00024 
00025 // Macros to be used if any of the method below are implemented in a dll
00026 // The dll project that implements the methods needs to define DATACHANNEL_IMP
00027 #ifdef DATACHANNEL_IMP
00028 #define DataChanExport __declspec(dllexport)
00029 #else
00030 #define DataChanExport __declspec(dllimport)
00031 #endif
00032 
00033 
00034 
00035 // A data channel is a homogeneous collection of objects of a user defined 
00036 // type (data objects). Data channels are uniquely identified by a Class_ID.
00037 //
00038 // Data channels can be associated with any element type of a Max object:
00039 // faces or vertexes of Meshes, etc.
00049 class IDataChannel : public InterfaceServer
00050 {
00051     public:
00052         // Returns the unique id of the channel
00055         virtual Class_ID DataChannelID() const =0;
00056 
00057         // Returns the number of data objects in this channel
00062         virtual ULONG Count() const { return 0; }
00063         
00064         // Self destruction
00066         virtual void DeleteThis() = 0;
00067 };
00068 
00069 // interface ID
00070 #define DATACHANNEL_INTERFACE Interface_ID(0x38a718a8, 0x14685b4b)
00071 #define GetDataChannelInterface(obj) ((IDataChannel*)obj->GetInterface(DATACHANNEL_INTERFACE)) 
00072 
00073 // Face-data channel interface
00074 // 
00075 // This is an abstraction of a collection of data objects that is 
00076 // associated with faces of Max objects
00077 // Max objects that have face-data channels call the methods of this interface
00078 // when those faces change in some way. The data channels can then react to
00079 // the changes to the faces.
00080 //
00081 // Currently only Meshes support face-data channels.
00093 class IFaceDataChannel : public IDataChannel
00094 {
00095     public:
00096 
00097         //
00098         // --- face specific operations\events ---
00099         //
00100         // These methods are called by the owner of face-data channels
00101         // when its faces change in some way. It's up to the face-data channel 
00102         // to do wathever it wants to do on these notification methods.
00103 
00104         // Called when num new faces were created at index at in the
00105         // object's list of faces. Returns TRUE on success
00106         // ULONG at - index in the object's array of faces where the new faces 
00107         // were inserted
00108         // ULONG num - the number of new faces created
00118         virtual BOOL FacesCreated( ULONG at, ULONG num ) = 0;
00119         
00120         // Called when the owner object has cloned some of its faces and appended
00121         // then to its list of faces.
00122         // BitArray& set - bitarray with as many bits as many faces the owner 
00123         // object has. Bits set to 1 correspond to cloned faces
00132         virtual BOOL FacesClonedAndAppended( BitArray& set ) = 0;
00133 
00134         // Called when faces were deleted in the owner object. Returns TRUE on success
00135         // BitArray& set - bitarray with as many bits as many faces the owner 
00136         // object has. Bits set to 1 correspond to deleted faces
00145         virtual BOOL FacesDeleted( BitArray& set ) = 0;
00146 
00147         // Called when faces were deleted in the owner object. Returns TRUE on success
00148         // Allwos for a more efficient deletion of a range of data objects
00149         // than using a BitArray
00150         // ULONG from - index in the object's array of faces. Faces starting 
00151         // from this index were deleted
00152         // ULONG num - number of faces that were deleted
00163         virtual BOOL FacesDeleted( ULONG from, ULONG num ) = 0;
00164         
00165         // Called when all faces in the owner object are deleted
00168         virtual void AllFacesDeleted() = 0;
00169 
00170         // Called when a face has been copied from index from in the owner object's
00171         // array of faces to the face at index to.
00172         // ULONG from - index of source face
00173         // ULONG to - index of dest face
00183         virtual BOOL FaceCopied( ULONG from, ULONG to ) = 0;
00184 
00185         // Called when a new face has been created in the owner object based on
00186         // data interpolated from other faces
00187         // ULONG numSrc - the number of faces used in the interpolation
00188         // ULONG* srcFaces - array of numSrc face indeces in the owner object's 
00189         // face array. These faces were used when creating the new face
00190         // float* coeff - array of numSrc coefficients used in the interpolation
00191         // ULONG targetFace - the index in the owner object's array of faces of the 
00192         // newly created face
00207         virtual BOOL FaceInterpolated( ULONG numSrc, 
00208                                                             ULONG* srcFaces, 
00209                                                             float* coeff, 
00210                                                             ULONG targetFace ) = 0;
00211 
00212         //
00213         // --- geometry pipeline (stack) specific methods ---
00214         //
00215         // These methods are called when the owner object is flowing up the 
00216         // pipeline (stack). They must be implemented to ensure that the 
00217         // face-data channel flows up the pipeline correctly.
00218         // The owner object expects the face-data to do exactly what the 
00219         // names of these methods imply. These can be seen as commands that are
00220         // given by the owner object to the face-data channel
00221 
00222         // Allocates an empty data-channel 
00224         virtual IFaceDataChannel* CreateChannel( ) = 0;
00225 
00226         // The data-channel needs to allocate a new instance of itself and fill it 
00227         // with copies of all data items it stores.
00228         // This method exist to make it more efficient to clone the whole data-channel
00232         virtual IFaceDataChannel* CloneChannel( ) = 0;
00233 
00234         // The data-channel needs to append the data objects in the fromChan
00235         // to itself. 
00242         virtual BOOL AppendChannel( const IFaceDataChannel* fromChan ) = 0;
00243 };
00244 
00245 // interface ID
00246 #define FACEDATACHANNEL_INTERFACE Interface_ID(0x181358d5, 0x3cab1bc9)
00247 #define GetFaceDataChannelInterface(obj) ((IFaceDataChannel*)obj->GetInterface(FACEDATACHANNEL_INTERFACE)) 
00248 
00249 // Interface class that allows to execute a callback method (Proc) for all 
00250 // face-data channels of an object.
00251 //
00252 // Developers should derive their own classes from this interface and 
00253 // overwrite the Proc method to call the desired IFaceDataChannel method
00254 // It is up to derived class to interpret the context parameter passed to
00255 // Proc.
00256 //
00257 // --- Usage ---
00258 // Classes that hold face-data channels, can implement a method called
00259 // EnumFaceDataChannels( IFaceDataEnumCallBack& cb, void* pContext)
00260 // This method would be called with a reference to an instance of a class
00261 // derived from IFaceDataEnumCallBack in which Proc was overwritten. The 
00262 // implementation of EnumFaceDataChannels would call cb.Proc for each of 
00263 // the face-data channels of the object
00264 //
00265 // Warning:
00266 // Deleting data channels from within Proc can lead to unexpected behaviour
00283 class IFaceDataChannelsEnumCallBack: public MaxHeapOperators
00284 {
00285     public:
00287         virtual ~IFaceDataChannelsEnumCallBack() {;}
00295         virtual BOOL Proc( IFaceDataChannel* pChan, void* pContext ) = 0;
00296 };
00297 
00298 
00299 
00300