public ConnectionPoint(Node node, string inname, string name, float deltay, ConnectionPointType type, GUIStyle style, VectorSubLayerProperties activeProp = null)
        {
            isActive = true;
            if (activeOutImage == null)
            {
                activeOutImage   = EditorGUIUtility.Load("builtin skins/darkskin/images/node3.png") as Texture2D;
                inactiveOutImage = EditorGUIUtility.Load("builtin skins/darkskin/images/node6.png") as Texture2D;
            }

            if (!string.IsNullOrEmpty(name))
            {
                this._outLabel = Regex.Replace(name, "(\\B[A-Z])", " $1");
            }
            else
            {
                this._outLabel = "";
            }
            inLabel    = inname;
            this.node  = node;
            this.type  = type;
            this.style = style;
            _deltaY    = deltay;
            rect       = new Rect(0, 0, 10f + (string.IsNullOrEmpty(inLabel) ? 0 : 100), 20f);
            left       = new Vector2(rect.x, rect.y + (rect.height / 2));

            labelRect   = new Rect(node.rect.xMin, node.rect.y + _deltaY - 15f, node.rect.width - 20, 25);
            inLabelRect = new Rect(rect.x + 4, rect.y - 1, rect.width, rect.height);

            _activeProp = activeProp;
        }
示例#2
0
 void Awake()
 {
     currentStep   = 0;
     busModifier   = ScriptableObject.CreateInstance <BusIndicatorModifier>();
     buildingLayer = GameObject.Find("CitySimulatorMap").GetComponent <AbstractMap>().VectorData.GetFeatureSubLayerAtIndex(0);
     busUIManager  = GameObject.Find("BusIndicatorUI").GetComponent <BusUIManager>();
 }
 public MapARLayer(VectorSubLayerProperties vslp)
 {
     this.vectorSubLayerProperties = vslp;
     this.layerName             = vslp.coreOptions.sublayerName;
     this.layerGameObjects.name = "LayerGameObjects_" + this.layerName;
     this.updateLayerGameObjects();
     this.setLayerAttributes();
 }
示例#4
0
    public void AddLayer()
    {
        VectorSubLayerProperties subLayerProperties = new VectorSubLayerProperties();

        subLayerProperties.coreOptions.geometryType = VectorPrimitiveType.Polygon;
        subLayerProperties.coreOptions.layerName    = "building";

        _abstractMap.VectorData.AddFeatureSubLayer(subLayerProperties);
    }
 public virtual LayerVisualizerBase FindVectorLayerVisualizer(VectorSubLayerProperties subLayer)
 {
     if (_layerBuilder.ContainsKey(subLayer.Key))
     {
         var visualizer = _layerBuilder[subLayer.Key].Find((obj) => obj.SubLayerProperties == subLayer);
         return(visualizer);
     }
     return(null);
 }
 private VectorSubLayerProperties[] GetLayers()
 {
     VectorSubLayerProperties[] vectorSubLayers;
     if (!string.IsNullOrEmpty(layerToWorkWith))
     {
         vectorSubLayers = new VectorSubLayerProperties[] { _abstractMap.VectorData.FindFeatureSubLayerWithName(layerToWorkWith) };
     }
     else
     {
         vectorSubLayers = _abstractMap.VectorData.GetAllFeatureSubLayers().ToArray();
     }
     return(vectorSubLayers);
 }
        void CellGUI(Rect cellRect, TreeViewItem <FeatureTreeElement> item, FeatureSubLayerColumns column, ref RowGUIArgs args)
        {
            // Center cell rect vertically (makes it easier to place controls, icons etc in the cells)
            if (Layers == null || Layers.arraySize == 0)
            {
                return;
            }

            if (Layers.arraySize <= args.item.id - uniqueId)
            {
                return;
            }

            var layer = Layers.GetArrayElementAtIndex(args.item.id - uniqueId);

            CenterRectUsingSingleLineHeight(ref cellRect);
            if (column == FeatureSubLayerColumns.Name)
            {
                Rect toggleRect = cellRect;
                toggleRect.x    += GetContentIndent(item);
                toggleRect.width = kToggleWidth;

                EditorGUI.BeginChangeCheck();
                item.data.isActive = layer.FindPropertyRelative("coreOptions.isActive").boolValue;
                if (toggleRect.xMax < cellRect.xMax)
                {
                    item.data.isActive = EditorGUI.Toggle(toggleRect, item.data.isActive);                     // hide when outside cell rect
                }
                layer.FindPropertyRelative("coreOptions.isActive").boolValue = item.data.isActive;
                if (EditorGUI.EndChangeCheck())
                {
                    VectorSubLayerProperties vectorSubLayerProperties = (VectorSubLayerProperties)EditorHelper.GetTargetObjectOfProperty(layer);
                    EditorHelper.CheckForModifiedProperty(layer, vectorSubLayerProperties.coreOptions);
                }

                cellRect.xMin += nameOffset;                 // Adding some gap between the checkbox and the name
                args.rowRect   = cellRect;

                layer.FindPropertyRelative("coreOptions.sublayerName").stringValue = item.data.Name;
                //This draws the name property
                base.RowGUI(args);
            }
            if (column == FeatureSubLayerColumns.Type)
            {
                cellRect.xMin += 15f;                 // Adding some gap between the checkbox and the name

                var typeString = ((PresetFeatureType)layer.FindPropertyRelative("presetFeatureType").intValue).ToString();
                item.data.Type = typeString;
                EditorGUI.LabelField(cellRect, item.data.Type, columnStyle);
            }
        }
 public void SetProperties(VectorSubLayerProperties properties, LayerPerformanceOptions performanceOptions)
 {
     base.SetProperties(properties, performanceOptions);
     ////TODO stop hard coding it
     //if (properties.coreOptions.layerName == "MyTileSet")
     //{
     //    foreach(var modifier in properties.GoModifiers)
     //    {
     //        if(typeof(CustomFeatureBehaviourModifier) == modifier.GetType())
     //        {
     //            featureModifier = (CustomFeatureBehaviourModifier)modifier;
     //        }
     //    }
     //}
 }
