public SurfaceSpace(SurfaceTileController tileController, SurfaceGestureStrategy gestureStrategy, Transform surface, MaterialProvider materialProvider) : base(tileController, gestureStrategy, surface, materialProvider) { _tileController = tileController; Animator = new SurfaceAnimator(tileController); }
public TileHandler(Tile tile, MaterialProvider materialProvider, IList <IObserver <MapData> > observers, ITrace trace) { _tile = tile; _materialProvider = materialProvider; _observers = observers; _trace = trace; }
/// <summary> Adapts element data received in raw form. </summary> public static void AdaptElement(Tile tile, MaterialProvider materialProvider, IList <IObserver <MapData> > observers, ITrace trace, long id, double[] vertices, string[] tags, string[] styles) { Element element = AdaptElement(id, tags, vertices, styles); NotifyObservers(new MapData(tile, new Union <Element, Mesh>(element)), observers); }
// PUT api/MaterialProvider/5 public async Task <IHttpActionResult> PutMaterialProvider([FromUri] int id, [FromBody] MaterialProvider materialprovider) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != materialprovider.MaterialProviderId) { return(BadRequest()); } db.Entry(materialprovider).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!MaterialProviderExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
private static bool BuildObjectMesh(Tile tile, MaterialProvider materialProvider, string name, double[] vertices, int[] triangles, int[] colors, double[] uvs, int[] uvMap, out Vector3[] worldPoints, out Color[] unityColors, out int textureIndex, out Vector2[] unityUvs, out Vector2[] unityUvs2, out Vector2[] unityUvs3) { long id; if (!ShouldLoad(tile, name, out id)) { worldPoints = null; unityColors = null;; unityUvs = null; unityUvs2 = null; unityUvs3 = null; textureIndex = 0; return(false); } int uvCount = uvs.Length; int colorCount = colors.Length; worldPoints = new Vector3[vertices.Length / 3]; for (int i = 0; i < vertices.Length; i += 3) { worldPoints[i / 3] = tile.Projection .Project(new GeoCoordinate(vertices[i + 1], vertices[i]), vertices[i + 2]); } unityColors = new Color[colorCount]; for (int i = 0; i < colorCount; ++i) { unityColors[i] = ColorUtils.FromInt(colors[i]); } if (uvCount > 0) { var textureMapper = CreateTextureAtlasMapper(uvCount / 2, uvs, uvMap, materialProvider); for (int i = 0; i < uvCount; i += 2) { textureMapper.UnityUvs[i / 2] = new Vector2((float)uvs[i], (float)uvs[i + 1]); textureMapper.SetUvs(i / 2, i); } unityUvs = textureMapper.UnityUvs; unityUvs2 = textureMapper.UnityUvs2; unityUvs3 = textureMapper.UnityUvs3; textureIndex = textureMapper.TextureIndex; } else { unityUvs = new Vector2[worldPoints.Length]; unityUvs2 = null; unityUvs3 = null; textureIndex = 0; } tile.Register(id); return(true); }
private static bool BuildTerrainMesh(Tile tile, MaterialProvider materialProvider, string name, double[] vertices, int[] triangles, int[] colors, double[] uvs, int[] uvMap, out Vector3[] worldPoints, out Color[] unityColors, out int textureIndex, out Vector2[] unityUvs, out Vector2[] unityUvs2, out Vector2[] unityUvs3) { worldPoints = new Vector3[triangles.Length]; unityColors = new Color[triangles.Length]; var atlasMapper = CreateTextureAtlasMapper(triangles.Length, uvs, uvMap, materialProvider); for (int i = 0; i < triangles.Length; ++i) { int vertIndex = triangles[i] * 3; worldPoints[i] = tile.Projection .Project(new GeoCoordinate(vertices[vertIndex + 1], vertices[vertIndex]), vertices[vertIndex + 2]); unityColors[i] = ColorUtils.FromInt(colors[triangles[i]]); atlasMapper.SetUvs(i, triangles[i] * 2); triangles[i] = i; } unityUvs = atlasMapper.UnityUvs; unityUvs2 = atlasMapper.UnityUvs2; unityUvs3 = atlasMapper.UnityUvs3; textureIndex = atlasMapper.TextureIndex; return(true); }
public UnityModelBuilder(MaterialProvider materialProvider) { _materialProvider = materialProvider; // register custom builders here. _elementBuilders.Add("info", new PlaceElementBuilder(_materialProvider)); _elementBuilders.Add("label", new LabelElementBuilder()); _elementBuilders.Add("import", new ImportElementBuilder()); }
protected override void OnEnter(GeoCoordinate coordinate, bool isFromTop) { Camera.GetComponent <Skybox>().material = MaterialProvider.GetSharedMaterial(@"Skyboxes/Space/Skybox"); Pivot.rotation = Quaternion.Euler(new Vector3((float)coordinate.Latitude, 270 - (float)coordinate.Longitude, 0)); Camera.transform.localPosition = new Vector3(0, 0, isFromTop ? -TileController.HeightRange.Maximum : -TileController.HeightRange.Minimum); TileController.Update(Target); }
public static void LoadMaterial(MaterialProvider materialProvider, string folderLocation) { var materialPaths = FileServices.GetResourceFiles(folderLocation, ".mat"); //build textures and sprite foreach (var path in materialPaths) { var material = FileServices.LoadMaterialResources(path); materialProvider.AddMaterial(material); } }
public async Task <IHttpActionResult> PostMaterialProvider([FromBody] MaterialProvider materialprovider) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.MaterialProviders.Add(materialprovider); await db.SaveChangesAsync(); return(CreatedAtRoute("DefaultApi", new { id = materialprovider.MaterialProviderId }, materialprovider)); }
public async Task <IHttpActionResult> GetMaterialProvider([FromUri] int id) { MaterialProvider materialprovider = await db.MaterialProviders.FindAsync(id); if (materialprovider == null) { return(NotFound()); } MaterialProviderEntity matEntity = new MaterialProviderEntity(materialprovider); return(Ok(matEntity)); }
public Space(TileController tileController, GestureStrategy gestureStrategy, Transform target, MaterialProvider materialProvider) { Target = target; TileController = tileController; MaterialProvider = materialProvider; GestureStrategy = gestureStrategy; Pivot = tileController.Pivot; Camera = tileController.Pivot.Find("Camera").GetComponent <Camera>(); Light = tileController.Pivot.Find("Directional Light"); }
public async Task <IHttpActionResult> DeleteMaterialProvider([FromUri] int id) { MaterialProvider materialprovider = await db.MaterialProviders.FindAsync(id); if (materialprovider == null) { return(NotFound()); } db.MaterialProviders.Remove(materialprovider); await db.SaveChangesAsync(); return(Ok(materialprovider)); }
protected override void OnEnter(GeoCoordinate coordinate, bool isFromTop) { Camera.GetComponent <Skybox>().material = MaterialProvider.GetSharedMaterial(@"Skyboxes/Surface/Skybox"); Camera.transform.localRotation = Quaternion.Euler(90, 0, 0); Light.transform.localRotation = Quaternion.Euler(90, 0, 0); Pivot.localPosition = new Vector3(0, isFromTop ? TileController.HeightRange.Maximum : TileController.HeightRange.Minimum, 0); // surface specific _tileController.MoveGeoOrigin(coordinate); TileController.Update(Target); }
/// <summary> Adapts element data received from utymap. </summary> public static void AdaptElement(Tile tile, MaterialProvider materialProvider, IList <IObserver <MapData> > observers, ITrace trace, long id, double[] vertices, string[] tags, string[] styles) { int vertexCount = vertices.Length; var geometry = new GeoCoordinate[vertexCount / 3]; var heights = new double[vertexCount / 3]; for (int i = 0; i < vertexCount; i += 3) { geometry[i / 3] = new GeoCoordinate(vertices[i + 1], vertices[i]); heights[i / 3] = vertices[i + 2]; } Element element = new Element(id, geometry, heights, ReadDict(tags), ReadDict(styles)); NotifyObservers(new MapData(tile, new Union <Element, Mesh>(element)), observers); }
public void OpenMaterialManager() { var surfacesStore = XmlSerializer <List <Surface> > .Deserialize(PluginInfoProvider.PathToSurfacesStore, Log) ?? new List <Surface>(); var materialsStore = XmlSerializer <List <Material> > .Deserialize(PluginInfoProvider.PathToMaterialsStore, Log) ?? new List <Material>(); var materialProvider = new MaterialProvider(materialsStore, surfacesStore); var dialogResult = materialProvider.ShowDialog(); if (dialogResult != DialogResult.OK) { return; } XmlSerializer <List <Material> > .Serialize(materialProvider.MaterialsStore, PluginInfoProvider.PathToMaterialsStore); XmlSerializer <List <Surface> > .Serialize(materialProvider.SurfacesStore, PluginInfoProvider.PathToSurfacesStore); }
/// <inheritdoc /> public IObservable <int> Get(Tile tile, IList <IObserver <MapData> > observers) { // NOTE workaround for static methods requirement if (_sMaterialProvider == null) { lock (this) { _observers = observers; _sMaterialProvider = _materialProvider; } } var tag = tile.GetHashCode(); Tiles.TryAdd(tag, tile); var observable = Get(tile, tag, OnMeshBuiltHandler, OnElementLoadedHandler, OnErrorHandler); Tiles.TryRemove(tag); return(observable); }
public void MaterialProviderTest() { TestSetup(null); var materials = new List <Material>(); var surfaces = new List <Surface>(); materials.Add(material); materials.Add(material); materials.Add(material); materials.Add(material); surfaces.Add(surface); surfaces.Add(surface); surfaces.Add(surface); surfaces.Add(surface); var materialProvider = new MaterialProvider(materials, surfaces); materialProvider.ShowDialog(); }
/// <summary> Adapts mesh data received in raw form. </summary> public static void AdaptMesh(Tile tile, MaterialProvider materialProvider, IList <IObserver <MapData> > observers, ITrace trace, string name, double[] vertices, int[] triangles, int[] colors, double[] uvs, int[] uvMap) { Vector3[] worldPoints; Color[] unityColors; Vector2[] unityUvs; Vector2[] unityUvs2; Vector2[] unityUvs3; int textureIndex; // NOTE process terrain differently to emulate flat shading effect by avoiding // triangles to share the same vertex. Remove "if" branch if you don't need it bool isCreated = name.Contains("terrain") ? BuildTerrainMesh(tile, materialProvider, name, vertices, triangles, colors, uvs, uvMap, out worldPoints, out unityColors, out textureIndex, out unityUvs, out unityUvs2, out unityUvs3) : BuildObjectMesh(tile, materialProvider, name, vertices, triangles, colors, uvs, uvMap, out worldPoints, out unityColors, out textureIndex, out unityUvs, out unityUvs2, out unityUvs3); if (isCreated) { BuildMesh(tile, observers, trace, name, worldPoints, triangles, unityColors, textureIndex, unityUvs, unityUvs2, unityUvs3); } }
public void Start() { /* RESOURCE LIST CREATION */ #if UNITY_EDITOR AssetDatabase.Refresh(); FileServices.CreateResourcesList("Assets/Resources/resourceslist.txt"); #endif FileServices.LoadResourcesList("resourceslist"); #region LOAD RESOURCES // logger and ioc _logger = new Logger("info.log", false); _resolver = new IoCResolver(_logger); _resolver.RegisterItem(_logger); _config = new UserConfigurationManager(new UserConfigurationData { GameVolume = 1f, MusicVolume = 1f }); _resolver.RegisterItem(_config); // messager _messager = new Messager(); _resolver.RegisterItem(_messager); // unity reference master _unity = GetComponent <UnityReferenceMaster>(); _unity.DebugModeActive = false; _resolver.RegisterItem(_unity); // player var player = new UserAccountManager(); _resolver.RegisterItem(player); // material provider var materialProvider = new MaterialProvider(_logger); MaterialLoader.LoadMaterial(materialProvider, "Materials"); _resolver.RegisterItem(materialProvider); // texture provider var textureProvider = new TextureProvider(_logger); var spriteProvider = new SpriteProvider(_logger); TextureLoader.LoadTextures(textureProvider, spriteProvider, "Textures"); _resolver.RegisterItem(textureProvider); _resolver.RegisterItem(spriteProvider); // sound provider var soundProvider = new SoundProvider(_logger); SoundLoader.LoadSounds(_logger, soundProvider, "Sounds"); _resolver.RegisterItem(soundProvider); // prefab provider var prefabProvider = new PrefabProvider(_logger); PrefabLoader.LoadPrefabs(prefabProvider); _resolver.RegisterItem(prefabProvider); // pooling var poolingObjectManager = new PoolingObjectManager(_logger, prefabProvider); _resolver.RegisterItem(poolingObjectManager); var soundPoolManager = new PoolingAudioPlayer(_logger, _config, _unity, prefabProvider.GetPrefab("audio_source_prefab")); _resolver.RegisterItem(soundPoolManager); _particles = new PoolingParticleManager(_resolver); _resolver.RegisterItem(_particles); // canvas provider var canvasProvider = new CanvasProvider(_logger); _unity.LoadCanvases(canvasProvider); _resolver.RegisterItem(canvasProvider); // data provider var gameDataProvider = new GameDataProvider(_logger); /* DATA GOES HERE */ _resolver.RegisterItem(gameDataProvider); #endregion _uiManager = new UiManager(); _resolver.RegisterItem(_uiManager); // lock the resolver (stop any new items being registered) _resolver.Lock(); /* BEGIN STATE */ _currentState = new MenuState(_resolver); _currentState.Initialize(); /* SUBSCRIBE FOR GAME END */ _onExit = _messager.Subscribe <ExitMessage>(OnExit); }
protected override void OnRender(DrawingContext drawingContext) { //TODO potential rendering loop. if (FilteredData.Count < 1) { FilteredData = DataFilter.Filter(DataSorter.Sort(Data)); base.OnRender(drawingContext); return; } visualContext = new ParetoChartVisualContext(); PART_bars.Children.Clear(); PART_barlabels.Children.Clear(); PART_line.Children.Clear(); PART_xaxis.Children.Clear(); //_highlightGrid.Children.Clear(); var max = FilteredData.MaxValue(); var context = new ProviderContext(FilteredData.Count); var barAvailableWidth = (PART_bars.RenderSize.Width) / FilteredData.Count; var barActiveWidth = barAvailableWidth * SegmentWidthPercentage; var barLeftSpacing = (barAvailableWidth - barActiveWidth) / 2; var barLabelSize = RenderingExtensions.EstimateLabelRenderSize(BarTotalFontFamily, BarTotalFontSize); MaterialProvider.Reset(context); #region X-Axis Label Generation var xtrace = 0; foreach (var d in FilteredData) { var material = MaterialProvider.ProvideNext(context); var categoryVisualContext = new ParetoChartCategoryVisualContext(); var axisLabel = new Label { Content = d.CategoryName, IsHitTestVisible = false, HorizontalContentAlignment = HorizontalAlignment.Center, VerticalContentAlignment = VerticalAlignment.Center, HorizontalAlignment = HorizontalAlignment.Left, VerticalAlignment = VerticalAlignment.Bottom, Width = barAvailableWidth, Margin = new Thickness(barAvailableWidth * xtrace, 0, 0, 0), DataContext = this, Foreground = XAxisForeground.GetMaterial(material) }; axisLabel.BindTextualPrimitive <XAxisPrimitive>(this); categoryVisualContext.AxisLabel = axisLabel; PART_xaxis.Children.Add(axisLabel); visualContext.CategoryVisuals.Add(categoryVisualContext); xtrace++; } #endregion MaterialProvider.Reset(context); var horizontalTrace = 0d; var xAxisHeight = barLabelSize.Height; //_xAxisGrid.ActualHeight; var backHeight = PART_bars.RenderSize.Height - xAxisHeight; var trace = 0; foreach (var d in FilteredData) { var currentCategoryVisualContext = visualContext.CategoryVisuals[trace]; currentCategoryVisualContext.CategoryDataPoint = d; //if (barActiveWidth <= 0 || backHeight <= 0) return; //TODO fix var material = MaterialProvider.ProvideNext(context); currentCategoryVisualContext.CategoryMaterialSet = material; var backRectangle = new Rectangle { Width = barActiveWidth, Height = Math.Abs(backHeight), VerticalAlignment = VerticalAlignment.Bottom, HorizontalAlignment = HorizontalAlignment.Left, Fill = SegmentSpaceBackground.GetMaterial(material), Margin = new Thickness(horizontalTrace + barLeftSpacing, 0, 0, xAxisHeight) }; currentCategoryVisualContext.InactiveBarVisual = backRectangle; PART_bars.Children.Add(backRectangle); var height = d.Value.Map(0, max, 0, PART_bars.RenderSize.Height - xAxisHeight - barLabelSize.Height); var rectangle = new Rectangle { Width = barActiveWidth, Height = Math.Abs(height), Fill = SegmentForeground.GetMaterial(material), VerticalAlignment = VerticalAlignment.Bottom, HorizontalAlignment = HorizontalAlignment.Left, Margin = new Thickness(horizontalTrace + barLeftSpacing, 0, 0, xAxisHeight), RenderTransform = new ScaleTransform(1, 0, .5, 1), RenderTransformOrigin = new Point(.5, 1) }; currentCategoryVisualContext.ActiveBarRenderTransformScaleYAnimationAspect = new AnimationAspect <double, Transform, DoubleAnimation>(rectangle.RenderTransform, ScaleTransform.ScaleYProperty, 0, 1, animationState) { AccelerationRatio = AnimationParameters.AccelerationRatio, DecelerationRatio = AnimationParameters.DecelerationRatio, Duration = TimeSpan.FromMilliseconds(800) }; //TODO replace .RenderedVisual pairing method completely d.RenderedVisual = rectangle; PART_bars.Children.Add(rectangle); #region Bar Value Label Generation var beginBarLabelMargin = new Thickness(horizontalTrace, 0, 0, xAxisHeight); var actualBarLabelMargin = new Thickness(horizontalTrace, 0, 0, xAxisHeight + height); var barLabel = new Label { Content = d.Value, IsHitTestVisible = false, HorizontalContentAlignment = HorizontalAlignment.Center, VerticalContentAlignment = VerticalAlignment.Center, HorizontalAlignment = HorizontalAlignment.Left, VerticalAlignment = VerticalAlignment.Bottom, Width = barAvailableWidth, Foreground = BarTotalForeground.GetMaterial(material) }; barLabel.BindTextualPrimitive <BarTotalPrimitive>(this); currentCategoryVisualContext.BarLabelMarginAnimationAspect = new AnimationAspect <Thickness, Label, ThicknessAnimation>( barLabel, MarginProperty, beginBarLabelMargin, actualBarLabelMargin, animationState) { AccelerationRatio = AnimationParameters.AccelerationRatio, DecelerationRatio = AnimationParameters.DecelerationRatio, Duration = TimeSpan.FromMilliseconds(800) }; #endregion PART_barlabels.Children.Add(barLabel); horizontalTrace += barAvailableWidth; trace++; } var total = FilteredData.SumValue(); var availableLineGraphSize = new Size(PART_bars.ActualWidth - (DotRadius * 2), PART_bars.ActualHeight - (DotRadius * 2) - xAxisHeight); var startX = (barAvailableWidth / 2) - DotRadius; var verticalpttrace = 0d; var pttrace = 0; var pathSegments = new PathSegmentCollection(); var pathFigure = new PathFigure { Segments = pathSegments }; MaterialProvider.Reset(context); var isFirstPoint = true; foreach (var d in FilteredData) { var material = MaterialProvider.ProvideNext(context); var currentCategoryVisualContext = visualContext.CategoryVisuals[pttrace]; var nextPoint = new Point(startX + (barAvailableWidth * pttrace), verticalpttrace + xAxisHeight); var baseAnimationPoint = new Point(nextPoint.X, 0).LocalizeInCartesianSpace(PART_line); var actualNextPoint = nextPoint.LocalizeInCartesianSpace(PART_line); // TODO get rid of this var plottedPoint = IsLoaded ? actualNextPoint : baseAnimationPoint; if (isFirstPoint) { visualContext.PolyLineStartPointAnimationAspect = new AnimationAspect <Point, PathFigure, PointAnimation>( pathFigure, PathFigure.StartPointProperty, baseAnimationPoint, actualNextPoint, animationState) { AccelerationRatio = AnimationParameters.AccelerationRatio, DecelerationRatio = AnimationParameters.DecelerationRatio, Duration = TimeSpan.FromMilliseconds(800), }; isFirstPoint = false; } else { var lineSegment = new LineSegment(plottedPoint, true) { IsSmoothJoin = true }; pathSegments.Add(lineSegment); visualContext.LineSegmentVisuals.Add(new ParetoChartLineSegmentVisualContext { PointAnimationAspect = new AnimationAspect <Point, LineSegment, PointAnimation>(lineSegment, LineSegment.PointProperty, baseAnimationPoint, actualNextPoint, animationState) { AccelerationRatio = AnimationParameters.AccelerationRatio, DecelerationRatio = AnimationParameters.DecelerationRatio, Duration = TimeSpan.FromMilliseconds(800) } }); } var beginDotMargin = new Thickness(nextPoint.X, 0, 0, xAxisHeight); var actualDotMargin = new Thickness(nextPoint.X, 0, 0, nextPoint.Y); var dot = new Ellipse { Width = (DotRadius * 2), Height = (DotRadius * 2), VerticalAlignment = VerticalAlignment.Bottom, HorizontalAlignment = HorizontalAlignment.Left, Fill = DotFill.GetMaterial(material), Stroke = DotStroke.GetMaterial(material), }; BindingOperations.SetBinding(dot, Shape.StrokeThicknessProperty, new Binding("DotStrokeThickness") { Source = this }); currentCategoryVisualContext.DotMarginAnimationAspect = new AnimationAspect <Thickness, Ellipse, ThicknessAnimation>(dot, MarginProperty, beginDotMargin, actualDotMargin, animationState) { AccelerationRatio = AnimationParameters.AccelerationRatio, DecelerationRatio = AnimationParameters.DecelerationRatio, Duration = TimeSpan.FromMilliseconds(800) }; PART_line.Children.Add(dot); Panel.SetZIndex(dot, 50); verticalpttrace += d.Value.Map(0, total, 0, availableLineGraphSize.Height); pttrace++; } var path = new Path { VerticalAlignment = VerticalAlignment.Bottom, HorizontalAlignment = HorizontalAlignment.Left, Data = new PathGeometry { Figures = new PathFigureCollection { pathFigure } }, Margin = new Thickness(DotRadius, 0, 0, xAxisHeight + DotRadius), Stroke = LineStroke.GetMaterial(FallbackMaterialSet), }; BindingOperations.SetBinding(path, Shape.StrokeThicknessProperty, new Binding("LineStrokeThickness") { Source = this }); PART_line.Children.Add(path); base.OnRender(drawingContext); }
public UnityModelBuilder(MaterialProvider materialProvider) { _materialProvider = materialProvider; }
private static TextureAtlasMapper CreateTextureAtlasMapper(int triangleCount, double[] uvs, int[] uvMap, MaterialProvider materialProvider) { const int infoEntrySize = 8; var count = uvMap == null ? 0 : uvMap.Length; List <TextureAtlasInfo> infos = new List <TextureAtlasInfo>(count / infoEntrySize); for (int i = 0; i < count;) { var info = new TextureAtlasInfo(); info.UvIndexRange = new Range <int>(!infos.Any() ? 0 : infos.Last().UvIndexRange.Maximum, uvMap[i++]); int textureIndex = uvMap[i++]; info.TextureIndex = textureIndex; info.HasAtlas = materialProvider.HasAtlas(textureIndex); int atlasWidth = uvMap[i++]; int atlasHeight = uvMap[i++]; float x = uvMap[i++]; float y = uvMap[i++]; float width = uvMap[i++]; float height = uvMap[i++]; bool isEmpty = atlasWidth == 0 || atlasHeight == 0; info.TextureSize = new Vector2(isEmpty ? 0 : width / atlasWidth, isEmpty ? 0 : height / atlasHeight); info.TextureOffset = new Vector2(isEmpty ? 0 : x / atlasWidth, isEmpty ? 0 : y / atlasHeight); infos.Add(info); } return(new TextureAtlasMapper(triangleCount, uvs, infos)); }
public SphereSpace(SphereTileController tileController, SphereGestureStrategy gestureStrategy, Transform planet, MaterialProvider materialProvider) : base(tileController, gestureStrategy, planet, materialProvider) { Animator = new SphereAnimator(tileController); }
protected override void OnRender(DrawingContext drawingContext) { //TODO potential rendering loop. if (FilteredData.Count < 1) { FilteredData = DataFilter.Filter(DataSorter.Sort(Data)); base.OnRender(drawingContext); return; } visualContext = new NestedArcChartVisualContext(); PART_segments.Children.Clear(); PART_inactivesegments.Children.Clear(); PART_categorylabels.Children.Clear(); var context = new ProviderContext(FilteredData.Count); MaterialProvider.Reset(context); var fullArcDiameter = PART_main.RenderSize.Height - TopRingPadding; var fullArcWidth = fullArcDiameter - BottomRingPadding; var subArcAvailableWidth = fullArcWidth / FilteredData.Count; var subArcActualWidth = subArcAvailableWidth * SegmentWidthPercentage; var subRingOffset = (subArcAvailableWidth - subArcActualWidth) / 2; var fullRadius = PART_main.RenderSize.Width / 2; var centerPoint = new Point(0, fullRadius); if (FilteredData.Count < 1) { base.OnRender(drawingContext); return; } var max = FilteredData.MaxValue(); var trace = 0; foreach (var d in FilteredData) { var categoryVisualContext = new NestedArcCategoryVisualContext(); var materialSet = MaterialProvider.ProvideNext(context); categoryVisualContext.CategoryDataPoint = d; var arcDiameter = BottomRingPadding + (subArcAvailableWidth * trace) + subRingOffset; var inactiveArcPath = CalculatePath(centerPoint, arcDiameter, subArcActualWidth); inactiveArcPath.Fill = SegmentSpaceBackground.GetMaterial(materialSet); //BindingOperations.SetBinding(inactiveArcPath, Shape.FillProperty, new Binding("SegmentSpaceBackground") { Source = this }); categoryVisualContext.InactiveArcVisual = inactiveArcPath; PART_inactivesegments.Children.Add(inactiveArcPath); var activeArcAngle = d.Value.Map(0, max, 0, MaxArcAngle); var activeArcPath = CalculateActiveArcPath(centerPoint, arcDiameter, subArcActualWidth, activeArcAngle); categoryVisualContext.CategoryMaterialSet = materialSet; activeArcPath.Fill = SegmentForeground.GetMaterial(materialSet); activeArcPath.MouseOverFill = materialSet.GetMaterial(Luminosity.P700); activeArcPath.RenderTransformOrigin = new Point(.5, 1); activeArcPath.RenderTransform = new RotateTransform((IsLoaded ? 0 : 180), .5, .5); d.RenderedVisual = activeArcPath; categoryVisualContext.ActiveArcVisual = activeArcPath; PART_segments.Children.Add(activeArcPath); visualContext.CategoryVisuals.Add(categoryVisualContext); trace++; } var ltrace = 0; for (var x = FilteredData.Count - 1; x >= 0; x--) { var d = FilteredData[x]; var currentCategoryVisualContext = visualContext.CategoryVisuals[x]; var shape = (Shape)d.RenderedVisual; //.ShouldBeCastable<Shape>(); var renderedFill = (SolidColorBrush)shape.Fill; //.ShouldBeType<SolidColorBrush>(); var arcLabelMarginLeft = fullRadius + LeftArcLabelSpacing; var categoryLabel = new Label { Width = ValueLabelHorizontalSpacing, VerticalAlignment = VerticalAlignment.Top, HorizontalAlignment = HorizontalAlignment.Left, VerticalContentAlignment = VerticalAlignment.Center, HorizontalContentAlignment = HorizontalAlignment.Left, Margin = new Thickness(arcLabelMarginLeft, (ltrace * subArcAvailableWidth) + subRingOffset + 6, 0, 0), //Foreground = renderedFill.Lighten(.2), Foreground = ValueForeground.GetMaterial(currentCategoryVisualContext.CategoryMaterialSet), Content = d.CategoryName.ToUpper(), Height = subArcAvailableWidth, Padding = new Thickness(0), Opacity = IsLoaded ? 1 : 0, // TODO isloaded DataContext = this }; currentCategoryVisualContext.CategoryLabel = categoryLabel; //BindingOperations.SetBinding(categoryLabel, FontFamilyProperty, new Binding("ValueFontFamily") { Source = this }); //BindingOperations.SetBinding(categoryLabel, FontStyleProperty, new Binding("ValueFontStyle") { Source = this }); //BindingOperations.SetBinding(categoryLabel, FontWeightProperty, new Binding("ValueFontWeight") { Source = this }); //BindingOperations.SetBinding(categoryLabel, FontSizeProperty, new Binding("ValueFontSize") { Source = this }); categoryLabel.BindTextualPrimitive <ValuePrimitive>(this); var valuePercentLabel = new Label { Width = ValueLabelHorizontalSpacing, VerticalAlignment = VerticalAlignment.Top, HorizontalAlignment = HorizontalAlignment.Left, VerticalContentAlignment = VerticalAlignment.Center, HorizontalContentAlignment = HorizontalAlignment.Right, Margin = new Thickness(arcLabelMarginLeft, (ltrace * subArcAvailableWidth) + subRingOffset + 6, 0, 0), //Foreground = renderedFill.Lighten(.2), Foreground = ValueForeground.GetMaterial(currentCategoryVisualContext.CategoryMaterialSet), Content = d.Value + " Minutes", Height = subArcAvailableWidth, Padding = new Thickness(0), Opacity = IsLoaded ? 1 : 0, DataContext = this }; currentCategoryVisualContext.ValuePercentLabel = valuePercentLabel; valuePercentLabel.BindTextualPrimitive <ValuePrimitive>(this); var valueLabelLeftSpace = arcLabelMarginLeft + ValueLabelHorizontalSpacing; var valueLabelWidth = PART_main.RenderSize.Width - valueLabelLeftSpace; if (valueLabelWidth < 0) { valueLabelWidth = 0; } var valueLabel = new Label() { Width = valueLabelWidth, VerticalAlignment = VerticalAlignment.Top, HorizontalAlignment = HorizontalAlignment.Left, VerticalContentAlignment = VerticalAlignment.Center, HorizontalContentAlignment = HorizontalAlignment.Left, Foreground = SecondaryValueForeground.GetMaterial(currentCategoryVisualContext.CategoryMaterialSet), Margin = new Thickness(arcLabelMarginLeft + ValueLabelHorizontalSpacing, (ltrace * subArcAvailableWidth) + subRingOffset + 6, 0, 0), Content = $" = {Math.Round(d.Value / 60, 2)} Hours", //{Math.Round(d.Value * 48):n0} Height = subArcAvailableWidth, Opacity = IsLoaded ? 1 : 0, // TODO isloaded Padding = new Thickness(0), }; currentCategoryVisualContext.ValueLabel = valueLabel; valueLabel.BindTextualPrimitive <SecondaryValuePrimitive>(this); PART_categorylabels.Children.Add(categoryLabel); PART_categorylabels.Children.Add(valuePercentLabel); PART_categorylabels.Children.Add(valueLabel); ltrace++; } base.OnRender(drawingContext); }
public void Load(string name) { List <StaticObjectVertex> vertices = GetVertices(); List <uint> indices = GetIndices(); MIntArray polygonIndexCounts = new MIntArray((uint)indices.Count / 3); MIntArray polygonIndices = new MIntArray((uint)indices.Count); MFloatPointArray meshVertices = new MFloatPointArray((uint)vertices.Count); MFloatArray arrayU = new MFloatArray((uint)vertices.Count); MFloatArray arrayV = new MFloatArray((uint)vertices.Count); MFnMesh mesh = new MFnMesh(); MDagPath meshDagPath = new MDagPath(); MDGModifier modifier = new MDGModifier(); MFnSet set = new MFnSet(); for (int i = 0; i < indices.Count / 3; i++) { polygonIndexCounts[i] = 3; } for (int i = 0; i < indices.Count; i++) { polygonIndices[i] = (int)indices[i]; } for (int i = 0; i < vertices.Count; i++) { StaticObjectVertex vertex = vertices[i]; meshVertices[i] = new MFloatPoint(vertex.Position.X, vertex.Position.Y, vertex.Position.Z); arrayU[i] = vertex.UV.X; arrayV[i] = 1 - vertex.UV.Y; } //Assign mesh data mesh.create(vertices.Count, indices.Count / 3, meshVertices, polygonIndexCounts, polygonIndices, arrayU, arrayV, MObject.kNullObj); mesh.getPath(meshDagPath); mesh.assignUVs(polygonIndexCounts, polygonIndices); //Set names mesh.setName(name); MFnTransform transformNode = new MFnTransform(mesh.parent(0)); transformNode.setName("transform_" + name); //Get render partition MFnPartition renderPartition = MayaHelper.FindRenderPartition(); //Create Materials uint startIndex = 0; for (int i = 0; i < this.Submeshes.Count; i++) { MFnDependencyNode dependencyNode = new MFnDependencyNode(); MFnLambertShader lambertShader = new MFnLambertShader(); StaticObjectSubmesh submesh = this.Submeshes[i]; lambertShader.create(true); lambertShader.setName(submesh.Name); lambertShader.color = MaterialProvider.GetMayaColor(i); MObject shadingEngine = dependencyNode.create("shadingEngine", submesh.Name + "_SG"); MObject materialInfo = dependencyNode.create("materialInfo", submesh.Name + "_MaterialInfo"); MPlug partitionPlug = new MFnDependencyNode(shadingEngine).findPlug("partition"); MPlug setsPlug = MayaHelper.FindFirstNotConnectedElement(renderPartition.findPlug("sets")); modifier.connect(partitionPlug, setsPlug); MPlug outColorPlug = lambertShader.findPlug("outColor"); MPlug surfaceShaderPlug = new MFnDependencyNode(shadingEngine).findPlug("surfaceShader"); modifier.connect(outColorPlug, surfaceShaderPlug); MPlug messagePlug = new MFnDependencyNode(shadingEngine).findPlug("message"); MPlug shadingGroupPlug = new MFnDependencyNode(materialInfo).findPlug("shadingGroup"); modifier.connect(messagePlug, shadingGroupPlug); modifier.doIt(); MFnSingleIndexedComponent component = new MFnSingleIndexedComponent(); MObject faceComponent = component.create(MFn.Type.kMeshPolygonComponent); MIntArray groupPolygonIndices = new MIntArray(); uint endIndex = (startIndex + (uint)submesh.Indices.Count) / 3; for (uint j = startIndex / 3; j < endIndex; j++) { groupPolygonIndices.append((int)j); } component.addElements(groupPolygonIndices); set.setObject(shadingEngine); set.addMember(meshDagPath, faceComponent); startIndex += (uint)submesh.Indices.Count; } mesh.updateSurface(); }
public void Load(string name, SKLFile skl = null) { MIntArray polygonIndexCounts = new MIntArray((uint)this.Indices.Count / 3); MIntArray polygonIndices = new MIntArray((uint)this.Indices.Count); MFloatPointArray vertices = new MFloatPointArray((uint)this.Vertices.Count); MFloatArray arrayU = new MFloatArray((uint)this.Vertices.Count); MFloatArray arrayV = new MFloatArray((uint)this.Vertices.Count); MVectorArray normals = new MVectorArray((uint)this.Vertices.Count); MIntArray normalIndices = new MIntArray((uint)this.Vertices.Count); MFnMesh mesh = new MFnMesh(); MDagPath meshDagPath = new MDagPath(); MDGModifier modifier = new MDGModifier(); MFnSet set = new MFnSet(); for (int i = 0; i < this.Indices.Count / 3; i++) { polygonIndexCounts[i] = 3; } for (int i = 0; i < this.Indices.Count; i++) { polygonIndices[i] = this.Indices[i]; } for (int i = 0; i < this.Vertices.Count; i++) { SKNVertex vertex = this.Vertices[i]; vertices[i] = new MFloatPoint(vertex.Position.X, vertex.Position.Y, vertex.Position.Z); arrayU[i] = vertex.UV.X; arrayV[i] = 1 - vertex.UV.Y; normals[i] = new MVector(vertex.Normal.X, vertex.Normal.Y, vertex.Normal.Z); normalIndices[i] = i; } //Assign mesh data mesh.create(this.Vertices.Count, this.Indices.Count / 3, vertices, polygonIndexCounts, polygonIndices, arrayU, arrayV, MObject.kNullObj); mesh.setVertexNormals(normals, normalIndices); mesh.getPath(meshDagPath); mesh.assignUVs(polygonIndexCounts, polygonIndices); //Set names mesh.setName(name); MFnTransform transformNode = new MFnTransform(mesh.parent(0)); transformNode.setName("transform_" + name); //Get render partition MGlobal.displayInfo("SKNFile:Load - Searching for Render Partition"); MItDependencyNodes itDependencyNodes = new MItDependencyNodes(MFn.Type.kPartition); MFnPartition renderPartition = new MFnPartition(); bool foundRenderPartition = false; for (; !itDependencyNodes.isDone; itDependencyNodes.next()) { renderPartition.setObject(itDependencyNodes.thisNode); MGlobal.displayInfo("SKNFile:Load - Iterating through partition: " + renderPartition.name + " IsRenderPartition: " + renderPartition.isRenderPartition); if (renderPartition.name == "renderPartition" && renderPartition.isRenderPartition) { MGlobal.displayInfo("SKNFile:Load - Found render partition"); foundRenderPartition = true; break; } } //Create Materials for (int i = 0; i < this.Submeshes.Count; i++) { MFnDependencyNode dependencyNode = new MFnDependencyNode(); MFnLambertShader lambertShader = new MFnLambertShader(); SKNSubmesh submesh = this.Submeshes[i]; MObject shader = lambertShader.create(true); lambertShader.setName(submesh.Name); lambertShader.color = MaterialProvider.GetMayaColor(i); MObject shadingEngine = dependencyNode.create("shadingEngine", submesh.Name + "_SG"); MObject materialInfo = dependencyNode.create("materialInfo", submesh.Name + "_MaterialInfo"); if (foundRenderPartition) { MPlug partitionPlug = new MFnDependencyNode(shadingEngine).findPlug("partition"); MPlug setsPlug = MayaHelper.FindFirstNotConnectedElement(renderPartition.findPlug("sets")); modifier.connect(partitionPlug, setsPlug); } else { MGlobal.displayInfo("SKNFile:Load - Couldn't find Render Partition for mesh: " + name + "." + submesh.Name); } MPlug outColorPlug = lambertShader.findPlug("outColor"); MPlug surfaceShaderPlug = new MFnDependencyNode(shadingEngine).findPlug("surfaceShader"); modifier.connect(outColorPlug, surfaceShaderPlug); MPlug messagePlug = new MFnDependencyNode(shadingEngine).findPlug("message"); MPlug shadingGroupPlug = new MFnDependencyNode(materialInfo).findPlug("shadingGroup"); modifier.connect(messagePlug, shadingGroupPlug); modifier.doIt(); MFnSingleIndexedComponent component = new MFnSingleIndexedComponent(); MObject faceComponent = component.create(MFn.Type.kMeshPolygonComponent); MIntArray groupPolygonIndices = new MIntArray(); uint endIndex = (submesh.StartIndex + submesh.IndexCount) / 3; for (uint j = submesh.StartIndex / 3; j < endIndex; j++) { groupPolygonIndices.append((int)j); } component.addElements(groupPolygonIndices); set.setObject(shadingEngine); set.addMember(meshDagPath, faceComponent); } if (skl == null) { mesh.updateSurface(); } else { MFnSkinCluster skinCluster = new MFnSkinCluster(); MSelectionList jointPathsSelectionList = new MSelectionList(); jointPathsSelectionList.add(meshDagPath); for (int i = 0; i < skl.Influences.Count; i++) { short jointIndex = skl.Influences[i]; SKLJoint joint = skl.Joints[jointIndex]; jointPathsSelectionList.add(skl.JointDagPaths[jointIndex]); MGlobal.displayInfo(string.Format("SKNFile:Load:Bind - Added joint [{0}] {1} to binding selection", joint.ID, joint.Name)); } MGlobal.selectCommand(jointPathsSelectionList); MGlobal.executeCommand("skinCluster -mi 4 -tsb -n skinCluster_" + name); MPlug inMeshPlug = mesh.findPlug("inMesh"); MPlugArray inMeshConnections = new MPlugArray(); inMeshPlug.connectedTo(inMeshConnections, true, false); if (inMeshConnections.length == 0) { MGlobal.displayError("SKNFile:Load:Bind - Failed to find the created Skin Cluster"); throw new Exception("SKNFile:Load:Bind - Failed to find the created Skin Cluster"); } MPlug outputGeometryPlug = inMeshConnections[0]; MDagPathArray influencesDagPaths = new MDagPathArray(); skinCluster.setObject(outputGeometryPlug.node); skinCluster.influenceObjects(influencesDagPaths); MIntArray influenceIndices = new MIntArray((uint)skl.Influences.Count); for (int i = 0; i < skl.Influences.Count; i++) { MDagPath influencePath = skl.JointDagPaths[skl.Influences[i]]; for (int j = 0; j < skl.Influences.Count; j++) { if (influencesDagPaths[j].partialPathName == influencePath.partialPathName) { influenceIndices[i] = j; MGlobal.displayInfo("SKNReader:Load:Bind - Added Influence Joint: " + i + " -> " + j); break; } } } MFnSingleIndexedComponent singleIndexedComponent = new MFnSingleIndexedComponent(); MObject vertexComponent = singleIndexedComponent.create(MFn.Type.kMeshVertComponent); MIntArray groupVertexIndices = new MIntArray((uint)this.Vertices.Count); for (int i = 0; i < this.Vertices.Count; i++) { groupVertexIndices[i] = i; } singleIndexedComponent.addElements(groupVertexIndices); MGlobal.executeCommand(string.Format("setAttr {0}.normalizeWeights 0", skinCluster.name)); MDoubleArray weights = new MDoubleArray((uint)(this.Vertices.Count * skl.Influences.Count)); for (int i = 0; i < this.Vertices.Count; i++) { SKNVertex vertex = this.Vertices[i]; for (int j = 0; j < 4; j++) { double weight = vertex.Weights[j]; int influence = vertex.BoneIndices[j]; if (weight != 0) { weights[(i * skl.Influences.Count) + influence] = weight; } } } skinCluster.setWeights(meshDagPath, vertexComponent, influenceIndices, weights, false); MGlobal.executeCommand(string.Format("setAttr {0}.normalizeWeights 1", skinCluster.name)); MGlobal.executeCommand(string.Format("skinPercent -normalize true {0} {1}", skinCluster.name, mesh.name)); mesh.updateSurface(); } }
protected override void OnRender(DrawingContext drawingContext) { PART_bars.Children.Clear(); PART_xAxis.Children.Clear(); PART_highlight.Children.Clear(); if (FilteredData.Count < 1) { base.OnRender(drawingContext); return; } var total = FilteredData.MaxValue(); var context = new ProviderContext(FilteredData.Count); var barAvailableWidth = PART_bars.RenderSize.Width / FilteredData.Count; var barActiveWidth = barAvailableWidth * SegmentWidthPercentage; var barLeftSpacing = (barAvailableWidth - barActiveWidth) / 2; var barLabelSize = RenderingExtensions.EstimateLabelRenderSize(BarTotalFontFamily, BarTotalFontSize); MaterialProvider.Reset(context); var xtrace = 0; foreach (var d in FilteredData) { var materialSet = MaterialProvider.ProvideNext(context); var axisLabel = new Label { Content = d.CategoryName, IsHitTestVisible = false, HorizontalContentAlignment = HorizontalAlignment.Center, VerticalContentAlignment = VerticalAlignment.Center, HorizontalAlignment = HorizontalAlignment.Left, VerticalAlignment = VerticalAlignment.Bottom, Width = barAvailableWidth, Margin = new Thickness(barAvailableWidth * xtrace, 0, 0, 0), Foreground = BarTotalForeground.GetMaterial(materialSet), DataContext = this }; axisLabel.BindTextualPrimitive <XAxisPrimitive>(this); PART_xAxis.Children.Add(axisLabel); xtrace++; } var horizontalTrace = 0d; var xAxisHeight = PART_xAxis.ActualHeight; var backHeight = PART_bars.RenderSize.Height - xAxisHeight; MaterialProvider.Reset(context); foreach (var d in FilteredData) { var materialSet = MaterialProvider.ProvideNext(context); var backRectangle = new Rectangle { Width = barActiveWidth, Height = backHeight, VerticalAlignment = VerticalAlignment.Bottom, HorizontalAlignment = HorizontalAlignment.Left, Margin = new Thickness(horizontalTrace + barLeftSpacing, 0, 0, xAxisHeight), Fill = SegmentSpaceBackground.GetMaterial(materialSet) }; //backRectangle.MouseEnter += (s, e) => barMouseEnter(d); //BindingOperations.SetBinding(backRectangle, Shape.FillProperty, new Binding("SegmentSpaceBackground") { Source = this }); PART_bars.Children.Add(backRectangle); var verticalTrace = 0d; var pathBuffer = new List <Shape>(); var height = d.Value.Map(0, total, 0, PART_bars.RenderSize.Height - xAxisHeight - barLabelSize.Height); var rectangle = new Rectangle { Width = barActiveWidth, Height = height + verticalTrace, Fill = SegmentForeground.GetMaterial(materialSet), VerticalAlignment = VerticalAlignment.Bottom, HorizontalAlignment = HorizontalAlignment.Left, Margin = new Thickness(horizontalTrace + barLeftSpacing, 0, 0, xAxisHeight) }; //rectangle.MouseEnter += (s, e) => barMouseEnter(d); //rectangle.MouseLeave += (s, e) => barMouseLeave(s, e, d, sd); rectangle.RenderTransform = new ScaleTransform(1, (IsLoaded ? 1 : 0), .5, 1); //TODO get rid of all isloaded conditional sets rectangle.RenderTransformOrigin = new Point(.5, 1); d.RenderedVisual = rectangle; pathBuffer.Add(rectangle); verticalTrace += height; for (var x = pathBuffer.Count - 1; x >= 0; x--) { var path = pathBuffer[x]; PART_bars.Children.Add(path); } var barLabel = new Label { Content = d.Value, IsHitTestVisible = false, HorizontalContentAlignment = HorizontalAlignment.Center, VerticalContentAlignment = VerticalAlignment.Center, HorizontalAlignment = HorizontalAlignment.Left, VerticalAlignment = VerticalAlignment.Bottom, Width = barAvailableWidth, Foreground = BarTotalForeground.GetMaterial(materialSet), Margin = new Thickness(horizontalTrace, 0, 0, xAxisHeight + verticalTrace), }; barLabel.BindTextualPrimitive <BarTotalPrimitive>(this); d.RenderedVisual = pathBuffer; PART_bars.Children.Add(barLabel); horizontalTrace += barAvailableWidth; } base.OnRender(drawingContext); }
protected override void OnRender(DrawingContext drawingContext) { if (FilteredData.Count < 1) { base.OnRender(drawingContext); return; } visualContext = new LineGraphVisualContext(); _bars.Children.Clear(); _barLabels.Children.Clear(); _lineVisual.Children.Clear(); _xAxisGrid.Children.Clear(); //_highlightGrid.Children.Clear(); var max = FilteredData.MaxValue(); var context = new ProviderContext(FilteredData.Count); var barAvailableWidth = (_bars.RenderSize.Width) / FilteredData.Count; MaterialProvider.Reset(context); MaterialProvider.Reset(context); var total = FilteredData.SumValue(); var availableLineGraphSize = new Size(_bars.ActualWidth - (DotRadius * 2), _bars.ActualHeight - (DotRadius * 2)); var startX = (barAvailableWidth / 2) - DotRadius; var verticalpttrace = 0d; var pttrace = 0; var pathSegments = new PathSegmentCollection(); var pathFigure = new PathFigure { Segments = pathSegments }; MaterialProvider.Reset(context); var isFirstPoint = true; foreach (var d in FilteredData) { var material = MaterialProvider.ProvideNext(context); var nextPoint = new Point(startX + (barAvailableWidth * pttrace), verticalpttrace + 0); var baseAnimationPoint = new Point(nextPoint.X, 0).LocalizeInCartesianSpace(_lineVisual); var actualNextPoint = nextPoint.LocalizeInCartesianSpace(_lineVisual); // TODO get rid of this var plottedPoint = IsLoaded ? actualNextPoint : baseAnimationPoint; if (isFirstPoint) { visualContext.PolyLineStartPointAnimationAspect = new AnimationAspect <Point, PathFigure, PointAnimation>( pathFigure, PathFigure.StartPointProperty, baseAnimationPoint, actualNextPoint, animationState) { AccelerationRatio = AnimationParameters.AccelerationRatio, DecelerationRatio = AnimationParameters.DecelerationRatio, Duration = TimeSpan.FromMilliseconds(800), }; isFirstPoint = false; } else { var lineSegment = new LineSegment(plottedPoint, true) { IsSmoothJoin = true }; pathSegments.Add(lineSegment); visualContext.LineSegmentVisuals.Add(new LineGraphLineSegmentVisualContext { PointAnimationAspect = new AnimationAspect <Point, LineSegment, PointAnimation>(lineSegment, LineSegment.PointProperty, baseAnimationPoint, actualNextPoint, animationState) { AccelerationRatio = AnimationParameters.AccelerationRatio, DecelerationRatio = AnimationParameters.DecelerationRatio, Duration = TimeSpan.FromMilliseconds(800) } }); } var beginDotMargin = new Thickness(nextPoint.X, 0, 0, 0); var actualDotMargin = new Thickness(nextPoint.X, 0, 0, nextPoint.Y); var dot = new Ellipse { Width = (DotRadius * 2), Height = (DotRadius * 2), VerticalAlignment = VerticalAlignment.Bottom, HorizontalAlignment = HorizontalAlignment.Left, Fill = DotFill.GetMaterial(material), Stroke = DotStroke.GetMaterial(material), }; BindingOperations.SetBinding(dot, Shape.StrokeThicknessProperty, new Binding("DotStrokeThickness") { Source = this }); //currentCategoryVisualContext.DotMarginAnimationAspect = // new AnimationAspect<Thickness, Ellipse, ThicknessAnimation>(dot, MarginProperty, // beginDotMargin, actualDotMargin, animationState) // { // AccelerationRatio = AnimationParameters.AccelerationRatio, // DecelerationRatio = AnimationParameters.DecelerationRatio, // Duration = TimeSpan.FromMilliseconds(800) // }; _lineVisual.Children.Add(dot); Panel.SetZIndex(dot, 50); verticalpttrace += d.Value.Map(0, total, 0, availableLineGraphSize.Height); pttrace++; } var path = new Path { VerticalAlignment = VerticalAlignment.Bottom, HorizontalAlignment = HorizontalAlignment.Left, Data = new PathGeometry { Figures = new PathFigureCollection { pathFigure } }, Margin = new Thickness(DotRadius, 0, 0, 0 + DotRadius), Stroke = LineStroke.GetMaterial(FallbackMaterialSet), }; BindingOperations.SetBinding(path, Shape.StrokeThicknessProperty, new Binding("LineStrokeThickness") { Source = this }); _lineVisual.Children.Add(path); base.OnRender(drawingContext); }
public void Start() { /* RESOURCE LIST CREATION */ #if UNITY_EDITOR AssetDatabase.Refresh(); FileServices.CreateResourcesList("Assets/Resources/resourceslist.txt"); #endif FileServices.LoadResourcesList("resourceslist"); #region LOAD RESOURCES // logger and ioc _logger = new Logger("info.log", false); _resolver = new IoCResolver(_logger); _resolver.RegisterItem(_logger); _config = new UserConfigurationManager(new UserConfigurationData { GameVolume = 1f, MusicVolume = 1f }); _resolver.RegisterItem(_config); // messager _messager = new Messager(); _resolver.RegisterItem(_messager); // unity reference master _unity = GetComponent<UnityReferenceMaster>(); _unity.DebugModeActive = false; _resolver.RegisterItem(_unity); // player var player = new UserAccountManager(); _resolver.RegisterItem(player); // material provider var materialProvider = new MaterialProvider(_logger); MaterialLoader.LoadMaterial(materialProvider,"Materials"); _resolver.RegisterItem(materialProvider); // texture provider var textureProvider = new TextureProvider(_logger); var spriteProvider = new SpriteProvider(_logger); TextureLoader.LoadTextures(textureProvider, spriteProvider, "Textures"); _resolver.RegisterItem(textureProvider); _resolver.RegisterItem(spriteProvider); // sound provider var soundProvider = new SoundProvider(_logger); SoundLoader.LoadSounds(_logger, soundProvider, "Sounds"); _resolver.RegisterItem(soundProvider); // prefab provider var prefabProvider = new PrefabProvider(_logger); PrefabLoader.LoadPrefabs(prefabProvider); _resolver.RegisterItem(prefabProvider); // pooling var poolingObjectManager = new PoolingObjectManager(_logger, prefabProvider); _resolver.RegisterItem(poolingObjectManager); var soundPoolManager = new PoolingAudioPlayer(_logger, _config, _unity, prefabProvider.GetPrefab("audio_source_prefab")); _resolver.RegisterItem(soundPoolManager); _particles = new PoolingParticleManager(_resolver); _resolver.RegisterItem(_particles); // canvas provider var canvasProvider = new CanvasProvider(_logger); _unity.LoadCanvases(canvasProvider); _resolver.RegisterItem(canvasProvider); // data provider var gameDataProvider = new GameDataProvider(_logger); /* DATA GOES HERE */ _resolver.RegisterItem(gameDataProvider); #endregion _uiManager = new UiManager(); _resolver.RegisterItem(_uiManager); // lock the resolver (stop any new items being registered) _resolver.Lock(); /* BEGIN STATE */ _currentState = new MenuState(_resolver); _currentState.Initialize(); /* SUBSCRIBE FOR GAME END */ _onExit = _messager.Subscribe<ExitMessage>(OnExit); }
public MapDataLibrary(MaterialProvider materialProvider, IPathResolver pathResolver, ITrace trace) { _materialProvider = materialProvider; _pathResolver = pathResolver; _trace = trace; }