2 * Copyright (c) 2022 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 #include <dali/public-api/math/matrix.h>
24 #include <dali-scene3d/internal/loader/gltf2-asset.h>
32 constexpr uint32_t ACCESSOR_TYPE_ELEMENT_COUNT[]{
40 static_cast<uint32_t>(-1)};
42 const std::map<std::string_view, AccessorType::Type> ACCESSOR_TYPES{
43 ENUM_STRING_MAPPING(AccessorType, SCALAR),
44 ENUM_STRING_MAPPING(AccessorType, VEC2),
45 ENUM_STRING_MAPPING(AccessorType, VEC3),
46 ENUM_STRING_MAPPING(AccessorType, VEC4),
47 ENUM_STRING_MAPPING(AccessorType, MAT2),
48 ENUM_STRING_MAPPING(AccessorType, MAT3),
49 ENUM_STRING_MAPPING(AccessorType, MAT4),
52 const std::map<std::string_view, AlphaMode::Type> ALPHA_MODE_TYPES{
53 ENUM_STRING_MAPPING(AlphaMode::Type, OPAQUE),
54 ENUM_STRING_MAPPING(AlphaMode::Type, MASK),
55 ENUM_STRING_MAPPING(AlphaMode::Type, BLEND),
58 const std::map<std::string_view, Attribute::Type> ATTRIBUTE_TYPES{
59 ENUM_STRING_MAPPING(Attribute::Type, POSITION),
60 ENUM_STRING_MAPPING(Attribute::Type, NORMAL),
61 ENUM_STRING_MAPPING(Attribute::Type, TANGENT),
62 ENUM_STRING_MAPPING(Attribute::Type, TEXCOORD_0),
63 ENUM_STRING_MAPPING(Attribute::Type, TEXCOORD_1),
64 ENUM_STRING_MAPPING(Attribute::Type, COLOR_0),
65 ENUM_STRING_MAPPING(Attribute::Type, JOINTS_0),
66 ENUM_STRING_MAPPING(Attribute::Type, WEIGHTS_0),
69 const std::map<std::string_view, Animation::Sampler::Interpolation::Type> ANIMATION_SAMPLER_INTERPOLATION{
70 ENUM_STRING_MAPPING(Animation::Sampler::Interpolation::Type, STEP),
71 ENUM_STRING_MAPPING(Animation::Sampler::Interpolation::Type, LINEAR),
72 ENUM_STRING_MAPPING(Animation::Sampler::Interpolation::Type, CUBICSPLINE),
75 const std::map<std::string_view, Animation::Channel::Target::Type> ANIMATION_CHANNEL_TARGET_PATH_TYPES{
76 ENUM_STRING_MAPPING(Animation::Channel::Target::Type, TRANSLATION),
77 ENUM_STRING_MAPPING(Animation::Channel::Target::Type, ROTATION),
78 ENUM_STRING_MAPPING(Animation::Channel::Target::Type, SCALE),
79 ENUM_STRING_MAPPING(Animation::Channel::Target::Type, WEIGHTS),
84 ENUM_TYPE_FROM_STRING(AccessorType, ACCESSOR_TYPES)
85 ENUM_TYPE_FROM_STRING(AlphaMode, ALPHA_MODE_TYPES)
86 ENUM_TYPE_FROM_STRING(Attribute, ATTRIBUTE_TYPES)
87 ENUM_TYPE_FROM_STRING(Animation::Sampler::Interpolation, ANIMATION_SAMPLER_INTERPOLATION)
88 ENUM_TYPE_FROM_STRING(Animation::Channel::Target, ANIMATION_CHANNEL_TARGET_PATH_TYPES)
90 bool Component::IsUnsigned(Type t)
92 return t == UNSIGNED_BYTE || t == UNSIGNED_SHORT || t == UNSIGNED_INT;
95 uint32_t Component::Size(Type t)
113 uint32_t AccessorType::ElementCount(Type t)
115 return ACCESSOR_TYPE_ELEMENT_COUNT[t];
118 uint32_t ComponentTypedBufferViewClient::GetBytesPerComponent() const
120 return Component::Size(mComponentType);
123 void Node::SetMatrix(const Matrix& m)
125 m.GetTransformComponents(mTranslation, mRotation, mScale);
128 Quaternion ReadQuaternion(const json_value_s& j)
130 return Quaternion(ReadDaliVector<Vector4>(j));