Skip to content

Commit 1d4d18a

Browse files
authored
feat(mesh): reworked stage model generation (breaking change)
Stage Model Rework (breaking)
2 parents a2b9054 + cfe2373 commit 1d4d18a

21 files changed

Lines changed: 375 additions & 143 deletions

examples/example.go

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ import (
88
"runtime/pprof"
99
"time"
1010

11-
GDTFMeshReader "github.com/Patch2PDF/GDTF-Mesh-Reader"
11+
GDTFMeshReader "github.com/Patch2PDF/GDTF-Mesh-Reader/v2"
12+
"github.com/Patch2PDF/GDTF-Mesh-Reader/v2/pkg/MeshTypes"
1213
STL "github.com/Patch2PDF/GDTF-Parser/examples/stl"
1314
MVRParser "github.com/Patch2PDF/MVR-Parser"
1415
MVRTypes "github.com/Patch2PDF/MVR-Parser/pkg/types"
@@ -25,8 +26,8 @@ var config = MVRTypes.MVRParserConfig{
2526
},
2627
Individual: map[string]MVRTypes.ModelNodeConfig{
2728
"FA992217-CB18-D844-9D42-5B791B2BF05E": {
28-
Exclude: &MVRTypes.FalsePtr,
29-
RenderOnlyAddressedFixture: &MVRTypes.TruePtr,
29+
Exclude: MVRTypes.GetBoolPtr(false),
30+
RenderOnlyAddressedFixture: MVRTypes.GetBoolPtr(true),
3031
},
3132
},
3233
},
@@ -56,6 +57,20 @@ func main() {
5657

5758
// write mesh as STL
5859
meshFile, _ := os.Create("Test.stl")
59-
STL.WriteBinary(meshFile, mvrData.StageModel)
60+
mesh := &MeshTypes.Mesh{}
61+
for _, fixture := range mvrData.StageModel.FixtureModels {
62+
for _, part := range fixture.MeshModel {
63+
mesh.Add(&part.Mesh)
64+
}
65+
}
66+
for _, sceneObject := range mvrData.StageModel.SceneObjectModels {
67+
for _, part := range sceneObject.MeshModel {
68+
mesh.Add(&part.Mesh)
69+
}
70+
for _, geometry := range sceneObject.Geometries {
71+
mesh.Add(&geometry)
72+
}
73+
}
74+
STL.WriteBinary(meshFile, mesh)
6075
f.Close()
6176
}

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ module github.com/Patch2PDF/MVR-Parser
33
go 1.25.4
44

55
require (
6-
github.com/Patch2PDF/GDTF-Mesh-Reader v1.1.2
7-
github.com/Patch2PDF/GDTF-Parser v0.2.2
6+
github.com/Patch2PDF/GDTF-Mesh-Reader/v2 v2.0.1
7+
github.com/Patch2PDF/GDTF-Parser v0.3.0
88
golang.org/x/sync v0.19.0
99
)
1010

go.sum

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
github.com/Patch2PDF/GDTF-Mesh-Reader v1.1.2 h1:4LHeQjH+cwRoXuv+O4X9YoJaZAO/DihGGN5t3jVIFFk=
2-
github.com/Patch2PDF/GDTF-Mesh-Reader v1.1.2/go.mod h1:4Uipj5UA1HhD3v032aSnEFlpItN80UY5zKB15mIeVwQ=
3-
github.com/Patch2PDF/GDTF-Parser v0.2.2 h1:MpUqTsRVxsgqfsM6oTFx1BPUgVL5TaAXfiomI2mMqYI=
4-
github.com/Patch2PDF/GDTF-Parser v0.2.2/go.mod h1:sXYpcmWKjVBL0JuRWyHwSFHRGzx6kex+HaS/vEPLZ2Y=
1+
github.com/Patch2PDF/GDTF-Mesh-Reader/v2 v2.0.1 h1:xc6xxlDRv9s19um206MW6lYsZU7sXOfHgROuo7PxTZg=
2+
github.com/Patch2PDF/GDTF-Mesh-Reader/v2 v2.0.1/go.mod h1:zAcGHlYdE75hdFo624nQfQHTzw9+NfPJT8Eo2mB1lI8=
3+
github.com/Patch2PDF/GDTF-Parser v0.3.0 h1:aUPiTMJrlNW06nMdzxbRuqU4ZVsrskC14ZzKN7gsUz0=
4+
github.com/Patch2PDF/GDTF-Parser v0.3.0/go.mod h1:4NWUS8fNAQJjQetvlZvrVE/lv2oFaEkuPUKc/r/TugE=
55
github.com/go-test/deep v1.0.1 h1:UQhStjbkDClarlmv0am7OXXO4/GaPdCGiUiMTvi28sg=
66
github.com/go-test/deep v1.0.1/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3aSFNA=
77
github.com/qmuntal/gltf v0.28.0 h1:C4A1temWMPtcI2+qNfpfRq8FEJxoBGUN3ZZM8BCc+xU=

