示例#1
0
 private static IStandardMaterial CreateUndefinedMaterial()
 {
     return(StandardMaterial.New()
            .SetDiffuseColor(Color4.Red)
            .SetNoSpecular(true)
            .FromGlobalCache());
 }
示例#2
0
 public MuseumStoryLayout(IEmbeddedResources embeddedResources, IWorldTreeService worldTreeService)
 {
     this.worldTreeService = worldTreeService;
     floorModel            = embeddedResources.PlaneModel(PlaneModelSourcePlane.Xy, PlaneModelSourceNormalDirection.Positive,
                                                          globalRadius, globalRadius, 1, 1);
     ceilingModel = embeddedResources.PlaneModel(PlaneModelSourcePlane.Xy, PlaneModelSourceNormalDirection.Negative,
                                                 globalRadius, globalRadius, 1, 1);
     exitWallModel = embeddedResources.PlaneModel(PlaneModelSourcePlane.Xz, PlaneModelSourceNormalDirection.Negative,
                                                  exitHalfLength, ceilingHalfHeight, 1, 1);
     corridorWallModel = embeddedResources.PlaneModel(PlaneModelSourcePlane.Xz, PlaneModelSourceNormalDirection.Negative,
                                                      corridorHalfWidth, ceilingHalfHeight, 1, 1);
     frustumModel  = embeddedResources.SimpleFrustumModel();
     floorMaterial = StandardMaterial.New()
                     .SetDiffuseMap(embeddedResources.Image("Textures/museum_floor.jpg"))
                     .SetNoSpecular(true)
                     .FromGlobalCache();
     ceilingMaterial = StandardMaterial.New()
                       .SetDiffuseMap(embeddedResources.Image("Textures/museum_ceiling.jpg"))
                       .SetNoSpecular(true)
                       .FromGlobalCache();
     wallMaterial = StandardMaterial.New()
                    .SetDiffuseMap(embeddedResources.Image("Textures/museum_wall.jpg"))
                    .SetNoSpecular(true)
                    .FromGlobalCache();
     frustumMaterial = StandardMaterial.New()
                       .SetDiffuseColor(Color4.Green)
                       .SetIgnoreLighting(true)
                       .FromGlobalCache();
 }
        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);
        }
示例#4
0
        private void BuildVisualElements()
        {
            if (Model == null)
            {
                visualElems = EmptyArrays <IVisualElement> .Array;
                return;
            }

            visualElems = new IVisualElement[Model.PartCount];
            for (var i = 0; i < Model.PartCount; i++)
            {
                var iLoc     = i;
                var material = StandardMaterial.New(this)
                               .SetDiffuseColor(x => x.GetColor(iLoc))
                               .SetDiffuseMap(x => x.Texture)
                               .SetNoSpecular(x => x.NoSpecular)
                               .SetIgnoreLighting(x => x.IgnoreLighting);

                var elem = new ModelVisualElement <ModelComponent>(this)
                           .SetModel(Model)
                           .SetModelPartIndex(i)
                           .SetMaterial(material)
                           .SetRenderState(StandardRenderState.New(this)
                                           .SetCullFace(x => x.DontCull ? CullFace.None : CullFace.Back))
                           .SetTransformSpace(x => x.Ortho ? TransformSpace.Ortho : TransformSpace.Scene);
                visualElems[i] = elem;
            }
        }
        protected StoryFlowchartEdgeGizmoComponent(IEmbeddedResources embeddedResources)
        {
            var lineModel = embeddedResources.LineModel();

            Material = StandardMaterial.New()
                       .SetDiffuseColor(new Color4(0f, 0.5f, 0f))
                       .SetIgnoreLighting(true)
                       .FromGlobalCache();

            RenderState = StandardRenderState.New()
                          .SetLineWidth(3)
                          .FromGlobalCache();

            visualElements = new IVisualElement[]
            {
                new ModelVisualElement <StoryFlowchartEdgeGizmoComponent>(this)
                .SetModel(lineModel)
                .SetMaterial(x => x.Material)
                .SetTransform(x => GetTransformForLine(x.FirstPoint, x.MiddlePoint)),
                new ModelVisualElement <StoryFlowchartEdgeGizmoComponent>(this)
                .SetModel(lineModel)
                .SetMaterial(x => x.Material)
                .SetTransform(x => GetTransformForLine(x.MiddlePoint, x.LastPoint))
            };
        }
