protected StoryFlowchartNodeGizmoComponent(IEmbeddedResources embeddedResources, IViewService viewService) { this.viewService = viewService; GlobalRectangle = new AaRectangle2(Vector2.Zero, 1, 1); var squareModel = embeddedResources.SimplePlaneXyModel(); var material = StandardMaterial.New(this) .SetDiffuseColor(x => x.DiffuseColorToUse()) .SetDiffuseMap(x => x.DiffuseMapToUse()) .SetIgnoreLighting(true) .SetHighlightEffect(x => x.viewService.SelectedNode == ReferencedNode ? HighlightEffect.RainbowBorder : x.viewService.ClosestStoryNode == ReferencedNode ? HighlightEffect.Pulsating : HighlightEffect.None); visualElement = new ModelVisualElement <StoryFlowchartNodeGizmoComponent>(this) .SetModel(squareModel) .SetMaterial(material) .SetTransform(x => Transform.Translation(new Vector3(x.GlobalRectangle.Center, x.Depth * 0.1f))) .SetNonUniformScale(x => new Vector3(x.GlobalRectangle.HalfWidth, -/*todo: correct text-coords*/ x.GlobalRectangle.HalfHeight, 1)); hittable = new RectangleHittable <StoryFlowchartNodeGizmoComponent>(this, Transform.Identity, x => new AaRectangle2(Vector2.Zero, x.GlobalRectangle.HalfWidth, x.GlobalRectangle.HalfHeight), x => - x.Depth); }
protected UserQuerySceneComponent(IUserQueryService queryService, IEmbeddedResources embeddedResources, IRtImageBuilder textImageBuilder) { this.queryService = queryService; this.textImageBuilder = textImageBuilder; planeModel = embeddedResources.SimplePlaneXyModel(); optionRects = new List <AaRectangle2>(); visualElements = new List <IVisualElement>(); hittable = new RectangleHittable <UserQuerySceneComponent>(this, Transform.Identity, x => new AaRectangle2(Vector2.Zero, 1f, 1f), x => 0); }
protected ImageRectangleComponent(IEmbeddedResources embeddedResources) { var material = StandardMaterial.New(this) .SetDiffuseMap(x => x.Image) .SetIgnoreLighting(true); visualElement = new ModelVisualElement <ImageRectangleComponent>(this) .SetModel(embeddedResources.SimplePlaneXyModel()) .SetMaterial(material) .SetTransform(x => Transform.Translation(new Vector3(x.Rectangle.Center, 0))) .SetNonUniformScale(x => new Vector3(x.Rectangle.HalfWidth, x.Rectangle.HalfHeight, 1)); }
public SimpleStoryLayout(IKeyboardInputProvider keyboardInputProvider, IEmbeddedResources embeddedResources) { this.keyboardInputProvider = keyboardInputProvider; planeModel = embeddedResources.SimplePlaneXyModel(); planeMaterials = new[] { new Color4(120, 222, 44), new Color4(222, 120, 44), new Color4(44, 120, 222), new Color4(222, 44, 120), new Color4(64, 222, 160), new Color4(120, 44, 222), }.Select(x => StandardMaterial.New(x).FromGlobalCache()) .Select(x => (IStandardMaterial)x) .ToArray(); }
protected CirclePackingAutoComponent(IEmbeddedResources embeddedResources, IViewService viewService, ICoroutineService coroutineService) { this.embeddedResources = embeddedResources; this.coroutineService = coroutineService; solver = new CirclePackingSolver(); Reset(); borderModel = new ExplicitModel(ResourceVolatility.Stable) { IndexSubranges = new ExplicitModelIndexSubrange[1], Topology = ExplicitModelPrimitiveTopology.LineStrip }; backgroundVisualElement = ModelVisualElement.New(this) .SetModel(embeddedResources.SimplePlaneXyModel()) .SetMaterial(StandardMaterial.New() .SetIgnoreLighting(true) .SetDiffuseColor(Color4.Black) .FromGlobalCache()) .SetRenderState(StandardRenderState.New() .SetZOffset(-GraphicsHelper.MinZOffset)) .SetTransform(x => Transform.Translation(new Vector3(x.border.BoundingRect.Center, 0))) .SetNonUniformScale(x => new Vector3( x.border.BoundingRect.HalfWidth, x.border.BoundingRect.HalfHeight, 1)); borderVisualElement = ModelVisualElement.New(this) .SetModel(x => x.GetRelevantBorderModel()) .SetMaterial(StandardMaterial.New() .SetDiffuseColor(Color4.Yellow) .SetIgnoreLighting(true) .FromGlobalCache()); circleVisualElements = new List <IVisualElement>(); selectOnClickInterationElement = new SelectOnClickInteractionElement(this, viewService); // todo: make precise hittable = new RectangleHittable <CirclePackingAutoComponent>(this, Transform.Identity, x => x.border.BoundingRect, x => 0); }
private void Reset() { simulationRunning = false; simulationTimestamp = 0; prevQueue = new Queue <FluidSimulationFrame>(); var size = new IntSize3(Width, Height, 1); var cellSize = CellSize; fluidSimulation.Reset(CreateConfig()); model = CreateModel(size, cellSize, fluidSimulation.Particles.Length); levelSetImageData = new byte[fluidSimulation.LevelSet.Size.Width * fluidSimulation.LevelSet.Size.Height * 4]; levelSetImage = new RawImage(ResourceVolatility.Volatile, new IntSize2(fluidSimulation.LevelSet.Size.Width, fluidSimulation.LevelSet.Size.Height), true, levelSetImageData); squareModel = embeddedResources.SimplePlaneXyModel(); visualElements.Clear(); visualElements.Add(ModelVisualElement.New() .SetModel(model) .SetMaterial(StandardMaterial.New() .SetDiffuseColor(Color4.Yellow) .SetIgnoreLighting(true) .FromGlobalCache())); visualElements.Add(ModelVisualElement.New() .SetModel(model) .SetModelPartIndex(1) .SetMaterial(StandardMaterial.New() .SetDiffuseColor(Color4.White) .SetIgnoreLighting(true) .FromGlobalCache()) .SetRenderState(StandardRenderState.New() .SetPointSize(3) .FromGlobalCache())); visualElements.Add(ModelVisualElement.New() .SetModel(squareModel) .SetMaterial(StandardMaterial.New() .SetDiffuseMap(levelSetImage) .SetIgnoreLighting(true) .FromGlobalCache()) .SetTransform(new Transform(cellSize * size.Width / 2, Quaternion.Identity, new Vector3(cellSize * size.Width / 2, cellSize * size.Height / 2, -0.1f)))); }
public NestedCirclesStoryLayout(IEmbeddedResources embeddedResources, ICoroutineService coroutineService) { this.coroutineService = coroutineService; planeModel = embeddedResources.SimplePlaneXyModel(); circleModel = embeddedResources.CircleModel(64); lineModel = embeddedResources.LineModel(); circleMaterials = new IMaterial[] { StandardMaterial.New().SetDiffuseColor(new Color4(new Color3(1f, 0f, 0f) * 0.5f, 1.0f)).SetIgnoreLighting(true).FromGlobalCache(), StandardMaterial.New().SetDiffuseColor(new Color4(new Color3(0f, 1f, 0f) * 0.5f, 1.0f)).SetIgnoreLighting(true).FromGlobalCache(), StandardMaterial.New().SetDiffuseColor(new Color4(new Color3(0f, 0f, 1f) * 0.5f, 1.0f)).SetIgnoreLighting(true).FromGlobalCache(), StandardMaterial.New().SetDiffuseColor(new Color4(new Color3(1f, 1f, 0f) * 0.5f, 1.0f)).SetIgnoreLighting(true).FromGlobalCache(), StandardMaterial.New().SetDiffuseColor(new Color4(new Color3(1f, 0f, 1f) * 0.5f, 1.0f)).SetIgnoreLighting(true).FromGlobalCache(), StandardMaterial.New().SetDiffuseColor(new Color4(new Color3(0f, 1f, 1f) * 0.5f, 1.0f)).SetIgnoreLighting(true).FromGlobalCache() }; lineMaterial = StandardMaterial.New().SetDiffuseColor(Color4.Blue).FromGlobalCache(); lineMaterialExternal = StandardMaterial.New().SetDiffuseColor(0.7f * Color4.White).FromGlobalCache(); circleRenderState = StandardRenderState.New() .SetLineWidth(2) .SetCullFace(CullFace.Front) .FromGlobalCache(); lineRenderState = StandardRenderState.New().SetLineWidth(3).FromGlobalCache(); }
protected MovieRectangleComponent(Lazy <IMoviePlayer> moviePlayerLazy, Lazy <IAppModeService> appModeServiceLazy, IEmbeddedResources embeddedResources, IViewService viewService) { this.moviePlayerLazy = moviePlayerLazy; this.appModeServiceLazy = appModeServiceLazy; var model = embeddedResources.SimplePlaneXyModel(); var mainMaterial = StandardMaterial.New(this) .SetDiffuseColor(x => x.moviePlayback?.FrameImage != null ? Color4.White : Color4.Black) .SetDiffuseMap(x => x.moviePlayback?.FrameImage) .SetIgnoreLighting(true); visualElem = new ModelVisualElement <MovieRectangleComponent>(this) .SetModel(model) .SetMaterial(mainMaterial) .SetTransform(x => Transform.Translation(new Vector3(x.Rectangle.Center, 0))) .SetNonUniformScale(x => new Vector3(x.Rectangle.HalfWidth, x.Rectangle.HalfHeight, 1)); progressBar = new ModelVisualElement <MovieRectangleComponent>(this) .SetModel(model) .SetMaterial(StandardMaterial.New() .SetDiffuseColor(Color4.Red) .SetIgnoreLighting(true) .FromGlobalCache()) .SetRenderState(StandardRenderState.New() .SetZOffset(GraphicsHelper.MinZOffset) .FromGlobalCache()) .SetTransform(x => Transform.Translation(new Vector3( x.Rectangle.MinX + x.Rectangle.HalfWidth * MovieRelativeLocation(), x.Rectangle.MinY + x.Rectangle.HalfHeight / BarHeightFactor, 0))) .SetNonUniformScale(x => new Vector3( x.Rectangle.HalfWidth * MovieRelativeLocation(), x.Rectangle.HalfHeight / BarHeightFactor, 1)) .SetHide(x => !x.showMovieGui); var movieButtonTextures = AllButtonTextureNames .Select(x => embeddedResources.Image(GetMovieButtonTextureFileName(x.ToString()))) .ToArray(); movieButtonsMaterials = AllButtonTextureNames.Select(x => StandardMaterial.New() .SetDiffuseMap(movieButtonTextures[(int)x]) .SetIgnoreLighting(true)) .Cast <IStandardMaterial>() .ToArray(); movieButtonVisualElems = AllMovieButtons.Select(b => new ModelVisualElement <MovieRectangleComponent>(this) .SetModel(model) .SetMaterial(x => x.movieButtonsMaterials[(int)GetButtonTextureName(b)]) .SetRenderState(StandardRenderState.New() .SetZOffset(GraphicsHelper.MinZOffset) .FromGlobalCache()) .SetTransform(x => GetMovieButtonTransform((int)b, x.Rectangle)) .SetHide(x => !x.showMovieGui)); movieSpeedTextures = StandardMoviePlayback.MovieSpeeds.Select(x => embeddedResources.Image(GetMovieSpeedTextureFileName(x))).ToArray(); movieSpeedVisualElem = new ModelVisualElement <MovieRectangleComponent>(this) .SetModel(model) .SetMaterial(StandardMaterial.New(this) .SetDiffuseMap(x => x.movieSpeedTextures[GetSpeedIndex(moviePlayback.GetVideoSpeed())])) .SetRenderState(StandardRenderState.New() .SetZOffset(GraphicsHelper.MinZOffset)) .SetTransform(x => GetMovieSpeedTransform(x.Rectangle)) .SetHide(x => !x.showMovieGui); presentationInteractionElems = new IInteractionElement[] { new MoviePlaybackInteractionElement <MovieRectangleComponent>(this, x => x.moviePlayback), new LambdaInteractionElement(args => { if (!(args is MouseEvent mouseArgs)) { return(true); } lastMouseEventTime = lastUpdateTime; if (!mouseArgs.IsLeftClickEvent()) { return(true); } if (!TryGetButton(mouseArgs, out var button)) { return(true); } switch (button) { case MovieButton.Start: moviePlayback.GoToStart(); break; case MovieButton.FBwrd: moviePlayback.PlaySlower(); break; case MovieButton.Bwrd: moviePlayback.ReverseDirection(); break; case MovieButton.Play: moviePlayback.UpdatePlayStatus(); break; case MovieButton.FFrwd: moviePlayback.PlayFaster(); break; case MovieButton.End: moviePlayback.GoToEnd(); break; default: throw new ArgumentOutOfRangeException(); } // Process button click return(true); }) }; hittable = new RectangleHittable <MovieRectangleComponent>(this, Transform.Identity, c => c.GetHittableRectangle(), c => 0); visualElems = new List <IVisualElement> { visualElem }; }