public void TestIsValid()
        {
            SceneLayer testLayer  = Scene.CreateLayer("Test layer");
            Window     testWindow = new Window("Test window");
            ConstantBuffer <Matrix> instanceBuffer = BufferFactory.NewConstantBuffer <Matrix>().WithUsage(ResourceUsage.DiscardWrite);
            VertexShader            testShader     = VertexShader.NewDefaultShader(instanceBuffer);
            HUDPass testPass = new HUDPass("Test pass");

            Assert.IsFalse(testPass.IsValid);
            testPass.Input = new Camera();
            testPass.AddLayer(testLayer);
            testPass.Output       = testWindow;
            testPass.VertexShader = testShader;
            Assert.IsFalse(testPass.IsValid);
            testPass.RasterizerState   = new RasterizerState(true, TriangleCullMode.FrontfaceCulling, false);
            testPass.DepthStencilState = new DepthStencilState();
            Assert.IsTrue(testPass.IsValid);
            testPass.RasterizerState.Dispose();
            Assert.IsFalse(testPass.IsValid);

            testPass.DepthStencilState.Dispose();
            testPass.Dispose();
            testShader.Dispose();
            instanceBuffer.Dispose();
            testWindow.Close();
            testLayer.Dispose();
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Generates a boom-alert
 /// </summary>
 /// <param name="layer"></param>
 /// <returns></returns>
 public static SpriteAlert GenerateBoom(SceneLayer layer)
 {
     return(new SpriteAlert(layer)
     {
         TextureName = "Graphics/Alert-Boom", MaxAlertTime = 1
     });
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Generates a jump spot alert
 /// </summary>
 /// <param name="layer"></param>
 /// <returns></returns>
 public static SpriteAlert GenerateJumpSpot(SceneLayer layer)
 {
     return(new SpriteAlert(layer)
     {
         TextureName = "Graphics/Alert-JumpSpot", MaxAlertTime = 2f
     });
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Creates a new hud
        /// </summary>
        /// <param name="layer"></param>
        public SpritesetHud(SceneLayer layer, PointsController controller, InputControllerState source)
            : base(layer)
        {
            _source     = source;
            _controller = controller;

            _cursorStandard = new Sprite(layer, "Graphics/Pointer-Standard");
            _cursorDelete   = new Sprite(layer, "Graphics/Pointer-Delete");

            _placingBlock  = new DataBlock(source.GridPosition, source.Type == BlockType.None ? BlockType.Normal : source.Type, null);
            _placingSprite = new SpriteBlock(layer, _placingBlock);

            _spriteLogo = new Sprite(layer, "Graphics/Logo")
            {
                Position = Vector2.UnitY * 40 + Vector2.UnitX * 50
            };
            _spriteHappyPoints = new Sprite(layer, "Graphics/Icon-HappyPoints")
            {
                Position = Vector2.UnitY * 40 + Vector2.UnitX * 520
            };
            _spriteTime = new Sprite(layer, "Graphics/Icon-Time")
            {
                Position = Vector2.UnitY * 40 + Vector2.UnitX * 1130
            };
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Generates a ninja-alert
 /// </summary>
 /// <param name="layer"></param>
 /// <returns></returns>
 public static SpriteAlert GenerateNinja(SceneLayer layer)
 {
     return(new SpriteAlert(layer)
     {
         TextureName = "Graphics/Alert-Ninja", MaxAlertTime = 2
     });
 }
Ejemplo n.º 6
0
        public void Save(string filename)
        {
            SceneLayer layer = scene.Layers.Single(a => a.Name == "Playfield\0");

            for (ushort y = 0; y < Height; y++)
            {
                for (ushort x = 0; x < Width; x++)
                {
                    layer.Tiles[y][x] = (ushort)(Layout[x, y] & ~SphereType.RingFlag);
                }
            }
            layer.Tiles[StartY][StartX] = (ushort)(SphereType.StartN + Angle);
            SceneLayer rings = scene.Layers.Single(a => a.Name == "Ring Count\0");

            for (int y = 0; y < Math.Min(rings.Height, Height); y++)
            {
                for (int x = 0; x < Math.Min(rings.Width, Width); x++)
                {
                    rings.Tiles[y][x] = Layout[x, y].HasFlag(SphereType.RingFlag) ? (ushort)SphereType.Ring : (ushort)0;
                }
            }
            if (HasPal)
            {
                SceneEntity palent = scene.Objects.Single(a => a.Name.Name == "BSS_Palette").Entities[0];
                palent.GetAttribute("paletteID").ValueVar    = PaletteID;
                palent.GetAttribute("skyAlpha").ValueUInt8   = SkyAlpha;
                palent.GetAttribute("globeAlpha").ValueUInt8 = GlobeAlpha;
                palent.GetAttribute("playfieldA").ValueColor = new RSDKColor(PlayfieldA.R, PlayfieldA.G, PlayfieldA.B);
                palent.GetAttribute("playfieldB").ValueColor = new RSDKColor(PlayfieldB.R, PlayfieldB.G, PlayfieldB.B);
                palent.GetAttribute("bgColor1").ValueColor   = new RSDKColor(BGColor1.R, BGColor1.G, BGColor1.B);
                palent.GetAttribute("bgColor2").ValueColor   = new RSDKColor(BGColor2.R, BGColor2.G, BGColor2.B);
                palent.GetAttribute("bgColor3").ValueColor   = new RSDKColor(BGColor3.R, BGColor3.G, BGColor3.B);
            }
            scene.Write(filename);
        }
        public void TestTransform()
        {
            // Define variables and constants
            ModelInstanceManager     mim   = new ModelInstanceManager();
            ConstantBuffer <Vector4> fsCB  = BufferFactory.NewConstantBuffer <Vector4>().WithUsage(ResourceUsage.DiscardWrite);
            FragmentShader           fs    = new FragmentShader(@"Tests\SimpleFS.cso", new ConstantBufferBinding(0U, "MaterialProperties", fsCB));
            Material            testMat    = new Material("TestMat", fs);
            SceneLayer          testLayer  = Scene.CreateLayer("TestLayer");
            ModelInstanceHandle testHandle = mim.AllocateInstance(testMat.Index, 0U, testLayer.Index, Transform.DEFAULT_TRANSFORM);

            // Set up context


            // Execute
            testHandle.Transform = new Transform(Vector3.ONE * 4f, Quaternion.IDENTITY, Vector3.ONE * -15f);

            // Assert outcome
            Assert.AreEqual(new Transform(Vector3.ONE * 4f, Quaternion.IDENTITY, Vector3.ONE * -15f), testHandle.Transform);
            testHandle.Dispose();
            testLayer.Dispose();
            mim.Dispose();
            testMat.Dispose();
            fs.Dispose();
            fsCB.Dispose();
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Builds the standard scene.
        /// </summary>
        /// <param name="newScene">The scenegraph to be updated.</param>
        /// <param name="newCamera">The camera to be updated.</param>
        public static void BuildStandardFloor(SceneManipulator manipulator, string sceneLayer)
        {
            SceneLayer bgLayer = manipulator.AddLayer("BACKGROUND");

            manipulator.SetLayerOrderID(bgLayer, 0);
            manipulator.SetLayerOrderID(Scene.DEFAULT_LAYER_NAME, 1);
            ResourceLink sourceBackgroundTexture = new AssemblyResourceLink(
                typeof(SeeingSharpSampleResources),
                "Textures.Background.dds");
            ResourceLink sourceTileTexture = new AssemblyResourceLink(
                typeof(SeeingSharpSampleResources),
                "Textures.Floor.dds");

            var resBackgroundTexture = manipulator.AddTexture(sourceBackgroundTexture);

            manipulator.Add(new FullscreenTextureObject(resBackgroundTexture), bgLayer.Name);

            // Define textures and materials
            var resTileTexture  = manipulator.AddResource(() => new StandardTextureResource(sourceTileTexture));
            var resTileMaterial = manipulator.AddResource(() => new SimpleColoredMaterialResource(resTileTexture));

            // Define floor geometry
            FloorType floorType = new FloorType(new Vector2(4f, 4f), 0f);

            floorType.BottomMaterial       = resTileMaterial;
            floorType.DefaultFloorMaterial = resTileMaterial;
            floorType.SideMaterial         = resTileMaterial;
            floorType.SetTilemap(25, 25);

            // Add floor to scene
            var resFloorGeometry = manipulator.AddResource((() => new GeometryResource(floorType)));
            var floorObject      = manipulator.AddGeneric(resFloorGeometry, sceneLayer);
        }
Ejemplo n.º 9
0
 /// <summary>
 /// Generates a completed spot alert
 /// </summary>
 /// <param name="layer"></param>
 /// <returns></returns>
 public static SpriteAlert GenerateCompleted(SceneLayer layer)
 {
     return(new SpriteAlert(layer)
     {
         TextureName = "Graphics/Alert-Completed", MaxAlertTime = 2f, Position = Vector2.UnitY * -50
     });
 }
Ejemplo n.º 10
0
        /// <summary>
        /// Creates a new flag sprite
        /// </summary>
        /// <param name="layer"></param>
        /// <param name="source"></param>
        public SpriteFlag(SceneLayer layer, DataJumpSpot source) : base(layer, "Graphics/Flag-Pole")
        {
            _source = source;

            //if (source.Placement == DataJumpSpot.Location.Left)
            //    this.Effects = SpriteEffects.FlipHorizontally;
        }
    public static Vector3 CellToPos(int cell, CellAlignment alignment, SceneLayer layer)
    {
        switch (alignment)
        {
        case CellAlignment.Bottom:
            return(CellToPosCBC(cell, layer));

        case CellAlignment.Left:
            return(CellToPosLCC(cell, layer));

        case CellAlignment.Right:
            return(CellToPosRCC(cell, layer));

        case CellAlignment.Top:
            return(CellToPosCTC(cell, layer));

        case CellAlignment.RandomInternal:
        {
            Vector3 b = new Vector3(UnityEngine.Random.Range(-0.3f, 0.3f), 0f, 0f);
            return(CellToPosCCC(cell, layer) + b);
        }

        default:
            return(CellToPosCCC(cell, layer));
        }
    }
Ejemplo n.º 12
0
        public virtual void ResetEntity(LevelGeometryEntity levelGeometryEntity, Material overrideMaterial = null)
        {
            SceneLayer sl = GetRecommendedSceneLayer();

            using (RenderingModule.RenderStateBarrier.AcquirePermit(withLock: instanceMutationLock)) {
                Entity rep = GetEntityRepresentation(levelGeometryEntity);
                rep.Dispose();
                GeometryEntity entity;
                if (levelGeometryEntity.IsStatic)
                {
                    entity = new GeometryEntity {
                        Transform = levelGeometryEntity.InitialMovementStep.Transform
                    };
                }
                else
                {
                    entity = new PresetMovementEntity(levelGeometryEntity.MovementSteps.ToArray(), levelGeometryEntity.AlternatingMovementDirection, levelGeometryEntity.InitialDelay)
                    {
                        Transform = levelGeometryEntity.InitialMovementStep.Transform
                    };
                }
                entity.SetModelInstance(sl, currentModelHandles[levelGeometryEntity.Geometry], overrideMaterial ?? currentMaterials[levelGeometryEntity.Material]);
                currentGeometryEntities[levelGeometryEntity] = entity;
            }
        }
Ejemplo n.º 13
0
        public void ResetEntities(bool fullReset)
        {
            SceneLayer sl = GetRecommendedSceneLayer();

            lock (instanceMutationLock) {
                currentGeometryEntities.Values.ForEach(e => e.Dispose());
                currentGeometryEntities.Clear();
                foreach (LevelGeometryEntity levelEntity in levelGeometryEntities)
                {
                    GeometryEntity entity;
                    if (levelEntity.IsStatic)
                    {
                        entity = new GeometryEntity {
                            Transform = levelEntity.InitialMovementStep.Transform
                        };
                    }
                    else
                    {
                        entity = new PresetMovementEntity(levelEntity.MovementSteps.ToArray(), levelEntity.AlternatingMovementDirection, levelEntity.InitialDelay)
                        {
                            Transform = levelEntity.InitialMovementStep.Transform
                        };
                    }
                    entity.SetModelInstance(sl, currentModelHandles[levelEntity.Geometry], currentMaterials[levelEntity.Material]);
                    currentGeometryEntities.Add(levelEntity, entity);
                }
            }
            ResetEntityPhysics(fullReset);
        }
Ejemplo n.º 14
0
        /// <summary>
        /// Creates a new spriteset
        /// </summary>
        /// <param name="layer"></param>
        public SpritesetGrid(SceneLayer layer) : base(layer)
        {
#if SILVERLIGHT
            _grid = new SpriteBlock[KeyFromPosition(new Point(DataGrid.Width, 0))];
#else
            _grid = new SortedList <Int32, SpriteBlock>();
#endif
        }
Ejemplo n.º 15
0
        /// <summary>
        /// Returns whether or not rendering is currently enabled for this scene layer.
        /// </summary>
        /// <param name="this">The extended SceneLayer.</param>
        /// <returns>True if rendering is currently enabled, false if not.</returns>
        public static bool GetRenderingEnabled(this SceneLayer @this)
        {
            if (@this == null)
            {
                throw new ArgumentNullException("this");
            }

            return((bool)@this[RENDERING_ENABLED_PROP]);
        }
Ejemplo n.º 16
0
        /// <summary>
        /// Enable or disable rendering all objects added to this scene layer.
        /// </summary>
        /// <param name="this">The extended SceneLayer.</param>
        /// <param name="enabled">True to enable rendering, false to disable.</param>
        public static void SetRenderingEnabled(this SceneLayer @this, bool enabled)
        {
            if (@this == null)
            {
                throw new ArgumentNullException("this");
            }

            @this[RENDERING_ENABLED_PROP] = enabled;
        }
Ejemplo n.º 17
0
        private async void OnMainPage_Loaded(object sender, RoutedEventArgs e)
        {
            if (m_panelPainter != null)
            {
                return;
            }

            // Attach the painter to the target render panel
            m_panelPainter = new SeeingSharpPanelPainter(this.RenderTargetPanel);
            m_panelPainter.RenderLoop.ClearColor = Color4.CornflowerBlue;

            // Build scene graph
            await m_panelPainter.Scene.ManipulateSceneAsync((manipulator) =>
            {
                // Define a BACKGROUND layer and configure layer IDs
                //  => Ensures correct render order
                SceneLayer bgLayer = manipulator.AddLayer("BACKGROUND");
                manipulator.SetLayerOrderID(bgLayer, 0);
                manipulator.SetLayerOrderID(Scene.DEFAULT_LAYER_NAME, 1);

                // Add the background texture painter to the BACKGROUND layer
                var resBackgroundTexture = manipulator.AddTexture(
                    new AssemblyResourceUriBuilder(
                        "SeeingSharp.Tutorials.Introduction03",
                        true,
                        "Assets/Textures/Background.png"));
                manipulator.Add(new FullscreenTextureObject(resBackgroundTexture), bgLayer.Name);

                // Create pallet geometry resource
                PalletType pType      = new PalletType();
                pType.ContentColor    = Color4.GreenColor;
                var resPalletGeometry = manipulator.AddResource <GeometryResource>(
                    () => new GeometryResource(pType));

                // Create pallet object and add it to the scene
                //  => The DEFAULT layer is used by default
                GenericObject palletObject = manipulator.AddGeneric(resPalletGeometry);
                palletObject.Color         = Color4.GreenColor;
                palletObject.EnableShaderGeneratedBorder();
                palletObject.BuildAnimationSequence()
                .RotateEulerAnglesTo(new Vector3(0f, EngineMath.RAD_180DEG, EngineMath.RAD_45DEG), TimeSpan.FromSeconds(2.0))
                .WaitFinished()
                .RotateEulerAnglesTo(new Vector3(0f, EngineMath.RAD_360DEG, EngineMath.RAD_45DEG), TimeSpan.FromSeconds(2.0))
                .WaitFinished()
                .RotateEulerAnglesTo(new Vector3(0f, 0f, 0f), TimeSpan.FromSeconds(2.0))
                .WaitFinished()
                .CallAction(() => palletObject.RotationEuler = Vector3.Zero)
                .ApplyAndRewind();
            });

            // Configure camera
            Camera3DBase camera = m_panelPainter.Camera;

            camera.Position = new Vector3(2f, 2f, 2f);
            camera.Target   = new Vector3(0f, 0.5f, 0f);
            camera.UpdateCamera();
        }
Ejemplo n.º 18
0
        /// <summary>
        /// Creates the configured layer if it does not exist on the given scene.
        /// </summary>
        /// <param name="manipulator">The manipulator for manipulating the scene.</param>
        protected void CreateLayerIfNotAvailable(SceneManipulator manipulator)
        {
            this.TargetLayer.EnsureNotNullOrEmptyOrWhiteSpace(nameof(this.TargetLayer));

            if (!manipulator.ContainsLayer(this.TargetLayer))
            {
                SceneLayer bgLayer = manipulator.AddLayer(this.TargetLayer);
                manipulator.SetLayerOrderID(bgLayer, this.TargetLayerOrderID);
            }
        }
Ejemplo n.º 19
0
 public void RemoveLayer(SceneLayer layer)
 {
     Assure.NotNull(layer);
     using (RenderingModule.RenderStateBarrier.AcquirePermit(withLock: InstanceMutationLock)) {
         if (!addedSceneLayers.Remove(layer))
         {
             throw new InvalidOperationException("Given layer is not already added.");
         }
     }
 }
Ejemplo n.º 20
0
 /// <summary>
 /// Creates a new sprite pea
 /// </summary>
 /// <param name="layer"></param>
 /// <param name="source"></param>
 /// <param name="pointsController"></param>
 public SpritePea(SceneLayer layer, DataPea source, PointsController pointsController)
     : base(layer)
 {
     _source                  = source;
     _pointsController        = pointsController;
     _source.OnJumpStarted   += new JumpEventHandler(_source_OnJumpStarted);
     _source.OnJumpCompleted += new JumpEventHandler(_source_OnJumpCompleted);
     _source.OnJumpFailed    += new JumpEventHandler(_source_OnJumpCompleted);
     _source.OnRevive        += new EventHandler(_source_OnRevive);
 }
Ejemplo n.º 21
0
 public void AddLayer(SceneLayer layer)
 {
     Assure.NotNull(layer);
     using (RenderingModule.RenderStateBarrier.AcquirePermit(withLock: InstanceMutationLock)) {
         if (addedSceneLayers.Contains(layer))
         {
             throw new InvalidOperationException("Given layer has already been added.");
         }
         addedSceneLayers.Add(layer);
     }
 }
Ejemplo n.º 22
0
 public void SetModelInstance(SceneLayer layer, ModelHandle modelHandle, Material material)
 {
     lock (InstanceMutationLock) {
         Assure.False(isDisposed);
         if (modelInstance != null)
         {
             modelInstance.Value.Dispose();
         }
         modelInstance = layer.CreateModelInstance(modelHandle, material, transform);
     }
 }
Ejemplo n.º 23
0
        internal FontString(Font font, SceneLayer sceneLayer, SceneViewport viewport, ViewportAnchoring anchoring, Vector2 anchorOffset, Vector2 scale)
        {
            this.sceneLayer         = sceneLayer;
            this.viewport           = viewport;
            this.anchoring          = anchoring;
            this.anchorOffset       = anchorOffset;
            this.scale              = scale;
            this.font               = font;
            this.createMaterialFunc = CreateNewMaterial;

            viewport.TargetWindow.WindowResized += ResizeText;
        }
Ejemplo n.º 24
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="layer"></param>
        public SpriteToolbox(SceneLayer layer) : base(layer, "Graphics/Tool-Background")
        {
            _toolTypes = new BlockType[] { BlockType.Normal, BlockType.Gel, BlockType.LeftRamp, BlockType.RightRamp, BlockType.Spring, BlockType.Delete };
            _tools     = new Sprite[_toolTypes.Length];

            for (Int32 i = 0; i < _toolTypes.Length; i++)
            {
                _tools[i] = new Sprite(layer, "Graphics/Tool-" + AssetName(_toolTypes[i]));
            }

            _selection = new Sprite(layer, "Graphics/Tool-Selected");
        }
Ejemplo n.º 25
0
        public EditorLayer(SceneLayer layer)
        {
            this.Layer = layer;

            TileChunksTextures = new Texture[DivideRoundUp(this.Layer.Height, TILES_CHUNK_SIZE)][];
            for (int i = 0; i < TileChunksTextures.Length; ++i)
            {
                TileChunksTextures[i] = new Texture[DivideRoundUp(this.Layer.Width, TILES_CHUNK_SIZE)];
            }

            SelectedTiles      = new PointsMap(this.Layer.Width, this.Layer.Height);
            TempSelectionTiles = new PointsMap(this.Layer.Width, this.Layer.Height);
        }
Ejemplo n.º 26
0
        public async Task Postprocessing_EdgeDetect()
        {
            await UnitTestHelper.InitializeWithGrahicsAsync();

            using (MemoryRenderTarget memRenderTarget = new MemoryRenderTarget(1024, 1024))
            {
                memRenderTarget.ClearColor = Color4.CornflowerBlue;

                // Get and configure the camera
                PerspectiveCamera3D camera = memRenderTarget.Camera as PerspectiveCamera3D;
                camera.Position = new Vector3(0f, 5f, -7f);
                camera.Target   = new Vector3(0f, 0f, 0f);
                camera.UpdateCamera();

                // Define scene
                await memRenderTarget.Scene.ManipulateSceneAsync((manipulator) =>
                {
                    var keyPostprocess = manipulator.AddResource <EdgeDetectPostprocessEffectResource>(
                        () => new EdgeDetectPostprocessEffectResource()
                    {
                        Thickness = 10f
                    });

                    SceneLayer defaultLayer           = manipulator.GetLayer(Scene.DEFAULT_LAYER_NAME);
                    defaultLayer.PostprocessEffectKey = keyPostprocess;

                    NamedOrGenericKey geoResource = manipulator.AddResource <GeometryResource>(
                        () => new GeometryResource(new PalletType()));

                    GenericObject newObject = manipulator.AddGeneric(geoResource);
                    newObject.RotationEuler = new Vector3(0f, EngineMath.RAD_90DEG / 2f, 0f);
                    newObject.Scaling       = new Vector3(2f, 2f, 2f);
                    newObject.Color         = Color4.RedColor;
                });

                // Take screenshot
                GDI.Bitmap screenshot = await memRenderTarget.RenderLoop.GetScreenshotGdiAsync();

                screenshot = await memRenderTarget.RenderLoop.GetScreenshotGdiAsync();

                //screenshot.DumpToDesktop("Blub.png");

                // Calculate and check difference
                bool isNearEqual = BitmapComparison.IsNearEqual(
                    screenshot, Properties.Resources.ReferenceImage_PostProcess_EdgeDetect);
                Assert.True(isNearEqual, "Difference to reference image is to big!");
            }

            // Finishing checks
            Assert.True(GraphicsCore.Current.MainLoop.RegisteredRenderLoopCount == 0, "RenderLoops where not disposed correctly!");
        }
Ejemplo n.º 27
0
        protected override void OnInitialize()
        {
            SphereModel sphere = new SphereModel(_coder, SPHERE_BREAKUPS);

            GlProgram wProgram = new GlProgram(
                new Shader(ShaderTypes.Vertex, File.ReadAllText(Path.Combine(SHADERS_DIR, WORLD_SHADERS, "vertex.glsl"))),
                new Shader(ShaderTypes.Fragment, File.ReadAllText(Path.Combine(SHADERS_DIR, WORLD_SHADERS, "fragment.glsl")))
                );

            GlProgram gProgram = new GlProgram(
                new Shader(ShaderTypes.Vertex, File.ReadAllText(Path.Combine(SHADERS_DIR, GUI_SHADERS, "vertex.glsl"))),
                new Shader(ShaderTypes.Fragment, File.ReadAllText(Path.Combine(SHADERS_DIR, GUI_SHADERS, "fragment.glsl")))
                );

            _universe.Add(new SpaceObject(2, 100000, sphere)
            {
                Position = new Vector3(0, 0, 0)
            });
            _universe.Add(new SpaceObject(8, 50, sphere)
            {
                Position = new Vector3(-500, -500, 0), Velocity = new Vector3(30f, 0, -5f)
            });
            _universe.Add(new SpaceObject(0, 250, sphere)
            {
                Position = new Vector3(500, -500, 0), Velocity = new Vector3(30f, 0, 5f)
            });
            _universe.Add(_rocket = new RocketObject(55, new RocketModel(_coder))
            {
                Position = new Vector3(500, 500, 500), Velocity = new Vector3(-30f, 0f, 0f)
            });

            RenderHandle handle = new RenderHandle(this, wProgram);

            _layer = new SceneLayer(_universe, handle);
            AddLayer(_layer);
            _cam = new OrbitalCamera(_layer.Camera)
            {
                Distance = 250
            };
            Font fnt = new Font(Path.Combine(ASSETS_DIR, FONT_DIR, FONT_FILE));

            AddLayer(new GuiFuelLayer(_rocket, this, gProgram, new GuiVertexCoder(), fnt));
            GuiLayer tutorial = new GuiLayer(this, gProgram, new GuiVertexCoder(), fnt);

            tutorial.Add(_tutorialLbl);
            AddLayer(tutorial);
            Background = new Color(50, 50, 50, 255);
            base.OnInitialize();
        }
Ejemplo n.º 28
0
        public FontString AddString(SceneLayer sceneLayer, SceneViewport viewport,
                                    ViewportAnchoring anchoring, Vector2 anchorOffset, Vector2 scale)
        {
            lock (instanceMutationLock) {
                Assure.NotNull(sceneLayer);
                Assure.False(sceneLayer.IsDisposed);
                Assure.NotNull(viewport);
                Assure.False(viewport.IsDisposed);
                if (isDisposed)
                {
                    throw new ObjectDisposedException(Name);
                }

                return(new FontString(this, sceneLayer, viewport, anchoring, anchorOffset, scale));
            }
        }
Ejemplo n.º 29
0
        /// <summary>
        /// Creates a new jump info sprite
        /// </summary>
        /// <param name="layer"></param>
        /// <param name="data"></param>
        public SpriteJumpInfo(SceneLayer layer, Dictionary <Data.BlockType, Int32> data)
            : base(layer, "")
        {
            _data = data;

            _blocks = new Sprite[] {
                new Sprite(layer, "Graphics/Icon-Tools"),
                new Sprite(layer, "Graphics/Icon-Tools"),
                new Sprite(layer, "Graphics/Icon-Tools"),
                new Sprite(layer, "Graphics/Icon-Tools"),
                new Sprite(layer, "Graphics/Icon-Tools"),
                new Sprite(layer, "Graphics/Icon-Tools"),
            };

            this.Color = Color.Transparent;
        }
Ejemplo n.º 30
0
        public HUDTexture(FragmentShader fragmentShader, SceneLayer targetLayer, SceneViewport targetViewport)
        {
            lock (staticMutationLock) {
                if (hudTextureModel == null)
                {
                    throw new InvalidOperationException("HUD Texture Model must be set before creating any HUDTexture objects.");
                }
            }
            this.targetViewport            = targetViewport;
            this.material                  = new Material("HUDTexture Mat", fragmentShader);
            this.curModelInstance          = targetLayer.CreateModelInstance(hudTextureModel.Value, material, Transform.DEFAULT_TRANSFORM);
            this.fsTexColorMultiplyBinding = (ConstantBufferBinding)fragmentShader.GetBindingByIdentifier(HUDFS_TEX_PROPS_CBB_NAME);
            this.fsTexBinding              = (ResourceViewBinding)fragmentShader.GetBindingByIdentifier(HUDFS_TEX_BINDING_NAME);
            material.SetMaterialConstantValue(fsTexColorMultiplyBinding, color);
            targetViewport.TargetWindow.WindowResized += WindowResize;

            this.fragmentShader = fragmentShader;
            this.sceneLayer     = targetLayer;
        }