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(); }
public IResource GetResource() { switch (ResourceType) { case EmbeddedResourceType.Image: return(embeddedResources.Image(Path)); case EmbeddedResourceType.Skybox: return(embeddedResources.Skybox(Path)); // todo: model loaders case EmbeddedResourceType.FlexibleModel: case EmbeddedResourceType.ExplicitModel: default: throw new ArgumentOutOfRangeException(); } }
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 }; }
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(); }