public void ExtractSparseOctreeAux(Node node, RT.CS.Node sNode) { for (int i = 0; i < 8; i++) { Node child = node.children[i]; if (child != null) { if (sNode.children == null) { sNode.children = new RT.CS.Node[8]; } sNode.children[i] = new RT.CS.Node(child.position, child.size, sNode.level + 1, false); if (child.chunk != null) { sNode.leaf = true; sNode.color = UtilFuncs.SinColor(sNode.position.x + sNode.position.y + sNode.position.z); sNode.normal = Vector3.up; } else { ExtractSparseOctreeAux(child, sNode.children[i]); } } } }
void UpdateMasterOctree() { RT.CS.NaiveCreator creator = new RT.CS.NaiveCreator(); RT.CS.Node sOctree = octree.ExtractSparseOctree(); int sphereIndex = 10000; RT.SVOData data = creator.Create(sOctree, x => sphereIndex); raytracingMaster.SetSVOBuffer(data); Debug.Log("Num child descriptors: " + data.childDescriptors.Count); string log = "SVO Trunk: \n"; log += "Compressed:\n" + string.Join("\n", data.childDescriptors.ConvertAll(code => new RT.CS.ChildDescriptor(code))) + "\n\n"; string path = Application.dataPath + "/trunkSVO.log"; System.IO.File.WriteAllText(path, log); RT.SVOData sphereData = creator.Create(SampleFunctions.functions[1], 4); raytracingMaster.SetSVOBuffer(sphereData, sphereIndex); }
public RT.CS.Node ExtractSparseOctree() { RT.CS.Node sRoot = new RT.CS.Node(root.position, root.size, 1, false); ExtractSparseOctreeAux(root, sRoot); return(sRoot); }