*
*/
-// INTERNAL INCLUDES
-#include "dali-scene3d/public-api/api.h"
-#include "dali-scene3d/public-api/loader/blend-shape-details.h"
-#include "dali-scene3d/public-api/loader/index.h"
-#include "dali-scene3d/public-api/loader/mesh-geometry.h"
-#include "dali-scene3d/public-api/loader/utils.h"
-#include <dali-scene3d/public-api/loader/buffer-definition.h>
-
// EXTERNAL INCLUDES
+#include <dali/public-api/common/vector-wrapper.h>
#include <memory>
-#include "dali/public-api/common/vector-wrapper.h"
-namespace Dali
-{
-namespace Scene3D
-{
-namespace Loader
+// INTERNAL INCLUDES
+#include <dali-scene3d/public-api/api.h>
+#include <dali-scene3d/public-api/loader/blend-shape-details.h>
+#include <dali-scene3d/public-api/loader/buffer-definition.h>
+#include <dali-scene3d/public-api/loader/index.h>
+#include <dali-scene3d/public-api/loader/mesh-geometry.h>
+#include <dali-scene3d/public-api/loader/utils.h>
+
+namespace Dali::Scene3D::Loader
{
/**
* @brief Defines a mesh with its attributes, the primitive type to render it as,
* and the file to load it from with the offset and length information for the
* individual attribute buffers.
+ * @SINCE_2_0.7
*/
struct DALI_SCENE3D_API MeshDefinition
{
INVALID = std::numeric_limits<uint32_t>::max()
};
- enum Flags : uint16_t
+ enum : uint32_t
+ {
+ MAX_NUMBER_OF_JOINT_SETS = 4
+ };
+
+ enum Flags : uint32_t
{
FLIP_UVS_VERTICAL = NthBit(0),
U32_INDICES = NthBit(1), // default is unsigned short
U8_INDICES = NthBit(2), // default is unsigned short
U16_JOINT_IDS = NthBit(3), // default is floats
U8_JOINT_IDS = NthBit(4),
+ U16_WEIGHT = NthBit(5), // default is floats
+ U8_WEIGHT = NthBit(6),
+ S8_POSITION = NthBit(7), // default is floats
+ U8_POSITION = NthBit(8), // default is floats
+ S16_POSITION = NthBit(9), // default is floats
+ U16_POSITION = NthBit(10), // default is floats
+ S8_NORMAL = NthBit(11), // default is floats
+ S16_NORMAL = NthBit(12), // default is floats
+ S8_TANGENT = NthBit(13), // default is floats
+ S16_TANGENT = NthBit(14), // default is floats
+ S8_TEXCOORD = NthBit(15), // default is floats
+ U8_TEXCOORD = NthBit(16), // default is floats
+ S16_TEXCOORD = NthBit(17), // default is floats
+ U16_TEXCOORD = NthBit(18), // default is floats
+ };
+
+ enum FlagMasks : uint32_t
+ {
+ POSITIONS_MASK = 0x780,
+ NORMALS_MASK = 0x1800,
+ TANGENTS_MASK = 0x6000,
+ TEXCOORDS_MASK = 0x78000,
};
enum Attributes
/**
* @brief Describes raw data in terms of its position and size in a buffer.
- * All units in bytes.
+ *
+ * All units in bytes.
+ * @SINCE_2_0.7
*/
struct Blob
{
static void ComputeMinMax(std::vector<float>& min, std::vector<float>& max, uint32_t numComponents, uint32_t count, const float* values);
- static void ApplyMinMax(const std::vector<float>& min, const std::vector<float>& max, uint32_t count, float* values);
+ static void ApplyMinMax(const std::vector<float>& min, const std::vector<float>& max, uint32_t count, float* values, std::vector<uint32_t>* sparseIndices = nullptr);
Blob() = default;
/**
* @brief Calculates the size of a tightly-packed buffer for the elements from the blob.
+ * @SINCE_2_0.7
*/
uint32_t GetBufferSize() const;
/**
* @brief Convenience method to tell whether a Blob has meaningful data.
+ * @SINCE_2_0.7
*/
bool IsDefined() const
{
}
/**
- * @brief Convenience method to tell whether the elements stored in the blob follow each
- * other tightly. The opposite would be interleaving.
+ * @brief Convenience method to tell whether the elements stored in the blob follow each other tightly.
+ *
+ * The opposite would be interleaving.
+ * @SINCE_2_0.7
*/
bool IsConsecutive() const
{
/**
* @brief Computes the min / max of the input value data.
- * The min and max are stored in mMin and mMax.
*
+ * The min and max are stored in mMin and mMax.
+ * @SINCE_2_0.7
* @param[in] numComponents number of components of data type. e.g., 3 for Vector3.
* @param[in] count The number of data.
* @param[in] values Data for the mesh.
/**
* @brief Applies the min / max values, if they're defined in the model
*
+ * @SINCE_2_0.7
* @param[in] count The number of data.
* @param[in] values Data for the mesh that min / max values will be applied.
+ * @param[in] sparseIndices Pointer to array of sparse indices (or nullptr if not provided)
*/
- void ApplyMinMax(uint32_t count, float* values) const;
+ void ApplyMinMax(uint32_t count, float* values, std::vector<uint32_t>* sparseIndices = nullptr) const;
};
/**
* @brief A sparse blob describes a change in a reference Blob.
* @p indices describe what positions of the reference Blob change and
* @p values describe the new values.
+ * @SINCE_2_0.7
*/
struct SparseBlob
{
Blob mBlob;
std::unique_ptr<SparseBlob> mSparse;
Index mBufferIdx = INVALID_INDEX;
+ bool mNormalized{false};
Accessor() = default;
Accessor(const MeshDefinition::Blob& blob,
const MeshDefinition::SparseBlob& sparse,
- Index bufferIndex = INVALID_INDEX);
+ Index bufferIndex = INVALID_INDEX,
+ bool normalized = false);
+
Accessor(MeshDefinition::Blob&& blob,
MeshDefinition::SparseBlob&& sparse,
- Index bufferIndex = INVALID_INDEX);
+ Index bufferIndex = INVALID_INDEX,
+ bool normalized = false);
bool IsDefined() const
{
/**
* @brief Stores a blend shape.
+ * @SINCE_2_0.7
*/
struct BlendShape
{
Accessor normals;
Accessor tangents;
float weight = 0.f;
+ uint32_t mFlags = 0x0;
};
struct RawData
/**
* @brief Determines whether the mesh definition is that of a quad.
+ * @SINCE_2_0.7
*/
bool IsQuad() const;
/**
* @brief Determines whether the mesh is used for skeletal animation.
+ * @SINCE_2_0.7
*/
bool IsSkinned() const;
/**
+ * @brief Determines if the mesh has any vertex colors
+ */
+ bool HasVertexColor() const;
+
+ /**
+ * @brief Returns the number of joint sets defined by the mesh
+ *
+ * @SINCE_2_2.52
+ * @note Clamped to 4 to minimise GPU attrs.
+ */
+ uint32_t GetNumberOfJointSets() const;
+
+ /**
* @brief Whether the mesh has blend shapes.
+ * @SINCE_2_0.7
*/
bool HasBlendShapes() const;
/**
* @brief Requests normals to be generated.
+ * @SINCE_2_0.7
* @note Generation happens in LoadRaw().
* @note Must have Vector3 positions defined.
*/
/**
* @brief Requests tangents to be generated.
+ * @SINCE_2_0.7
* @note Generation happens in LoadRaw().
* @note Must have Vector3 normals defined.
*/
void RequestTangents();
/**
- * @brief Loads raw geometry data, which includes index (optional) and
- * attribute buffers, as well as blend shape data. This is then returned.
+ * @brief Loads raw geometry data, which includes index (optional) and attribute buffers, as well as blend shape data.
+ *
+ * This is then returned.
+ * @SINCE_2_0.7
* @note This can be done on any thread.
*/
RawData LoadRaw(const std::string& modelsPath, BufferDefinition::Vector& buffers);
* attribute (and index) buffers and blend shape information (if available)
* from @a raw.
* If mFlipVertical was set, the UVs are flipped in Y, i.e. v = 1.0 - v.
+ * @SINCE_2_0.7
*/
MeshGeometry Load(RawData&& raw) const;
+ /**
+ * @brief Retrieves what Components information is in this mesh's BlendShape.
+ *
+ * @SINCE_2_2.21
+ * @param[out] hasPositions True if the BlendShape has position components
+ * @param[out] hasNormals True if the BlendShape has normal components
+ * @param[out] hasTangents True if the BlendShape has tangent components
+ */
+ void RetrieveBlendShapeComponents(bool& hasPositions, bool& hasNormals, bool& hasTangents) const;
+
public: // DATA
std::shared_ptr<RawData> mRawData;
uint32_t mFlags = 0x0;
std::string mUri; // When the mesh data is loaded from embedded resources, this URI is used as a data stream.
Accessor mIndices;
Accessor mPositions;
- Accessor mNormals; // data can be generated based on positions
- Accessor mTexCoords;
- Accessor mColors;
+ Accessor mNormals; // data can be generated based on positions
Accessor mTangents; // data can be generated based on normals and texCoords (the latter isn't mandatory; the results will be better if available)
- Accessor mJoints0;
- Accessor mWeights0;
+ std::vector<Accessor> mTexCoords;
+ std::vector<Accessor> mColors;
+ std::vector<Accessor> mJoints;
+ std::vector<Accessor> mWeights;
Property::Type mTangentType{Property::VECTOR3};
Blob mBlendShapeHeader;
std::vector<BlendShape> mBlendShapes;
BlendShapes::Version mBlendShapeVersion = BlendShapes::Version::INVALID;
- Index mSkeletonIdx = INVALID_INDEX;
+ Index mSkeletonIdx = INVALID_INDEX;
+ ModelPrimitive mModelPrimitive;
};
-} // namespace Loader
-} // namespace Scene3D
-} // namespace Dali
+} // namespace Dali::Scene3D::Loader
#endif //DALI_SCENE3D_LOADER_MESH_DEFINITION_H