internal/gdtfreader/getgdtf.go

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"archive/zip"
55
"strings"
66

7-
"github.com/Patch2PDF/GDTF-Mesh-Reader/pkg/MeshTypes"
87
GDTFParser "github.com/Patch2PDF/GDTF-Parser"
98
MVRTypes "github.com/Patch2PDF/MVR-Parser/pkg/types"
109
"golang.org/x/sync/errgroup"
@@ -43,20 +42,17 @@ func getGDTF(jobs <-chan *GDTFTask, results chan<- *MVRTypes.GDTF, fileMap map[s
4342
if err != nil {
4443
return err
4544
}
46-
meshes := map[string]*MeshTypes.Mesh{}
4745
for gdtfMode := range task.GDTFModes {
48-
if config.MeshHandling >= MVRTypes.BuildFixtureModels {
49-
mesh, err := gdtf.BuildMesh(gdtfMode)
46+
if config.MeshHandling >= MVRTypes.BuildFixtureModels && gdtf.FixtureType.DMXModes[gdtfMode].MeshModels == nil {
47+
_, err := gdtf.BuildMesh(gdtfMode)
5048
if err != nil {
5149
return err
5250
}
53-
meshes[gdtfMode] = mesh
5451
}
5552
}
5653
results <- &MVRTypes.GDTF{
57-
Name: task.GDTFSpec,
58-
Data: gdtf,
59-
Meshes: meshes,
54+
Name: task.GDTFSpec,
55+
Data: gdtf,
6056
}
6157
}
6258
return nil

internal/types/mvrxml/general.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import (
66
"strconv"
77
"strings"
88

9-
"github.com/Patch2PDF/GDTF-Mesh-Reader/pkg/MeshTypes"
9+
"github.com/Patch2PDF/GDTF-Mesh-Reader/v2/pkg/MeshTypes"
1010
GDTFReader "github.com/Patch2PDF/MVR-Parser/internal/gdtfreader"
1111
)
1212

mvr-parser.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,7 @@ func ParseMVRZipReader(zipfile *zip.Reader, config MVRTypes.MVRParserConfig) (*M
6363

6464
if config.MeshHandling >= MVRTypes.BuildStageModel {
6565
meshTasks := MVRTypes.MeshTasks{}
66-
parsedData.CreateMeshTasks(&meshTasks, config.ModelConfig)
67-
fmt.Println(len(meshTasks))
68-
69-
parsedData.StageModel = MVRTypes.CompleteMeshTasks(&meshTasks, config)
66+
parsedData.GenerateMeshes(&meshTasks, config.ModelConfig)
7067
}
7168

7269
return parsedData, nil

pkg/types/config.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,14 @@ type GlobalModelConfig struct {
99
RenderOnlyAddressedFixture bool
1010
}
1111

12-
var FalsePtr = false
13-
var TruePtr = true
12+
func GetBoolPtr(value bool) *bool {
13+
return &value
14+
}
1415

1516
func (a GlobalModelConfig) asNodeConfig() ModelNodeConfig {
1617
return ModelNodeConfig{
1718
RenderOnlyAddressedFixture: &a.RenderOnlyAddressedFixture,
18-
Exclude: &FalsePtr,
19+
Exclude: GetBoolPtr(false),
1920
}
2021
}
2122

pkg/types/fixture.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package MVRTypes
33
import (
44
"archive/zip"
55

6-
"github.com/Patch2PDF/GDTF-Mesh-Reader/pkg/MeshTypes"
6+
"github.com/Patch2PDF/GDTF-Mesh-Reader/v2/pkg/MeshTypes"
77
)
88

99
type Fixture struct {

pkg/types/focuspoint.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package MVRTypes
33
import (
44
"archive/zip"
55

6-
"github.com/Patch2PDF/GDTF-Mesh-Reader/pkg/MeshTypes"
6+
"github.com/Patch2PDF/GDTF-Mesh-Reader/v2/pkg/MeshTypes"
77
)
88

99
type FocusPoint struct {

pkg/types/gdtfdata.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
package MVRTypes
22

33
import (
4-
"github.com/Patch2PDF/GDTF-Mesh-Reader/pkg/MeshTypes"
54
GDTFTypes "github.com/Patch2PDF/GDTF-Parser/pkg/types"
65
)
76

87
type GDTF struct {
9-
Name string
10-
Data *GDTFTypes.GDTF
11-
Meshes map[string]*MeshTypes.Mesh
8+
Name string
9+
Data *GDTFTypes.GDTF
1210
}

0 commit comments

Comments
 (0)