示例#9
0
        // height in meters
        public static void AssignBuildings(Building type, float min, float max, AbstractMap map, bool combineMesh = false)
        {
            if (type == Building.Road)
            {
                return;
            }

            VectorSubLayerProperties vectorSubLayerProperties = new VectorSubLayerProperties();

            vectorSubLayerProperties.colliderOptions.colliderType           = ColliderType.MeshCollider;
            vectorSubLayerProperties.coreOptions.combineMeshes              = false;
            vectorSubLayerProperties.coreOptions.geometryType               = VectorPrimitiveType.Polygon;
            vectorSubLayerProperties.coreOptions.layerName                  = "building";
            vectorSubLayerProperties.coreOptions.snapToTerrain              = true;
            vectorSubLayerProperties.coreOptions.combineMeshes              = combineMesh;
            vectorSubLayerProperties.extrusionOptions.extrusionType         = ExtrusionType.PropertyHeight;
            vectorSubLayerProperties.extrusionOptions.extrusionScaleFactor  = 1.3203f;
            vectorSubLayerProperties.extrusionOptions.propertyName          = "height";
            vectorSubLayerProperties.extrusionOptions.extrusionGeometryType = ExtrusionGeometryType.RoofAndSide;
            vectorSubLayerProperties.moveFeaturePositionTo                  = PositionTargetType.CenterOfVertices;
            vectorSubLayerProperties.coreOptions.sublayerName               = type.ToString();

            string    atlasPath = "Atlases/" + type.ToString() + "BuildingAtlas";
            AtlasInfo atlasInfo = Resources.Load(atlasPath) as AtlasInfo;
            Material  material  = Resources.Load(Constants.buildingMaterialPath) as Material;
            GeometryMaterialOptions materialOptions = new GeometryMaterialOptions();

            materialOptions.SetDefaultMaterialOptions();
            materialOptions.customStyleOptions.texturingType             = UvMapType.Atlas;
            materialOptions.customStyleOptions.materials[0].Materials[0] = material;
            materialOptions.customStyleOptions.materials[1].Materials[0] = material;
            materialOptions.customStyleOptions.atlasInfo = atlasInfo;
            materialOptions.SetStyleType(StyleTypes.Custom);
            vectorSubLayerProperties.materialOptions        = materialOptions;
            vectorSubLayerProperties.buildingsWithUniqueIds = true;
            if (min < 100)
            {
                vectorSubLayerProperties.filterOptions.AddNumericFilterInRange("height", min, max);
                vectorSubLayerProperties.filterOptions.AddNumericFilterEquals("height", max);
            }
            else
            {
                vectorSubLayerProperties.filterOptions.AddNumericFilterGreaterThan("height", min);
            }

            map.VectorData.AddFeatureSubLayer(vectorSubLayerProperties);
        }
示例#10
0
        public static void AddRoad(AbstractMap map)
        {
            VectorSubLayerProperties vectorSubLayerProperties = new VectorSubLayerProperties();

            vectorSubLayerProperties.colliderOptions.colliderType           = ColliderType.MeshCollider;
            vectorSubLayerProperties.coreOptions.combineMeshes              = false;
            vectorSubLayerProperties.coreOptions.geometryType               = VectorPrimitiveType.Line;
            vectorSubLayerProperties.coreOptions.layerName                  = "Road";
            vectorSubLayerProperties.coreOptions.snapToTerrain              = true;
            vectorSubLayerProperties.coreOptions.combineMeshes              = true;
            vectorSubLayerProperties.extrusionOptions.extrusionGeometryType = ExtrusionGeometryType.RoofAndSide;
            vectorSubLayerProperties.extrusionOptions.extrusionType         = ExtrusionType.AbsoluteHeight;
            vectorSubLayerProperties.extrusionOptions.extrusionScaleFactor  = 1;
            // This value doesn't really matter but should be big
            vectorSubLayerProperties.extrusionOptions.SetAbsoluteHeight(24);
            vectorSubLayerProperties.moveFeaturePositionTo    = PositionTargetType.CenterOfVertices;
            vectorSubLayerProperties.coreOptions.sublayerName = Building.Road.ToString();
        }
    void Start()
    {
        _abstractMap = FindObjectOfType <AbstractMap>();
        _layer       = _abstractMap.VectorData.FindFeatureSubLayerWithName("test");
        Assert.IsNotNull(_layer, "No layer named test found");

        testMethods = new List <System.Action>
        {
            SetStyle,
            SetRealisticStyleType,
            SetFantasyStyleType,
            SetSimpleStylePaletteType,
            SetLightStyleOpacity,
            SetDarkStyleOpacity,
            SetColorStyleColor,
            SetCustomTexturingType,
            SetCustomTopMaterial,
            SetCustomSideMaterial,
            SetCustomMaterials
        };
    }
        public void DrawUI(SerializedProperty subLayerCoreOptions, SerializedProperty layerProperty, VectorPrimitiveType primitiveTypeProp)
        {
            VectorSubLayerProperties vectorSubLayerProperties = (VectorSubLayerProperties)EditorHelper.GetTargetObjectOfProperty(layerProperty);

            objectId = layerProperty.serializedObject.targetObject.GetInstanceID().ToString();

            EditorGUILayout.BeginVertical();
            showModeling = EditorGUILayout.Foldout(showModeling, new GUIContent {
                text = "Modeling", tooltip = "This section provides you with options to fine tune your meshes"
            });
            if (showModeling)
            {
                GUILayout.Space(-_lineHeight);
                EditorGUILayout.PropertyField(subLayerCoreOptions);

                if (primitiveTypeProp != VectorPrimitiveType.Point && primitiveTypeProp != VectorPrimitiveType.Custom)
                {
                    GUILayout.Space(-_lineHeight);
                    var extrusionOptions = layerProperty.FindPropertyRelative("extrusionOptions");
                    extrusionOptions.FindPropertyRelative("_selectedLayerName").stringValue = subLayerCoreOptions.FindPropertyRelative("layerName").stringValue;
                    EditorGUILayout.PropertyField(extrusionOptions);
                }

                var snapToTerrainProperty = subLayerCoreOptions.FindPropertyRelative("snapToTerrain");
                snapToTerrainProperty.boolValue = EditorGUILayout.Toggle(snapToTerrainProperty.displayName, snapToTerrainProperty.boolValue);
                EditorHelper.CheckForModifiedProperty(snapToTerrainProperty, vectorSubLayerProperties);

                var combineMeshesProperty = subLayerCoreOptions.FindPropertyRelative("combineMeshes");
                combineMeshesProperty.boolValue = EditorGUILayout.Toggle(combineMeshesProperty.displayName, combineMeshesProperty.boolValue);
                EditorHelper.CheckForModifiedProperty(combineMeshesProperty, vectorSubLayerProperties);

                if (primitiveTypeProp != VectorPrimitiveType.Point && primitiveTypeProp != VectorPrimitiveType.Custom)
                {
                    EditorGUILayout.PropertyField(layerProperty.FindPropertyRelative("colliderOptions"));
                }
            }
            EditorGUILayout.EndVertical();
        }
示例#13
0
        public SerialMeshBuilder(VectorSubLayerProperties subLayerProperties)
        {
            SubLayerProperties = subLayerProperties;
            SubLayerProperties.materialOptions.SetDefaultMaterialOptions();
            SubLayerProperties.extrusionOptions.extrusionType         = ExtrusionType.PropertyHeight;
            SubLayerProperties.extrusionOptions.extrusionScaleFactor  = 1.3203f;
            SubLayerProperties.extrusionOptions.propertyName          = "height";
            SubLayerProperties.extrusionOptions.extrusionGeometryType = ExtrusionGeometryType.RoofAndSide;

            _processor = new MeshProcessor();

            var uvOptions = new UVModifierOptions
            {
                texturingType = UvMapType.Atlas,
                atlasInfo     = Resources.Load("Atlases/BuildingAtlas") as AtlasInfo,
                style         = StyleTypes.Custom
            };
            var atlasOptions = new GeometryExtrusionWithAtlasOptions(SubLayerProperties.extrusionOptions, uvOptions);

            _processor.SetOptions(uvOptions, atlasOptions);

            SubLayerProperties.filterOptions.RegisterFilters();
        }
        public virtual LayerVisualizerBase AddVectorLayerVisualizer(VectorSubLayerProperties subLayer)
        {
            //if its of type prefabitemoptions then separate the visualizer type
            LayerVisualizerBase visualizer = CreateInstance <VectorLayerVisualizer>();

            //TODO : FIX THIS !!
            visualizer.LayerVisualizerHasChanged += UpdateTileFactory;

            // Set honorBuildingSettings - need to set here in addition to the UI.
            // Not setting it here can lead to wrong filtering.

            bool isPrimitiveTypeValidForBuidingIds = (subLayer.coreOptions.geometryType == VectorPrimitiveType.Polygon) || (subLayer.coreOptions.geometryType == VectorPrimitiveType.Custom);
            bool isSourceValidForBuildingIds       = _properties.sourceType != VectorSourceType.MapboxStreets;

            subLayer.honorBuildingIdSetting = isPrimitiveTypeValidForBuidingIds && isSourceValidForBuildingIds;
            // Setup visualizer.
            ((VectorLayerVisualizer)visualizer).SetProperties(subLayer);

            visualizer.Initialize();
            if (visualizer == null)
            {
                return(visualizer);
            }

            if (_layerBuilder.ContainsKey(visualizer.Key))
            {
                _layerBuilder[visualizer.Key].Add(visualizer);
            }
            else
            {
                _layerBuilder.Add(visualizer.Key, new List <LayerVisualizerBase> {
                    visualizer
                });
            }
            return(visualizer);
        }
