}
///@brief Reads arc properties.
-void ReadArcField(const TreeNode* eArc, ArcNode& arc)
+void ReadArcField(const TreeNode* eArc, ArcRenderable& arc)
{
ReadBool(eArc->GetChild("antiAliasing"), arc.mAntiAliasing);
ReadInt(eArc->GetChild("arcCaps"), arc.mArcCaps);
}
}
-} //namespace
+} // namespace
struct DliLoader::Impl
{
// get index of root node.
auto docRoot = mParser.GetRoot();
-
- // Process resources first - these are shared
- if(auto environments = docRoot->GetChild("environment"))
+ if(docRoot)
{
- ParseEnvironments(environments, output.mResources); // NOTE: must precede parsing of materials
- }
+ // Process resources first - these are shared
+ if(auto environments = docRoot->GetChild("environment"))
+ {
+ ParseEnvironments(environments, output.mResources); // NOTE: must precede parsing of materials
+ }
- if(auto meshes = docRoot->GetChild("meshes"))
- {
- ParseMeshes(meshes, output.mResources);
- }
+ if(auto meshes = docRoot->GetChild("meshes"))
+ {
+ ParseMeshes(meshes, output.mResources);
+ }
- if(auto shaders = docRoot->GetChild("shaders"))
- {
- ParseShaders(shaders, output.mResources);
- }
+ if(auto shaders = docRoot->GetChild("shaders"))
+ {
+ ParseShaders(shaders, output.mResources);
+ }
- if(auto materials = docRoot->GetChild("materials"))
- {
- ParseMaterials(materials, input.mConvertColorCode, output.mResources);
- }
+ if(auto materials = docRoot->GetChild("materials"))
+ {
+ ParseMaterials(materials, input.mConvertColorCode, output.mResources);
+ }
- for(auto& c : input.mPreNodeCategoryProcessors)
- {
- if(auto node = docRoot->GetChild(c.first))
+ for(auto& c : input.mPreNodeCategoryProcessors)
{
- Property::Array array;
- ParseProperties(*node, array);
- c.second(std::move(array), mOnError);
+ if(auto node = docRoot->GetChild(c.first))
+ {
+ Property::Array array;
+ ParseProperties(*node, array);
+ c.second(std::move(array), mOnError);
+ }
}
- }
- // Process scenes
- Index iScene = 0; // default scene
- ReadIndex(docRoot->GetChild("scene"), iScene);
+ // Process scenes
+ Index iScene = 0; // default scene
+ ReadIndex(docRoot->GetChild("scene"), iScene);
- auto tnScenes = RequireChild(docRoot, "scenes");
- auto tnNodes = RequireChild(docRoot, "nodes");
- ParseSceneInternal(iScene, tnScenes, tnNodes, params);
+ auto tnScenes = RequireChild(docRoot, "scenes");
+ auto tnNodes = RequireChild(docRoot, "nodes");
+ ParseSceneInternal(iScene, tnScenes, tnNodes, params);
- ParseSkeletons(docRoot->GetChild("skeletons"), output.mScene, output.mResources);
+ ParseSkeletons(docRoot->GetChild("skeletons"), output.mScene, output.mResources);
- output.mScene.EnsureUniqueSkinningShaderInstances(output.mResources);
- output.mScene.EnsureUniqueBlendShapeShaderInstances(output.mResources);
+ output.mScene.EnsureUniqueSkinningShaderInstances(output.mResources);
+ output.mScene.EnsureUniqueBlendShapeShaderInstances(output.mResources);
- // Ger cameras and lights
- GetCameraParameters(output.mCameraParameters);
- GetLightParameters(output.mLightParameters);
+ // Ger cameras and lights
+ GetCameraParameters(output.mCameraParameters);
+ GetLightParameters(output.mLightParameters);
- // Post-node processors and animations last
- for(auto& c : input.mPostNodeCategoryProcessors)
- {
- if(auto node = docRoot->GetChild(c.first))
+ // Post-node processors and animations last
+ for(auto& c : input.mPostNodeCategoryProcessors)
{
- Property::Array array;
- ParseProperties(*node, array);
- c.second(std::move(array), mOnError);
+ if(auto node = docRoot->GetChild(c.first))
+ {
+ Property::Array array;
+ ParseProperties(*node, array);
+ c.second(std::move(array), mOnError);
+ }
}
- }
- if(auto animations = docRoot->GetChild("animations"))
- {
- ParseAnimations(animations, params);
- }
+ if(auto animations = docRoot->GetChild("animations"))
+ {
+ ParseAnimations(animations, params);
+ }
- if(!output.mAnimationDefinitions.empty())
- {
- if(auto animationGroups = docRoot->GetChild("animationGroups"))
+ if(!output.mAnimationDefinitions.empty())
{
- ParseAnimationGroups(animationGroups, params);
+ if(auto animationGroups = docRoot->GetChild("animationGroups"))
+ {
+ ParseAnimationGroups(animationGroups, params);
+ }
}
}
}
default:
mOnError(FormatString(
- "shader %d: Ignoring uniform '%s': failed to infer type from %d elements.",
+ "shader %u: Ignoring uniform '%s': failed to infer type from %zu elements.",
iShader,
- key.c_str()));
+ key.c_str(),
+ size));
break;
}
}
}
- //TODO : need to consider AGIF
+ // TODO : need to consider AGIF
std::vector<std::string> texturePaths;
std::string texturePath;
if(ReadString(node.GetChild("albedoMap"), texturePath))
virtual unsigned int Resolve(Index iDli) override
{
- auto iFind = std::lower_bound(mIndices.begin(), mIndices.end(), iDli, [](const Entry& idx, Index iDli) {
- return idx.iDli < iDli;
- });
+ auto iFind = std::lower_bound(mIndices.begin(), mIndices.end(), iDli, [](const Entry& idx, Index iDli) { return idx.iDli < iDli; });
DALI_ASSERT_ALWAYS(iFind != mIndices.end());
return iFind->iScene;
}
else // something renderable maybe
{
std::unique_ptr<NodeDefinition::Renderable> renderable;
- ModelNode* modelNode = nullptr; // no ownership, aliasing renderable for the right type.
+ ModelRenderable* modelRenderable = nullptr; // no ownership, aliasing renderable for the right type.
const TreeNode* eRenderable = nullptr;
if((eRenderable = node->GetChild("model")))
ExceptionFlinger(ASSERT_LOCATION) << "node " << nodeDef.mName << ": Missing mesh definition.";
}
- modelNode = new ModelNode();
- renderable.reset(modelNode);
+ modelRenderable = new ModelRenderable();
+ renderable.reset(modelRenderable);
- resourceIds.push_back({ResourceType::Mesh, eMesh, modelNode->mMeshIdx});
+ resourceIds.push_back({ResourceType::Mesh, eMesh, modelRenderable->mMeshIdx});
}
else if((eRenderable = node->GetChild("arc")))
{
ExceptionFlinger(ASSERT_LOCATION) << "node " << nodeDef.mName << ": Missing mesh definition.";
}
- auto arcNode = new ArcNode;
- renderable.reset(arcNode);
- modelNode = arcNode;
+ auto arcRenderable = new ArcRenderable;
+ renderable.reset(arcRenderable);
+ modelRenderable = arcRenderable;
- resourceIds.push_back({ResourceType::Mesh, eMesh, arcNode->mMeshIdx});
+ resourceIds.push_back({ResourceType::Mesh, eMesh, arcRenderable->mMeshIdx});
- ReadArcField(eRenderable, *arcNode);
+ ReadArcField(eRenderable, *arcRenderable);
}
- if(renderable) // process common properties of all renderables + register payload
+ if(renderable && eRenderable != nullptr) // process common properties of all renderables + register payload
{
// shader
renderable->mShaderIdx = 0;
auto eShader = eRenderable->GetChild("shader");
- resourceIds.push_back({ResourceType::Shader, eShader, renderable->mShaderIdx});
+ if(eShader)
+ {
+ resourceIds.push_back({ResourceType::Shader, eShader, renderable->mShaderIdx});
+ }
// color
- if(modelNode)
+ if(modelRenderable)
{
- modelNode->mMaterialIdx = 0; // must offer default of 0
- auto eMaterial = eRenderable->GetChild("material");
- resourceIds.push_back({ResourceType::Material, eMaterial, modelNode->mMaterialIdx});
+ modelRenderable->mMaterialIdx = 0; // must offer default of 0
+ auto eMaterial = eRenderable->GetChild("material");
+ if(eMaterial)
+ {
+ resourceIds.push_back({ResourceType::Material, eMaterial, modelRenderable->mMaterialIdx});
+ }
- if(!ReadColorCodeOrColor(eRenderable, modelNode->mColor, params.input.mConvertColorCode))
+ if(!ReadColorCodeOrColor(eRenderable, modelRenderable->mColor, params.input.mConvertColorCode))
{
- ReadColorCodeOrColor(node, modelNode->mColor, params.input.mConvertColorCode);
+ ReadColorCodeOrColor(node, modelRenderable->mColor, params.input.mConvertColorCode);
}
}
- nodeDef.mRenderable = std::move(renderable);
+ nodeDef.mRenderables.push_back(std::move(renderable));
}
}
const unsigned int myIndex = output.mScene.GetNodeCount();
if(!mapper.Map(index, myIndex))
{
- mOnError(FormatString("node %d: error mapping dli index %d: node has multiple parents. Ignoring subtree."));
+ mOnError(FormatString("node %d: error mapping dli index %d: node has multiple parents. Ignoring subtree.", index, myIndex));
return;
}
AnimationDefinition animDef;
ReadString(tnAnim.GetChild(NAME), animDef.mName);
- auto iFind = std::lower_bound(definitions.begin(), definitions.end(), animDef, [](const AnimationDefinition& ad0, const AnimationDefinition& ad1) {
- return ad0.mName < ad1.mName;
- });
+ auto iFind = std::lower_bound(definitions.begin(), definitions.end(), animDef, [](const AnimationDefinition& ad0, const AnimationDefinition& ad1) { return ad0.mName < ad1.mName; });
const bool overwrite = iFind != definitions.end() && iFind->mName == animDef.mName;
if(overwrite)
{
animProp.mKeyFrames = KeyFrames::New();
- //In binary animation file only is saved the position, rotation, scale and blend shape weight keys.
- //so, if it is vector3 we assume is position or scale keys, if it is vector4 we assume is rotation,
- // otherwise are blend shape weight keys.
- // TODO support for binary header with size information
+ // In binary animation file only is saved the position, rotation, scale and blend shape weight keys.
+ // so, if it is vector3 we assume is position or scale keys, if it is vector4 we assume is rotation,
+ // otherwise are blend shape weight keys.
+ // TODO support for binary header with size information
Property::Type propType = Property::FLOAT; // assume blend shape weights
if(animProp.mPropertyName == "orientation")
{
propType = Property::VECTOR3;
}
- //alphafunction is reserved for future implementation
- // NOTE: right now we're just using AlphaFunction::LINEAR.
+ // alphafunction is reserved for future implementation
+ // NOTE: right now we're just using AlphaFunction::LINEAR.
unsigned char dummyAlphaFunction;
float progress;
continue;
}
- auto iFind = std::lower_bound(animGroups.begin(), animGroups.end(), groupName, [](const AnimationGroupDefinition& group, const std::string& name) {
- return group.mName < name;
- });
+ auto iFind = std::lower_bound(animGroups.begin(), animGroups.end(), groupName, [](const AnimationGroupDefinition& group, const std::string& name) { return group.mName < name; });
if(iFind != animGroups.end() && iFind->mName == groupName)
{
mOnError(FormatString("Animation group with name '%s' already exists; new entries will be merged.", groupName.c_str()));
{
if(const TreeNode* jsonCameras = mParser.GetRoot()->GetChild("cameras"))
{
+ float dummyFloatArray[4];
+
cameras.resize(jsonCameras->Size());
auto iCamera = cameras.begin();
for(auto i0 = jsonCameras->CBegin(), i1 = jsonCameras->CEnd(); i0 != i1; ++i0)
ReadFloat(jsonCamera.GetChild("fov"), iCamera->yFov);
ReadFloat(jsonCamera.GetChild("near"), iCamera->zNear);
ReadFloat(jsonCamera.GetChild("far"), iCamera->zFar);
- if(ReadVector(jsonCamera.GetChild("orthographic"), iCamera->orthographicSize.AsFloat(), 4u))
+ if(ReadVector(jsonCamera.GetChild("orthographic"), dummyFloatArray, 4u))
{
iCamera->isPerspective = false;
+
+ iCamera->orthographicSize = dummyFloatArray[2] * 0.5f;
+ iCamera->aspectRatio = dummyFloatArray[1] / dummyFloatArray[2];
}
if(auto jsonMatrix = jsonCamera.GetChild("matrix"))