示例#6
0
 public SphereStoryLayout(IEmbeddedResources embeddedResources)
 {
     frustumModel    = embeddedResources.SimpleFrustumModel();
     frustumMaterial = StandardMaterial.New()
                       .SetDiffuseColor(Color4.Green)
                       .SetIgnoreLighting(true)
                       .FromGlobalCache();
 }
        public void OnQueryServiceUpdated()
        {
            visualElements.Clear();
            optionRects.Clear();

            currentQuery = queryService.Queries.LastOrDefault() as OptionsUserQuery;
            if (currentQuery == null || !currentQuery.Options.Any())
            {
                return;
            }
            const float OptionMargin     = 0.1f;
            const float OptionHalfHeight = 0.09f;
            const float OptionHalfWidth  = 0.9f;
            var         currentY         = 1f;

            for (var i = 0; i < currentQuery.Options.Count; i++)
            {
                currentY -= OptionMargin;
                currentY -= OptionHalfHeight;
                optionRects.Add(new AaRectangle2(new Vector2(0, currentY), OptionHalfWidth, OptionHalfHeight));
                currentY -= OptionHalfHeight;
                currentY -= OptionMargin;
            }
            var totalHeight = 1f - currentY;
            var centerY     = 1f - totalHeight / 2;

            for (int i = 0; i < currentQuery.Options.Count; i++)
            {
                var option = currentQuery.Options[i];

                var rect = optionRects[i];
                rect.Center.Y -= centerY;
                optionRects[i] = rect;

                var textBox = RichTextHelper.Label(option,
                                                   new IntSize2((int)(2 * 512 * OptionHalfWidth), (int)(2 * 512 * OptionHalfHeight)),
                                                   RtParagraphAlignment.Center,
                                                   Color4.Black,
                                                   RtTransparencyMode.Opaque,
                                                   "Arial",
                                                   32,
                                                   Color4.Orange,
                                                   FontDecoration.None);
                var textImageRgba = textImageBuilder.BuildImageRgba(textBox);
                var textImage     = new RawImage(ResourceVolatility.Immutable, textBox.Size, false, textImageRgba);
                visualElements.Add(ModelVisualElement.New()
                                   .SetModel(planeModel)
                                   .SetMaterial(StandardMaterial.New()
                                                .SetDiffuseMap(textImage)
                                                .SetIgnoreLighting(true)
                                                .FromGlobalCache())
                                   .SetTransform(Transform.Translation(new Vector3(rect.Center, 0)))
                                   .SetNonUniformScale(new Vector3(rect.HalfWidth, rect.HalfHeight, 1)));
            }
        }
        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));
        }
示例#9
0
 public OrbitStoryLayout(IEmbeddedResources embeddedResources)
 {
     frustumModel    = embeddedResources.SimpleFrustumModel();
     circleModel     = embeddedResources.CircleModel(256);
     frustumMaterial = StandardMaterial.New()
                       .SetDiffuseColor(Color4.Green)
                       .SetIgnoreLighting(true)
                       .FromGlobalCache();
     circleMaterial = StandardMaterial.New()
                      .SetDiffuseColor(Color4.Yellow)
                      .SetIgnoreLighting(true)
                      .FromGlobalCache();
 }
 protected ResizeRectangleGizmoComponent(IInputHandler inputHandler, IEmbeddedResources embeddedResources, IUndoRedoService undoRedo)
 {
     visualElement = ModelVisualElement.New()
                     .SetModel(embeddedResources.CubeModel())
                     .SetMaterial(StandardMaterial.New()
                                  .SetNoSpecular(true)
                                  .FromGlobalCache())
                     .SetTransform(Transform.Scaling(0.025f));
     interactionElement = new ResizeRectangleInteractionElement <ResizeRectangleGizmoComponent>(
         this, x => x.GetRectAspect(), x => x.GetChildSpace(), x => x.Place, inputHandler, undoRedo);
     hittable = new SphereHittable <ResizeRectangleGizmoComponent>(this, x =>
     {
         var globalTransform = Node.GlobalTransform;
         return(new Sphere(globalTransform.Offset, 0.025f * globalTransform.Scale));
     });
 }
