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 2.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /*
  2. * =====================================================================================
  3. *
  4. * Filename: voxelinfo.h
  5. *
  6. * Description: Stores information about voxel types, like texture coordinates.
  7. *
  8. * Version: 1.0
  9. * Created: 04/06/2014 01:07:52 PM
  10. * Revision: none
  11. * Compiler: gcc
  12. *
  13. * Author: YOUR NAME (),
  14. * Organization:
  15. *
  16. * =====================================================================================
  17. */
  18. #pragma once
  19. #include "voxelutils.h"
  20. #include <map>
  21. #include <vector>
  22. #include <glm/glm.hpp>
  23. namespace vtk {
  24. enum class Corner2D {
  25. TOPLEFT,
  26. TOPRIGHT,
  27. BOTTOMLEFT,
  28. BOTTOMRIGHT
  29. };
  30. enum class Face3D {
  31. TOP,
  32. BOTTOM,
  33. LEFT,
  34. RIGHT,
  35. FRONT,
  36. BACK
  37. };
  38. enum class Orientation2D {
  39. UP,
  40. DOWN,
  41. LEFT,
  42. RIGHT
  43. };
  44. struct VoxelData{
  45. std::map<Face3D, float> faceTextureIndices;
  46. std::map<Face3D, Orientation2D> faceOrientation;
  47. std::map<FaceDirection, unsigned> faceTextures;
  48. bool transparent;
  49. };
  50. class World;
  51. class VoxelInfo {
  52. public:
  53. void pushTexCoordFromWorldCoords(std::vector<float>& data, const glm::ivec3& pos, const Face3D& face, const Corner2D& corner);
  54. void pushTexCoordFromVoxelID(std::vector<float>& data, const unsigned& id, const Face3D& face, const Corner2D& corner);
  55. float getTexIndexFromID(const unsigned& id, const Face3D& face);
  56. unsigned getTextureIndex(const unsigned& id, const FaceDirection& face);
  57. void setTextureIndex(const unsigned& id, const FaceDirection& face, const unsigned& index);
  58. void setAllTextureIndexes(const unsigned& id, const unsigned& index);
  59. void setTextureData(const unsigned& id, const Face3D& face, const Orientation2D& orientation, const float& textureIndex);
  60. void setTransparent(const unsigned& id, const bool& transparent);
  61. bool isTransparent(const unsigned& id);
  62. std::pair<float, float> getTexCoordFromID(const unsigned& id, const Face3D& face, const Corner2D& corner);
  63. World* linkedWorld;
  64. protected:
  65. std::map<unsigned, VoxelData> voxelDataMap;
  66. };
  67. }