Skip to content

Commit

Permalink
[OpcViewer] multiple opc rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
haraldsteinlechner committed Feb 8, 2024
1 parent f9a6acb commit 9472096
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 20 deletions.
10 changes: 5 additions & 5 deletions src/OpcViewer/Program.fs
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@ let main argv =

let kind = Solarsystem

let jezero =
let shaler =
{
useCompressedTextures = true
preTransform = Trafo3d.Identity
patchHierarchies =
Seq.delay (fun _ ->
System.IO.Directory.GetDirectories(@"I:\OPC\2020-08-06-Jezero-OPC")
System.IO.Directory.GetDirectories(@"K:\PRo3D Data\Shaler_OPCs_2019\Shaler_Navcam")
|> Seq.collect System.IO.Directory.GetDirectories
)
boundingBox = Box3d.Parse("[[709869.947406691, 3140052.258326461, 1075121.095408683], [710116.986329168, 3140296.918390740, 1075374.689812710]]")
boundingBox = Box3d.Parse("[[-2490137.664354247, 2285874.562728135, -271408.476700304], [-2490136.248131170, 2285875.658034266, -271406.605430601]]")
near = 0.1
far = 10000.0
speed = 5.0
Expand All @@ -48,11 +48,11 @@ let main argv =
match kind with

| Solarsystem ->
Solarsytsem.run mola
Solarsytsem.run [mola;]

| Scene ->

TestViewer.run jezero
TestViewer.run shaler

| Annotations ->

Expand Down
36 changes: 21 additions & 15 deletions src/OpcViewer/Solarsystem.fs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ type BodyState =
radius : float
}

let run (scene : OpcScene) =
let run (scenes : list<OpcScene>) =
Aardvark.Init()

use app = new OpenGlApplication()
Expand All @@ -130,16 +130,18 @@ let run (scene : OpcScene) =
if r <> 0 then failwith "could not add spice kernel"

let hierarchies =
let runner = win.Runtime.CreateLoadRunner 4
let runner = win.Runtime.CreateLoadRunner 1
let serializer = FsPickler.CreateBinarySerializer()

scene.patchHierarchies
|> Seq.toList
|> List.map (fun basePath ->
let h = PatchHierarchy.load serializer.Pickle serializer.UnPickle (OpcPaths.OpcPaths basePath)
let t = PatchLod.toRoseTree h.tree
Sg.patchLod win.FramebufferSignature runner basePath scene.lodDecider false false ViewerModality.XYZ PatchLod.CoordinatesMapping.Local true t
)
scenes |> List.collect (fun scene ->
scene.patchHierarchies
|> Seq.toList
|> List.map (fun basePath ->
let h = PatchHierarchy.load serializer.Pickle serializer.UnPickle (OpcPaths.OpcPaths basePath)
let t = PatchLod.toRoseTree h.tree
Sg.patchLod win.FramebufferSignature runner basePath scene.lodDecider true true ViewerModality.XYZ PatchLod.CoordinatesMapping.Local true t
)
)


let bodySources =
Expand All @@ -151,7 +153,7 @@ let run (scene : OpcScene) =
//"mars", C4f.Red, 6779.0
"phobos", C4f.Red, 22.533
"deimos", C4f.Red, 12.4
"HERA", C4f.Magenta, 12742.0
"HERA", C4f.Magenta, 0.1
|]

let time =
Expand All @@ -175,11 +177,14 @@ let run (scene : OpcScene) =
CameraView.viewTrafo view * projTrafo
)

let inNdcBox =
let box = Box3d.FromPoints(V3d(-1,-1,-1),V3d(1,1,1))
fun (p : V3d) -> box.Contains p

let getProjPos (t : AdaptiveToken) (clip : bool) (pos : V3d) =
let vp = viewProj.GetValue(t)
let ndc = vp.Forward.TransformPosProj(pos)
let box = Box3d.FromPoints(V3d(-1,-1,-1),V3d(1,1,1))
if not clip || box.Contains(ndc) then
if not clip || inNdcBox ndc then
V3d ndc |> Some
else
None
Expand Down Expand Up @@ -239,6 +244,7 @@ let run (scene : OpcScene) =
let p =
(b.pos, viewProj, scale) |||> AVal.map3 (fun p vp scale ->
let ndc = vp.Forward.TransformPosProj b.pos.Value
let scale = if inNdcBox ndc then scale else Trafo3d.Scale(0.0)
Trafo3d.Scale(0.05) * scale * Trafo3d.Translation(ndc.XYO)
)
p, AVal.constant b.name
Expand Down Expand Up @@ -288,9 +294,9 @@ let run (scene : OpcScene) =
Shader.stableTrafo |> toEffect
DefaultSurfaces.constantColor C4f.White |> toEffect
DefaultSurfaces.diffuseTexture |> toEffect
//Shader.LoDColor |> toEffect
Shader.LoDColor |> toEffect
]
|> Sg.uniform "LodVisEnabled" (cval false)
|> Sg.uniform "LodVisEnabled" (cval true)
|> Sg.scale 0.001

let sg =
Expand All @@ -300,7 +306,7 @@ let run (scene : OpcScene) =
let s =
win.AfterRender.Add(fun _ ->
transact (fun _ ->
time.Value <- time.Value + TimeSpan.FromDays(0.01)
time.Value <- time.Value + TimeSpan.FromDays(0.001)
animationStep()

)
Expand Down

0 comments on commit 9472096

Please sign in to comment.