You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

voxelinfo.h 1.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. #pragma once
  2. #include "voxelutils.h"
  3. #include <map>
  4. #include <vector>
  5. #include <glm/glm.hpp>
  6. namespace vtk {
  7. enum class Corner2D {
  8. TOPLEFT,
  9. TOPRIGHT,
  10. BOTTOMLEFT,
  11. BOTTOMRIGHT
  12. };
  13. enum class Face3D {
  14. TOP,
  15. BOTTOM,
  16. LEFT,
  17. RIGHT,
  18. FRONT,
  19. BACK
  20. };
  21. enum class Orientation2D {
  22. UP,
  23. DOWN,
  24. LEFT,
  25. RIGHT
  26. };
  27. struct VoxelData{
  28. std::map<Face3D, float> faceTextureIndices;
  29. std::map<Face3D, Orientation2D> faceOrientation;
  30. std::map<FaceDirection, unsigned> faceTextures;
  31. bool transparent;
  32. unsigned short emission;
  33. };
  34. class World;
  35. class VoxelInfo {
  36. public:
  37. void pushTexCoordFromWorldCoords(std::vector<float>& data, const glm::ivec3& pos, const Face3D& face, const Corner2D& corner);
  38. void pushTexCoordFromVoxelID(std::vector<float>& data, const unsigned& id, const Face3D& face, const Corner2D& corner);
  39. float getTexIndexFromID(const unsigned& id, const Face3D& face);
  40. unsigned getTextureIndex(const unsigned& id, const FaceDirection& face);
  41. void setTextureIndex(const unsigned& id, const FaceDirection& face, const unsigned& index);
  42. void setAllTextureIndexes(const unsigned& id, const unsigned& index);
  43. void setTextureData(const unsigned& id, const Face3D& face, const Orientation2D& orientation, const float& textureIndex);
  44. void setTransparent(const unsigned& id, const bool& transparent);
  45. bool isTransparent(const unsigned& id);
  46. std::pair<float, float> getTexCoordFromID(const unsigned& id, const Face3D& face, const Corner2D& corner);
  47. void setEmission(const unsigned& id, const unsigned short& emission);
  48. unsigned short getEmission(const unsigned& id);
  49. World* linkedWorld;
  50. protected:
  51. std::map<unsigned, VoxelData> voxelDataMap;
  52. };
  53. }