userClipPlane.cpp 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. #include "testUtils.h"
  2. using namespace irr;
  3. static bool withSphere(video::E_DRIVER_TYPE type)
  4. {
  5. IrrlichtDevice* device = createDevice(type, core::dimension2d<u32>(160, 120));
  6. if (device == 0)
  7. return true;
  8. video::IVideoDriver* driver = device->getVideoDriver();
  9. scene::ISceneManager* smgr = device->getSceneManager();
  10. stabilizeScreenBackground(driver);
  11. driver->setClipPlane(0, core::plane3df(core::vector3df(0,18,0), core::vector3df(0,-1,0)), true);
  12. smgr->addLightSceneNode(0, core::vector3df(30,30,50));
  13. // create first sphere
  14. scene::ISceneNode* sphere = smgr->addMeshSceneNode(smgr->addSphereMesh("sphere", 10, 64, 64));
  15. if (sphere)
  16. {
  17. sphere->setPosition(core::vector3df(0,10,0));
  18. sphere->setMaterialFlag(video::EMF_BACK_FACE_CULLING, false);
  19. }
  20. sphere = smgr->addMeshSceneNode(smgr->addHillPlaneMesh("mesh", core::dimension2df(10,10), core::dimension2du(10,10)));
  21. sphere->setPosition(core::vector3df(0,10,0));
  22. smgr->addCameraSceneNode(0, core::vector3df(-25,30,20), core::vector3df());
  23. driver->setClipPlane(1, core::plane3df(core::vector3df(0,2,0), core::vector3df(0,1,0)), true);
  24. driver->setClipPlane(2, core::plane3df(core::vector3df(8,0,0), core::vector3df(-1,0,0)));
  25. device->run();
  26. // while(device->run())
  27. {
  28. driver->beginScene(video::ECBF_COLOR | video::ECBF_DEPTH, video::SColor(255,113,113,133));
  29. driver->setClipPlane(3, core::plane3df(core::vector3df(-8,0,0), core::vector3df(1,0,0)), true);
  30. driver->setClipPlane(4, core::plane3df(core::vector3df(0,0,8), core::vector3df(0,0,-1)));
  31. driver->setClipPlane(5, core::plane3df(core::vector3df(0,0,-8), core::vector3df(0,0,1)));
  32. driver->enableClipPlane(2, true);
  33. driver->enableClipPlane(4, true);
  34. driver->enableClipPlane(5, true);
  35. smgr->drawAll();
  36. driver->enableClipPlane(1, false);
  37. driver->enableClipPlane(2, false);
  38. driver->enableClipPlane(4, false);
  39. driver->enableClipPlane(5, false);
  40. driver->setTransform(video::ETS_WORLD, core::IdentityMatrix);
  41. driver->setMaterial(video::IdentityMaterial);
  42. driver->draw3DLine(core::vector3df(), core::vector3df(0,0,50));
  43. driver->endScene();
  44. }
  45. bool result = takeScreenshotAndCompareAgainstReference(driver, "-ucpsphere.png");
  46. device->closeDevice();
  47. device->run();
  48. device->drop();
  49. return result;
  50. }
  51. bool userclipplane()
  52. {
  53. bool result = true;
  54. TestWithAllHWDrivers(withSphere);
  55. return result;
  56. }