示例#11
0
        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();
        }
        private void Rebuild()
        {
            if (SpherePackingResult == null)
            {
                return;
            }
            var material = StandardMaterial.New(this)
                           .SetDiffuseColor(x => x.Color);

            visualElems = SpherePackingResult.Points.Select(p =>
                                                            ModelVisualElement.New(this)
                                                            .SetModel(embeddedResources.SphereModel(64))
                                                            .SetTransform(x => new Transform(x.Radius, Quaternion.Identity, p))
                                                            .SetMaterial(material))
                          .Cast <IVisualElement>()
                          .ToArray();
            LocalBoundingSphere = Sphere.BoundingSphere(SpherePackingResult.Points);
        }
示例#13
0
        protected StoryFlowchartEditSceneComponent()
        {
            gizmosByNodes = new Dictionary <ISceneNode, ISceneNode>();
            edgeGizmos    = new Dictionary <UnorderedPair <ISceneNode>, ISceneNode>();

            defaultViewpointMechanism = new OrthoDefaultViewpointMechanism(Node,
                                                                           new PlaneOrthoBoundControlledCamera.Props
            {
                Distance = 3f,
                ZFar     = 1000f,
                ZNear    = 0.01f
            });
            routeMaterial = StandardMaterial.New()
                            .SetIgnoreLighting(true)
                            .FromGlobalCache();
            routeRenderState = StandardRenderState.New()
                               .SetLineWidth(3)
                               .FromGlobalCache();
        }
        public IEnumerable <IVisualElement> GetVisualElements()
        {
            yield return(borderVisualElement);

            yield return(backgroundVisualElement);

            for (int i = 0; i < solvingProcess.Packer.NumCircles; i++)
            {
                var iLoc = i;
                if (circleVisualElements.Count <= i)
                {
                    circleVisualElements.Add(ModelVisualElement.New(this)
                                             .SetModel(x => x.embeddedResources.CircleModel(64))
                                             .SetMaterial(StandardMaterial.New(this)
                                                          .SetIgnoreLighting(true)
                                                          .SetDiffuseColor(x => x.ColorForStatus(x.solvingProcess.Packer.FrontCircleStatuses[iLoc])))
                                             .SetTransform(x => new Transform(x.solvingProcess.Packer.CircleRadius, Quaternion.Identity, new Vector3(x.solvingProcess.Packer.FrontCircleCenters[iLoc], 0))));
                }
                yield return(circleVisualElements[i]);
            }
        }
        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();
 }
        public NestedSpheresStoryLayout(IEmbeddedResources embeddedResources, ICoroutineService coroutineService, Lazy <IViewService> viewServiceLazy)
        {
            this.coroutineService = coroutineService;
            this.viewServiceLazy  = viewServiceLazy;
            focusVisualEffect     = new FocusVisualEffect();

            mainModel       = embeddedResources.SphereModel(64, true);
            lineModel       = embeddedResources.LineModel();
            sphereMaterials = new IMaterial[]
            {
                StandardMaterial.New().SetDiffuseColor(new Color4(new Color3(1.0f, 0.5f, 0.5f) * 1.0f, 0.5f)).FromGlobalCache(),
                StandardMaterial.New().SetDiffuseColor(new Color4(new Color3(0.5f, 1.0f, 0.5f) * 1.0f, 0.5f)).FromGlobalCache(),
                StandardMaterial.New().SetDiffuseColor(new Color4(new Color3(0.5f, 0.5f, 1.0f) * 1.0f, 0.5f)).FromGlobalCache(),
                StandardMaterial.New().SetDiffuseColor(new Color4(new Color3(1.0f, 1.0f, 0.5f) * 1.0f, 0.5f)).FromGlobalCache(),
                StandardMaterial.New().SetDiffuseColor(new Color4(new Color3(1.0f, 0.5f, 1.0f) * 1.0f, 0.5f)).FromGlobalCache(),
                StandardMaterial.New().SetDiffuseColor(new Color4(new Color3(0.5f, 1.0f, 1.0f) * 1.0f, 0.5f)).FromGlobalCache(),
            };
            sphereRenderState = StandardRenderState.New().SetCullFace(CullFace.Back).FromGlobalCache();

            lineMaterial         = StandardMaterial.New().SetDiffuseColor(Color4.Red).FromGlobalCache();
            lineMaterialExternal = StandardMaterial.New().SetDiffuseColor(0.7f * Color4.Red);
            lineRenderState      = StandardRenderState.New().SetLineWidth(3).FromGlobalCache();
        }
