00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #pragma once
00015
00016 #include "..\maxheap.h"
00017 #include "BipExp.h"
00018 #include "keytrack.h"
00019 #include "CSConstants.h"
00020 #include "..\assetmanagement\AssetUser.h"
00021 #include "..\point2.h"
00022 #include "..\ipoint2.h"
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096 class Snippet;
00097 class MoFlow;
00098
00099 class BipMaster;
00100 class Transition;
00101 class MFL_IOProcessor;
00102 class animal;
00103 class Layer;
00104 class path_properties;
00105 class crowd_script;
00106
00107
00108 class TranInfo: public MaxHeapOperators {
00109
00110 public:
00111
00112 int start1,start2,length;
00113 int rolling1,rolling2,randpct;
00114 int transFocus;
00115 float angle,easein,easeout,cost;
00116 float flow_angle;
00117 path_properties prop;
00118 MCHAR note[MAXTRANNOTE];
00119
00120 BIPExport TranInfo();
00121 BIPExport TranInfo& operator=(const TranInfo& TI);
00122 BIPExport int operator==(const TranInfo& TI);
00123
00124
00125 void Output(MFL_IOProcessor *IOProc);
00126 void Input(MFL_IOProcessor *IOProc);
00127
00128 inline int GetSourceStart() const { return start1; }
00129 inline void SetSourceStart(int s) { start1 = s; }
00130 inline int GetDestStart() const { return start2; }
00131 inline void SetDestStart(int s) { start2 = s; }
00132 inline int GetSourceState() const { return rolling1; }
00133 inline void SetSourceState(int s) { rolling1 = s; }
00134 inline int GetDestState() const { return rolling2; }
00135 inline void SetDestState(int s) { rolling2 = s; }
00136 inline int GetLength() const { return length; }
00137 inline void SetLength(int l) { length = l; }
00138 inline float GetAngle() const { return angle; }
00139 inline void SetAngle(float a) { angle = a; }
00140 inline int GetRandPercent() const { return randpct; }
00141 inline void SetRandPercent(float r) { randpct = (int)r; }
00142 inline float GetCost() const { return cost; }
00143 inline void SetCost(float c) { cost = c; }
00144 inline float GetEaseIn() const { return easein; }
00145 inline void SetEaseIn(float in) { easein = in; }
00146 inline float GetEaseOut() const { return easeout; }
00147 inline void SetEaseOut(float out) { easeout = out; }
00148 inline int GetTransFocus() const { return transFocus; }
00149 inline void SetTransFocus(int t) { transFocus = t; }
00150 inline const MCHAR* GetNote() const { return note; }
00151 inline void SetNote(const MCHAR* n) { _tcscpy_s(note, MAXTRANNOTE, n); }
00152 };
00153
00154 class Transition: public MaxHeapOperators {
00155 public:
00156 Snippet *from;
00157 Snippet *to;
00158 int active;
00159 int selected;
00160 int start1,start2,length;
00161 int rolling1,rolling2;
00162 float easein,easeout;
00163 float angle;
00164 float flow_angle;
00165 int transFocus;
00166 path_properties prop;
00167 int randpct;
00168 float cost;
00169 int index;
00170 int nTransInfo;
00171 int maxTransInfo;
00172 TranInfo *TranList;
00173 MCHAR note[MAXTRANNOTE];
00174 HWND hwnd;
00175
00176 BIPExport Transition();
00177 BIPExport ~Transition();
00178 BIPExport Transition& operator=(const Transition& T);
00179 BIPExport void SetTranListSize(int NUM);
00180 BIPExport void InfoToTransition(int i);
00181 BIPExport void TransitionToInfo(int i);
00182 BIPExport int NewTranInfo();
00183 BIPExport void ShiftTranInfo(int TIindex, int storecurrent);
00184 BIPExport void DeleteTranInfo(int TIindex);
00185 void Output(MFL_IOProcessor *IOProc);
00186 void Input(MFL_IOProcessor *IOProc);
00187
00188 inline int GetRandPercent() const { return randpct; }
00189 inline void SetRandPercent(float r) { randpct = (int)r; }
00190 inline float GetCost() const { return cost; }
00191 inline void SetCost(float c) { cost = c; }
00192
00193 inline int GetTranListSize() const { return nTransInfo; }
00194 inline Snippet* GetFromSnippet() const { return from; }
00195 inline void SetFromSnippet(Snippet* s) { from = s; }
00196
00197 inline Snippet* GetToSnippet() const { return to; }
00198 inline void SetToSnippet(Snippet* s){ to = s; }
00199
00200 inline BOOL GetActive() const { return active; }
00201 inline void SetActive(BOOL act) { active = act; }
00202
00203 inline BOOL GetSelected() const { return selected; }
00204 inline void SetSelected(BOOL sel) { selected = sel; }
00205
00206 inline TranInfo GetTranInfo(int TIindex) const
00207 { assert (TIindex < nTransInfo); return TranList[TIindex]; }
00208 inline void SetTranInfo(int TIindex, TranInfo ti) {
00209 assert (TIindex < nTransInfo);
00210 TranList[TIindex] = ti;
00211 if (index == TIindex ) InfoToTransition(index);
00212 }
00213
00214 BIPExport void UpdateUI(bool redraw=false);
00215 };
00216
00217 class Script;
00218
00219 class Snippet: public MaxHeapOperators {
00220 public:
00221 int visited;
00222 float distance_to_stop;
00223 float distance_to_loop;
00224 int start;
00225 int end;
00226 MCHAR sname[MAXNAME];
00227 MaxSDK::AssetManagement::AssetUser file;
00228 int posx;
00229 int posy;
00230 int width;
00231 int nTrans;
00232 int curtime;
00233 int active;
00234 int validload;
00235 BOOL randstart;
00236 int randstartpct;
00237 Transition *Transitions;
00238 HWND hwnd;
00239 int orgposx;
00240 int orgposy;
00241
00242 public:
00243 Snippet *next;
00244 animal *A;
00245
00246 BIPExport Snippet();
00247 BIPExport virtual ~Snippet();
00248 BIPExport void ClearActiveTransitions();
00249 BIPExport void ClearSelectedTransitions();
00250 BIPExport int ActivateTransitionTo(Snippet *toSN);
00251 BIPExport Transition *GetTransitionTo(Snippet *toSN);
00252 BIPExport int GetTransitionIndex(Transition *theTR);
00253 BIPExport float AddTransition(Snippet *child, int optimize);
00254 BIPExport float ComputeTransitionPoints(Transition *nTR, Snippet *Src , Snippet *Dest, int preference, int optimize);
00255 BIPExport float ComputeOptimalTransitionPoints(BOOL SearchAll,int PrefTranLen,int SearchBefore, int SearchAfter, Transition *nTR, Snippet *Src , Snippet *Dst);
00256 BIPExport void RecomputeTransitions();
00257 BIPExport int DeleteTransitionsTo(Snippet *child);
00258 BIPExport int DeleteTransition(int index);
00259 BIPExport void DeleteSelectedTransitions(MoFlow *MF);
00260 BIPExport int IsChild(Snippet *Child);
00261 void Paint(HDC hdc, int selected, int startnode, int editnode, int transhow);
00262 void PaintTransitions(HDC hdc, BOOL transhow);
00263 void ComputeWidth(HDC hdc, BOOL transhow);
00264 int Inside(POINT &mp, float *dist);
00265 BIPExport void UpdateUI();
00266 BIPExport Snippet& operator=(const Snippet& SN);
00267 Transition* TranHitTest(POINT &mp);
00268 void TranRegionSelect(POINT &min, POINT &max, int set, int active);
00269 void Output(MFL_IOProcessor *IOProc);
00270 void Input(MFL_IOProcessor *IOProc);
00271 BIPExport int LoadFile(bool UpdateTheUI = true, int ErrorType = 3);
00272 Snippet *GetNextRandScriptSnippet(int *transindex);
00273
00274
00276 Snippet * NextRealTime(BipMaster *mc, Script *scr, animal *A, int frame, path_properties *desired_properties, int global_frame, int global_last_clip_start, int currentScript_index, int *transindex, int *found);
00277
00278
00279
00280 inline int GetStart() const { return start; }
00281 inline void SetStart(int s) { start = s; }
00282 inline int GetEnd() const { return end; }
00283 inline void SetEnd(int e) { end = e; }
00284
00285 inline const MCHAR* GetClipName() const { return sname; }
00286 inline void SetClipName(const MCHAR* n) { _tcscpy_s(sname, MAXNAME, n); }
00287
00288 inline const MaxSDK::AssetManagement::AssetUser& GetFile() const { return file; }
00289 inline void SetFile(const MaxSDK::AssetManagement::AssetUser& assetUser) { file = assetUser; }
00290
00291 inline virtual IPoint2 GetPosition() const { return IPoint2(posx, posy); }
00292 inline virtual void SetPosition(IPoint2 p){ posx = p.x; posy = p.y; }
00293 inline BOOL GetActive() const { return active; }
00294 inline void SetActive(BOOL act) { active = act; }
00295
00296 inline BOOL GetRandStart() const { return randstart; }
00297 inline void SetRandStart(BOOL rs) { randstart = rs; }
00298 inline BOOL GetRandStartPercent() const { return randstartpct; }
00299 inline void SetRandStartPercent(int rsp){ randstartpct = rsp; }
00300
00301 inline int NumTransitions() { return nTrans; }
00302 inline Transition* GetTransition(int Tindex) const
00303 { assert (Tindex < nTrans); return &Transitions[Tindex]; }
00304 inline void SetTransition(int Tindex, Transition* ti)
00305 { assert (Tindex < nTrans); Transitions[Tindex] = *ti; }
00306 };
00307
00308
00309 class ScriptItem: public MaxHeapOperators {
00310 public:
00311 Snippet *snip;
00312 int transindex;
00313 vector flow_pos;
00314 vector2D flow_pivot;
00315 float flow_yaw;
00316 int glob_snipstart;
00317 MCHAR *tempSnipName;
00318
00319
00320 int foothold_frame[2];
00321 int footlift_frame[2];
00322
00323 inline Snippet* GetSnippet() { return snip; }
00324 inline void SetSnippet(Snippet* s) { snip = s; }
00325 inline int GetTransIndex() const { return transindex; }
00326 inline void SetTransIndex(int i) { transindex = i; }
00327 inline vector GetFlowPos() const { return flow_pos; }
00328 inline void SetFlowPos(vector p) { flow_pos = p; }
00329 inline vector2D GetFlowPivot() const { return flow_pivot; }
00330 inline void SetFlowPivot(vector2D p){ flow_pivot = p; }
00331 inline float GetFlowYaw() const { return flow_yaw; }
00332 inline void SetFlowYaw(float y) { flow_yaw = y; }
00333 inline int GetSnipStart() const { return glob_snipstart; }
00334 inline void SetSnipStart(int s) { glob_snipstart = s; }
00335
00336
00337 BIPExport ScriptItem();
00338 BIPExport ScriptItem& operator=(const ScriptItem& SI);
00339 };
00340
00341 class Script: public MaxHeapOperators {
00342 public:
00343 MCHAR name[MAXSCRIPTNAME];
00344 Point3 startpos;
00345 float startrot;
00346 int startframe;
00347 int nitems;
00348 int maxitems;
00349 ScriptItem *items;
00350 int nlayers;
00351 Layer *layers;
00352 Layer *EditLayer;
00353 Script *next;
00354
00355 BIPExport Script();
00356 BIPExport ~Script();
00357 BIPExport Script& operator=(const Script& P);
00358 BIPExport int AddSnippet(Snippet *SN);
00359 BIPExport int InsertSnippet(int index, Snippet *SN);
00360 BIPExport int DeleteSnippet(int index);
00361 BIPExport int Get_Backtrackframe();
00362 BIPExport int GetScriptItemIndex(ScriptItem *SI);
00363 BIPExport int InsertScriptItem(int index, ScriptItem *SI);
00364 BIPExport int GetLastTransitionIndex();
00365 Transition *GetLastTransition();
00366 inline int NumScriptItems() { return nitems; }
00367 inline ScriptItem* GetScriptItem(int ind)
00368 { assert (ind < nitems); return &items[ind]; }
00369 BIPExport int IncludesSnippet(Snippet *SN);
00370 BIPExport int IncludesTransition(Transition *TR);
00371 void Output(MFL_IOProcessor *IOProc);
00372 void Input(MFL_IOProcessor *IOProc, MoFlow *MF);
00373 inline int GetStartFrame() { return startframe; }
00374 inline void SetStartFrame(int f) { startframe = f; }
00375 BIPExport void Set_crowd_script(crowd_script *CS);
00376 inline Point3 GetStartPos() { return startpos; }
00377 inline void SetStartPos(Point3 p) { startpos = p;}
00378 inline float GetStartRot() { return startrot; }
00379 inline void SetStartRot(float r) { startrot = r;}
00380 inline const MCHAR* GetName() const { return name; }
00381 inline void SetName(const MCHAR* n) { _tcscpy_s(name, MAXSCRIPTNAME, n); }
00382
00383
00384 inline int NumLayers() { return nlayers; }
00385 inline Layer *GetEditLayer() { return EditLayer; }
00386 BIPExport Layer *GetLayer(int index);
00387 BIPExport int AddLayer(Script *SCR, TimeValue t);
00388 BIPExport void DeleteLayer(Layer *delLY);
00389 BIPExport void SortLayer(Layer *SORTLY);
00390 BIPExport int GetLayerIndex(Layer *LYR);
00391 BIPExport int InsertLayer(Layer *newLY);
00392 BIPExport void CloneLayer(Layer *orgLY,TimeValue t);
00393 BIPExport void DeleteAllLayers();
00394 };
00395
00396 class IBipMaster;
00397 class IMoFlow: public MaxHeapOperators
00398 {
00399 public:
00400 virtual ~IMoFlow() {;}
00401 virtual int NumScripts() const=0;
00402 virtual int NumSelected() const=0;
00403 virtual Script* GetScript(int index)=0;
00404 virtual Script* GetActiveScript()=0;
00405 virtual void SetActiveScript(Script* scr)=0;
00406 virtual int GetScriptIndex(Script *theSCR) const=0;
00407 virtual int AddScript(const MCHAR *newscriptname, bool activate=true)=0;
00408 virtual void DeleteScript(Script *delSCR)=0;
00409 virtual void DeleteScript(int ind)=0;
00410 virtual void DeleteAllScripts()=0;
00411
00412 virtual int NumSnippets() const=0;
00413 virtual const BitArray& GetSelected() const=0;
00414 virtual void SetSelected(const BitArray& sel)=0;
00415 virtual Snippet* GetSnip(int index)=0;
00416 virtual Snippet* GetSnip(const MCHAR *str)=0;
00417 virtual int GetIndex(Snippet *theSN) const=0;
00418 virtual int LoadSnippetFiles(bool UpdateTheUI = true, int ErrorType = 3, bool UpdateSNLengths=false)=0;
00419
00420 virtual int GetActiveStartFrame() const=0;
00421 virtual int GetActiveEndFrame() const=0;
00422 virtual int Save(const MCHAR *fname)=0;
00423 virtual int Load(const MCHAR *fname, bool Append=false, bool UpdateTheUI = true, int ErrorType = 3)=0;
00424 virtual IBipMaster* GetMaster()=0;
00425 virtual void ComputeAnimation(int redraw, int globalsToo = FALSE)=0;
00426
00427
00428
00429 virtual void CurscriptToActiveLinks() = 0;
00430
00431
00432 virtual Snippet* NewSnippet(const MCHAR *fname, POINT &mp, bool load=false, bool redraw=false)=0;
00433 virtual void DeleteSnip(Snippet *DelSnip)=0;
00434
00435 virtual void RedrawGraphWnd()=0;
00436 virtual void UpdateUI()=0;
00437 virtual void HoldTrack(int HoldAnimals, BOOL HoldScriptOffsetOnly = false)=0;
00438
00439 };
00440
00441 BIPExport void UpdateMotionFlowGraph();
00442
00443