示例#15
0
        public DronesMap()
        {
            _options.locationOptions.zoom               = 16;
            _options.scalingOptions.scalingStrategy     = new MapScalingAtWorldScaleStrategy();
            _options.placementOptions.placementStrategy = new MapPlacementAtTileCenterStrategy();

            CenterLatitudeLongitude = new double2(40.764170691358686, -73.97670925665614);
            WorldRelativeScale      = math.pow(2.0f, AbsoluteZoom - InitialZoom) * (float)math.cos(math.radians(CenterLatitudeLongitude.x));
            CenterMercator          = Conversions.TileBounds(FromCoordinates(CenterLatitudeLongitude)).Center.ToSIMD();

            Tiles = ManhattanTileProvider.GetTiles(this);

            BuildingProperties = new VectorSubLayerProperties
            {
                colliderOptions = { colliderType = ColliderType.None },
                coreOptions     =
                {
                    geometryType  = VectorPrimitiveType.Polygon,
                    layerName     = LayerName,
                    snapToTerrain = true,
                    combineMeshes = true
                },
                extrusionOptions =
                {
                    extrusionType         = ExtrusionType.PropertyHeight,
                    extrusionScaleFactor  =                      1.3203f,
                    propertyName          = "height",
                    extrusionGeometryType = ExtrusionGeometryType.RoofAndSide
                },
                moveFeaturePositionTo = PositionTargetType.CenterOfVertices
            };
            BuildingProperties.coreOptions.sublayerName = "Buildings";
            BuildingProperties.buildingsWithUniqueIds   = true;
            BuildingProperties.coreOptions.geometryType = VectorPrimitiveType.Polygon;
            BuildingProperties.honorBuildingIdSetting   = true;
        }
示例#16
0
        public void SetProperties(VectorSubLayerProperties properties)
        {
            List <MeshModifier>       defaultMeshModifierStack = new List <MeshModifier>();
            List <GameObjectModifier> defaultGOModifierStack   = new List <GameObjectModifier>();

            _layerProperties    = properties;
            _performanceOptions = properties.performanceOptions;

            Active = _layerProperties.coreOptions.isActive;

            if (properties.coreOptions.combineMeshes)
            {
                _defaultStack = ScriptableObject.CreateInstance <MergedModifierStack>();
            }
            else
            {
                _defaultStack = ScriptableObject.CreateInstance <ModifierStack>();
                ((ModifierStack)_defaultStack).moveFeaturePositionTo = _layerProperties.moveFeaturePositionTo;
            }

            _defaultStack.MeshModifiers = new List <MeshModifier>();
            _defaultStack.GoModifiers   = new List <GameObjectModifier>();

            switch (properties.coreOptions.geometryType)
            {
            case VectorPrimitiveType.Point:
            case VectorPrimitiveType.Custom:
                // Let the user add anything that they want
                if (_layerProperties.coreOptions.snapToTerrain == true)
                {
                    defaultMeshModifierStack.Add(CreateInstance <SnapTerrainModifier>());
                }
                break;

            case VectorPrimitiveType.Line:

                var lineMeshMod = CreateInstance <LineMeshModifier>();
                lineMeshMod.Width = _layerProperties.coreOptions.lineWidth;
                defaultMeshModifierStack.Add(lineMeshMod);

                if (_layerProperties.extrusionOptions.extrusionType != Map.ExtrusionType.None)
                {
                    var heightMod = CreateInstance <HeightModifier>();
                    heightMod.SetProperties(_layerProperties.extrusionOptions);
                    defaultMeshModifierStack.Add(heightMod);
                }
                if (_layerProperties.coreOptions.snapToTerrain == true)
                {
                    defaultMeshModifierStack.Add(CreateInstance <SnapTerrainModifier>());
                }

                //collider modifier options
                if (_layerProperties.colliderOptions.colliderType != ColliderType.None)
                {
                    var lineColliderMod = CreateInstance <ColliderModifier>();
                    lineColliderMod.SetProperties(_layerProperties.colliderOptions);
                    defaultGOModifierStack.Add(lineColliderMod);
                }

                var lineStyleMod = CreateInstance <MaterialModifier>();
                lineStyleMod.SetProperties(MapboxDefaultStyles.GetGeometryMaterialOptions(_layerProperties.materialOptions));
                defaultGOModifierStack.Add(lineStyleMod);

                break;

            case VectorPrimitiveType.Polygon:
                if (_layerProperties.coreOptions.snapToTerrain == true)
                {
                    defaultMeshModifierStack.Add(CreateInstance <SnapTerrainModifier>());
                }
                defaultMeshModifierStack.Add(CreateInstance <PolygonMeshModifier>());

                GeometryMaterialOptions geometryMaterialOptions = MapboxDefaultStyles.GetGeometryMaterialOptions(_layerProperties.materialOptions);

                UVModifierOptions uvModOptions = new UVModifierOptions();
                uvModOptions.texturingType = geometryMaterialOptions.texturingType;
                uvModOptions.atlasInfo     = geometryMaterialOptions.atlasInfo;
                uvModOptions.style         = geometryMaterialOptions.style;

                var uvMod = CreateInstance <UvModifier>();
                uvMod.SetProperties(uvModOptions);
                defaultMeshModifierStack.Add(uvMod);

                if (_layerProperties.extrusionOptions.extrusionType != Map.ExtrusionType.None)
                {
                    //replace materialOptions with styleOptions
                    if (geometryMaterialOptions.texturingType == UvMapType.Atlas || geometryMaterialOptions.texturingType == UvMapType.AtlasWithColorPalette)
                    {
                        var atlasMod = CreateInstance <TextureSideWallModifier>();
                        GeometryExtrusionWithAtlasOptions atlasOptions = new GeometryExtrusionWithAtlasOptions(_layerProperties.extrusionOptions, uvModOptions);
                        atlasMod.SetProperties(atlasOptions);
                        defaultMeshModifierStack.Add(atlasMod);
                    }
                    else
                    {
                        var heightMod = CreateInstance <HeightModifier>();
                        heightMod.SetProperties(_layerProperties.extrusionOptions);
                        defaultMeshModifierStack.Add(heightMod);
                    }
                }

                //collider modifier options
                if (_layerProperties.colliderOptions.colliderType != ColliderType.None)
                {
                    var polyColliderMod = CreateInstance <ColliderModifier>();
                    polyColliderMod.SetProperties(_layerProperties.colliderOptions);
                    defaultGOModifierStack.Add(polyColliderMod);
                }

                var styleMod = CreateInstance <MaterialModifier>();

                styleMod.SetProperties(geometryMaterialOptions);
                defaultGOModifierStack.Add(styleMod);

                if (geometryMaterialOptions.texturingType == UvMapType.AtlasWithColorPalette)
                {
                    var colorPaletteMod = CreateInstance <MapboxStylesColorModifier>();
                    colorPaletteMod.m_scriptablePalette = geometryMaterialOptions.colorPalette;

                    defaultGOModifierStack.Add(colorPaletteMod);
                }
                break;

            default:
                break;
            }

            _defaultStack.MeshModifiers.AddRange(defaultMeshModifierStack);
            _defaultStack.GoModifiers.AddRange(defaultGOModifierStack);

            //Add any additional modifiers that were added.
            _defaultStack.MeshModifiers.AddRange(_layerProperties.MeshModifiers);
            _defaultStack.GoModifiers.AddRange(_layerProperties.GoModifiers);

            //Adding filters from the types dropdown

            //if ((MapboxSpecialLayerParameters.LayerNameTypeProperty.ContainsKey(properties.coreOptions.layerName)) && !string.IsNullOrEmpty(properties.selectedTypes))
            //{
            //	LayerFilter filter = new LayerFilter(LayerFilterOperationType.Contains);

            //	filter.Key = MapboxSpecialLayerParameters.LayerNameTypeProperty[properties.coreOptions.layerName];
            //	filter.PropertyValue = properties.selectedTypes;

            //	//if (properties.coreOptions.layerName == properties.roadLayer)
            //	//{
            //	//	filter.Key = properties.roadLayer_TypeProperty;
            //	//	filter.PropertyValue = properties.selectedTypes;
            //	//}
            //	//else if (properties.coreOptions.layerName == "landuse")
            //	//{
            //	//	filter.Key = properties.landuseLayer_TypeProperty;
            //	//	filter.PropertyValue = properties.selectedTypes;
            //	//}
            //	properties.filterOptions.filters.Add(filter);
            //}
        }
