PageRenderTime 43ms CodeModel.GetById 15ms RepoModel.GetById 1ms app.codeStats 0ms

/CS/migrated/branches/R0_94/apps/demo/demoseq.cpp

#
C++ | 701 lines | 594 code | 51 blank | 56 comment | 94 complexity | ef3207a8baf6bcdc742028c9f50da8a7 MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.1, LGPL-2.0
  1. /*
  2. Copyright (C) 2001 by Jorrit Tyberghein
  3. This library is free software; you can redistribute it and/or
  4. modify it under the terms of the GNU Library General Public
  5. License as published by the Free Software Foundation; either
  6. version 2 of the License, or (at your option) any later version.
  7. This library is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  10. Library General Public License for more details.
  11. You should have received a copy of the GNU Library General Public
  12. License along with this library; if not, write to the Free
  13. Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  14. */
  15. #include "cssysdef.h"
  16. #include "demo.h"
  17. #include "demoseq.h"
  18. #include "demoop.h"
  19. #include "demoldr.h"
  20. #include "ivideo/graph3d.h"
  21. #include "ivideo/graph2d.h"
  22. #include "ivideo/txtmgr.h"
  23. #include "ivaria/conout.h"
  24. #include "ivaria/view.h"
  25. #include "iengine/engine.h"
  26. #include "iengine/sector.h"
  27. #include "iengine/light.h"
  28. #include "iengine/camera.h"
  29. #include "iengine/mesh.h"
  30. #include "iengine/movable.h"
  31. #include "imesh/thing/polygon.h"
  32. #include "imesh/thing/thing.h"
  33. #include "imesh/object.h"
  34. #include "imesh/particle.h"
  35. #include "ivaria/reporter.h"
  36. #include "iutil/eventh.h"
  37. #include "iutil/comp.h"
  38. #include "iutil/objreg.h"
  39. #include "csutil/cscolor.h"
  40. #include "csgeom/path.h"
  41. #include "cstool/csfxscr.h"
  42. #include "iutil/plugin.h"
  43. //-----------------------------------------------------------------------------
  44. Demo* DemoSequenceManager::demo;
  45. DemoSequenceManager* DemoSequenceManager::demoseq;
  46. DemoSequenceManager::DemoSequenceManager (Demo* demo)
  47. {
  48. DemoSequenceManager::demo = demo;
  49. demoseq = this;
  50. iObjectRegistry* object_reg = demo->object_reg;
  51. iPluginManager* plugin_mgr = CS_QUERY_REGISTRY (object_reg, iPluginManager);
  52. seqmgr = CS_LOAD_PLUGIN (plugin_mgr, "crystalspace.utilities.sequence",
  53. iSequenceManager);
  54. plugin_mgr->DecRef ();
  55. if (!seqmgr)
  56. {
  57. demo->Report (CS_REPORTER_SEVERITY_ERROR,
  58. "Could not load sequence manager plugin!");
  59. exit (0);
  60. }
  61. do_fade = false;
  62. fade_value = 0;
  63. suspended = true;
  64. suspend_one_frame = false;
  65. main_sequence = NULL;
  66. }
  67. DemoSequenceManager::~DemoSequenceManager ()
  68. {
  69. Clear ();
  70. int i;
  71. for (i = 0 ; i < paths.Length () ; i++)
  72. {
  73. csNamedPath* np = (csNamedPath*)paths[i];
  74. delete np;
  75. }
  76. paths.DeleteAll ();
  77. if (seqmgr) seqmgr->DecRef ();
  78. if (main_sequence) main_sequence->DecRef ();
  79. }
  80. void DemoSequenceManager::Clear ()
  81. {
  82. seqmgr->Clear ();
  83. int i;
  84. for (i = 0 ; i < pathForMesh.Length () ; i++)
  85. {
  86. PathForMesh* pfm = (PathForMesh*)pathForMesh[i];
  87. delete pfm;
  88. }
  89. pathForMesh.DeleteAll ();
  90. for (i = 0 ; i < meshRotation.Length () ; i++)
  91. {
  92. MeshRotation* mrot = (MeshRotation*)meshRotation[i];
  93. if (mrot->particle) mrot->particle->DecRef ();
  94. delete mrot;
  95. }
  96. meshRotation.DeleteAll ();
  97. }
  98. void DemoSequenceManager::Setup (const char* sequenceFileName)
  99. {
  100. if (main_sequence) main_sequence->DecRef ();
  101. DemoSequenceLoader* loader = new DemoSequenceLoader (
  102. DemoSequenceManager::demo, this, seqmgr, sequenceFileName);
  103. main_sequence = loader->GetSequence ("main");
  104. main_sequence->IncRef ();
  105. seqmgr->RunSequence (0, main_sequence);
  106. seqmgr->Resume ();
  107. suspended = false;
  108. main_start_time = seqmgr->GetMainTime ();
  109. num_frames = 0;
  110. delete loader;
  111. }
  112. void DemoSequenceManager::Suspend ()
  113. {
  114. if (!suspended)
  115. {
  116. suspended = true;
  117. seqmgr->Suspend ();
  118. }
  119. }
  120. void DemoSequenceManager::Resume ()
  121. {
  122. if (suspended)
  123. {
  124. suspended = false;
  125. seqmgr->Resume ();
  126. }
  127. }
  128. void DemoSequenceManager::Restart (const char* sequenceFileName)
  129. {
  130. Clear ();
  131. int i;
  132. for (i = 0 ; i < paths.Length () ; i++)
  133. {
  134. csNamedPath* np = (csNamedPath*)paths[i];
  135. delete np;
  136. }
  137. paths.DeleteAll ();
  138. if (main_sequence) { main_sequence->DecRef (); main_sequence = NULL; }
  139. do_fade = false;
  140. fade_value = 0;
  141. suspended = true;
  142. suspend_one_frame = false;
  143. Setup (sequenceFileName);
  144. }
  145. void DemoSequenceManager::TimeWarp (csTicks dt, bool restart)
  146. {
  147. // Temporarily resume everything to make sure our data is ok.
  148. bool sus = suspended;
  149. Resume ();
  150. // If we were suspended we say to the sequence manager to
  151. // suspend after one frame again. But we will have to go on
  152. // one frame to update the screen.
  153. if (sus) suspend_one_frame = true;
  154. if (seqmgr->GetMainTime () + dt <= main_start_time)
  155. {
  156. Clear ();
  157. seqmgr->RunSequence (0, main_sequence);
  158. main_start_time = seqmgr->GetMainTime ();
  159. num_frames = 0;
  160. return;
  161. }
  162. if (restart)
  163. {
  164. dt = seqmgr->GetMainTime () + dt - main_start_time;
  165. Clear ();
  166. seqmgr->RunSequence (0, main_sequence);
  167. main_start_time = seqmgr->GetMainTime ();
  168. num_frames = 0;
  169. seqmgr->TimeWarp (dt, false);
  170. return;
  171. }
  172. seqmgr->TimeWarp (dt, false);
  173. if (seqmgr->IsEmpty ())
  174. {
  175. // If the sequence manager is empty we insert the main sequence
  176. // again.
  177. seqmgr->RunSequence (0, main_sequence);
  178. }
  179. }
  180. void DemoSequenceManager::Draw3DEffects (iGraphics3D* g3d)
  181. {
  182. num_frames++;
  183. csTicks current_time = seqmgr->GetMainTime ();
  184. if (!suspended)
  185. {
  186. if (do_fade)
  187. {
  188. float r = float (current_time - start_fade_time)
  189. / float (total_fade_time);
  190. if (r >= 1)
  191. {
  192. r = 1;
  193. do_fade = false;
  194. }
  195. fade_value = start_fade * (1-r) + end_fade * r;
  196. if (fade_value < 0) fade_value = 0;
  197. if (fade_value > 1) fade_value = 1;
  198. }
  199. }
  200. if (fade_value > .001) csfxFadeOut (g3d, fade_value);
  201. }
  202. void DemoSequenceManager::Draw2DEffects (iGraphics2D* /*g2d*/)
  203. {
  204. }
  205. void DemoSequenceManager::SetupFade (float start_fade, float end_fade,
  206. csTicks total_fade_time, csTicks already_elapsed)
  207. {
  208. DemoSequenceManager::start_fade = start_fade;
  209. DemoSequenceManager::end_fade = end_fade;
  210. DemoSequenceManager::total_fade_time = total_fade_time;
  211. start_fade_time = seqmgr->GetMainTime ()-already_elapsed;
  212. if (already_elapsed >= total_fade_time)
  213. {
  214. // The fading is already done so we just set the fade
  215. // result to the final value.
  216. fade_value = end_fade;
  217. do_fade = false;
  218. }
  219. else
  220. {
  221. do_fade = true;
  222. }
  223. }
  224. void DemoSequenceManager::ReplacePathObject (csNamedPath* path,
  225. iMeshWrapper* mesh)
  226. {
  227. int i;
  228. for (i = 0 ; i < pathForMesh.Length () ; i++)
  229. {
  230. PathForMesh* pfm = (PathForMesh*)pathForMesh[i];
  231. if (pfm->path == path)
  232. {
  233. pfm->mesh = mesh;
  234. return;
  235. }
  236. }
  237. }
  238. void DemoSequenceManager::SetupPath (csNamedPath* path,
  239. iMeshWrapper* mesh,
  240. csTicks total_path_time,
  241. csTicks already_elapsed)
  242. {
  243. PathForMesh* pfm = new PathForMesh ();
  244. pfm->path = path;
  245. pfm->mesh = mesh;
  246. pfm->total_path_time = total_path_time;
  247. pfm->start_path_time = seqmgr->GetMainTime ()-already_elapsed;
  248. pathForMesh.Push (pfm);
  249. }
  250. void DemoSequenceManager::ControlPaths (iCamera* camera, csTicks elapsed_time)
  251. {
  252. if (suspended) return;
  253. csTicks current_time = seqmgr->GetMainTime ();
  254. int i = 0;
  255. int len = pathForMesh.Length ();
  256. while (i < len)
  257. {
  258. PathForMesh* pfm = (PathForMesh*)pathForMesh[i];
  259. float r = float (current_time - pfm->start_path_time)
  260. / float (pfm->total_path_time);
  261. bool do_path = true;
  262. if (r >= 1)
  263. {
  264. r = 1;
  265. do_path = false;
  266. }
  267. pfm->path->Calculate (r);
  268. csVector3 oldpos;
  269. iSector* oldsector;
  270. csVector3 pos, up, forward;
  271. if (pfm->mesh)
  272. {
  273. iMovable* movable = pfm->mesh->GetMovable ();
  274. oldpos = movable->GetPosition ();
  275. oldsector = movable->GetSectors ()->Get (0);
  276. }
  277. else
  278. {
  279. oldpos = camera->GetTransform ().GetOrigin ();
  280. oldsector = camera->GetSector ();
  281. }
  282. pfm->path->GetInterpolatedPosition (pos);
  283. pfm->path->GetInterpolatedUp (up);
  284. pfm->path->GetInterpolatedForward (forward);
  285. // See if we have to go to another sector when going through a
  286. // portal.
  287. csReversibleTransform trans;
  288. trans.SetOrigin (oldpos);
  289. bool mirror = false;
  290. iSector* newsector = oldsector->FollowSegment (trans,
  291. pos, mirror, true);
  292. if (pfm->mesh)
  293. {
  294. iMovable* movable = pfm->mesh->GetMovable ();
  295. movable->SetPosition (pos);
  296. if (oldsector != newsector)
  297. movable->SetSector (newsector);
  298. movable->GetTransform ().LookAt (forward.Unit (), up.Unit ());
  299. movable->UpdateMove ();
  300. pfm->mesh->DeferUpdateLighting (CS_NLIGHT_STATIC|CS_NLIGHT_DYNAMIC, 10);
  301. }
  302. else
  303. {
  304. if (oldsector != newsector)
  305. camera->SetSector (newsector);
  306. camera->GetTransform ().SetOrigin (pos);
  307. camera->GetTransform ().LookAt (forward.Unit (), up.Unit ());
  308. }
  309. if (!do_path)
  310. {
  311. delete pfm;
  312. pathForMesh.Delete (i);
  313. len--;
  314. }
  315. else i++;
  316. }
  317. i = 0;
  318. len = meshRotation.Length ();
  319. while (i < len)
  320. {
  321. MeshRotation* mrot = (MeshRotation*)meshRotation[i];
  322. if (current_time > mrot->start_time + mrot->total_time)
  323. {
  324. if (mrot->particle) mrot->particle->DecRef ();
  325. delete mrot;
  326. meshRotation.Delete (i);
  327. len--;
  328. }
  329. else
  330. {
  331. mrot->particle->Rotate (mrot->angle_speed * float (elapsed_time/1000.));
  332. i++;
  333. }
  334. }
  335. if (suspend_one_frame) { Suspend (); suspend_one_frame = false; }
  336. }
  337. void DemoSequenceManager::DebugPositionObjects (iCamera* camera,
  338. csTicks debug_time)
  339. {
  340. int i = 0;
  341. int len = pathForMesh.Length ();
  342. while (i < len)
  343. {
  344. PathForMesh* pfm = (PathForMesh*)pathForMesh[i];
  345. float r = float (debug_time - pfm->start_path_time)
  346. / float (pfm->total_path_time);
  347. if (r >= 0 && r <= 1)
  348. {
  349. pfm->path->Calculate (r);
  350. csVector3 pos, up, forward;
  351. pfm->path->GetInterpolatedPosition (pos);
  352. pfm->path->GetInterpolatedUp (up);
  353. pfm->path->GetInterpolatedForward (forward);
  354. if (pfm->mesh)
  355. {
  356. iMovable* movable = pfm->mesh->GetMovable ();
  357. movable->SetPosition (pos);
  358. movable->GetTransform ().LookAt (forward.Unit (), up.Unit ());
  359. movable->UpdateMove ();
  360. pfm->mesh->DeferUpdateLighting (CS_NLIGHT_STATIC|CS_NLIGHT_DYNAMIC, 10);
  361. }
  362. else
  363. {
  364. camera->GetTransform ().SetOrigin (pos);
  365. camera->GetTransform ().LookAt (forward.Unit (), up.Unit ());
  366. }
  367. }
  368. i++;
  369. }
  370. }
  371. void DemoSequenceManager::DebugDrawPath (csNamedPath* np, bool hi,
  372. const csVector2& tl, const csVector2& br, int selpoint)
  373. {
  374. int dim = demo->myG2D->GetHeight ()-10;
  375. int col = demo->col_gray;
  376. if (hi) col = demo->col_white;
  377. float r;
  378. csVector3 p;
  379. for (r = 0 ; r <= 1 ; r += 0.001f)
  380. {
  381. np->Calculate (r);
  382. np->GetInterpolatedPosition (p);
  383. int x = int ((p.x-tl.x)*dim / (br.x-tl.x));
  384. int y = int ((p.z-tl.y)*dim / (br.y-tl.y));
  385. if (x > 0 && x < dim && y > 0 && y < dim)
  386. demo->myG2D->DrawPixel (x, y, col);
  387. }
  388. float* px, * py, * pz;
  389. px = np->GetDimensionValues (0);
  390. py = np->GetDimensionValues (1);
  391. pz = np->GetDimensionValues (2);
  392. float* fx, * fy, * fz;
  393. fx = np->GetDimensionValues (6);
  394. fy = np->GetDimensionValues (7);
  395. fz = np->GetDimensionValues (8);
  396. int j;
  397. for (j = 0 ; j < np->GetPointCount () ; j++)
  398. {
  399. int col = demo->col_red;
  400. if (hi && selpoint == j) col = demo->col_green;
  401. int x = int ((px[j]-tl.x)*dim/(br.x-tl.x));
  402. int y = int ((pz[j]-tl.y)*dim/(br.y-tl.y));
  403. if (x > 0 && x < dim && y > 0 && y < dim)
  404. {
  405. demo->myG2D->DrawPixel (x, y, col);
  406. demo->myG2D->DrawPixel (x-1, y, col);
  407. demo->myG2D->DrawPixel (x+1, y, col);
  408. demo->myG2D->DrawPixel (x, y-1, col);
  409. demo->myG2D->DrawPixel (x, y+1, col);
  410. if (hi && selpoint == j)
  411. {
  412. csVector3 forward (fx[j], fy[j], fz[j]);
  413. forward.Normalize ();
  414. forward *= 20.;
  415. demo->myG2D->DrawLine (x, y, int (x+forward.x), int (y-forward.z),
  416. demo->col_cyan);
  417. }
  418. }
  419. }
  420. }
  421. void DemoSequenceManager::DrawSelPoint (
  422. const csVector3& pos, const csVector3& forward,
  423. const csVector2& tl, const csVector2& br,
  424. int dim, int col, float fwlen)
  425. {
  426. int x = int ((pos.x-tl.x)*dim/(br.x-tl.x));
  427. int y = int ((pos.z-tl.y)*dim/(br.y-tl.y));
  428. if (x > 0 && x < dim && y > 0 && y < dim)
  429. {
  430. demo->myG2D->DrawPixel (x, y, col);
  431. demo->myG2D->DrawPixel (x-1, y-1, col);
  432. demo->myG2D->DrawPixel (x-2, y-2, col);
  433. demo->myG2D->DrawPixel (x+1, y+1, col);
  434. demo->myG2D->DrawPixel (x+2, y+2, col);
  435. demo->myG2D->DrawPixel (x+1, y-1, col);
  436. demo->myG2D->DrawPixel (x+2, y-2, col);
  437. demo->myG2D->DrawPixel (x-1, y+1, col);
  438. demo->myG2D->DrawPixel (x-2, y+2, col);
  439. csVector3 f = forward;
  440. f.Normalize ();
  441. f *= fwlen;
  442. demo->myG2D->DrawLine (x, y, int (x+f.x), int (y-f.z), col);
  443. }
  444. }
  445. void DemoSequenceManager::DebugDrawPaths (iCamera* camera,
  446. const char* hilight, const csVector2& tl, const csVector2& br,
  447. int selpoint)
  448. {
  449. int i;
  450. int len = pathForMesh.Length ();
  451. csTicks current_time = seqmgr->GetMainTime ();
  452. //=====
  453. // Draw the border around the map.
  454. //=====
  455. int dim = demo->myG2D->GetHeight ()-10;
  456. demo->myG2D->DrawLine (0, 0, dim, 0, demo->col_cyan);
  457. demo->myG2D->DrawLine (0, dim, dim, dim, demo->col_cyan);
  458. demo->myG2D->DrawLine (0, 0, 0, dim, demo->col_cyan);
  459. demo->myG2D->DrawLine (dim, 0, dim, dim, demo->col_cyan);
  460. //=====
  461. // Draw the current camera.
  462. //=====
  463. csVector3 campos = camera->GetTransform ().GetOrigin ();
  464. csVector3 camfwd = camera->GetTransform ().This2Other (csVector3 (0, 0, 1)) -
  465. campos;
  466. DrawSelPoint (campos, camfwd, tl, br, dim, demo->col_green, 20);
  467. //=====
  468. // Get the current selected path.
  469. //=====
  470. csTicks start = 0, total = 0, seltime = 0;
  471. csNamedPath* selnp = NULL;
  472. if (hilight) selnp = GetSelectedPath (hilight, start, total);
  473. if (selnp)
  474. {
  475. // Calculate where we are in time on the selected path.
  476. float t = selnp->GetTimeValue (selpoint);
  477. seltime = csTicks (start + total*t);
  478. }
  479. //=====
  480. // Draw all active paths.
  481. //=====
  482. i = 0;
  483. while (i < len)
  484. {
  485. PathForMesh* pfm = (PathForMesh*)pathForMesh[i];
  486. bool hi = (pfm->path == selnp);
  487. DebugDrawPath (pfm->path, hi, tl, br, selpoint);
  488. i++;
  489. }
  490. //=====
  491. // Indicate the current camera point on all paths.
  492. // In addition also indicate points on the other paths
  493. // which correspond with the current selected point on the selected path.
  494. //=====
  495. i = 0;
  496. while (i < len)
  497. {
  498. PathForMesh* pfm = (PathForMesh*)pathForMesh[i];
  499. bool hi = (pfm->path == selnp);
  500. // Fetch the current time.
  501. csTicks ct = current_time;
  502. // Calculate where we are on this path at the moment.
  503. // r should be between 0 and 1.
  504. float r = float (ct - pfm->start_path_time)
  505. / float (pfm->total_path_time);
  506. if (r >= 1) r = 1;
  507. pfm->path->Calculate (r);
  508. // We are going to show both the position as the forward vector.
  509. csVector3 pos, forward;
  510. pfm->path->GetInterpolatedPosition (pos);
  511. pfm->path->GetInterpolatedForward (forward);
  512. DrawSelPoint (pos, forward, tl, br, dim, demo->col_yellow, 20);
  513. // If there is a hilighted path and we are not busy drawing the hilighted
  514. // path then we will draw an additional point on this path to indicate
  515. // where this path will be when the selected path is at the selected point.
  516. if (!hi && selnp)
  517. {
  518. r = float (seltime - pfm->start_path_time)
  519. / float (pfm->total_path_time);
  520. if (r >= 0 && r <= 1)
  521. {
  522. pfm->path->Calculate (r);
  523. pfm->path->GetInterpolatedPosition (pos);
  524. pfm->path->GetInterpolatedForward (forward);
  525. DrawSelPoint (pos, forward, tl, br, dim, demo->col_cyan, 10);
  526. }
  527. }
  528. i++;
  529. }
  530. }
  531. void DemoSequenceManager::SelectFirstPath (char* hilight)
  532. {
  533. if (pathForMesh.Length () > 0)
  534. {
  535. strcpy (hilight, ((PathForMesh*)pathForMesh[0])->path->GetName ());
  536. }
  537. }
  538. void DemoSequenceManager::SelectLastPath (char* hilight)
  539. {
  540. if (pathForMesh.Length () > 0)
  541. {
  542. strcpy (hilight, ((PathForMesh*)pathForMesh[
  543. pathForMesh.Length ()-1])->path->GetName ());
  544. }
  545. }
  546. void DemoSequenceManager::SelectPreviousPath (char* hilight)
  547. {
  548. csNamedPath* np = GetSelectedPath (hilight);
  549. if (!np)
  550. {
  551. SelectLastPath (hilight);
  552. return;
  553. }
  554. int i;
  555. for (i = 0 ; i < pathForMesh.Length () ; i++)
  556. {
  557. PathForMesh* pfm = (PathForMesh*)pathForMesh[i];
  558. if (pfm->path == np)
  559. {
  560. if (i == 0)
  561. return;
  562. else
  563. {
  564. pfm = (PathForMesh*)pathForMesh[i-1];
  565. strcpy (hilight, pfm->path->GetName ());
  566. }
  567. return;
  568. }
  569. }
  570. // We can't find the path. Switch back to last path.
  571. SelectLastPath (hilight);
  572. return;
  573. }
  574. void DemoSequenceManager::SelectNextPath (char* hilight)
  575. {
  576. csNamedPath* np = GetSelectedPath (hilight);
  577. if (!np)
  578. {
  579. SelectFirstPath (hilight);
  580. return;
  581. }
  582. int i;
  583. for (i = 0 ; i < pathForMesh.Length () ; i++)
  584. {
  585. PathForMesh* pfm = (PathForMesh*)pathForMesh[i];
  586. if (pfm->path == np)
  587. {
  588. if (i < pathForMesh.Length ()-1)
  589. {
  590. pfm = (PathForMesh*)pathForMesh[i+1];
  591. strcpy (hilight, pfm->path->GetName ());
  592. }
  593. return;
  594. }
  595. }
  596. // We can't find the path. Switch back to first path.
  597. SelectFirstPath (hilight);
  598. return;
  599. }
  600. csNamedPath* DemoSequenceManager::GetSelectedPath (const char* hilight)
  601. {
  602. csTicks s, t;
  603. return GetSelectedPath (hilight, s, t);
  604. }
  605. csNamedPath* DemoSequenceManager::GetSelectedPath (const char* hilight,
  606. csTicks& start, csTicks& total)
  607. {
  608. int i = 0;
  609. int len = pathForMesh.Length ();
  610. while (i < len)
  611. {
  612. PathForMesh* pfm = (PathForMesh*)pathForMesh[i];
  613. csNamedPath* np = pfm->path;
  614. bool hi = (hilight && !strcmp (np->GetName (), hilight));
  615. if (hi)
  616. {
  617. start = pfm->start_path_time;
  618. total = pfm->total_path_time;
  619. return np;
  620. }
  621. i++;
  622. }
  623. return NULL;
  624. }
  625. void DemoSequenceManager::SetupRotatePart (iMeshWrapper* mesh,
  626. float angle_speed, csTicks total_rotate_time, csTicks already_elapsed)
  627. {
  628. MeshRotation* mrot = new MeshRotation ();
  629. mrot->particle = SCF_QUERY_INTERFACE (mesh->GetMeshObject (), iParticle);
  630. if (!mrot->particle)
  631. {
  632. delete mrot;
  633. return;
  634. }
  635. mrot->mesh = mesh;
  636. mrot->total_time = total_rotate_time;
  637. mrot->start_time = seqmgr->GetMainTime ()-already_elapsed;
  638. mrot->angle_speed = angle_speed;
  639. meshRotation.Push (mrot);
  640. }
  641. float DemoSequenceManager::GetFPS ()
  642. {
  643. csTicks cur_time = seqmgr->GetMainTime ();
  644. csTicks dt = cur_time-main_start_time;
  645. return (float (num_frames) / float (dt)) * 1000.0f;
  646. }
  647. //-----------------------------------------------------------------------------