userClipPlane.cpp 2.3 KB

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