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.

84 lines
1.9 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose: sheet definitions for particles and other sprite functions
  4. //
  5. //===========================================================================//
  6. #ifndef PSHEET_H
  7. #define PSHEET_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #include "tier1/utlobjectreference.h"
  12. class CUtlBuffer;
  13. // classes for keeping a dictionary of sheet files in memory. A sheet is a bunch of frames packewd
  14. // within one texture. Each sheet has 1 or more frame sequences stored for it.
  15. // for fast lookups to retrieve sequence data, we store the sequence information discretized into
  16. // a fixed # of frames. If this discretenesss is a visual problem, you can lerp the blend values to get it
  17. // perfect.
  18. #define SEQUENCE_SAMPLE_COUNT 1024
  19. #define MAX_SEQUENCES 64
  20. #define MAX_IMAGES_PER_FRAME_ON_DISK 4
  21. #define MAX_IMAGES_PER_FRAME_IN_MEMORY 2
  22. struct SequenceSampleTextureCoords_t
  23. {
  24. float m_fLeft_U0;
  25. float m_fTop_V0;
  26. float m_fRight_U0;
  27. float m_fBottom_V0;
  28. float m_fLeft_U1;
  29. float m_fTop_V1;
  30. float m_fRight_U1;
  31. float m_fBottom_V1;
  32. };
  33. struct SheetSequenceSample_t
  34. {
  35. // coordinates of two rectangles (old and next frame coords)
  36. SequenceSampleTextureCoords_t m_TextureCoordData[MAX_IMAGES_PER_FRAME_IN_MEMORY];
  37. float m_fBlendFactor;
  38. void CopyFirstFrameToOthers(void)
  39. {
  40. // for old format files only supporting one image per frame
  41. for(int i=1; i < MAX_IMAGES_PER_FRAME_IN_MEMORY; i++)
  42. {
  43. m_TextureCoordData[i] = m_TextureCoordData[0];
  44. }
  45. }
  46. };
  47. class CSheet
  48. {
  49. public:
  50. // read form a .sht file. This is the usual thing to do
  51. CSheet( CUtlBuffer &buf );
  52. CSheet( void );
  53. ~CSheet( void );
  54. // references for smart ptrs
  55. CUtlReferenceList<CSheet> m_References;
  56. SheetSequenceSample_t *m_pSamples[MAX_SEQUENCES];
  57. bool m_bClamp[MAX_SEQUENCES];
  58. bool m_bSequenceIsCopyOfAnotherSequence[MAX_SEQUENCES];
  59. int m_nNumFrames[MAX_SEQUENCES];
  60. float m_flFrameSpan[MAX_SEQUENCES];
  61. };
  62. #endif // PSHEET_H