示例#19
0
        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
            };
        }
示例#20
0
        public BuildingStoryLayout(ICoroutineService coroutineService, IEmbeddedResources embeddedResources,
                                   IInputService inputService, Lazy <INavigationService> navigationServiceLazy)
        {
            this.embeddedResources     = embeddedResources;
            this.inputService          = inputService;
            this.navigationServiceLazy = navigationServiceLazy;
            this.coroutineService      = coroutineService;
            planeModel     = embeddedResources.SimplePlaneXzModel();
            lineModel      = embeddedResources.LineModel();
            frustumModel   = embeddedResources.SimpleFrustumModel();
            colorMaterials = new IMaterial[]
            {
                StandardMaterial.New().SetDiffuseColor(new Color4(new Color3(1f, 0f, 0f) * 0.8f, 1.0f)).SetIgnoreLighting(true),
                StandardMaterial.New().SetDiffuseColor(new Color4(new Color3(0f, 1f, 0f) * 0.8f, 1.0f)).SetIgnoreLighting(true),
                StandardMaterial.New().SetDiffuseColor(new Color4(new Color3(0f, 0f, 1f) * 0.8f, 1.0f)).SetIgnoreLighting(true),
                StandardMaterial.New().SetDiffuseColor(new Color4(new Color3(1f, 1f, 0f) * 0.8f, 1.0f)).SetIgnoreLighting(true),
                StandardMaterial.New().SetDiffuseColor(new Color4(new Color3(1f, 0f, 1f) * 0.8f, 1.0f)).SetIgnoreLighting(true),
                StandardMaterial.New().SetDiffuseColor(new Color4(new Color3(0f, 1f, 1f) * 0.8f, 1.0f)).SetIgnoreLighting(true),
            };
            frustumMaterial = StandardMaterial.New()
                              .SetDiffuseColor(new Color4(0f, 1f, 0f))
                              .SetIgnoreLighting(true)
                              .FromGlobalCache();
            lineMaterial = StandardMaterial.New()
                           .SetDiffuseColor(Color4.White)
                           .SetIgnoreLighting(true)
                           .FromGlobalCache();
            currentLineMaterial = StandardMaterial.New()
                                  .SetDiffuseColor(Color4.Red)
                                  .SetIgnoreLighting(true)
                                  .FromGlobalCache();
            lineRenderState = StandardRenderState.New().SetLineWidth(3).FromGlobalCache();

            var mirrorSampler = new ImageSampler
            {
                AddressModeU = ImageSamplerAddressMode.Mirror,
                AddressModeV = ImageSamplerAddressMode.Mirror,
                AddressModeW = ImageSamplerAddressMode.Mirror,
            }.FromGlobalCache();

            floorMaterial = StandardMaterial.New()
                            .SetDiffuseMap(embeddedResources.Image("Textures/museum_floor.jpg"))
                            .SetNoSpecular(true)
                            .SetSampler(mirrorSampler)
                            .FromGlobalCache();
            ceilingMaterial = StandardMaterial.New()
                              .SetDiffuseMap(embeddedResources.Image("Textures/museum_ceiling.jpg"))
                              .SetNoSpecular(true)
                              .SetSampler(mirrorSampler)
                              .FromGlobalCache();
            wallMaterial = StandardMaterial.New()
                           .SetDiffuseMap(embeddedResources.Image("Textures/museum_wall.jpg"))
                           .SetDiffuseColor(new Color4(92, 82, 72))
                           //.SetNoSpecular(true)
                           .SetNormalMap(embeddedResources.Image("Textures/museum_wall_2_norm.jpg"))
                           .FromGlobalCache();
            rawWallMaterial = StandardMaterial.New()
                              .SetDiffuseColor(Color4.Green)
                              .SetIgnoreLighting(true)
                              .FromGlobalCache();
        }