示例#17
0
        public override void SetProperties(VectorSubLayerProperties properties)
        {
            var item = properties as PrefabItemOptions;

            SubLayerProperties = item;

            _performanceOptions = item.performanceOptions;

            item.filterOptions.filters.Clear();

            //These are fixed properties
            item.coreOptions.geometryType = item.primitiveType;
            item.extrusionOptions         = new GeometryExtrusionOptions
            {
                extrusionType = item.extrusionType
            };

            item.coreOptions.combineMeshes = item.combineMeshes;
            item.moveFeaturePositionTo     = item._movePrefabFeaturePositionTo;

            string layerName = "";

            if (item.layerNameFromFindByTypeDictionary.TryGetValue(item.findByType, out layerName))
            {
                item.coreOptions.layerName = layerName;
                base.Key = layerName;
            }

            if (item.spawnPrefabOptions.prefab == null)
            {
                item.spawnPrefabOptions.prefab = Resources.Load <GameObject>("MapboxPin");
                Debug.LogWarning("No prefab assigned for POI Layer - " + layerName + " , using default prefab! You may want to assign a custom prefab.");
            }

            //These properties are dependent on user choices
            if (item.findByType != LocationPrefabFindBy.AddressOrLatLon)
            {
                if (item.findByType == LocationPrefabFindBy.MapboxCategory)
                {
                    SetCategoryFilterOptions(item);
                }
                if (item.findByType == LocationPrefabFindBy.POIName)
                {
                    SetNameFilters(item);
                }

                SetDensityFilters(item);
            }

            switch (item.coreOptions.geometryType)
            {
            case VectorPrimitiveType.Point:
#if ENABLE_WINMD_SUPPORT
                if (typeof(PrefabItemOptions).GetTypeInfo().IsAssignableFrom(item.GetType().GetTypeInfo())) //to check that the instance is of type PrefabItemOptions
#else
                if (typeof(PrefabItemOptions).IsAssignableFrom(item.GetType()))                             //to check that the instance is of type PrefabItemOptions
#endif
                {
                    PrefabItemOptions itemProperties = (PrefabItemOptions)item;

                    if (_defaultStack == null)
                    {
                        _defaultStack = ScriptableObject.CreateInstance <ModifierStack>();
                    }

                    (_defaultStack as ModifierStack).moveFeaturePositionTo = item.moveFeaturePositionTo;
                    if (itemProperties.snapToTerrain == true)
                    {
                        AddOrCreateMeshModifier <SnapTerrainModifier>();
                    }

                    if (_defaultStack.GoModifiers == null)
                    {
                        _defaultStack.GoModifiers = new List <GameObjectModifier>();
                    }

                    if (item.findByType == LocationPrefabFindBy.MapboxCategory)
                    {
                        if (_prefabModifier != null)
                        {
                            _prefabModifier.Clear();
                        }
                        _defaultStack.GoModifiers.Clear();
                    }

                    if ((item.findByType == LocationPrefabFindBy.MapboxCategory && item.categories == LocationPrefabCategories.None))
                    {
                        itemProperties.spawnPrefabOptions.PropertyHasChanged += UpdatePois;
                    }
                    else
                    {
                        _prefabModifier = AddOrCreateGameObjectModifier <PrefabModifier>();
                        _prefabModifier.SetProperties(itemProperties.spawnPrefabOptions);
                        _prefabModifier.ModifierHasChanged += UpdatePois;
                    }
                }
                break;

            default:
                break;
            }

            item.coreOptions.PropertyHasChanged += UpdatePois;
            (SubLayerProperties as PrefabItemOptions).PropertyHasChanged += UpdatePois;
        }
        public void DrawUI(SerializedProperty property)
        {
            objectId = property.serializedObject.targetObject.GetInstanceID().ToString();
            var         serializedMapObject = property.serializedObject;
            AbstractMap mapObject           = (AbstractMap)serializedMapObject.targetObject;

            tileJSONData = mapObject.VectorData.GetTileJsonData();

            var sourceTypeProperty = property.FindPropertyRelative("_sourceType");
            var sourceTypeValue    = (VectorSourceType)sourceTypeProperty.enumValueIndex;

            var displayNames = sourceTypeProperty.enumDisplayNames;
            var names        = sourceTypeProperty.enumNames;
            int count        = sourceTypeProperty.enumDisplayNames.Length;

            if (!_isGUIContentSet)
            {
                _sourceTypeContent = new GUIContent[count];

                var index = 0;
                foreach (var name in names)
                {
                    _sourceTypeContent[index] = new GUIContent
                    {
                        text    = displayNames[index],
                        tooltip = ((VectorSourceType)Enum.Parse(typeof(VectorSourceType), name)).Description(),
                    };
                    index++;
                }

                //				for (int index0 = 0; index0 < count; index0++)
                //				{
                //					_sourceTypeContent[index0] = new GUIContent
                //					{
                //						text = displayNames[index0],
                //						tooltip = ((VectorSourceType)index0).Description(),
                //					};
                //				}
                _isGUIContentSet = true;
            }

            //sourceTypeValue = (VectorSourceType)sourceTypeProperty.enumValueIndex;
            sourceTypeValue = ((VectorSourceType)Enum.Parse(typeof(VectorSourceType), names[sourceTypeProperty.enumValueIndex]));
            var sourceOptionsProperty = property.FindPropertyRelative("sourceOptions");
            var layerSourceProperty   = sourceOptionsProperty.FindPropertyRelative("layerSource");
            var layerSourceId         = layerSourceProperty.FindPropertyRelative("Id");
            var isActiveProperty      = sourceOptionsProperty.FindPropertyRelative("isActive");

            switch (sourceTypeValue)
            {
            case VectorSourceType.MapboxStreets:
            case VectorSourceType.MapboxStreetsV8:
            case VectorSourceType.MapboxStreetsWithBuildingIds:
            case VectorSourceType.MapboxStreetsV8WithBuildingIds:
                var sourcePropertyValue = MapboxDefaultVector.GetParameters(sourceTypeValue);
                layerSourceId.stringValue = sourcePropertyValue.Id;
                GUI.enabled = false;
                if (_isInitialized)
                {
                    LoadEditorTileJSON(property, sourceTypeValue, layerSourceId.stringValue);
                }
                else
                {
                    _isInitialized = true;
                }
                if (tileJSONData.PropertyDisplayNames.Count == 0 && tileJSONData.tileJSONLoaded)
                {
                    EditorGUILayout.HelpBox("Invalid Tileset Id / There might be a problem with the internet connection.", MessageType.Error);
                }
                GUI.enabled = true;
                isActiveProperty.boolValue = true;
                break;

            case VectorSourceType.Custom:
                if (_isInitialized)
                {
                    string test = layerSourceId.stringValue;
                    LoadEditorTileJSON(property, sourceTypeValue, layerSourceId.stringValue);
                }
                else
                {
                    _isInitialized = true;
                }
                if (tileJSONData.PropertyDisplayNames.Count == 0 && tileJSONData.tileJSONLoaded)
                {
                    EditorGUILayout.HelpBox("Invalid Tileset Id / There might be a problem with the internet connection.", MessageType.Error);
                }
                isActiveProperty.boolValue = true;
                break;

            case VectorSourceType.None:
                isActiveProperty.boolValue = false;
                break;

            default:
                isActiveProperty.boolValue = false;
                break;
            }

            if (sourceTypeValue != VectorSourceType.None)
            {
                EditorGUILayout.LabelField(new GUIContent
                {
                    text    = "Map Features",
                    tooltip = "Visualizers for vector features contained in a layer. "
                });

                var subLayerArray = property.FindPropertyRelative("vectorSubLayers");

                var layersRect = EditorGUILayout.GetControlRect(GUILayout.MinHeight(Mathf.Max(subLayerArray.arraySize + 1, 1) * _lineHeight + MultiColumnHeader.DefaultGUI.defaultHeight),
                                                                GUILayout.MaxHeight((subLayerArray.arraySize + 1) * _lineHeight + MultiColumnHeader.DefaultGUI.defaultHeight));

                if (!m_Initialized)
                {
                    bool firstInit   = m_MultiColumnHeaderState == null;
                    var  headerState = FeatureSubLayerTreeView.CreateDefaultMultiColumnHeaderState();
                    if (MultiColumnHeaderState.CanOverwriteSerializedFields(m_MultiColumnHeaderState, headerState))
                    {
                        MultiColumnHeaderState.OverwriteSerializedFields(m_MultiColumnHeaderState, headerState);
                    }
                    m_MultiColumnHeaderState = headerState;

                    var multiColumnHeader = new FeatureSectionMultiColumnHeader(headerState);

                    if (firstInit)
                    {
                        multiColumnHeader.ResizeToFit();
                    }

                    treeModel = new TreeModel <FeatureTreeElement>(GetData(subLayerArray));
                    if (m_TreeViewState == null)
                    {
                        m_TreeViewState = new TreeViewState();
                    }

                    if (layerTreeView == null)
                    {
                        layerTreeView = new FeatureSubLayerTreeView(m_TreeViewState, multiColumnHeader, treeModel);
                    }
                    layerTreeView.multiColumnHeader = multiColumnHeader;
                    m_Initialized = true;
                }
                layerTreeView.Layers = subLayerArray;
                layerTreeView.Reload();
                layerTreeView.OnGUI(layersRect);

                if (layerTreeView.hasChanged)
                {
                    EditorHelper.CheckForModifiedProperty(property);
                    layerTreeView.hasChanged = false;
                }

                selectedLayers = layerTreeView.GetSelection();

                //if there are selected elements, set the selection index at the first element.
                //if not, use the Selection index to persist the selection at the right index.
                if (selectedLayers.Count > 0)
                {
                    //ensure that selectedLayers[0] isn't out of bounds
                    if (selectedLayers[0] - FeatureSubLayerTreeView.uniqueIdFeature > subLayerArray.arraySize - 1)
                    {
                        selectedLayers[0] = subLayerArray.arraySize - 1 + FeatureSubLayerTreeView.uniqueIdFeature;
                    }

                    SelectionIndex = selectedLayers[0];
                }
                else
                {
                    if (SelectionIndex > 0 && (SelectionIndex - FeatureSubLayerTreeView.uniqueIdFeature <= subLayerArray.arraySize - 1))
                    {
                        selectedLayers = new int[1] {
                            SelectionIndex
                        };
                        layerTreeView.SetSelection(selectedLayers);
                    }
                }

                GUILayout.Space(EditorGUIUtility.singleLineHeight);

                EditorGUILayout.BeginHorizontal();
                GenericMenu menu = new GenericMenu();
                foreach (var name in Enum.GetNames(typeof(PresetFeatureType)))
                {
                    menu.AddItem(new GUIContent()
                    {
                        text = name
                    }, false, FetchPresetProperties, name);
                }
                GUILayout.Space(0);                 // do not remove this line; it is needed for the next line to work
                Rect rect = GUILayoutUtility.GetLastRect();
                rect.y += 2 * _lineHeight / 3;

                if (EditorGUILayout.DropdownButton(new GUIContent {
                    text = "Add Feature"
                }, FocusType.Passive, (GUIStyle)"minibuttonleft"))
                {
                    menu.DropDown(rect);
                }

                //Assign subLayerProperties after fetching it from the presets class. This happens everytime an element is added
                if (subLayerProperties != null)
                {
                    subLayerArray.arraySize++;
                    var subLayer = subLayerArray.GetArrayElementAtIndex(subLayerArray.arraySize - 1);
                    SetSubLayerProps(subLayer);

                    //Refreshing the tree
                    layerTreeView.Layers = subLayerArray;
                    layerTreeView.AddElementToTree(subLayer);
                    layerTreeView.Reload();

                    selectedLayers = new int[1] {
                        subLayerArray.arraySize - 1 + FeatureSubLayerTreeView.uniqueIdFeature
                    };
                    layerTreeView.SetSelection(selectedLayers);
                    subLayerProperties = null;                     // setting this to null so that the if block is not called again

                    if (EditorHelper.DidModifyProperty(property))
                    {
                        isLayerAdded = true;
                    }
                }

                if (GUILayout.Button(new GUIContent("Remove Selected"), (GUIStyle)"minibuttonright"))
                {
                    foreach (var index in selectedLayers.OrderByDescending(i => i))
                    {
                        if (layerTreeView != null)
                        {
                            var subLayer = subLayerArray.GetArrayElementAtIndex(index - FeatureSubLayerTreeView.uniqueIdFeature);

                            VectorLayerProperties    vectorLayerProperties    = (VectorLayerProperties)EditorHelper.GetTargetObjectOfProperty(property);
                            VectorSubLayerProperties vectorSubLayerProperties = (VectorSubLayerProperties)EditorHelper.GetTargetObjectOfProperty(subLayer);

                            vectorLayerProperties.OnSubLayerPropertyRemoved(new VectorLayerUpdateArgs {
                                property = vectorSubLayerProperties
                            });

                            layerTreeView.RemoveItemFromTree(index);
                            subLayerArray.DeleteArrayElementAtIndex(index - FeatureSubLayerTreeView.uniqueIdFeature);
                            layerTreeView.treeModel.SetData(GetData(subLayerArray));
                        }
                    }

                    selectedLayers = new int[0];
                    layerTreeView.SetSelection(selectedLayers);
                }

                EditorGUILayout.EndHorizontal();

                GUILayout.Space(EditorGUIUtility.singleLineHeight);

                if (selectedLayers.Count == 1 && subLayerArray.arraySize != 0 && selectedLayers[0] - FeatureSubLayerTreeView.uniqueIdFeature >= 0)
                {
                    //ensure that selectedLayers[0] isn't out of bounds
                    if (selectedLayers[0] - FeatureSubLayerTreeView.uniqueIdFeature > subLayerArray.arraySize - 1)
                    {
                        selectedLayers[0] = subLayerArray.arraySize - 1 + FeatureSubLayerTreeView.uniqueIdFeature;
                    }

                    SelectionIndex = selectedLayers[0];

                    var layerProperty = subLayerArray.GetArrayElementAtIndex(SelectionIndex - FeatureSubLayerTreeView.uniqueIdFeature);

                    layerProperty.isExpanded = true;
                    var  subLayerCoreOptions = layerProperty.FindPropertyRelative("coreOptions");
                    bool isLayerActive       = subLayerCoreOptions.FindPropertyRelative("isActive").boolValue;
                    if (!isLayerActive)
                    {
                        GUI.enabled = false;
                    }

                    DrawLayerVisualizerProperties(sourceTypeValue, layerProperty, property);

                    if (!isLayerActive)
                    {
                        GUI.enabled = true;
                    }
                }
                else
                {
                    GUILayout.Label("Select a visualizer to see properties");
                }
            }
        }
        /// <summary>
        /// Fetches the preset properties using the supplied <see cref="PresetFeatureType">PresetFeatureType</see>
        /// </summary>
        /// <param name="name">Name.</param>
        void FetchPresetProperties(object name)
        {
            PresetFeatureType featureType = ((PresetFeatureType)Enum.Parse(typeof(PresetFeatureType), name.ToString()));

            subLayerProperties = PresetSubLayerPropertiesFetcher.GetSubLayerProperties(featureType);
        }
        /// <summary>
        /// Gets the default sub layer properties for the chosen preset type.
        /// </summary>
        /// <returns>The sub layer properties.</returns>
        /// <param name="type">Type.</param>
        public static VectorSubLayerProperties GetSubLayerProperties(PresetFeatureType type)
        {
            //CoreOptions properties
            VectorPrimitiveType geometryType = VectorPrimitiveType.Polygon;
            string layerName    = "building";
            string sublayerName = "Untitled";
            float  lineWidth    = 1.0f;

            //Geometry Extrusion Options
            ExtrusionType         extrusionType         = ExtrusionType.None;
            ExtrusionGeometryType extrusionGeometryType = ExtrusionGeometryType.RoofAndSide;
            string propertyName         = "height";
            float  extrusionScaleFactor = 1.0f;

            //Filter Options
            LayerFilterCombinerOperationType combinerType = LayerFilterCombinerOperationType.Any;
            List <LayerFilter> filters = new List <LayerFilter>();


            // Material Options
            StyleTypes style = StyleTypes.Realistic;

            //Misc options
            bool buildingsWithUniqueIds           = true;
            PositionTargetType positionTargetType = PositionTargetType.TileCenter;

            //Modifiers
            List <MeshModifier>       meshModifiers       = new List <MeshModifier>();
            List <GameObjectModifier> gameObjectModifiers = new List <GameObjectModifier>();
            ColliderType colliderType = ColliderType.None;

            switch (type)
            {
            case PresetFeatureType.Buildings:
                layerName             = "building";
                geometryType          = VectorPrimitiveType.Polygon;
                extrusionType         = ExtrusionType.PropertyHeight;
                extrusionGeometryType = ExtrusionGeometryType.RoofAndSide;
                propertyName          = "height";
                style = StyleTypes.Realistic;
                break;

            case PresetFeatureType.Roads:
                layerName    = "road";
                geometryType = VectorPrimitiveType.Line;
                lineWidth    = 1.0f;
                style        = StyleTypes.Custom;
                break;

            case PresetFeatureType.Points:
                layerName    = "poi_label";
                geometryType = VectorPrimitiveType.Point;
                break;

            case PresetFeatureType.Landuse:
                layerName    = "landuse";
                geometryType = VectorPrimitiveType.Polygon;
                break;

            case PresetFeatureType.Custom:
                break;

            default:
                break;
            }

            VectorSubLayerProperties _properties = new VectorSubLayerProperties();

            _properties.presetFeatureType = type;

            _properties.coreOptions = new CoreVectorLayerProperties
            {
                isActive      = true,
                layerName     = layerName,
                geometryType  = geometryType,
                snapToTerrain = true,
                combineMeshes = false,
                lineWidth     = lineWidth,
                sublayerName  = sublayerName
            };

            _properties.extrusionOptions = new GeometryExtrusionOptions
            {
                extrusionType         = extrusionType,
                extrusionGeometryType = extrusionGeometryType,
                propertyName          = propertyName,
                extrusionScaleFactor  = extrusionScaleFactor
            };

            _properties.filterOptions = new VectorFilterOptions
            {
                combinerType = combinerType,
                filters      = filters
            };

            _properties.materialOptions = new GeometryMaterialOptions
            {
                style = style,
            };

            _properties.buildingsWithUniqueIds = buildingsWithUniqueIds;
            _properties.moveFeaturePositionTo  = positionTargetType;
            _properties.MeshModifiers          = meshModifiers;
            _properties.GoModifiers            = gameObjectModifiers;
            _properties.colliderOptions        = new ColliderOptions
            {
                colliderType = colliderType
            };

            return(_properties);
        }
 public virtual void SetProperties(VectorSubLayerProperties properties)
 {
 }
