本文整理汇总了C++中PropertyDescriptor::Deserialize方法的典型用法代码示例。如果您正苦于以下问题:C++ PropertyDescriptor::Deserialize方法的具体用法?C++ PropertyDescriptor::Deserialize怎么用?C++ PropertyDescriptor::Deserialize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PropertyDescriptor
的用法示例。
在下文中一共展示了PropertyDescriptor::Deserialize方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Deserialize
void BaseEntity::Deserialize(SerializableNodeObject* parentNode, EngineContext* engineContext)
{
if (!parentNode)
{
LOG("Cannot deserialize Entity: Node is null.");
return;
}
// Position.
/*SerializableProperty* positionProp = (SerializableProperty*)parentNode->FindNodeByName("position");
if (positionProp)
this->SetPosition(positionProp->Value.toVec3f());
// Pose.
SerializableProperty* poseProp = (SerializableProperty*)parentNode->FindNodeByName("pose");
if (poseProp)
this->SetPose(poseProp->Value.toMat4f());
// Direction.
SerializableProperty* directionProp = (SerializableProperty*)parentNode->FindNodeByName("direction");
if (directionProp)
this->SetDirection(directionProp->Value.toVec3f());
// Scale.
SerializableProperty* scaleProp = (SerializableProperty*)parentNode->FindNodeByName("scale");
if (scaleProp)
this->SetScale(scaleProp->Value.toVec3f());*/
auto nbNodes = parentNode->GetChildNodesCount();
auto nodes = parentNode->GetChildNodes();
for (size_t i = 0; i < nbNodes; ++i)
{
auto node = nodes[i];
if (node->GetType() == SerializableNodeType::ARRAY && node->Name.toLower() == "properties")
{
auto nbProperties = node->GetChildNodesCount();
auto properties = node->GetChildNodes();
for (size_t p = 0; p < nbProperties; ++p)
{
if (properties[p]->GetType() != SerializableNodeType::OBJECT)
continue;
PropertyDescriptor pDesc;
pDesc.Deserialize((SerializableNodeObject*)properties[p], engineContext);
Property* prop = this->AddProperty(pDesc);
// Look for the value node.
SerializableProperty* valueNode = (SerializableProperty*)properties[p]->FindNodeByName("value");
if (valueNode)
prop->Set(valueNode->Value);
}
}
else if (node->GetType() == SerializableNodeType::ARRAY && node->Name.toLower() == "components")
{
auto nbComponents = node->GetChildNodesCount();
auto components = node->GetChildNodes();
for (size_t c = 0; c < nbComponents; ++c)
{
if (components[c]->GetType() != SerializableNodeType::OBJECT)
continue;
SerializableNodeObject* nodeInfo = (SerializableNodeObject*)components[c];
BaseComponent* component = BaseComponent::DeserializeComponent(nodeInfo, engineContext, this);
if (!component)
{
LOG("Unable to deserialize component. Skipping.");
continue;
}
this->AddComponent(component);
//component->Deserialize(nodeInfo);
}
}
else if (node->GetType() == SerializableNodeType::PROPERTY)
{
if (node->Name.toLower() == "class")
{
this->SetClass(node->Value.c_str());
}
}
}
}