ParticleChannelMask.h

Go to the documentation of this file.
00001 
00007 /**********************************************************************
00008  *<
00009     CREATED BY: Oleg Bayborodin
00010 
00011     HISTORY: created 9-19-01
00012 
00013  *> Copyright (c) 2001, All Rights Reserved.
00014  **********************************************************************/
00015 
00016 #pragma once
00017 
00018 #include "PFExport.h"
00019 #include <WTypes.h>
00020 #include "..\MaxHeap.h"
00021 // forward declarations
00022 class Interface_ID;
00023 
00024 // all generic particle channel listed (implemented by max)
00025 enum PCU_genericChannelIndex {
00026     PCG_float=      1<<0,
00027     PCG_int=        1<<1,
00028 //  PCG_RGBA=       1<<2,
00029     PCG_Point3=     1<<3,
00030     PCG_bool=       1<<4,
00031 //  PCG_String=     1<<5,
00032 //  PCG_TimeValue=  1<<6,
00033     PCG_PTV=        1<<7,   // Precise Time Value
00034 //  PCG_TexMap=     1<<8,
00035     PCG_INode=      1<<9,
00036     PCG_Matrix3=    1<<10,
00037     PCG_void=       1<<11,
00038 //  PCG_Interval=   1<<12,
00039     PCG_AngAxis=    1<<13,
00040     PCG_Quat=       1<<14,
00041 //  PCG_Point2=     1<<15,
00042 //  PCG_BitArray=   1<<16,
00043     PCG_Mesh=       1<<17,
00044 //  PCG_TabPoint3=  1<<18,
00045 //  PCG_TabFace=    1<<19
00046     PCG_TabUVVert=  1<<20,
00047     PCG_TabTVFace=  1<<21,
00048     PCG_Map=        1<<22,
00049     PCG_MeshMap=    1<<23
00050 };
00051 
00052 // all standard particle channels listed (implemented by max)
00053 // Note to Developer: update index2InterfaceID and InterfaceID2index methods 
00054 // if number/content of standard classes is changed
00055 // maximum amount of standard particle channels is 31; restricted by bit size of DWORD
00056 enum PCU_channelIndex {
00057     PCU_Undefined=         0,
00058     PCU_Amount=         1<<0, // fictional channel to indicate that Operator changes number of particles
00059     PCU_New=            1<<1, // channel to trace newly born/entered particles
00060     PCU_ID=             1<<2, // channel to keep particleID=(index,born)
00061     PCU_Time=           1<<3, // current valid time for a particle (PCG_PTV)
00062     PCU_BirthTime=      1<<4, // time when particle was born (PCG_PTV)
00063     PCU_EventStart=     1<<5, // time when particle entered the current event (PCG_PTV)
00064     PCU_Position=       1<<6, // particle position (PCG_Point3)
00065     PCU_Speed=          1<<7, // particle speed (PCG_Point3)
00066     PCU_Acceleration=   1<<8, // particle acceleration (PCG_Point3)
00067     PCU_Orientation=    1<<9, // 3D orientation of a particle (PCG_Quad)
00068     PCU_Spin=           1<<10, // angular velocity of a particle (PCG_AngAxis)
00069     PCU_Scale=          1<<11, // scaling factor for particle (Point3: x, y, z axes)
00070     PCU_Shape=          1<<12, // shape as a whole mesh (PCG_Mesh)
00071 //  PCU_ShapeTopology=  1<<13, // topology data (Tab<Face>)
00072 //  PCU_ShapeGeometry=  1<<14, // geometry data (Tab<Point3>)
00073 //  PCU_ShapeNormals=   1<<15, // normals data
00074     PCU_ShapeTexture=   1<<16, // texture coordinate data
00075 //  PCU_Mass=           1<<17, // particle mass
00076     PCU_MtlIndex=       1<<18, // material index for particles
00077     PCU_Selection=      1<<19,  // selection status
00078     PCU_MXSInteger=     1<<20,  // maxscript integer value
00079     PCU_MXSFloat=       1<<21,  // maxscript float value
00080     PCU_MXSVector=      1<<22,  // maxscript Point3 value
00081     PCU_MXSMatrix=      1<<23,  // maxscript Matrix3 value
00082     PCU_DeathTime=      1<<24,  // time when particle is expected to die (PCG_PTV)
00083     PCU_Lifespan=       1<<25   // lifespan of a particle
00084 };
00085 
00086 class ParticleChannelMask: public MaxHeapOperators 
00087 {
00088 public:
00089 
00097     PFExport ParticleChannelMask();
00098 
00102     PFExport ParticleChannelMask(const ParticleChannelMask&);
00103 
00107     PFExport ParticleChannelMask(DWORD readMask, DWORD writeMask);
00108 
00112     PFExport ParticleChannelMask& operator=(const ParticleChannelMask&);
00113 
00117     PFExport ~ParticleChannelMask();
00118 
00122     PFExport int operator==(const ParticleChannelMask&) const;
00123 
00127     PFExport int operator!=(const ParticleChannelMask&) const;
00128 
00132     PFExport void SetReadChannels(DWORD channelsFlag);
00133 
00137     PFExport void SetWriteChannels(DWORD channelsFlag);
00138 
00142     PFExport bool SetChannels(int numChannels, Interface_ID* channels);
00143 
00147     PFExport void AddReadChannels(DWORD channelsFlag); // adds more standard read channels
00148 
00152     PFExport void RemoveReadChannels(DWORD channelsFlag); // removes some standard read channels
00153 
00157     PFExport void AddWriteChannels(DWORD channelsFlag); // adds more standard write channels
00158 
00162     PFExport void RemoveWriteChannels(DWORD channelsFlag); // removes some standard write channels
00163 
00167     PFExport bool AddChannel(Interface_ID& channel);
00168 
00172     PFExport bool RemoveChannel(Interface_ID& channel);
00173 
00177     PFExport const int GetNumChannels() const; // standard read/write and custom together
00178 
00182     PFExport const Interface_ID GetChannel(int i) const;
00183 
00187     PFExport const bool HasChannel(Interface_ID& channel) const;
00188 
00192     PFExport const bool HasReadChannels(DWORD channelsFlag) const;
00193 
00197     PFExport const bool HasWriteChannels(DWORD channelsFlag) const;
00198 
00202     PFExport static int NumStandardParticleChannels();
00203 
00207     PFExport static const ParticleChannelMask& Null();
00208 
00209 private:
00210     // conversion between channel index and standard channel Class_ID
00211         // returns PCU_Undefined if the channel isn't standard particle channel
00212     PFExport static const PCU_channelIndex InterfaceID2readIndex(Interface_ID& id);
00213     PFExport static const PCU_channelIndex InterfaceID2writeIndex(Interface_ID& id);
00214         // returns false if not a valid index
00215     PFExport static const Interface_ID readIndex2InterfaceID(PCU_channelIndex index);
00216     PFExport static const Interface_ID writeIndex2InterfaceID(PCU_channelIndex index);
00217 
00218     void invalidateNumSRChannels() { _numSRChannelsValid() = false; }
00219     void invalidateNumSWChannels() { _numSWChannelsValid() = false; }
00220 
00221     // const access to class members
00222     const DWORD         readFlag()                  const   { return m_readFlag; }
00223     const DWORD         writeFlag()                 const   { return m_writeFlag; }
00224     const bool          numSRChannelsValid()        const   { return m_numSRChannelsValid; }
00225     const bool          numSWChannelsValid()        const   { return m_numSWChannelsValid; }
00226     const int           numStandardReadChannels()   const; // updates num of standard read channels if invalid
00227     const int           numStandardWriteChannels()  const; // updates num of standard write channels if invalid
00228     const int           numCustomChannels()         const   { return m_numCustomChannels; }
00229     const Interface_ID* customChannels()            const   { return m_customChannels; }
00230 
00231     // access to class members
00232     DWORD&          _readFlag()                 { return m_readFlag; }
00233     DWORD&          _writeFlag()                { return m_writeFlag; }
00234     bool&           _numSRChannelsValid()       { return m_numSRChannelsValid; }
00235     bool&           _numSWChannelsValid()       { return m_numSWChannelsValid; }
00236     int&            _numStandardReadChannels()  { return m_numStandardReadChannels; }
00237     int&            _numStandardWriteChannels() { return m_numStandardWriteChannels; }
00238     int&            _numCustomChannels()        { return m_numCustomChannels; }
00239     Interface_ID*&  _customChannels()           { return m_customChannels; }
00240 
00241 
00242 protected:
00243 
00244     DWORD m_readFlag, m_writeFlag;
00245     mutable bool m_numSRChannelsValid, m_numSWChannelsValid;
00246     mutable int m_numStandardReadChannels, m_numStandardWriteChannels;
00247     int m_numCustomChannels;
00248     Interface_ID *m_customChannels;
00249     const static DWORD kChannelsCast;
00250     const static int kNumStandardParticleChannels;
00251     const static ParticleChannelMask kNull; // empty mask
00252 };
00253