llgltfaccessor.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. /**
  2. * @file llgltfaccessor.h
  3. * @brief LL GLTF Implementation
  4. *
  5. * $LicenseInfo:firstyear=2024&license=viewergpl$
  6. *
  7. * Copyright (c) 2024, Linden Research, Inc.
  8. *
  9. * Second Life Viewer Source Code
  10. * The source code in this file ("Source Code") is provided by Linden Lab
  11. * to you under the terms of the GNU General Public License, version 2.0
  12. * ("GPL"), unless you have obtained a separate licensing agreement
  13. * ("Other License"), formally executed by you and Linden Lab. Terms of
  14. * the GPL can be found in doc/GPL-license.txt in this distribution, or
  15. * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
  16. *
  17. * There are special exceptions to the terms and conditions of the GPL as
  18. * it is applied to this Source Code. View the full text of the exception
  19. * in the file doc/FLOSS-exception.txt in this software distribution, or
  20. * online at
  21. * http://secondlifegrid.net/programs/open_source/licensing/flossexception
  22. *
  23. * By copying, modifying or distributing this software, you acknowledge
  24. * that you have read and understood your obligations described above,
  25. * and agree to abide by those obligations.
  26. *
  27. * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
  28. * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
  29. * COMPLETENESS OR PERFORMANCE.
  30. * $/LicenseInfo$
  31. */
  32. #ifndef LL_LLGLTFACCESSOR_H
  33. #define LL_LLGLTFACCESSOR_H
  34. #include <vector>
  35. #include <string>
  36. #include "llpreprocessor.h"
  37. #include "stdtypes.h"
  38. // Saves from including "tinygltf/tiny_gltf.h" here. HB
  39. #ifndef TINYGLTF_TYPE_VEC2
  40. # define TINYGLTF_TYPE_VEC2 (2)
  41. # define TINYGLTF_TYPE_VEC3 (3)
  42. # define TINYGLTF_TYPE_VEC4 (4)
  43. # define TINYGLTF_TYPE_MAT2 (32 + 2)
  44. # define TINYGLTF_TYPE_MAT3 (32 + 3)
  45. # define TINYGLTF_TYPE_MAT4 (32 + 4)
  46. # define TINYGLTF_TYPE_SCALAR (64 + 1)
  47. # define LL_CLEANUP_TINYGLTF_DEFINES
  48. #endif
  49. namespace tinygltf
  50. {
  51. struct Accessor;
  52. struct Buffer;
  53. struct BufferView;
  54. }
  55. namespace LLGLTF
  56. {
  57. constexpr S32 INVALID_INDEX = -1;
  58. class Buffer
  59. {
  60. public:
  61. const Buffer& operator=(const tinygltf::Buffer& src);
  62. public:
  63. std::string mName;
  64. std::string mUri;
  65. std::vector<U8> mData;
  66. };
  67. class BufferView
  68. {
  69. public:
  70. LL_INLINE BufferView()
  71. : mBuffer(INVALID_INDEX)
  72. {
  73. }
  74. const BufferView& operator=(const tinygltf::BufferView& src);
  75. public:
  76. std::string mName;
  77. S32 mBuffer;
  78. S32 mByteLength;
  79. S32 mByteOffset;
  80. S32 mByteStride;
  81. S32 mTarget;
  82. S32 mComponentType;
  83. };
  84. class Accessor
  85. {
  86. public:
  87. LL_INLINE Accessor()
  88. : mBufferView(INVALID_INDEX)
  89. {
  90. }
  91. const Accessor& operator=(const tinygltf::Accessor& src);
  92. enum class Type : S32
  93. {
  94. SCALAR = TINYGLTF_TYPE_SCALAR,
  95. VEC2 = TINYGLTF_TYPE_VEC2,
  96. VEC3 = TINYGLTF_TYPE_VEC3,
  97. VEC4 = TINYGLTF_TYPE_VEC4,
  98. MAT2 = TINYGLTF_TYPE_MAT2,
  99. MAT3 = TINYGLTF_TYPE_MAT3,
  100. MAT4 = TINYGLTF_TYPE_MAT4
  101. };
  102. public:
  103. std::string mName;
  104. std::vector<F64> mMax;
  105. std::vector<F64> mMin;
  106. S32 mType;
  107. S32 mBufferView;
  108. S32 mByteOffset;
  109. S32 mComponentType;
  110. S32 mCount;
  111. bool mNormalized;
  112. };
  113. }
  114. #ifdef LL_CLEANUP_TINYGLTF_DEFINES
  115. # undef TINYGLTF_TYPE_VEC2
  116. # undef TINYGLTF_TYPE_VEC3
  117. # undef TINYGLTF_TYPE_VEC4
  118. # undef TINYGLTF_TYPE_MAT2
  119. # undef TINYGLTF_TYPE_MAT3
  120. # undef TINYGLTF_TYPE_MAT4
  121. # undef TINYGLTF_TYPE_SCALAR
  122. # undef LL_CLEANUP_TINYGLTF_DEFINES
  123. #endif
  124. #endif // LL_LLGLTFACCESSOR_H