diff --git a/src/Aardvark.Rendering.PointSet/LodTreeInstance.fs b/src/Aardvark.Rendering.PointSet/LodTreeInstance.fs index 95df23d..a935902 100644 --- a/src/Aardvark.Rendering.PointSet/LodTreeInstance.fs +++ b/src/Aardvark.Rendering.PointSet/LodTreeInstance.fs @@ -17,6 +17,7 @@ module LodTreeInstance = module Semantic = let Intensities = Sym.ofString "Intensities" let Classifications = Sym.ofString "Classifications" + let PartIndices = Sym.ofString "PartIndices" module private AsciiFormatParser = open System.Text.RegularExpressions @@ -105,6 +106,7 @@ module LodTreeInstance = root : Option, parent : Option, level : int, + partIndexOffset : int, self : IPointCloudNode) as this = let customAttributeId = fst getCustomIndexedAttributes @@ -134,7 +136,8 @@ module LodTreeInstance = (self : IPointCloudNode) (globalTrafo : Similarity3d) (localBounds : Box3d) - (level : int) = + (level : int) + (partIndexOffset : int) = let cid = let customIndexedAttributeId = customIndexedAttributes |> MapExt.values |> Seq.map (fun ci -> string ci.Id) |> String.concat "." cacheId self customIndexedAttributeId globalTrafo level @@ -194,12 +197,25 @@ module LodTreeInstance = attributes.[Semantic.Classifications] <- arr vertexSize <- vertexSize + 4L + if MapExt.containsKey "PartIndices" ips then + let arr = + match self.TryGetPartIndices() with + | (true, v) -> + v |> Array.map (fun i -> i + partIndexOffset) + | _ -> + Array.replicate original.Length -1 + + attributes.[Semantic.PartIndices] <- arr + vertexSize <- vertexSize + 4L + customIndexedAttributes |> MapExt.iter (fun sym { AttribSize = size; Attrib = arr } -> if MapExt.containsKey (sym.ToString()) ips then attributes.[sym] <- arr vertexSize <- vertexSize + size ) + + if MapExt.containsKey "AvgPointDistance" ips then let dist = match self.HasPointDistanceAverage with @@ -394,14 +410,14 @@ module LodTreeInstance = //member x.AcquireChild() = // Interlocked.Increment(&livingChildren) |> ignore - static member Create(pointCloudId : System.Guid, world : obj, cache : LruDictionary, source : Symbol, getCustomIndexedAttributes : Guid * (IPointCloudNode -> int -> MapExt), globalTrafo : Similarity3d, root : Option, parent : Option, level : int, self : IPointCloudNode) = + static member Create(pointCloudId : System.Guid, world : obj, cache : LruDictionary, source : Symbol, getCustomIndexedAttributes : Guid * (IPointCloudNode -> int -> MapExt), globalTrafo : Similarity3d, root : Option, parent : Option, level : int, partIndexOffset : int, self : IPointCloudNode) = if isNull self then None else - PointTreeNode(pointCloudId, world, cache, source, getCustomIndexedAttributes, globalTrafo, root, parent, level, self) |> Some + PointTreeNode(pointCloudId, world, cache, source, getCustomIndexedAttributes, globalTrafo, root, parent, level, partIndexOffset, self) |> Some - static member Create(pointCloudId : System.Guid, world : obj, cache : LruDictionary, source : Symbol, globalTrafo : Similarity3d, root : Option, parent : Option, level : int, self : IPointCloudNode) = - PointTreeNode.Create(pointCloudId, world, cache, source, (Guid.NewGuid(),(fun _ _ -> MapExt.empty)), globalTrafo, root, parent, level, self) + static member Create(pointCloudId : System.Guid, world : obj, cache : LruDictionary, source : Symbol, globalTrafo : Similarity3d, root : Option, parent : Option, level : int, partIndexOffset : int, self : IPointCloudNode) = + PointTreeNode.Create(pointCloudId, world, cache, source, (Guid.NewGuid(),(fun _ _ -> MapExt.empty)), globalTrafo, root, parent, level, partIndexOffset, self) member x.ReleaseChildren() = let old = @@ -430,6 +446,7 @@ module LodTreeInstance = None, None, 0, + partIndexOffset, r ) |> Some @@ -442,7 +459,7 @@ module LodTreeInstance = if isNull n then None else - PointTreeNode(System.Guid.NewGuid(), world, cache, source, (customAttributeId,getCustomIndexedAttributes), globalTrafo, root, parent, level, n) |> Some + PointTreeNode(System.Guid.NewGuid(), world, cache, source, (customAttributeId,getCustomIndexedAttributes), globalTrafo, root, parent, level, partIndexOffset, n) |> Some member x.Acquire() = () @@ -515,7 +532,7 @@ module LodTreeInstance = unbox n |> Some | _ -> //Log.warn "alloc %A" id - PointTreeNode(pointCloudId, world, cache, source, (customAttributeId,getCustomIndexedAttributes), globalTrafo, Some this.Root, Some this, level + 1, c) :> ILodTreeNode |> Some + PointTreeNode(pointCloudId, world, cache, source, (customAttributeId,getCustomIndexedAttributes), globalTrafo, Some this.Root, Some this, level + 1, partIndexOffset, c) :> ILodTreeNode |> Some with | :? ObjectDisposedException -> None @@ -533,7 +550,7 @@ module LodTreeInstance = member x.Id = id member x.GetData(ct, ips) = - load ct ips cache (getCustomIndexedAttributes self level) self globalTrafo localBounds level + load ct ips cache (getCustomIndexedAttributes self level) self globalTrafo localBounds level partIndexOffset member x.ShouldSplit (splitfactor : float, quality : float, view : Trafo3d, proj : Trafo3d) = if isOrtho proj then @@ -880,7 +897,7 @@ module LodTreeInstance = let trafo = Similarity3d(1.0, Euclidean3d(Rot3d.Identity, -bounds.Center)) let source = Symbol.Create sourceName - let root = PointTreeNode.Create(System.Guid.NewGuid(), null, store.Cache, source, trafo, None, None, 0, root) + let root = PointTreeNode.Create(System.Guid.NewGuid(), null, store.Cache, source, trafo, None, None, 0, 0, root) match root with | Some root -> let uniforms = MapExt.ofList uniforms @@ -917,9 +934,9 @@ module LodTreeInstance = - let ofPointSet (uniforms : list) (set : PointSet) = + let ofPointSet (uniforms : list) (partIndexOffset : int) (set : PointSet) = let store = set.Storage - let root = PointTreeNode.Create(System.Guid.NewGuid(), null, store.Cache, Symbol.CreateNewGuid(), Similarity3d.Identity, None, None, 0, set.Root.Value) + let root = PointTreeNode.Create(System.Guid.NewGuid(), null, store.Cache, Symbol.CreateNewGuid(), Similarity3d.Identity, None, None, 0, partIndexOffset, set.Root.Value) match root with | Some root -> let uniforms = MapExt.ofList uniforms @@ -930,9 +947,9 @@ module LodTreeInstance = | None -> None - let ofPointCloudNode (uniforms : list) (root : IPointCloudNode) = + let ofPointCloudNode (uniforms : list) (partIndexOffset : int) (root : IPointCloudNode) = let store = root.Storage - let root = PointTreeNode.Create(System.Guid.NewGuid(), null, store.Cache, Symbol.CreateNewGuid(), Similarity3d.Identity, None, None, 0, root) + let root = PointTreeNode.Create(System.Guid.NewGuid(), null, store.Cache, Symbol.CreateNewGuid(), Similarity3d.Identity, None, None, 0, partIndexOffset, root) match root with | Some root -> let uniforms = MapExt.ofList uniforms diff --git a/src/Aardvark.Rendering.PointSet/LodTreeSceneGraph.fs b/src/Aardvark.Rendering.PointSet/LodTreeSceneGraph.fs index 173b442..77ec2c6 100644 --- a/src/Aardvark.Rendering.PointSet/LodTreeSceneGraph.fs +++ b/src/Aardvark.Rendering.PointSet/LodTreeSceneGraph.fs @@ -200,6 +200,7 @@ module private DeferredPointSetShaders = [] c : V2d [] n : V3d [] id : int + [] partIndex : int [] treeDepth : int [] n32 : int [] fc : V4d @@ -209,11 +210,30 @@ module private DeferredPointSetShaders = [] let div (v : V4d) = v.XYZ / v.W - let colorOrWhite (v : Effects.Vertex) = + + let mapColors = + [| + C4b(141uy, 211uy, 199uy, 255uy) + C4b(255uy, 255uy, 179uy, 255uy) + C4b(190uy, 186uy, 218uy, 255uy) + C4b(251uy, 128uy, 114uy, 255uy) + C4b(128uy, 177uy, 211uy, 255uy) + C4b(253uy, 180uy, 98uy, 255uy) + C4b(179uy, 222uy, 105uy, 255uy) + C4b(252uy, 205uy, 229uy, 255uy) + C4b(217uy, 217uy, 217uy, 255uy) + C4b(188uy, 128uy, 189uy, 255uy) + C4b(204uy, 235uy, 197uy, 255uy) + + |] |> Array.map (fun c -> c.ToC4f().ToV4d()) + + + let colorOrWhite (v : PointVertex) = vertex { - let mutable color = v.c - if not uniform?ShowColors then color <- V4d.IIII - return { v with c = color } + let mutable color = v.col + if not uniform?ShowColors then + color <- mapColors.[(v.partIndex+11)%11] + return { v with col = color } } let lodPointSize (v : PointVertex) = diff --git a/src/Apps/Viewer/Program.fs b/src/Apps/Viewer/Program.fs index 4704a7e..6bda050 100644 --- a/src/Apps/Viewer/Program.fs +++ b/src/Apps/Viewer/Program.fs @@ -5,14 +5,16 @@ open Aardvark.Algodat.App.Viewer [] let main args = - //let pts = @"C:\Users\Spot\Desktop\Laserscan-MS60_Beiglboeck-2015.pts" - //import pts @"C:\Users\Spot\Desktop\teststore" "a" (Args.parse [||]) + //let pts = @"C:\bla\TEST DATEI_resampled.laz" + //import pts @"C:\bla\TestdateiStore\data.uds" "a" (Args.parse [||]) + //exit 0 + //view @"C:\stores\innen_store" ["a2b7e0c1-e672-48d3-8958-9ff8678f2dc4"] (Args.parse [||]) //view @"C:\Users\sm\Downloads\C_31EN2.LAZ.store" [File.readAllText @"C:\Users\sm\Downloads\C_31EN2.LAZ.key"] (Args.parse [||]) //view @"C:\Users\sm\Downloads\C_30DN2.LAZ.store" [File.readAllText @"C:\Users\sm\Downloads\C_30DN2.LAZ.key"] (Args.parse [||]) //view @"C:\Users\sm\Downloads\test.store" ["128330b1-8761-4a07-b160-76bcd7e2f70a"; "ab2f6f76-7eae-47c9-82d1-ad28b816abb9"] (Args.parse [||]) - let store = @"E:\e57tests\stores\inference_full.binary.ply\data.uds" + let store = @"C:\bla\store\lowergetikum\data.bin" let key = Path.combine [System.IO.Path.GetDirectoryName store;"key.txt"] |> File.readAllText view store [key] (Args.parse [||]) diff --git a/src/Apps/Viewer/Rendering.fs b/src/Apps/Viewer/Rendering.fs index 290e274..93a5fb8 100644 --- a/src/Apps/Viewer/Rendering.fs +++ b/src/Apps/Viewer/Rendering.fs @@ -110,12 +110,12 @@ module Rendering = let picktrees : cmap = cmap() let config = { - pointSize = AVal.init 0.8 + pointSize = AVal.init 0.225 overlayAlpha = AVal.init 0.0 maxSplits = AVal.init 8 renderBounds = AVal.init false sort = AVal.init false - splitfactor = AVal.init 0.45 + splitfactor = AVal.init 0.1 budget = AVal.init -(256L <<< 10) lighting = AVal.init true colors = AVal.init false @@ -133,7 +133,7 @@ module Rendering = ssaoSharpness = AVal.init 4.0 } - + let pcs = pcs |> ASet.map (fun t -> @@ -322,10 +322,10 @@ module Rendering = | Keys.D9 -> transact (fun () -> config.ssaoSigma.Value <- max 0.0 (config.ssaoSigma.Value - 0.1)); Log.line "sigma: %A" config.ssaoSigma.Value | Keys.D8 -> transact (fun () -> config.ssaoSamples.Value <- min 8 (config.ssaoSamples.Value + 1)); Log.line "samples: %A" config.ssaoSamples.Value - | Keys.D7 -> transact (fun () -> config.ssaoSamples.Value <- max 1 (config.ssaoSamples.Value - 1)); Log.line "samples: %A" config.ssaoSamples.Value + //| Keys.D7 -> transact (fun () -> config.ssaoSamples.Value <- max 1 (config.ssaoSamples.Value - 1)); Log.line "samples: %A" config.ssaoSamples.Value - | Keys.D6 -> transact (fun () -> config.ssaoSampleDirections.Value <- min 8 (config.ssaoSampleDirections.Value + 1)); Log.line "dirs: %A" config.ssaoSampleDirections.Value - | Keys.D5 -> transact (fun () -> config.ssaoSampleDirections.Value <- max 1 (config.ssaoSampleDirections.Value - 1)); Log.line "dirs: %A" config.ssaoSampleDirections.Value + // | Keys.D6 -> transact (fun () -> config.ssaoSampleDirections.Value <- min 8 (config.ssaoSampleDirections.Value + 1)); Log.line "dirs: %A" config.ssaoSampleDirections.Value + //| Keys.D5 -> transact (fun () -> config.ssaoSampleDirections.Value <- max 1 (config.ssaoSampleDirections.Value - 1)); Log.line "dirs: %A" config.ssaoSampleDirections.Value | Keys.D4 -> transact (fun () -> config.ssaoRadius.Value <- min 2.0 (config.ssaoRadius.Value + 0.01)); Log.line "radius: %A" config.ssaoRadius.Value | Keys.D3 -> transact (fun () -> config.ssaoRadius.Value <- max 0.01 (config.ssaoRadius.Value - 0.01)); Log.line "radius: %A" config.ssaoRadius.Value @@ -528,19 +528,40 @@ module Rendering = V3d.III * 6.0, V3d.Zero ) let speed = AVal.init 2.0 + + let initial = CameraView.ofTrafo <| Trafo3d.Parse "[[[-0.707106781186548, 0.707106781186548, 0, 0], [-0.408248290463863, -0.408248290463863, 0.816496580927726, 0], [0.577350269189626, 0.577350269189626, 0.577350269189626, -342.288592930008], [0, 0, 0, 1]], [[-0.707106781186548, -0.408248290463863, 0.577350269189626, 197.620411268678], [0.707106781186548, -0.408248290463863, 0.577350269189626, 197.620411268678], [0, 0.816496580927726, 0.577350269189626, 197.620411268678], [0, 0, 0, 1]]]" + let target = CameraView.ofTrafo <| Trafo3d.Parse "[[[-0.567502843343406, 0.823371436714408, 0, -0.0700798647066693], [-0.362138228540449, -0.249601170524128, 0.898084160367263, 0.212820843806073], [0.739456845412046, 0.509665314570097, 0.439823647496845, -1.68800745703926], [0, 0, 0, 1]], [[-0.567502843343406, -0.362138228540449, 0.739456845412046, 1.28550871010452], [0.823371436714408, -0.249601170524128, 0.509665314570097, 0.971140942202795], [0, 0.898084160367263, 0.439823647496845, 0.551294567938653], [0, 0, 0, 1]]]" + + + + let custom = AVal.init None + let camera = + custom |> AVal.bind (fun (custom : Option) -> + printfn "%A" (locAndCenter |> AVal.force) + printfn "%A" (initial.Location) + match custom with + | None -> + locAndCenter |> AVal.bind (fun (loc, center) -> + CameraView.lookAt loc center V3d.OOI + |> DefaultCameraController.controlWithSpeed speed win.Mouse win.Keyboard win.Time + ) + | Some cv -> + locAndCenter |> AVal.map (fun (_,center) -> + cv.WithLocation (cv.Location + center) + ) + //AVal.constant cv + ) + //let bb = Box3d.FromCenterAndSize(V3d.Zero, V3d.III * 300.0) + win.Keyboard.DownWithRepeats.Values.Add(function | Keys.PageUp | Keys.Up -> transact(fun () -> speed.Value <- speed.Value * 1.5) | Keys.PageDown | Keys.Down -> transact(fun () -> speed.Value <- speed.Value / 1.5) + | Keys.D5 -> transact(fun () -> custom.Value <- Some initial) + | Keys.D6 -> transact(fun () -> custom.Value <- Some target) + | Keys.D7 -> transact(fun () -> custom.Value <- None) | _ -> () ) - let camera = - locAndCenter |> AVal.bind (fun (loc, center) -> - CameraView.lookAt loc center V3d.OOI - |> DefaultCameraController.controlWithSpeed speed win.Mouse win.Keyboard win.Time - ) - //let bb = Box3d.FromCenterAndSize(V3d.Zero, V3d.III * 300.0) - let frustum = AVal.custom (fun t -> let s = win.Sizes.GetValue t