示例#22
0
 void Start()
 {
     sample_data_i2 = 0;
     sampleModifier = ScriptableObject.CreateInstance <Modifier_Template>();
     buildingLayer  = GameObject.Find("Map").GetComponent <AbstractMap>().VectorData.GetFeatureSubLayerAtIndex(0);
 }
 public SubLayerModeling(VectorSubLayerProperties subLayerProperties)
 {
     _subLayerProperties = subLayerProperties;
 }
示例#24
0
        public override void SetProperties(VectorSubLayerProperties properties)
        {
            _coreModifiers = new HashSet <ModifierBase>();

            if (_layerProperties == null && properties != null)
            {
                _layerProperties = properties;
                if (_performanceOptions == null && properties.performanceOptions != null)
                {
                    _performanceOptions = properties.performanceOptions;
                }
            }

            if (_layerProperties.coreOptions.combineMeshes)
            {
                if (_defaultStack == null)
                {
                    _defaultStack = ScriptableObject.CreateInstance <MergedModifierStack>();
                }
                else if (!(_defaultStack is MergedModifierStack))
                {
                    _defaultStack.Clear();
                    DestroyImmediate(_defaultStack);
                    _defaultStack = ScriptableObject.CreateInstance <MergedModifierStack>();
                }
                else
                {
                    // HACK - to clean out the Modifiers.
                    // Will this trigger GC that we could avoid ??
                    _defaultStack.MeshModifiers.Clear();
                    _defaultStack.GoModifiers.Clear();
                }
            }
            else
            {
                if (_defaultStack == null)
                {
                    _defaultStack = ScriptableObject.CreateInstance <ModifierStack>();
                    ((ModifierStack)_defaultStack).moveFeaturePositionTo = _layerProperties.moveFeaturePositionTo;
                }
                if (!(_defaultStack is ModifierStack))
                {
                    _defaultStack.Clear();
                    DestroyImmediate(_defaultStack);
                    _defaultStack = ScriptableObject.CreateInstance <ModifierStack>();
                    ((ModifierStack)_defaultStack).moveFeaturePositionTo = _layerProperties.moveFeaturePositionTo;
                }
                else
                {
                    // HACK - to clean out the Modifiers.
                    // Will this trigger GC that we could avoid ??
                    _defaultStack.MeshModifiers.Clear();
                    _defaultStack.GoModifiers.Clear();
                }
            }

            //Add any additional modifiers that were added.
            if (_defaultStack.MeshModifiers == null)
            {
                _defaultStack.MeshModifiers = new List <MeshModifier>();
            }
            if (_defaultStack.GoModifiers == null)
            {
                _defaultStack.GoModifiers = new List <GameObjectModifier>();
            }

            // Setup material options.
            _layerProperties.materialOptions.SetDefaultMaterialOptions();

            switch (_layerProperties.coreOptions.geometryType)
            {
            case VectorPrimitiveType.Point:
            case VectorPrimitiveType.Custom:
            {
                // Let the user add anything that they want
                if (_layerProperties.coreOptions.snapToTerrain == true)
                {
                    AddOrCreateMeshModifier <SnapTerrainModifier>();
                }

                break;
            }

            case VectorPrimitiveType.Line:
            {
                if (_layerProperties.coreOptions.snapToTerrain == true)
                {
                    AddOrCreateMeshModifier <SnapTerrainModifier>();
                }

                var lineMeshMod = AddOrCreateMeshModifier <LineMeshModifier>();
                lineMeshMod.SetProperties(_layerProperties.lineGeometryOptions);
                lineMeshMod.ModifierHasChanged += UpdateVector;

                if (_layerProperties.extrusionOptions.extrusionType != Map.ExtrusionType.None)
                {
                    var heightMod = AddOrCreateMeshModifier <HeightModifier>();
                    heightMod.SetProperties(_layerProperties.extrusionOptions);
                    heightMod.ModifierHasChanged += UpdateVector;
                }
                else
                {
                    _layerProperties.extrusionOptions.PropertyHasChanged += UpdateVector;
                }

                //collider modifier options
                var lineColliderMod = AddOrCreateGameObjectModifier <ColliderModifier>();
                lineColliderMod.SetProperties(_layerProperties.colliderOptions);
                lineColliderMod.ModifierHasChanged += UpdateVector;

                var lineStyleMod = AddOrCreateGameObjectModifier <MaterialModifier>();
                lineStyleMod.SetProperties(_layerProperties.materialOptions);
                lineStyleMod.ModifierHasChanged += UpdateVector;

                break;
            }

            case VectorPrimitiveType.Polygon:
            {
                if (_layerProperties.coreOptions.snapToTerrain == true)
                {
                    AddOrCreateMeshModifier <SnapTerrainModifier>();
                }

                var poly = AddOrCreateMeshModifier <PolygonMeshModifier>();

                UVModifierOptions uvModOptions = new UVModifierOptions();
                uvModOptions.texturingType = (_layerProperties.materialOptions.style == StyleTypes.Custom) ? _layerProperties.materialOptions.customStyleOptions.texturingType : _layerProperties.materialOptions.texturingType;
                uvModOptions.atlasInfo     = (_layerProperties.materialOptions.style == StyleTypes.Custom) ? _layerProperties.materialOptions.customStyleOptions.atlasInfo : _layerProperties.materialOptions.atlasInfo;
                uvModOptions.style         = _layerProperties.materialOptions.style;
                poly.SetProperties(uvModOptions);

                if (_layerProperties.extrusionOptions.extrusionType != Map.ExtrusionType.None)
                {
                    //replace materialOptions with styleOptions
                    bool useTextureSideWallModifier =
                        (_layerProperties.materialOptions.style == StyleTypes.Custom) ?
                        (_layerProperties.materialOptions.customStyleOptions.texturingType == UvMapType.Atlas || _layerProperties.materialOptions.customStyleOptions.texturingType == UvMapType.AtlasWithColorPalette)
                                                                : (_layerProperties.materialOptions.texturingType == UvMapType.Atlas || _layerProperties.materialOptions.texturingType == UvMapType.AtlasWithColorPalette);

                    if (useTextureSideWallModifier)
                    {
                        var atlasMod = AddOrCreateMeshModifier <TextureSideWallModifier>();
                        GeometryExtrusionWithAtlasOptions atlasOptions = new GeometryExtrusionWithAtlasOptions(_layerProperties.extrusionOptions, uvModOptions);
                        atlasMod.SetProperties(atlasOptions);
                        _layerProperties.extrusionOptions.PropertyHasChanged += UpdateVector;
                    }
                    else
                    {
                        var heightMod = AddOrCreateMeshModifier <HeightModifier>();
                        heightMod.SetProperties(_layerProperties.extrusionOptions);
                        heightMod.ModifierHasChanged += UpdateVector;
                    }
                }
                else
                {
                    _layerProperties.extrusionOptions.PropertyHasChanged += UpdateVector;
                }

                //collider modifier options
                var polyColliderMod = AddOrCreateGameObjectModifier <ColliderModifier>();
                polyColliderMod.SetProperties(_layerProperties.colliderOptions);
                polyColliderMod.ModifierHasChanged += UpdateVector;

                var styleMod = AddOrCreateGameObjectModifier <MaterialModifier>();
                styleMod.SetProperties(_layerProperties.materialOptions);
                styleMod.ModifierHasChanged += UpdateVector;


                bool isCustomStyle = (_layerProperties.materialOptions.style == StyleTypes.Custom);
                if ((isCustomStyle) ? (_layerProperties.materialOptions.customStyleOptions.texturingType == UvMapType.AtlasWithColorPalette)
                                                        : (_layerProperties.materialOptions.texturingType == UvMapType.AtlasWithColorPalette))
                {
                    var colorPaletteMod = AddOrCreateGameObjectModifier <MapboxStylesColorModifier>();
                    colorPaletteMod.m_scriptablePalette = (isCustomStyle) ? _layerProperties.materialOptions.customStyleOptions.colorPalette : _layerProperties.materialOptions.colorPalette;
                    _layerProperties.materialOptions.PropertyHasChanged += UpdateVector;
                    //TODO: Add SetProperties Method to MapboxStylesColorModifier
                }

                break;
            }

            default:
                break;
            }

            _layerProperties.coreOptions.PropertyHasChanged   += UpdateVector;
            _layerProperties.filterOptions.PropertyHasChanged += UpdateVector;

            _layerProperties.filterOptions.RegisterFilters();
            if (_layerProperties.MeshModifiers != null)
            {
                _defaultStack.MeshModifiers.AddRange(_layerProperties.MeshModifiers);
            }
            if (_layerProperties.GoModifiers != null)
            {
                _defaultStack.GoModifiers.AddRange(_layerProperties.GoModifiers);
            }

            _layerProperties.PropertyHasChanged += UpdateVector;
        }
