PFSimpleAction.h

Go to the documentation of this file.
00001 
00010 /**********************************************************************
00011  *<
00012     CREATED BY: Oleg Bayborodin
00013 
00014     HISTORY: created 05-28-02
00015 
00016  *> Copyright (c) 2001, All Rights Reserved.
00017  **********************************************************************/
00018 
00019 #pragma once
00020 
00021 #include "PFExport.h"
00022 #include "IPFAction.h"
00023 #include "IPViewItem.h"
00024 #include "IPFIntegrator.h"
00025 #include "IPFSystem.h"
00026 #include "OneClickCreateCallBack.h"
00027 #include "PFClassIDs.h"
00028 #include "IPViewManager.h"
00029 #include "RandObjLinker.h"
00030 #include "..\iparamb2.h"
00031 
00032 class PFSimpleAction:   public HelperObject,
00033                         public IPFAction,
00034                         public IPViewItem
00035 {
00036 public:
00037     PFExport virtual ~PFSimpleAction();
00038 
00039     // From InterfaceServer
00040     PFExport virtual BaseInterface* GetInterface(Interface_ID id);
00041 
00042     // From Animatable
00043     PFExport virtual void DeleteThis();
00044     virtual int NumSubs() { return 1; } // the paramBlock
00045     PFExport virtual Animatable* SubAnim(int i);
00046     PFExport virtual MSTR SubAnimName(int i);
00047     PFExport BOOL SelectSubAnim(int subNum);
00048     PFExport virtual ParamDimension* GetParamDimension(int i);
00049     PFExport virtual int SubNumToRefNum(int subNum);
00050     virtual BOOL CanCopyAnim() { return FALSE; }
00051     PFExport virtual int HasSubElements(int type);
00052     #pragma warning(push)
00053     #pragma warning(disable:4100)
00054     virtual BOOL CanDeleteSubAnim(int i) { return FALSE; }
00055     virtual BOOL IsAnimated() { return _pblock()->IsAnimated(); }
00056     virtual void FreeCaches() { ; }
00057     virtual int NumParamBlocks() { return 1; } // the paramBlock
00058     PFExport virtual IParamBlock2* GetParamBlock(int i);
00059     PFExport virtual IParamBlock2* GetParamBlockByID(short id);
00060 
00061     // From ReferenceMaker
00062     virtual int NumRefs() { return 1; }
00063     PFExport virtual RefTargetHandle GetReference(int i);
00064 protected:
00065     PFExport virtual void SetReference(int i, RefTargetHandle rtarg);
00066 public:
00067     PFExport virtual RefResult NotifyRefChanged(Interval changeInt,RefTargetHandle hTarget,PartID& partID, RefMessage message);
00068     PFExport virtual int RemapRefOnLoad(int iref);
00069     PFExport virtual IOResult Save(ISave *isave);
00070     PFExport virtual IOResult Load(ILoad *iload);
00071 
00072     // From BaseObject
00073     virtual CreateMouseCallBack* GetCreateMouseCallBack() { return OneClickCreateCallBack::Instance(); }
00074     virtual BOOL OKToChangeTopology(MSTR &modName) { return FALSE; }
00075 
00076     // From Object
00077     virtual void InitNodeName(MSTR& s) { s = GetObjectName(); }
00078     virtual ObjectState Eval(TimeValue t) { return ObjectState(this); }
00079 
00080     // --- These methods MUST be implemented by the derived class --- //
00081     // --- These methods have a default virtual implementation to --- //
00082     // --- ease PFExport implementation of Clone(...) method     --- //
00083 
00084     // constructor: inherited as a base class constructor
00085     PFSimpleAction()
00086     {
00087         _pblock() = NULL;
00088         RegisterParticleFlowNotification();
00089     }
00090     // implement it like this
00091     //  {
00092     //      GetClassDesc()->MakeAutoParamBlocks(this);
00093     //  }
00094     //
00095 
00096     // From Animatable
00097     virtual void GetClassName(MSTR& s) { ; }
00098     virtual Class_ID ClassID() { return Class_ID(0,0); }
00099     virtual void BeginEditParams(IObjParam *ip,ULONG flags,Animatable *prev) = 0;
00100     // implement it like this
00101     //  {
00102     //      GetClassDesc()->BeginEditParams(ip, this, flags, prev);
00103     //  }
00104     virtual void EndEditParams(IObjParam *ip,   ULONG flags,Animatable *next) = 0;
00105     //  {
00106     //      GetClassDesc()->EndEditParams(ip, this, flags, next );
00107     //  }
00108 
00109     // From ReferenceTarget
00110     virtual RefTargetHandle Clone(RemapDir &remap) = 0;
00111     // implement it like this
00112     //  {
00113     //      PFOperatorXXX* newOp = new PFOperatorXXX();
00114     //      newOp->ReplaceReference(0, remap.CloneRef(pblock()));
00115     //      BaseClone(this, newOp, remap);
00116     //      return newOp;
00117     //  }
00118 
00119     // From BaseObject
00120     virtual MCHAR *GetObjectName() = 0;
00121 
00122     // From IPFAction interface
00123     PFExport virtual bool   Init(IObject* pCont, Object* pSystem, INode* node, Tab<Object*>& actions, Tab<INode*>& actionNodes);
00124     PFExport virtual bool   Release(IObject* pCont);
00125 
00126     // SimpleOperator doesn't support randomness
00127     // If you need randomness for the operator please override
00128     // the following four methods
00129     virtual bool    SupportRand() const { return false; }
00130     virtual int     GetRand()           { return 0; }
00131     virtual void    SetRand(int seed)   { ; }
00132     #pragma warning(pop)
00133     PFExport virtual int NewRand();
00134 
00135     virtual const ParticleChannelMask& ChannelsUsed(const Interval& time) const = 0;
00136     virtual const Interval ActivityInterval() const = 0;
00137 
00138     PFExport virtual IObject* GetCurrentState(IObject* pContainer);
00139     PFExport virtual void SetCurrentState(IObject* actionState, IObject* pContainer);
00140 
00141     // From IPViewItem interface
00142     virtual int NumPViewParamBlocks() const { return 1; } // the paramBlock
00143     PFExport virtual IParamBlock2* GetPViewParamBlock(int i) const;
00144 
00145     // supply ClassDesc descriptor for the concrete implementation of the operator
00146     virtual ClassDesc* GetClassDesc() const = 0;
00147 
00148 public:
00149         PFExport void RefreshUI(WPARAM message, IParamMap2* map=NULL) const;
00150         PFExport void UpdatePViewUI(ParamID updateID) const;
00151 
00152         // const access to class members
00153         IParamBlock2*           pblock()        const   { return m_pblock; }
00154         const RandObjLinker&    randLinker()    const   { return m_randLinker; }
00155 
00156         // access to class members
00157         IParamBlock2*&  _pblock()           { return m_pblock; }
00158         RandObjLinker&  _randLinker()       { return m_randLinker; }
00159 
00160 protected:
00161         // parameters
00162         IParamBlock2*   m_pblock;
00163 
00164         // to keep track of client particle systems
00165         // the test may serve several particle systems at once
00166         // each particle system has its own randomization scheme
00167         RandObjLinker   m_randLinker;
00168 };
00169