GPBFile.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. /*
  2. * GPBFile.h
  3. */
  4. #ifndef GPBFILE_H_
  5. #define GPBFILE_H_
  6. #include <iostream>
  7. #include <list>
  8. #include "FileIO.h"
  9. #include "Object.h"
  10. #include "Scene.h"
  11. #include "Node.h"
  12. #include "Camera.h"
  13. #include "Light.h"
  14. #include "Mesh.h"
  15. #include "Reference.h"
  16. #include "ReferenceTable.h"
  17. #include "Animation.h"
  18. #include "AnimationChannel.h"
  19. namespace gameplay
  20. {
  21. /**
  22. * Increment the version number when making a change that break binary compatibility.
  23. * [0] is major, [1] is minor.
  24. */
  25. const unsigned char VERSION[2] = {1, 0};
  26. class GPBFile
  27. {
  28. public:
  29. /**
  30. * Constructor.
  31. */
  32. GPBFile(void);
  33. /**
  34. * Destructor.
  35. */
  36. ~GPBFile(void);
  37. /**
  38. * Saves the GPBFile as a binary file at filepath.
  39. *
  40. * @param filepath The file name and path to save to.
  41. */
  42. void saveBinary(const std::string& filepath);
  43. /**
  44. * Saves the GPBFile as a text file at filepath.
  45. *
  46. * @param filepath The file name and path to save to.
  47. */
  48. void saveText(const std::string& filepath);
  49. void add(Object* obj);
  50. void addScene(Scene* scene);
  51. void addCamera(Camera* camera);
  52. void addLight(Light* light);
  53. void addMesh(Mesh* mesh);
  54. void addNode(Node* node);
  55. void addAnimation(Animation* animation);
  56. /**
  57. * Adds the given object to the ref table.
  58. */
  59. void addToRefTable(Object* obj);
  60. /**
  61. * Returns the object with the given id. Returns NULL if not found.
  62. */
  63. Object* getFromRefTable(const std::string& id);
  64. /**
  65. * Returns true if the id was found in the ref table.
  66. */
  67. bool idExists(const std::string& id);
  68. Camera* getCamera(const char* id);
  69. Light* getLight(const char* id);
  70. Mesh* getMesh(const char* id);
  71. Node* getNode(const char* id);
  72. /**
  73. * Adjusts the game play binary file before it is written.
  74. */
  75. void adjust();
  76. /**
  77. * Returns the animation that the given joint's animation channel's should be added to.
  78. *
  79. * @param id The ID of the joint.
  80. * @return The animation belonging to the skin that the joint is part of.
  81. */
  82. Animation* findAnimationForJoint(const char* id);
  83. private:
  84. FILE* file;
  85. std::list<Object*> objects;
  86. std::list<Camera*> cameras;
  87. std::list<Light*> lights;
  88. std::list<Mesh*> geometry;
  89. std::list<Node*> nodes;
  90. ReferenceTable refTable;
  91. };
  92. }
  93. #endif