示例#25
0
        public void SetProperties(VectorSubLayerProperties properties, LayerPerformanceOptions performanceOptions)
        {
            List <MeshModifier>       defaultMeshModifierStack = new List <MeshModifier>();
            List <GameObjectModifier> defaultGOModifierStack   = new List <GameObjectModifier>();

            _layerProperties    = properties;
            _performanceOptions = performanceOptions;

            Active = _layerProperties.coreOptions.isActive;

            if (properties.coreOptions.groupFeatures)
            {
                _defaultStack = ScriptableObject.CreateInstance <MergedModifierStack>();
            }
            else
            {
                _defaultStack = ScriptableObject.CreateInstance <ModifierStack>();
                ((ModifierStack)_defaultStack).moveFeaturePositionTo = _layerProperties.moveFeaturePositionTo;
            }

            _defaultStack.MeshModifiers = new List <MeshModifier>();
            _defaultStack.GoModifiers   = new List <GameObjectModifier>();

            switch (properties.coreOptions.geometryType)
            {
            case VectorPrimitiveType.Point:
            case VectorPrimitiveType.Custom:
                // Let the user add anything that they want
                if (_layerProperties.coreOptions.snapToTerrain == true)
                {
                    defaultMeshModifierStack.Add(CreateInstance <SnapTerrainModifier>());
                }
                break;

            case VectorPrimitiveType.Line:

                var lineMeshMod = CreateInstance <LineMeshModifier>();
                lineMeshMod.Width = _layerProperties.coreOptions.lineWidth;
                defaultMeshModifierStack.Add(lineMeshMod);

                if (_layerProperties.extrusionOptions.extrusionType != Map.ExtrusionType.None)
                {
                    var heightMod = CreateInstance <HeightModifier>();
                    heightMod.SetProperties(_layerProperties.extrusionOptions);
                    defaultMeshModifierStack.Add(heightMod);
                }
                if (_layerProperties.coreOptions.snapToTerrain == true)
                {
                    defaultMeshModifierStack.Add(CreateInstance <SnapTerrainModifier>());
                }

                //collider modifier options
                if (_layerProperties.colliderOptions.colliderType != ColliderType.None)
                {
                    var lineColliderMod = CreateInstance <ColliderModifier>();
                    lineColliderMod.SetProperties(_layerProperties.colliderOptions);
                    defaultGOModifierStack.Add(lineColliderMod);
                }

                var lineStyleMod = CreateInstance <MaterialModifier>();
                lineStyleMod.SetProperties(MapboxDefaultStyles.GetGeometryMaterialOptions(_layerProperties.materialOptions));
                defaultGOModifierStack.Add(lineStyleMod);

                break;

            case VectorPrimitiveType.Polygon:
                if (_layerProperties.coreOptions.snapToTerrain == true)
                {
                    defaultMeshModifierStack.Add(CreateInstance <SnapTerrainModifier>());
                }
                defaultMeshModifierStack.Add(CreateInstance <PolygonMeshModifier>());

                GeometryMaterialOptions geometryMaterialOptions = MapboxDefaultStyles.GetGeometryMaterialOptions(_layerProperties.materialOptions);

                UVModifierOptions uvModOptions = new UVModifierOptions();
                uvModOptions.texturingType = geometryMaterialOptions.texturingType;
                uvModOptions.atlasInfo     = geometryMaterialOptions.atlasInfo;
                uvModOptions.style         = geometryMaterialOptions.style;

                var uvMod = CreateInstance <UvModifier>();
                uvMod.SetProperties(uvModOptions);
                defaultMeshModifierStack.Add(uvMod);

                if (_layerProperties.extrusionOptions.extrusionType != Map.ExtrusionType.None)
                {
                    //replace materialOptions with styleOptions
                    if (geometryMaterialOptions.texturingType == UvMapType.Atlas || geometryMaterialOptions.texturingType == UvMapType.AtlasWithColorPalette)
                    {
                        var atlasMod = CreateInstance <TextureSideWallModifier>();
                        GeometryExtrusionWithAtlasOptions atlasOptions = new GeometryExtrusionWithAtlasOptions(_layerProperties.extrusionOptions, uvModOptions);
                        atlasMod.SetProperties(atlasOptions);
                        defaultMeshModifierStack.Add(atlasMod);
                    }
                    else
                    {
                        var heightMod = CreateInstance <HeightModifier>();
                        heightMod.SetProperties(_layerProperties.extrusionOptions);
                        defaultMeshModifierStack.Add(heightMod);
                    }
                }

                //collider modifier options
                if (_layerProperties.colliderOptions.colliderType != ColliderType.None)
                {
                    var polyColliderMod = CreateInstance <ColliderModifier>();
                    polyColliderMod.SetProperties(_layerProperties.colliderOptions);
                    defaultGOModifierStack.Add(polyColliderMod);
                }

                var styleMod = CreateInstance <MaterialModifier>();

                styleMod.SetProperties(geometryMaterialOptions);
                defaultGOModifierStack.Add(styleMod);

                if (geometryMaterialOptions.texturingType == UvMapType.AtlasWithColorPalette)
                {
                    var colorPaletteMod = CreateInstance <MapboxStylesColorModifier>();
                    colorPaletteMod.m_scriptablePalette = geometryMaterialOptions.colorPalette;

                    defaultGOModifierStack.Add(colorPaletteMod);
                }
                break;

            default:
                break;
            }

            _defaultStack.MeshModifiers.AddRange(defaultMeshModifierStack);
            _defaultStack.GoModifiers.AddRange(defaultGOModifierStack);

            //Add any additional modifiers that were added.
            _defaultStack.MeshModifiers.AddRange(_layerProperties.MeshModifiers);
            _defaultStack.GoModifiers.AddRange(_layerProperties.GoModifiers);
        }