flyCircleAnimator.cpp 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. // Copyright (C) 2008-2012 Colin MacDonald
  2. // No rights reserved: this software is in the public domain.
  3. #include "testUtils.h"
  4. using namespace irr;
  5. using namespace core;
  6. using namespace scene;
  7. using namespace video;
  8. /** Tests the offset capability of the fly circle animator */
  9. bool flyCircleAnimator(void)
  10. {
  11. IrrlichtDevice *device = createDevice(video::EDT_BURNINGSVIDEO,
  12. core::dimension2du(160,120), 32);
  13. if (!device)
  14. return false;
  15. IVideoDriver* driver = device->getVideoDriver();
  16. ISceneManager* smgr = device->getSceneManager();
  17. const f32 offsetDegrees[] = { 0.f, 45.f, 135.f, 270.f };
  18. for(u32 i = 0; i < sizeof(offsetDegrees) / sizeof(offsetDegrees[0]); ++i)
  19. {
  20. IBillboardSceneNode * node = smgr->addBillboardSceneNode();
  21. // Have the animator rotate around the Z axis plane, rather than the default Y axis
  22. ISceneNodeAnimator * animator = smgr->createFlyCircleAnimator(
  23. vector3df(0, 0, 0), 30.f, 0.001f,
  24. vector3df(0, 0, 1), (offsetDegrees[i] / 360.f));
  25. if(!node || !animator)
  26. return false;
  27. node->setMaterialType(video::EMT_TRANSPARENT_ADD_COLOR );
  28. node->setMaterialTexture(0, driver->getTexture("../media/particle.bmp"));
  29. node->setMaterialFlag(video::EMF_LIGHTING, false);
  30. node->addAnimator(animator);
  31. animator->drop();
  32. }
  33. (void)smgr->addCameraSceneNode(0, vector3df(0, 0, -50), vector3df(0, 0, 0));
  34. bool result = false;
  35. // Don't do device->run() since I need the time to remain at 0.
  36. if (driver->beginScene(video::ECBF_COLOR | video::ECBF_DEPTH, video::SColor(0, 80, 80, 80)))
  37. {
  38. smgr->drawAll();
  39. driver->endScene();
  40. result = takeScreenshotAndCompareAgainstReference(driver, "-flyCircleAnimator.png");
  41. }
  42. device->closeDevice();
  43. device->run();
  44. device->drop();
  45. return result;
  46. }