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
2.5 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // A class representing an abstract shape (ie drawable object)
  4. //
  5. //=============================================================================
  6. #ifndef DMEFACESET_H
  7. #define DMEFACESET_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #include "datamodel/dmelement.h"
  12. #include "datamodel/dmattribute.h"
  13. #include "datamodel/dmattributevar.h"
  14. #include "tier1/utlvector.h"
  15. //-----------------------------------------------------------------------------
  16. // Forward declarations
  17. //-----------------------------------------------------------------------------
  18. class CDmeMaterial;
  19. //-----------------------------------------------------------------------------
  20. // A class representing a face of a polygonal mesh
  21. //-----------------------------------------------------------------------------
  22. class CDmeFaceSet : public CDmElement
  23. {
  24. DEFINE_ELEMENT( CDmeFaceSet, CDmElement );
  25. public:
  26. // material accessors
  27. CDmeMaterial *GetMaterial();
  28. void SetMaterial( CDmeMaterial *pMaterial );
  29. // Total number of indices in the face set including the -1 end of face designators
  30. int NumIndices() const;
  31. const int *GetIndices() const;
  32. int AddIndices( int nCount );
  33. void SetIndex( int i, int nValue );
  34. void SetIndices( int nFirstIndex, int nCount, int *pIndices );
  35. int GetIndex( int i ) const;
  36. // Returns the number of vertices in the next polygon
  37. int GetNextPolygonVertexCount( int nFirstIndex ) const;
  38. // Returns the number of triangulated indices total
  39. int GetTriangulatedIndexCount() const;
  40. // Total number of indices in the face set excluding the -1 end of face designators
  41. int GetIndexCount() const;
  42. // Removes multiple faces from the face set
  43. void RemoveMultiple( int elem, int num );
  44. // Returns the number of faces in total... This should be the number of -1 indices in the face set
  45. // Which should equal NumIndices() - GetIndexCount() but this function accounts for
  46. // empty faces (which aren't counted as faces) and a missing -1 terminator at the end
  47. int GetFaceCount() const;
  48. private:
  49. CDmaArray< int > m_indices;
  50. CDmaElement< CDmeMaterial > m_material;
  51. };
  52. //-----------------------------------------------------------------------------
  53. // Inline methods
  54. //-----------------------------------------------------------------------------
  55. inline int CDmeFaceSet::NumIndices() const
  56. {
  57. return m_indices.Count();
  58. }
  59. inline const int *CDmeFaceSet::GetIndices() const
  60. {
  61. return m_indices.Base();
  62. }
  63. inline int CDmeFaceSet::GetIndex( int i ) const
  64. {
  65. return m_indices[i];
  66. }
  67. #endif // DMEFACESET_H