public static void UpdateLodBoxAllow(Sg.LodBox node, bool allowTraversal) { //node.Settings.DeciderCombination = deciderCombination; node.AllowTraversal = allowTraversal; foreach (var subNode in node.DetailNodes) { var lodBox = subNode as Sg.LodBox; if (lodBox != null) { UpdateLodBoxAllow(lodBox, allowTraversal); } } }
private static ISg LodBoxHierarchy( int level, Volume <ISg> vgsVolume, LevelOfDetailSettings settings, int maxLevel) { int detailCount = 1; if (vgsVolume.SX > 1) { detailCount *= 2; } if (vgsVolume.SY > 1) { detailCount *= 2; } if (vgsVolume.SZ > 1) { detailCount *= 2; } //detail count is 1 when space is not dividable #region detailCount == 1 if (detailCount == 1) { //if level > 0 keep subsampling without subdivision if (level > 0) //|| ( level == 0 && (vgsVolume[0, 0, 0].TileSize.X > 256 || vgsVolume[0, 0, 0].TileSize.Y > 256))) { var detailNodeList = LodBoxHierarchy(level - 1, vgsVolume, settings, maxLevel).IntoList(); var dist = DistanceFunc(level - 1, settings); Report.Line("LOD.cs Level " + level + " " + dist); var box = new Sg.LodBox() { Name = "level" + level, DetailNodes = detailNodeList, Settings = new LodBoxSettings { Distance = dist, DeciderCombination = "Distance, ScreenPixToTriSize, ScreenPixToTexPix, VisualImpact => Distance", }, }; box["TileLayout"] = GetTileLayout(vgsVolume.Dim); return(box); } return(vgsVolume[0, 0, 0]); } #endregion var detailNodes = new List <ISg>(detailCount); for (int i = 0; i < 8; i++) { bool valid = true; V3l origin = V3l.Zero; V3l length = vgsVolume.Size; //compute splitting dimensions for each axis for (int dim = 0; dim < 3; dim++) { if ((i & (1 << dim)) == 0) { if (length[dim] > 1) { length[dim] /= 2; } } else { if (length[dim] > 1) { origin[dim] = length[dim] / 2; length[dim] = length[dim] - origin[dim]; } else { valid = false; } } } if (valid) { ISg detailNode = LodBoxHierarchy(level - 1, vgsVolume.SubVolume(origin, length), settings, maxLevel); detailNodes.Add(detailNode); } } { var dist = LevelOfDetail.DistanceFunc(level - 1, settings); //Report.Line("LOD.cs Level " + level + " " + dist); bool isMax = false; // level == maxLevel; var box = new Sg.LodBox() { Name = "level" + level, DetailNodes = detailNodes, Pinned = Sg.LodBox.PinnedOptions.Default, Settings = new LodBoxSettings { Distance = dist, DeciderCombination = !isMax ? "Distance, ScreenPixToTriSize, ScreenPixToTexPix, VisualImpact => Distance" : "Distance, ScreenPixToTriSize, ScreenPixToTexPix, VisualImpact => false", }, }; // s_numOfBoxes++; box["TileLayout"] = GetTileLayout(vgsVolume.Dim); //Report.Line("DIM: " + vgsVolume.Dim.ToString() + " " // + box["TileLayout"].ToString() + " __lvl: " // + level + " Desc.: " + box.DetailNodes.Count()); var sg = Rsg.Apply( new ResourcePinningEnabledValue() { Value = level == maxLevel }, box); return(box); } }