VGearsBackground2DFile.cpp 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /*
  2. * Copyright (C) 2022 The V-Gears Team
  3. *
  4. * This file is part of V-Gears
  5. *
  6. * V-Gears is free software: you can redistribute it and/or modify it under
  7. * terms of the GNU General Public License as published by the Free Software
  8. * Foundation, version 3.0 (GPLv3) of the License.
  9. *
  10. * V-Gears is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. */
  15. #include <OgreLogManager.h>
  16. #include <OgreResourceGroupManager.h>
  17. #include "formats/field/VGearsBackground2DFile.h"
  18. #include "formats/field/VGearsBackground2DFileXMLSerializer.h"
  19. namespace VGears{
  20. const String Background2DFile::RESOURCE_TYPE("VGearsBackground2DFile");
  21. Background2DFile::Background2DFile(
  22. Ogre::ResourceManager *creator, const String &name, Ogre::ResourceHandle handle,
  23. const String &group, bool is_manual, Ogre::ManualResourceLoader *loader
  24. ) : Resource(creator, name, handle, group, is_manual, loader){}
  25. Background2DFile::~Background2DFile(){unload();}
  26. void Background2DFile::loadImpl(){
  27. Background2DFileXMLSerializer serializer;
  28. Ogre::DataStreamPtr stream(openResource());
  29. serializer.ImportBackground2DFile(stream, this);
  30. }
  31. void Background2DFile::unloadImpl(){
  32. texture_name_.clear();
  33. palette_name_.clear();
  34. // GCC error:
  35. // error: no match for ‘operator=’ (operand types are ‘Ogre::Vector4’
  36. // {aka ‘Ogre::Vector<4, float>’} and ‘int’)
  37. //range_ = 0;
  38. position_ = Ogre::Vector3::ZERO;
  39. orientation_ = Ogre::Quaternion::IDENTITY;
  40. fov_ = 0;
  41. tiles_.clear();
  42. }
  43. size_t Background2DFile::calculateSize() const{return 0;}
  44. void Background2DFile::SetTextureName(const String &texture_name){texture_name_ = texture_name;}
  45. String Background2DFile::GetTextureName() const{ return texture_name_;}
  46. void Background2DFile::SetPaletteName(const String &palette_name){palette_name_ = palette_name;}
  47. String Background2DFile::GetPaletteName() const{return palette_name_;}
  48. void Background2DFile::SetClip(const Ogre::Vector2 &clip){clip_ = clip;}
  49. Ogre::Vector2 Background2DFile::GetClip() const{return clip_;}
  50. void Background2DFile::SetRange(const Ogre::Vector4 &range){range_ = range;}
  51. Ogre::Vector4 Background2DFile::GetRange() const{return range_;}
  52. void Background2DFile::SetPosition(const Ogre::Vector3 &position){position_ = position;}
  53. Ogre::Vector3 Background2DFile::GetPosition() const{return position_;}
  54. void Background2DFile::SetOrientation(const Ogre::Quaternion &orientation){
  55. orientation_ = orientation;
  56. }
  57. Ogre::Quaternion Background2DFile::GetOrientation() const{return orientation_;}
  58. void Background2DFile::SetFov(const Ogre::Radian &fov){fov_ = fov;}
  59. Ogre::Radian Background2DFile::GetFov() const{return fov_;}
  60. Background2DFile::TileList& Background2DFile::GetTiles(){return tiles_;}
  61. }