billboards.cpp 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  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. namespace
  6. {
  7. // Test billboard sizing
  8. bool billboardSize(void)
  9. {
  10. // Use EDT_BURNINGSVIDEO since it is not dependent on (e.g.) OpenGL driver versions.
  11. IrrlichtDevice *device = createDevice(video::EDT_BURNINGSVIDEO, core::dimension2d<u32>(160, 120), 32);
  12. assert_log(device);
  13. if (!device)
  14. return false;
  15. video::IVideoDriver* driver = device->getVideoDriver();
  16. scene::ISceneManager * smgr = device->getSceneManager();
  17. smgr->addCameraSceneNode();
  18. scene::IBillboardSceneNode* bill = smgr->addBillboardSceneNode();
  19. bill->setPosition(core::vector3df(0,0,50));
  20. bill = smgr->addBillboardSceneNode();
  21. bill->setPosition(core::vector3df(-30,0,50));
  22. bill->getMaterial(0).Lighting=false;
  23. bill = smgr->addBillboardSceneNode();
  24. bill->setPosition(core::vector3df(30,0,50));
  25. bill->getMaterial(0).Lighting=false;
  26. bill->getMaterial(0).Wireframe=true;
  27. bill = smgr->addBillboardSceneNode();
  28. bill->setPosition(core::vector3df(30,0,50));
  29. bill->setSize(2,2,2);
  30. bill = smgr->addBillboardSceneNode();
  31. bill->setSize(10,20,2);
  32. bill->setPosition(core::vector3df(0,30,50));
  33. bill = smgr->addBillboardSceneNode();
  34. bill->setSize(10,2,20);
  35. bill->setPosition(core::vector3df(-30,30,50));
  36. bill->getMaterial(0).Lighting=false;
  37. bill = smgr->addBillboardSceneNode();
  38. bill->setSize(10,2,20);
  39. bill->setPosition(core::vector3df(30,30,50));
  40. bill->getMaterial(0).Lighting=false;
  41. bill->getMaterial(0).Wireframe=true;
  42. bill = smgr->addBillboardSceneNode();
  43. bill->setPosition(core::vector3df(30,30,50));
  44. bill->setSize(2,2,2);
  45. video::ITexture* tex = driver->getTexture("../media/fireball.bmp");
  46. bill = smgr->addBillboardSceneNode();
  47. bill->getMaterial(0).Lighting=false;
  48. bill->getMaterial(0).TextureLayer[0].AnisotropicFilter=true;
  49. bill->getMaterial(0).setTexture(0, tex);
  50. bill->setSize(10,20,2);
  51. bill->setPosition(core::vector3df(0,-30,50));
  52. bill = smgr->addBillboardSceneNode();
  53. bill->setSize(10,2,20);
  54. bill->setPosition(core::vector3df(-30,-30,50));
  55. bill->getMaterial(0).TextureLayer[0].AnisotropicFilter=true;
  56. bill->getMaterial(0).setTexture(0, tex);
  57. bill->getMaterial(0).Lighting=false;
  58. bill = smgr->addBillboardSceneNode();
  59. bill->setSize(10,2,20);
  60. bill->setPosition(core::vector3df(30,-30,50));
  61. bill->getMaterial(0).TextureLayer[0].AnisotropicFilter=true;
  62. bill->getMaterial(0).setTexture(0, tex);
  63. bill->getMaterial(0).Lighting=false;
  64. bill->getMaterial(0).Wireframe=true;
  65. bill = smgr->addBillboardSceneNode();
  66. bill->setPosition(core::vector3df(30,-30,50));
  67. bill->setSize(2,2,2);
  68. bill = smgr->addBillboardSceneNode();
  69. bill->getMaterial(0).Lighting=false;
  70. bill->getMaterial(0).setTexture(0, tex);
  71. bill->setSize(10,20,14);
  72. bill->setPosition(core::vector3df(0,-15,50));
  73. bill = smgr->addBillboardSceneNode();
  74. bill->setSize(10,14,20);
  75. bill->setPosition(core::vector3df(-30,-15,50));
  76. bill->getMaterial(0).setTexture(0, tex);
  77. bill->getMaterial(0).Lighting=false;
  78. bill = smgr->addBillboardSceneNode();
  79. bill->setSize(10,14,20);
  80. bill->setPosition(core::vector3df(30,-15,50));
  81. bill->getMaterial(0).setTexture(0, tex);
  82. bill->getMaterial(0).Lighting=false;
  83. bill->getMaterial(0).Wireframe=true;
  84. bill = smgr->addBillboardSceneNode();
  85. bill->setPosition(core::vector3df(30,-15,50));
  86. bill->setSize(2,2,2);
  87. bool result = false;
  88. device->run();
  89. driver->beginScene(video::ECBF_COLOR | video::ECBF_DEPTH, video::SColor(255, 60, 60, 60));
  90. smgr->drawAll();
  91. driver->endScene();
  92. result = takeScreenshotAndCompareAgainstReference(driver, "-billboard.png");
  93. device->closeDevice();
  94. device->run();
  95. device->drop();
  96. return result;
  97. }
  98. // Test billboard orientation
  99. // Should generate a properly readable (i.e. not mirrored or flipped)
  100. // font file display.
  101. bool billboardOrientation(void)
  102. {
  103. // Use EDT_BURNINGSVIDEO since it is not dependent on (e.g.) OpenGL driver versions.
  104. IrrlichtDevice *device = createDevice(video::EDT_BURNINGSVIDEO, core::dimension2d<u32>(160, 120), 32);
  105. assert_log(device);
  106. if (!device)
  107. return false;
  108. video::IVideoDriver* driver = device->getVideoDriver();
  109. scene::ISceneManager * smgr = device->getSceneManager();
  110. smgr->addCameraSceneNode();
  111. scene::IBillboardSceneNode* bill = smgr->addBillboardSceneNode(0, core::dimension2df(40,40));
  112. bill->setPosition(core::vector3df(0,-15,10));
  113. bill->getMaterial(0).Lighting=false;
  114. bill->getMaterial(0).setTexture(0, driver->getTexture("../media/fontcourier.bmp"));
  115. bool result = false;
  116. device->run();
  117. driver->beginScene(video::ECBF_COLOR | video::ECBF_DEPTH, video::SColor(255, 60, 60, 60));
  118. smgr->drawAll();
  119. driver->endScene();
  120. result = takeScreenshotAndCompareAgainstReference(driver, "-billboardOrientation.png");
  121. device->closeDevice();
  122. device->run();
  123. device->drop();
  124. return result;
  125. }
  126. } // end anonymous namespace
  127. // Test billboards
  128. bool billboards(void)
  129. {
  130. bool result = billboardSize();
  131. result &= billboardOrientation();
  132. return result;
  133. }