Skip to content

Commit

Permalink
prepared object importer to support multiple formats (see Surface-Mod…
Browse files Browse the repository at this point in the history
…el.fs => MeshLoaderType), first implementation of #274, the sketchfab transformation is unclear to me - fixed it temporarily to make show the results of #274 (further discussion here #117), started integrating glTF loader, renamed SurfaceType.SurfaceOBJ to SurfaceType.Mesh which better fits its semantics
  • Loading branch information
haraldsteinlechner committed Jan 4, 2023
1 parent ef47c8c commit 1693b4f
Show file tree
Hide file tree
Showing 14 changed files with 693 additions and 474 deletions.
18 changes: 6 additions & 12 deletions src/PRo3D.Base/Utilities.fs
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,11 @@ module OPCFilter =

let improvedDiffuseTextureAndColor (v : Effects.Vertex) =
fragment {
if uniform.HasDiffuseColorTexture then
let texColor = diffuseSampler.Sample(v.tc,-1.0)
return texColor
else
return v.c
if uniform.HasDiffuseColorTexture then
let texColor = diffuseSampler.Sample(v.tc,-1.0)
return texColor
else
return v.c
}

let improvedDiffuseTexture (v : Effects.Vertex) =
Expand Down Expand Up @@ -587,18 +587,12 @@ module Shader =

let footprintV (v : FootPrintVertex) =
vertex {
//let vp = uniform.ModelViewTrafo * v.pos
//let p = uniform.ProjTrafo * vp

let footprintProjM : M44d = uniform?FootprintModelViewProj // was proj * view (earlier there was pretransform in it?)
//let textureProjM : M44d = uniform?textureProj

return {
v with
tc0 = footprintProjM * v.pos;
//sv = 0
//tc1 = textureProjM * v.wp;
} //v.pos
}
}

let footPrintF (v : FootPrintVertex) =
Expand Down
3 changes: 1 addition & 2 deletions src/PRo3D.Core/Groups-Model.fs
Original file line number Diff line number Diff line change
Expand Up @@ -432,8 +432,7 @@ module SurfaceModel =
{
version = current
surfaces = surfaces
sgSurfaces = HashMap.Empty //sgs //
//sgSurfaceObjs = hmap.Empty
sgSurfaces = HashMap.Empty
sgGrouped = IndexList.Empty
kdTreeCache = HashMap.Empty
debugPreTrafo = ""
Expand Down
1 change: 1 addition & 0 deletions src/PRo3D.Core/PRo3D.Core.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
<Compile Include="Core-Types.fs" />
<Compile Include="ReferenceSystem-Model.fs" />
<Compile Include="Surface-Model.fs" />
<Compile Include="glTF.fs" />
<Compile Include="SceneObjects-Model.fs" />
<Compile Include="Bookmark-Model.fs" />
<Compile Include="Groups-Model.fs" />
Expand Down
25 changes: 19 additions & 6 deletions src/PRo3D.Core/Surface-Model.fs
Original file line number Diff line number Diff line change
Expand Up @@ -362,12 +362,21 @@ type SurfaceTrafo = {

type SurfaceType =
| SurfaceOPC = 0
| SurfaceOBJ = 1
| Mesh = 1


type MeshLoaderType =
| Unkown = 0
| Assimp = 1
| GlTf = 2
| Wavefront = 3
| Ply = 4


[<ModelType>]
type Surface = {

version : int
version : int

guid : System.Guid

Expand All @@ -389,14 +398,15 @@ type Surface = {

preTransform : Trafo3d

scalarLayers : HashMap<int, ScalarLayer> //IndexList<ScalarLayer>
scalarLayers : HashMap<int, ScalarLayer>
selectedScalar : option<ScalarLayer>

textureLayers : IndexList<TextureLayer>
selectedTexture : option<TextureLayer>

[<Adaptify.NonAdaptiveAttribute>]
[<NonAdaptiveAttribute>]
surfaceType : SurfaceType
preferredLoader : MeshLoaderType

colorCorrection : ColorCorrection
homePosition : Option<CameraView>
Expand Down Expand Up @@ -431,6 +441,8 @@ module Surface =
let! colorCorrection = Json.read "colorCorrection"
let! transformation = Json.read "transformation"

let! preferredLoader = Json.readOrDefault "preferredMeshLoader" 0

let! (cameraView : list<string>) = Json.read "homePosition"
let cameraView = cameraView |> List.map V3d.Parse
let view =
Expand Down Expand Up @@ -470,7 +482,8 @@ module Surface =
selectedScalar = selectedScalar
textureLayers = textureLayers
selectedTexture = selectedTexture
surfaceType = surfaceType |> enum<SurfaceType>
surfaceType = surfaceType |> enum<SurfaceType>
preferredLoader = preferredLoader |> enum<MeshLoaderType>
colorCorrection = colorCorrection
homePosition = view
transformation = transformation
Expand Down Expand Up @@ -513,6 +526,7 @@ type Surface with
do! Json.write "selectedTexture" x.selectedTexture
do! Json.write "surfaceType" (x.surfaceType |> int)
do! Json.write "colorCorrection" x.colorCorrection
do! Json.write "preferredMeshLoader" (x.preferredLoader |> int)

let home =
match x.homePosition with
Expand Down Expand Up @@ -546,7 +560,6 @@ type SgSurface = {

[<NonAdaptive>]
isObj : bool
//transformation : Transformations
}


Expand Down
8 changes: 2 additions & 6 deletions src/PRo3D.Core/Surface/Surface.Files.fs
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ open PRo3D.Core.Surface
open PRo3DCompability




module Files =
open System.IO
open Aardvark.Prinziple
Expand Down Expand Up @@ -175,7 +173,7 @@ module Files =
| None -> None
else
match surface.surfaceType with
| SurfaceType.SurfaceOBJ ->
| SurfaceType.Mesh ->
let p = Path.GetDirectoryName surface.importPath
if Directory.Exists p then Some p else None
|_->
Expand Down Expand Up @@ -247,7 +245,7 @@ module Files =
match surfaces |> HashMap.tryFind s.surface with
| Some surf ->
match surf.surfaceType with
| SurfaceType.SurfaceOBJ -> Some s
| SurfaceType.Mesh -> Some s
| _ ->
let kd =
ks
Expand Down Expand Up @@ -294,5 +292,3 @@ module Files =
| None ->
Log.error "can't make surface relative. no valid scene path has not been saved yet."
surfaceModel


Loading

0 comments on commit 1693b4f

Please sign in to comment.