QGearsWalkmeshFile.cpp 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /*
  2. -----------------------------------------------------------------------------
  3. Copyright (c) 2013-09-05 Tobias Peters <tobias.peters@kreativeffekt.at>
  4. This file is part of Q-Gears
  5. Q-Gears is free software: you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation, version 2.0 (GPLv2) of the License.
  8. Q-Gears is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. -----------------------------------------------------------------------------
  13. */
  14. #include "map/QGearsWalkmeshFile.h"
  15. #include <OgreLogManager.h>
  16. #include "map/QGearsWalkmeshFileXMLSerializer.h"
  17. namespace QGears
  18. {
  19. //---------------------------------------------------------------------
  20. const String WalkmeshFile::RESOURCE_TYPE( "QGearsWalkmeshFile" );
  21. //---------------------------------------------------------------------
  22. WalkmeshFile::WalkmeshFile( Ogre::ResourceManager *creator
  23. ,const String &name, Ogre::ResourceHandle handle
  24. ,const String &group, bool isManual
  25. ,Ogre::ManualResourceLoader *loader ) :
  26. Resource( creator, name, handle, group, isManual, loader )
  27. {
  28. }
  29. //---------------------------------------------------------------------
  30. WalkmeshFile::~WalkmeshFile()
  31. {
  32. unload();
  33. }
  34. //---------------------------------------------------------------------
  35. void
  36. WalkmeshFile::loadImpl()
  37. {
  38. WalkmeshFileXMLSerializer serializer;
  39. Ogre::DataStreamPtr stream( openResource() );
  40. serializer.importWalkmeshFile( stream, this );
  41. }
  42. //---------------------------------------------------------------------
  43. void
  44. WalkmeshFile::unloadImpl()
  45. {
  46. m_triangles.clear();
  47. }
  48. //---------------------------------------------------------------------
  49. size_t
  50. WalkmeshFile::calculateSize() const
  51. {
  52. return sizeof(Triangle) * m_triangles.size();
  53. }
  54. //---------------------------------------------------------------------
  55. WalkmeshFile::TriangleList&
  56. WalkmeshFile::getTriangles()
  57. {
  58. return m_triangles;
  59. }
  60. //---------------------------------------------------------------------
  61. }