skinnedMesh.cpp 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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. // Tests skinned meshes.
  6. bool skinnedMesh(void)
  7. {
  8. // Use EDT_BURNINGSVIDEO since it is not dependent on (e.g.) OpenGL driver versions.
  9. IrrlichtDevice *device = createDevice(video::EDT_BURNINGSVIDEO, core::dimension2d<u32>(160, 120), 32);
  10. if (!device)
  11. return false;
  12. scene::ISceneManager * smgr = device->getSceneManager();
  13. logTestString("Testing setMesh()\n");
  14. scene::ISkinnedMesh* mesh = (scene::ISkinnedMesh*)smgr->getMesh("../media/ninja.b3d");
  15. if (!mesh)
  16. {
  17. logTestString("Could not load ninja.\n");
  18. return false;
  19. }
  20. scene::IAnimatedMeshSceneNode* node = smgr->addAnimatedMeshSceneNode(mesh);
  21. if (!node)
  22. {
  23. logTestString("Could not add ninja node.\n");
  24. return false;
  25. }
  26. // test if certain joint is found
  27. bool result = (node->getJointNode("Joint1") != 0);
  28. if (!result)
  29. logTestString("Could not find joint in ninja.\n");
  30. mesh = (scene::ISkinnedMesh*)smgr->getMesh("../media/dwarf.x");
  31. if (!mesh)
  32. {
  33. logTestString("Could not load dwarf.\n");
  34. return false;
  35. }
  36. node->setMesh(mesh);
  37. // make sure old joint is non-existant anymore
  38. logTestString("Ignore error message in log, this is intended.\n");
  39. result &= (node->getJointNode("Joint1")==0);
  40. if (!result)
  41. logTestString("Found non-existing joint in dwarf.\n");
  42. // and check that a new joint can be found
  43. // we use a late one, in order to see also inconsistencies in the joint cache
  44. result &= (node->getJointNode("hit") != 0);
  45. if (!result)
  46. logTestString("Could not find joint in dwarf.\n");
  47. node = smgr->addAnimatedMeshSceneNode(mesh);
  48. if (!node)
  49. {
  50. logTestString("Could not add dwarf node.\n");
  51. return false;
  52. }
  53. // check that a joint can really be found
  54. result &= (node->getJointNode("hit") != 0);
  55. if (!result)
  56. logTestString("Could not find joint in dwarf.\n");
  57. device->closeDevice();
  58. device->run();
  59. device->drop();
  60. return result;
  61. }