Basic Voxel Class


SUBMITTED BY: Guest

DATE: April 24, 2013, 6:52 p.m.

FORMAT: C++

SIZE: 1.1 kB

HITS: 1217

  1. //
  2. // Okzoniom::RPG
  3. // Copyright (C) 2010 - 2013
  4. //
  5. // - Louis SCHNELLBACH
  6. //
  7. #ifndef VOXEL_H_INCLUDED
  8. #define VOXEL_H_INCLUDED
  9. class Voxel {
  10. protected:
  11. uint8_t data = 0;
  12. /**
  13. * Bits and usages
  14. * 7 :
  15. * 6 :
  16. * 5 :
  17. * 4 :
  18. * 3 : Type
  19. * 2 : Type
  20. * 1 : Type
  21. * 0 : Active / Inactive
  22. **/
  23. /**
  24. * Type value
  25. * 0 : None (Whatever color / information it can take)
  26. * 1 : Water
  27. * 2 : Sand
  28. * 3 : Grass
  29. * 4 : Rock
  30. * 5 :
  31. * 6 :
  32. **/
  33. public:
  34. enum Modifier
  35. {
  36. GET = 0,
  37. SET = 1
  38. };
  39. bool active(Modifier m = GET, bool value = false)
  40. {
  41. if(m == SET)
  42. data = (0xFE | value);
  43. return data & 0x1;
  44. }
  45. uint8_t type(Modifier m = GET, uint8_t value = 0x7)
  46. {
  47. if(m == SET)
  48. data = (0xF1 | (value << 1));
  49. return (data & 0xE) >> 1;
  50. }
  51. };
  52. #endif

comments powered by Disqus