void LodNodePropertyControl::ReadFrom(Entity * sceneNode) { NodesPropertyControl::ReadFrom(sceneNode); LodComponent *lodComponent = GetLodComponent(sceneNode); DVASSERT(lodComponent); propertyList->AddSection("property.lodnode", GetHeaderState("property.lodnode", true)); propertyList->AddBoolProperty("property.lodnode.forcedistance"); propertyList->SetBoolPropertyValue("property.lodnode.forcedistance", false); propertyList->AddSliderProperty("property.lodnode.distanceslider", false); propertyList->SetSliderPropertyValue("property.lodnode.distanceslider", 0, LodComponent::MAX_LOD_DISTANCE, LodComponent::MIN_LOD_DISTANCE); int32 lodCount = lodComponent->GetLodLayersCount(); if(1 < lodCount) { propertyList->AddDistanceProperty("property.lodnode.distances"); float32 *distances = new float32[lodComponent->GetLodLayersCount()]; int32 *triangles = new int32[lodComponent->GetLodLayersCount()]; Vector<LodComponent::LodData*> lodLayers; lodComponent->GetLodData(lodLayers); Vector<LodComponent::LodData*>::const_iterator lodLayerIt = lodLayers.begin(); for(int32 i = 0; i < lodComponent->GetLodLayersCount(); ++i) { distances[i] = lodComponent->GetLodLayerDistance(i); LodComponent::LodData *layer = *lodLayerIt; triangles[i] = GetTrianglesForLodLayer(layer); ++lodLayerIt; } propertyList->SetDistancePropertyValue("property.lodnode.distances", distances, triangles, lodComponent->GetLodLayersCount()); SafeDeleteArray(distances); SafeDeleteArray(triangles); } }
void SceneValidator::ValidateLodComponent(Entity *ownerNode, Set<String> &errorsLog) { LodComponent *lodComponent = GetLodComponent(ownerNode); if(!lodComponent) return; int32 layersCount = lodComponent->GetLodLayersCount(); if (GetEmitter(ownerNode)) layersCount = LodComponent::MAX_LOD_LAYERS; if(layersCount == 0) { errorsLog.insert(Format("Node %s: Count of layers is 0", ownerNode->GetName().c_str())); } for(int32 layer = 0; layer < layersCount; ++layer) { float32 distance = lodComponent->GetLodLayerDistance(layer); if(LodComponent::INVALID_DISTANCE == distance) { //TODO: why this function isn't realized for lodcomponent? lodComponent->SetLodLayerDistance(layer, LodComponent::GetDefaultDistance(layer)); errorsLog.insert(Format("Node %s: lod distances weren't correct. Re-save.", ownerNode->GetName().c_str())); } } Vector<LodComponent::LodData *>lodLayers; lodComponent->GetLodData(lodLayers); Vector<LodComponent::LodData *>::const_iterator endIt = lodLayers.end(); int32 layer = 0; for(Vector<LodComponent::LodData *>::iterator it = lodLayers.begin(); it != endIt; ++it, ++layer) { LodComponent::LodData * ld = *it; if(ld->layer != layer) { ld->layer = layer; errorsLog.insert(Format("Node %s: lod layers weren't correct. Rename childs. Re-save.", ownerNode->GetName().c_str())); } } }