Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions pkg/types/childlist.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,13 @@ func ReadMeshes[T MeshReader](src []T, fileMap map[string]*zip.File) error {
return nil
}

func (c *ChildList) addNodeModelsToStageModel(stageModel *StageModel, modelConfig ModelConfig, parentConfig ModelNodeConfig) {
addNodeModelsToStageModel(c.SceneObjects, stageModel, modelConfig, parentConfig)
addNodeModelsToStageModel(c.GroupObjects, stageModel, modelConfig, parentConfig)
addNodeModelsToStageModel(c.FocusPoints, stageModel, modelConfig, parentConfig)
addNodeModelsToStageModel(c.Fixtures, stageModel, modelConfig, parentConfig)
addNodeModelsToStageModel(c.Supports, stageModel, modelConfig, parentConfig)
addNodeModelsToStageModel(c.Trusses, stageModel, modelConfig, parentConfig)
addNodeModelsToStageModel(c.VideoScreens, stageModel, modelConfig, parentConfig)
addNodeModelsToStageModel(c.Projectors, stageModel, modelConfig, parentConfig)
func (c *ChildList) addNodeModelsToStageModel(stageModel *StageModel, modelConfig ModelConfig, parentConfig ModelNodeConfig, parentParameters parentNodeParameters) {
addNodeModelsToStageModel(c.SceneObjects, stageModel, modelConfig, parentConfig, parentParameters)
addNodeModelsToStageModel(c.GroupObjects, stageModel, modelConfig, parentConfig, parentParameters)
addNodeModelsToStageModel(c.FocusPoints, stageModel, modelConfig, parentConfig, parentParameters)
addNodeModelsToStageModel(c.Fixtures, stageModel, modelConfig, parentConfig, parentParameters)
addNodeModelsToStageModel(c.Supports, stageModel, modelConfig, parentConfig, parentParameters)
addNodeModelsToStageModel(c.Trusses, stageModel, modelConfig, parentConfig, parentParameters)
addNodeModelsToStageModel(c.VideoScreens, stageModel, modelConfig, parentConfig, parentParameters)
addNodeModelsToStageModel(c.Projectors, stageModel, modelConfig, parentConfig, parentParameters)
}
35 changes: 33 additions & 2 deletions pkg/types/config.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package MVRTypes

type ModelConfig struct {
Global GlobalModelConfig
Individual map[string]ModelNodeConfig // configure by Node (fixture, ...) UUID (also applies to children)
Global GlobalModelConfig
Individual map[string]ModelNodeConfig // configure by Node (fixture, ...) UUID (also applies to children)
ClassConfig ModelClassConfig
}

type GlobalModelConfig struct {
Expand All @@ -25,6 +26,32 @@ type ModelNodeConfig struct {
Exclude *bool
}

// Note: include has precedence over exclude
type ModelClassConfig struct {
Excludes map[string]struct{} // specify if you want to exclude these Class UUIDs from the model
Includes map[string]struct{} // specify if only want to include these Class UUIDs in the model
}

func checkShouldIncludeClassInModel(classConfig ModelClassConfig, classID *string, parentClassID *string) (result bool, newParentClassID *string) {
if classID == nil {
if parentClassID == nil {
return false, nil
} else {
classID = parentClassID
}
}
if len(classConfig.Includes) > 0 {
if _, ok := classConfig.Includes[*classID]; ok {
return true, classID
}
} else {
if _, ok := classConfig.Excludes[*classID]; !ok {
return true, classID
}
}
return false, classID
}

type MVRParserConfig struct {
MeshHandling int
ReadThumbnail bool
Expand All @@ -44,3 +71,7 @@ func getConfigOverrides(modelConfig ModelConfig, parentModelConfig ModelNodeConf
}
return parentModelConfig
}

type parentNodeParameters struct {
classID *string
}
11 changes: 9 additions & 2 deletions pkg/types/fixture.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,17 +63,24 @@ func (a *Fixture) ReadMesh(fileMap map[string]*zip.File) error {
return a.ChildList.ReadMesh(fileMap)
}

func (a *Fixture) addNodeModelsToStageModel(stageModel *StageModel, modelConfig ModelConfig, parentConfig ModelNodeConfig) {
func (a *Fixture) addNodeModelsToStageModel(stageModel *StageModel, modelConfig ModelConfig, parentConfig ModelNodeConfig, parentParameters parentNodeParameters) {
config := getConfigOverrides(modelConfig, parentConfig, a.UUID)

validClass, classID := checkShouldIncludeClassInModel(modelConfig.ClassConfig, a.Class.String, parentParameters.classID)

if (config.Exclude == nil ||
!(*config.Exclude)) &&
validClass &&
!(config.RenderOnlyAddressedFixture != nil && *config.RenderOnlyAddressedFixture &&
(a.Addresses == nil || len(a.Addresses.Addresses) == 0)) { // remove unpatched fixtures if desired
stageModel.FixtureModels = append(stageModel.FixtureModels, a.Model.Copy())
}

a.ChildList.addNodeModelsToStageModel(stageModel, modelConfig, config)
childParameters := parentNodeParameters{
classID: classID,
}

a.ChildList.addNodeModelsToStageModel(stageModel, modelConfig, config, childParameters)
}

type Gobo struct {
Expand Down
6 changes: 4 additions & 2 deletions pkg/types/focuspoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,12 @@ func (a *FocusPoint) ReadMesh(fileMap map[string]*zip.File) error {
return a.Geometries.ReadMesh(fileMap)
}

func (a *FocusPoint) addNodeModelsToStageModel(stageModel *StageModel, modelConfig ModelConfig, parentConfig ModelNodeConfig) {
func (a *FocusPoint) addNodeModelsToStageModel(stageModel *StageModel, modelConfig ModelConfig, parentConfig ModelNodeConfig, parentParameters parentNodeParameters) {
config := getConfigOverrides(modelConfig, parentConfig, a.UUID)

if config.Exclude == nil || !(*config.Exclude) {
validClass, _ := checkShouldIncludeClassInModel(modelConfig.ClassConfig, a.Class.String, parentParameters.classID)

if (config.Exclude == nil || !(*config.Exclude)) && validClass {
stageModel.FocusPointModels = append(stageModel.FocusPointModels, a.Model.Copy())
}
}
2 changes: 1 addition & 1 deletion pkg/types/generalscenedescription.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func (a *GeneralSceneDescription) GetStageModel(config ModelConfig) StageModel {

local_config := config.Global.asNodeConfig()

addNodeModelsToStageModel(a.Scene.Layers, &model, config, local_config)
addNodeModelsToStageModel(a.Scene.Layers, &model, config, local_config, parentNodeParameters{})

return model
}
12 changes: 10 additions & 2 deletions pkg/types/groupobject.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,16 @@ func (a *GroupObject) ReadMesh(fileMap map[string]*zip.File) error {
return a.ChildList.ReadMesh(fileMap)
}

func (a *GroupObject) addNodeModelsToStageModel(stageModel *StageModel, modelConfig ModelConfig, parentConfig ModelNodeConfig) {
func (a *GroupObject) addNodeModelsToStageModel(stageModel *StageModel, modelConfig ModelConfig, parentConfig ModelNodeConfig, parentParameters parentNodeParameters) {
config := getConfigOverrides(modelConfig, parentConfig, a.UUID)

a.ChildList.addNodeModelsToStageModel(stageModel, modelConfig, config)
classID := a.Class.String
if classID == nil {
classID = parentParameters.classID
}
childParameters := parentNodeParameters{
classID: classID,
}

a.ChildList.addNodeModelsToStageModel(stageModel, modelConfig, config, childParameters)
}
8 changes: 6 additions & 2 deletions pkg/types/scene.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,12 @@ func (a *Layer) ResolveReference(refPointers *ReferencePointers) {
a.ChildList.ResolveReference(refPointers)
}

func (a *Layer) addNodeModelsToStageModel(stageModel *StageModel, modelConfig ModelConfig, parentConfig ModelNodeConfig) {
func (a *Layer) addNodeModelsToStageModel(stageModel *StageModel, modelConfig ModelConfig, parentConfig ModelNodeConfig, parentParameters parentNodeParameters) {
config := getConfigOverrides(modelConfig, parentConfig, a.UUID)

a.ChildList.addNodeModelsToStageModel(stageModel, modelConfig, config)
childParameters := parentNodeParameters{
classID: nil,
}

a.ChildList.addNodeModelsToStageModel(stageModel, modelConfig, config, childParameters)
}
12 changes: 9 additions & 3 deletions pkg/types/sceneobject.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,20 @@ func (a *SceneObject) ReadMesh(fileMap map[string]*zip.File) error {
return a.ChildList.ReadMesh(fileMap)
}

func (a *SceneObject) addNodeModelsToStageModel(stageModel *StageModel, modelConfig ModelConfig, parentConfig ModelNodeConfig) {
func (a *SceneObject) addNodeModelsToStageModel(stageModel *StageModel, modelConfig ModelConfig, parentConfig ModelNodeConfig, parentParameters parentNodeParameters) {
config := getConfigOverrides(modelConfig, parentConfig, a.UUID)

if config.Exclude == nil || !(*config.Exclude) {
validClass, classID := checkShouldIncludeClassInModel(modelConfig.ClassConfig, a.Class.String, parentParameters.classID)

if (config.Exclude == nil || !(*config.Exclude)) && validClass {
stageModel.SceneObjectModels = append(stageModel.SceneObjectModels, a.Model.Copy())
}

a.ChildList.addNodeModelsToStageModel(stageModel, modelConfig, config)
childParameters := parentNodeParameters{
classID: classID,
}

a.ChildList.addNodeModelsToStageModel(stageModel, modelConfig, config, childParameters)
}

type Alignment struct {
Expand Down
6 changes: 3 additions & 3 deletions pkg/types/stagemodel.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@ func CopyMeshSlice(source []MeshTypes.Mesh) []MeshTypes.Mesh {
}

type NodeModel interface {
addNodeModelsToStageModel(stageModel *StageModel, modelConfig ModelConfig, parentConfig ModelNodeConfig)
addNodeModelsToStageModel(stageModel *StageModel, modelConfig ModelConfig, parentConfig ModelNodeConfig, parentParameters parentNodeParameters)
}

func addNodeModelsToStageModel[T NodeModel](source []T, stageModel *StageModel, modelConfig ModelConfig, parentConfig ModelNodeConfig) {
func addNodeModelsToStageModel[T NodeModel](source []T, stageModel *StageModel, modelConfig ModelConfig, parentConfig ModelNodeConfig, parentParameters parentNodeParameters) {
if source == nil {
return
}
for i := range source {
source[i].addNodeModelsToStageModel(stageModel, modelConfig, parentConfig)
source[i].addNodeModelsToStageModel(stageModel, modelConfig, parentConfig, parentParameters)
}
}

Expand Down
12 changes: 9 additions & 3 deletions pkg/types/support.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,18 @@ func (a *Support) ReadMesh(fileMap map[string]*zip.File) error {
return a.ChildList.ReadMesh(fileMap)
}

func (a *Support) addNodeModelsToStageModel(stageModel *StageModel, modelConfig ModelConfig, parentConfig ModelNodeConfig) {
func (a *Support) addNodeModelsToStageModel(stageModel *StageModel, modelConfig ModelConfig, parentConfig ModelNodeConfig, parentParameters parentNodeParameters) {
config := getConfigOverrides(modelConfig, parentConfig, a.UUID)

if config.Exclude == nil || !(*config.Exclude) {
validClass, classID := checkShouldIncludeClassInModel(modelConfig.ClassConfig, a.Class.String, parentParameters.classID)

if (config.Exclude == nil || !(*config.Exclude)) && validClass {
stageModel.SupportModels = append(stageModel.SupportModels, a.Model.Copy())
}

a.ChildList.addNodeModelsToStageModel(stageModel, modelConfig, config)
childParameters := parentNodeParameters{
classID: classID,
}

a.ChildList.addNodeModelsToStageModel(stageModel, modelConfig, config, childParameters)
}
12 changes: 9 additions & 3 deletions pkg/types/truss.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,18 @@ func (a *Truss) ReadMesh(fileMap map[string]*zip.File) error {
return a.ChildList.ReadMesh(fileMap)
}

func (a *Truss) addNodeModelsToStageModel(stageModel *StageModel, modelConfig ModelConfig, parentConfig ModelNodeConfig) {
func (a *Truss) addNodeModelsToStageModel(stageModel *StageModel, modelConfig ModelConfig, parentConfig ModelNodeConfig, parentParameters parentNodeParameters) {
config := getConfigOverrides(modelConfig, parentConfig, a.UUID)

if config.Exclude == nil || !(*config.Exclude) {
validClass, classID := checkShouldIncludeClassInModel(modelConfig.ClassConfig, a.Class.String, parentParameters.classID)

if (config.Exclude == nil || !(*config.Exclude)) && validClass {
stageModel.TrussModels = append(stageModel.TrussModels, a.Model.Copy())
}

a.ChildList.addNodeModelsToStageModel(stageModel, modelConfig, config)
childParameters := parentNodeParameters{
classID: classID,
}

a.ChildList.addNodeModelsToStageModel(stageModel, modelConfig, config, childParameters)
}
24 changes: 18 additions & 6 deletions pkg/types/video.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,20 @@ func (a *VideoScreen) ReadMesh(fileMap map[string]*zip.File) error {
return a.ChildList.ReadMesh(fileMap)
}

func (a *VideoScreen) addNodeModelsToStageModel(stageModel *StageModel, modelConfig ModelConfig, parentConfig ModelNodeConfig) {
func (a *VideoScreen) addNodeModelsToStageModel(stageModel *StageModel, modelConfig ModelConfig, parentConfig ModelNodeConfig, parentParameters parentNodeParameters) {
config := getConfigOverrides(modelConfig, parentConfig, a.UUID)

if config.Exclude == nil || !(*config.Exclude) {
validClass, classID := checkShouldIncludeClassInModel(modelConfig.ClassConfig, a.Class.String, parentParameters.classID)

if (config.Exclude == nil || !(*config.Exclude)) && validClass {
stageModel.VideoScreenModels = append(stageModel.VideoScreenModels, a.Model.Copy())
}

a.ChildList.addNodeModelsToStageModel(stageModel, modelConfig, config)
childParameters := parentNodeParameters{
classID: classID,
}

a.ChildList.addNodeModelsToStageModel(stageModel, modelConfig, config, childParameters)
}

type Projector struct {
Expand Down Expand Up @@ -114,14 +120,20 @@ func (a *Projector) ReadMesh(fileMap map[string]*zip.File) error {
return a.ChildList.ReadMesh(fileMap)
}

func (a *Projector) addNodeModelsToStageModel(stageModel *StageModel, modelConfig ModelConfig, parentConfig ModelNodeConfig) {
func (a *Projector) addNodeModelsToStageModel(stageModel *StageModel, modelConfig ModelConfig, parentConfig ModelNodeConfig, parentParameters parentNodeParameters) {
config := getConfigOverrides(modelConfig, parentConfig, a.UUID)

if config.Exclude == nil || !(*config.Exclude) {
validClass, classID := checkShouldIncludeClassInModel(modelConfig.ClassConfig, a.Class.String, parentParameters.classID)

if (config.Exclude == nil || !(*config.Exclude)) && validClass {
stageModel.ProjectorModels = append(stageModel.ProjectorModels, a.Model.Copy())
}

a.ChildList.addNodeModelsToStageModel(stageModel, modelConfig, config)
childParameters := parentNodeParameters{
classID: classID,
}

a.ChildList.addNodeModelsToStageModel(stageModel, modelConfig, config, childParameters)
}

type Source struct {
Expand Down
Loading