VoxHeader.cs 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. #region License
  2. // Copyright 2020 Kastellanos Nikolaos
  3. //
  4. // Licensed under the Apache License, Version 2.0 (the "License");
  5. // you may not use this file except in compliance with the License.
  6. // You may obtain a copy of the License at
  7. //
  8. // http://www.apache.org/licenses/LICENSE-2.0
  9. //
  10. // Unless required by applicable law or agreed to in writing, software
  11. // distributed under the License is distributed on an "AS IS" BASIS,
  12. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. // See the License for the specific language governing permissions and
  14. // limitations under the License.
  15. #endregion
  16. using System;
  17. using Microsoft.Xna.Framework.Content.Pipeline;
  18. namespace nkast.Aether.Content.Pipeline
  19. {
  20. struct VoxHeader
  21. {
  22. static readonly int VoxSignature = (BitConverter.IsLittleEndian) ? 0x20584F56 : 0x564F5820;
  23. public readonly Int32 Signature;
  24. public readonly Int32 Version;
  25. public VoxHeader(System.IO.BinaryReader reader)
  26. {
  27. Signature = reader.ReadInt32();
  28. if (Signature != VoxHeader.VoxSignature)
  29. throw new InvalidContentException("This does not appear to be a VOX file");
  30. Version = reader.ReadInt32();
  31. if (Version != 150)
  32. throw new InvalidContentException("Unknown version");
  33. }
  34. }
  35. struct Chunk
  36. {
  37. public readonly int ChunkId;
  38. public readonly int NumBytesOfChunkContent;
  39. public readonly int NumBytesOfChildrenChunks;
  40. public Chunk(System.IO.BinaryReader reader)
  41. {
  42. ChunkId = reader.ReadInt32();
  43. NumBytesOfChunkContent = reader.ReadInt32();
  44. NumBytesOfChildrenChunks = reader.ReadInt32();
  45. }
  46. public const int MAIN = 0x4E49414D;
  47. public const int PACK = 0x4B434150;
  48. public const int SIZE = 0x455A4953;
  49. public const int XYZI = 0x495A5958;
  50. public const int RGBA = 0x41424752;
  51. public const int MATT = 0x5454414D;
  52. }
  53. struct XYZI
  54. {
  55. public Point3 Point;
  56. public byte ColorIndex;
  57. public Sides SharedSides;
  58. }
  59. }