void LodComponent::Deserialize(KeyedArchive *archive, SceneFileV2 *sceneFile) { if(NULL != archive) { if(archive->IsKeyExists("lc.flags")) flags = archive->GetUInt32("lc.flags"); if(archive->IsKeyExists("lc.forceDistance")) forceDistance = archive->GetFloat("lc.forceDistance"); if(archive->IsKeyExists("lc.forceDistanceSq")) forceDistanceSq = archive->GetFloat("lc.forceDistanceSq"); if(archive->IsKeyExists("lc.forceLodLayer")) forceLodLayer = archive->GetInt32("lc.forceLodLayer"); KeyedArchive *lodDistArch = archive->GetArchive("lc.loddist"); if(NULL != lodDistArch) { for(uint32 i = 0; i < MAX_LOD_LAYERS; ++i) { KeyedArchive *lodDistValuesArch = lodDistArch->GetArchive(KeyedArchive::GenKeyFromIndex(i)); if(NULL != lodDistValuesArch) { lodLayersArray[i].distance = lodDistValuesArch->GetFloat("ld.distance"); lodLayersArray[i].nearDistance = lodDistValuesArch->GetFloat("ld.neardist"); lodLayersArray[i].farDistance = lodDistValuesArch->GetFloat("ld.fardist"); lodLayersArray[i].nearDistanceSq = lodDistValuesArch->GetFloat("ld.neardistsq"); lodLayersArray[i].farDistanceSq = lodDistValuesArch->GetFloat("ld.fardistsq"); } } } KeyedArchive *lodDataArch = archive->GetArchive("lc.loddata"); if(NULL != lodDataArch) { for(uint32 i = 0; i < archive->GetUInt32("lc.loddatacount"); ++i) { KeyedArchive *lodDataValuesArch = lodDataArch->GetArchive(KeyedArchive::GenKeyFromIndex(i)); if(NULL != lodDataValuesArch) { LodData data; if(lodDataValuesArch->IsKeyExists("layer")) data.layer = lodDataValuesArch->GetInt32("layer"); if(lodDataValuesArch->IsKeyExists("isdummy")) data.isDummy = lodDataValuesArch->GetBool("isdummy"); KeyedArchive *lodDataIndexesArch = lodDataValuesArch->GetArchive("indexes"); if(NULL != lodDataIndexesArch) { for(uint32 j = 0; j < lodDataValuesArch->GetUInt32("indexescount"); ++j) { data.indexes.push_back(lodDataIndexesArch->GetInt32(KeyedArchive::GenKeyFromIndex(j))); } } lodLayers.push_back(data); } } } } flags |= NEED_UPDATE_AFTER_LOAD; Component::Deserialize(archive, sceneFile); }
bool NodesPropertyControl::GetHeaderState(const String & headerName, bool defaultValue) { KeyedArchive *settings = EditorSettings::Instance()->GetSettings(); return settings->GetBool("NodesProperety." + headerName, defaultValue); }
void NodesPropertyControl::ReadFrom(Entity *sceneNode) { SafeRelease(currentSceneNode); currentSceneNode = SafeRetain(sceneNode); currentDataNode = NULL; ReleaseChildLodData(); propertyList->ReleaseProperties(); if(!createNodeProperties) { propertyList->AddSection("property.scenenode.generalc++", GetHeaderState("property.scenenode.generalc++", true)); propertyList->AddIntProperty("property.scenenode.retaincount", PropertyList::PROPERTY_IS_READ_ONLY); propertyList->AddStringProperty("property.scenenode.classname", PropertyList::PROPERTY_IS_READ_ONLY); propertyList->AddStringProperty("property.scenenode.c++classname", PropertyList::PROPERTY_IS_READ_ONLY); propertyList->AddStringProperty("property.scenenode.ptr", PropertyList::PROPERTY_IS_READ_ONLY); // for (uint32 k = 0; k < Component::COMPONENT_COUNT; ++k) // { // propertyList->AddStringProperty(Format("Component:%s", sceneNode->components sa M. zz)) // } propertyList->SetIntPropertyValue("property.scenenode.retaincount", sceneNode->GetRetainCount()); propertyList->SetStringPropertyValue("property.scenenode.classname", sceneNode->GetClassName()); propertyList->SetStringPropertyValue("property.scenenode.c++classname", typeid(*sceneNode).name()); propertyList->SetStringPropertyValue("property.scenenode.ptr", Format("%p", sceneNode)); AABBox3 unitBox = sceneNode->GetWTMaximumBoundingBoxSlow(); if((-AABBOX_INFINITY != unitBox.max.x) && (AABBOX_INFINITY != unitBox.min.x)) { propertyList->AddSubsection(String("Unit size")); Vector3 size = unitBox.max - unitBox.min; propertyList->AddFloatProperty(String("X-Size"), PropertyList::PROPERTY_IS_READ_ONLY); propertyList->SetFloatPropertyValue(String("X-Size"), size.x); propertyList->AddFloatProperty(String("Y-Size"), PropertyList::PROPERTY_IS_READ_ONLY); propertyList->SetFloatPropertyValue(String("Y-Size"), size.y); propertyList->AddFloatProperty(String("Z-Size"), PropertyList::PROPERTY_IS_READ_ONLY); propertyList->SetFloatPropertyValue(String("Z-Size"), size.z); } } propertyList->AddSection("property.scenenode.scenenode", GetHeaderState("property.scenenode.scenenode", true)); propertyList->AddStringProperty(SCENE_NODE_NAME_PROPERTY_NAME, PropertyList::PROPERTY_IS_EDITABLE); propertyList->SetStringPropertyValue(SCENE_NODE_NAME_PROPERTY_NAME, sceneNode->GetName()); if(!createNodeProperties) { propertyList->AddBoolProperty(SCENE_NODE_IS_VISIBLE_PROPERTY_NAME, PropertyList::PROPERTY_IS_EDITABLE); propertyList->SetBoolPropertyValue(SCENE_NODE_IS_VISIBLE_PROPERTY_NAME, sceneNode->GetVisible()); propertyList->AddSection("property.scenenode.matrixes", GetHeaderState("property.scenenode.matrixes", false)); propertyList->AddMatrix4Property("property.scenenode.localmatrix", PropertyList::PROPERTY_IS_EDITABLE); propertyList->AddMatrix4Property("property.scenenode.worldmatrix", PropertyList::PROPERTY_IS_READ_ONLY); propertyList->SetMatrix4PropertyValue("property.scenenode.localmatrix", sceneNode->GetLocalTransform()); propertyList->SetMatrix4PropertyValue("property.scenenode.worldmatrix", sceneNode->GetWorldTransform()); } { //static light propertyList->AddSection("Used in static lighting", GetHeaderState("Used in static lighting", true)); propertyList->AddBoolProperty(SCENE_NODE_USED_IN_STATIC_LIGHTING_PROPERTY_NAME); propertyList->SetBoolPropertyValue(SCENE_NODE_USED_IN_STATIC_LIGHTING_PROPERTY_NAME, sceneNode->GetCustomProperties()->GetBool("editor.staticlight.used", true)); propertyList->AddBoolProperty(SCENE_NODE_CAST_SHADOWS_PROPERTY_NAME); propertyList->SetBoolPropertyValue(SCENE_NODE_CAST_SHADOWS_PROPERTY_NAME, sceneNode->GetCustomProperties()->GetBool("editor.staticlight.castshadows", true)); propertyList->AddBoolProperty(SCENE_NODE_RECEIVE_SHADOWS_PROPERTY_NAME); propertyList->SetBoolPropertyValue(SCENE_NODE_RECEIVE_SHADOWS_PROPERTY_NAME, sceneNode->GetCustomProperties()->GetBool("editor.staticlight.receiveshadows", true)); } { // LodNodes at Hierarchy LodComponent *lodComponent = GetLodComponent(currentSceneNode); if(!lodComponent) { AddChildLodSection(); } } //must be last if(!createNodeProperties) { propertyList->AddSection("property.scenenode.customproperties", GetHeaderState("property.scenenode.customproperties", true)); KeyedArchive *customProperties = sceneNode->GetCustomProperties(); Map<String, VariantType*> propsData = customProperties->GetArchieveData(); for (Map<String, VariantType*>::iterator it = propsData.begin(); it != propsData.end(); ++it) { String name = it->first; VariantType * key = it->second; if(EditorConfig::Instance()->HasProperty(name)) { EditorConfig::Instance()->AddPropertyEditor(propertyList, name, key); } else { switch (key->type) { case VariantType::TYPE_BOOLEAN: propertyList->AddBoolProperty(name, PropertyList::PROPERTY_IS_EDITABLE); propertyList->SetBoolPropertyValue(name, key->AsBool()); break; case VariantType::TYPE_STRING: propertyList->AddStringProperty(name, PropertyList::PROPERTY_IS_EDITABLE); propertyList->SetStringPropertyValue(name, key->AsString()); break; case VariantType::TYPE_INT32: propertyList->AddIntProperty(name, PropertyList::PROPERTY_IS_EDITABLE); propertyList->SetIntPropertyValue(name, key->AsInt32()); break; case VariantType::TYPE_FLOAT: propertyList->AddFloatProperty(name, PropertyList::PROPERTY_IS_EDITABLE); propertyList->SetFloatPropertyValue(name, key->AsFloat()); break; default: break; } } } } else { KeyedArchive *customProperties = sceneNode->GetCustomProperties(); if(customProperties && customProperties->IsKeyExists("editor.isLocked")) { propertyList->AddSection("property.scenenode.customproperties", GetHeaderState("property.scenenode.customproperties", true)); propertyList->AddBoolProperty("editor.isLocked", PropertyList::PROPERTY_IS_EDITABLE); propertyList->SetBoolPropertyValue("editor.isLocked", customProperties->GetBool("editor.isLocked")); } } }