Team Fortress 2 Source Code as on 22/4/2020
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.

87 lines
1.8 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Hardware Texels
  4. //
  5. // Contains texture data that was encoded with the map. The initial use case
  6. // is for per-texel lightmaps to allow static props to match the lighting
  7. // of the surrounding BSP geometry.
  8. //
  9. //=============================================================================//
  10. #ifndef HARDWARETEXELS_H
  11. #define HARDWARETEXELS_H
  12. #ifdef _WIN32
  13. #pragma once
  14. #endif
  15. #include "bitmap/imageformat.h"
  16. #include "datamap.h"
  17. // valve hardware texels
  18. #define VHT_VERSION 0
  19. namespace HardwareTexels
  20. {
  21. #pragma pack(1)
  22. // ------------------------------------------------------------------------------------------------
  23. struct MeshHeader_t
  24. {
  25. DECLARE_BYTESWAP_DATADESC();
  26. // this mesh is part of this lod
  27. unsigned int m_nLod;
  28. // starting at this offset
  29. unsigned int m_nOffset;
  30. // this mesh consumes this many bytes
  31. unsigned int m_nBytes;
  32. // with this width and height
  33. unsigned int m_nWidth;
  34. unsigned int m_nHeight;
  35. unsigned int m_nUnused[3];
  36. };
  37. // ------------------------------------------------------------------------------------------------
  38. struct FileHeader_t
  39. {
  40. DECLARE_BYTESWAP_DATADESC();
  41. // file version as defined by VHV_VERSION
  42. int m_nVersion;
  43. // must match checkSum in the .mdl header
  44. unsigned int m_nChecksum;
  45. // all texels are encoded in the same format
  46. // This is a value from ImageFormat.
  47. unsigned int m_nTexelFormat;
  48. // Number of meshes
  49. int m_nMeshes;
  50. inline MeshHeader_t *pMesh( int nMesh ) const
  51. {
  52. Assert(nMesh < m_nMeshes);
  53. return (MeshHeader_t *)(((byte *)this) + sizeof(FileHeader_t)) + nMesh;
  54. };
  55. inline void *pTexelBase( int nMesh ) const
  56. {
  57. return (void *)((byte *)this + pMesh( nMesh )->m_nOffset);
  58. };
  59. unsigned int m_nUnused[4];
  60. };
  61. #pragma pack()
  62. }; // end namespace
  63. #endif // HARDWARETEXELS_H