示例#1
0
        public void PlayBadelineCutscene(On.Celeste.BadelineOldsite.orig_Added orig, BadelineOldsite self, Scene scene)
        {
            orig(self, scene);
            var level = scene as Level;

            if (!level.Session.GetFlag("evil_maddy_intro") && level.Session.Level.StartsWith("Celeste/2-OldSite/A/3"))
            {
                foreach (var c in self.Components)
                {
                    if (c is Coroutine)
                    {
                        self.Components.Remove(c);
                        break;
                    }
                }

                self.Hovering     = false;
                self.Visible      = true;
                self.Hair.Visible = false;
                self.Sprite.Play("pretendDead", false, false);
                if (level.Session.Area.Mode == AreaMode.Normal)
                {
                    level.Session.Audio.Music.Event = null;
                    level.Session.Audio.Apply(false);
                }
                scene.Add(new CS02_BadelineIntro(self));
            }
        }
        public override void OnEnter(Player player)
        {
            base.OnEnter(player);

            // create boundaries if enabled.
            if (blockPlayer)
            {
                Level level = SceneAs <Level>();
                if (!left)
                {
                    Scene.Add(leftBound = new InvisibleBarrier(level.Camera.Position - Vector2.UnitX * 9, 8, 180));
                }
                if (!right)
                {
                    Scene.Add(rightBound = new InvisibleBarrier(level.Camera.Position + Vector2.UnitX * 320, 8, 180));
                }
                if (!up)
                {
                    Scene.Add(upperBound = new InvisibleBarrier(level.Camera.Position - Vector2.UnitY * 9, 320, 8));
                }
                if (!down)
                {
                    Scene.Add(lowerBound = new Killbox(new EntityData {
                        Width = 320
                    }, level.Camera.Position + Vector2.UnitY * 186));
                }
            }
        }
示例#3
0
文件: ListMenu.cs 项目: JOCP9733/tank
 private void OnAdd()
 {
     foreach (MenuChoice m in _choiceList)
     {
         Scene.Add(m);
     }
 }
示例#4
0
        private void CreateButton(ComponentHandler onClick, string name, Point point, Size2 size, string text)
        {
            var entity = new Entity {
                Name = name
            };

            var transform = SystemManager.Get <Transform2D>().Create(entity);

            transform.Position = new Vector2(point.X, point.Y);

            var sprite = SystemManager.Get <Components.Sprite>().Create(entity);

            sprite.Size    = new Vector2(size.Width, size.Height);
            sprite.Texture = ResourceManager.Get <Texture>("button");

            var textComponent = SystemManager.Get <Text>().Create(entity);

            textComponent.Label = text;
            textComponent.Color = Color.Black;

            var button = SystemManager.Get <Button>().Create(entity);

            button.Click += onClick;

            Scene.Add(entity);
        }
示例#5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="control"></param>
        public override void Load(Control control)
        {
            base.Load(control);

            camera = new PerspectiveCamera(40, control.Width / (float)control.Height, 1, 10000);
            this.camera.Position.Z = 2000;

            scene = new Scene();

            geometry = new SphereGeometry(15, 64, 32);

            for (var i = 0; i < N; i++)
            {
                var material = new ShaderMaterial()
                {
                    VertexShader = VertexShader, FragmentShader = this.GenerateFragmentShader()
                };

                var mesh = new Mesh(geometry, material);

                mesh.Position.X = (0.5f - Mat.Random()) * 1000;
                mesh.Position.Y = (0.5f - Mat.Random()) * 1000;
                mesh.Position.Z = (0.5f - Mat.Random()) * 1000;

                scene.Add(mesh);

                meshes.Add(mesh);
            }

            renderer.SetClearColor(Color.White);
            this.renderer.Size = control.Size;
        }
示例#6
0
        void RebuildScene(InspectView view, bool recreateScene = true)
        {
            if (recreateScene)
            {
                Scene = new SCNScene();
            }
            else
            {
                currentViewNode?.RemoveFromParentNode();
            }

            currentViewNode = null;

            if (view != null)
            {
                currentViewNode = new InspectViewNode(view).Rebuild(
                    new TreeState(DisplayMode, ShowHiddenViews));

                Scene.Add(currentViewNode);

                Trackball.Target = Scene.RootNode;
            }

            Play(this);
        }
示例#7
0
        public override void Update(float deltaTime)
        {
            base.Update(deltaTime);
            var ap = GetComponent <TrafficLightDetector>();

            if (ap == null || !ap.RedTrafficLightDetected)
            {
                Position += (Velocity * Speed) * (deltaTime / 30f);
            }

            //Add smoke to exhaust.
            if ((int)(TimeAlive / 10) % 10 == 0)
            {
                float   RotInvert        = Util.InvertAngle(Rotation);
                float   InvInRadians     = Util.ToRadians(RotInvert);
                Vector2 RotVec           = Vector2.FromAngle(InvInRadians, 30);
                Vector2 ParticlePosition = Position + RotVec;

                Scene.Add(new Particle(ParticlePosition, Assets.Smoke)
                {
                    Rotation      = Util.Float(360),
                    RotationSpeed = Util.RandFloat(40, 60),
                    FinalScale    = 0.2f,
                    Velocity      = Util.RandomDirection()
                });
            }
        }
示例#8
0
        public override void Added(Scene scene)
        {
            // turn off createdFromLevel to prevent vanilla from spawning ReflectionTentacles.
            DynData <ReflectionTentacles> self = new DynData <ReflectionTentacles>(this);
            bool createdFromLevel = self.Get <bool>("createdFromLevel");

            self["createdFromLevel"] = false;

            // run vanilla code.
            base.Added(scene);

            // restore the createdFromLevel value.
            self["createdFromLevel"] = createdFromLevel;

            // add tentacles like vanilla would, but make them ForegroundReflectionTentacles.
            if (createdFromLevel)
            {
                for (int i = 1; i < 4; i++)
                {
                    ForegroundReflectionTentacles reflectionTentacles = new ForegroundReflectionTentacles();
                    reflectionTentacles.Create(self.Get <float>("fearDistance"), self.Get <int>("slideUntilIndex"), i, Nodes);
                    scene.Add(reflectionTentacles);
                }
            }

            // bring all tentacles to the foreground.
            Depth = -1000000 + self.Get <int>("layer");
        }
        private IEnumerator CollectRoutine(int collectIndex)
        {
            _     = (Scene is Level);
            Tag   = Tags.TransitionUpdate;
            Depth = -2000010;
            int color = 0;

            if (Moon)
            {
                color = 3;
            }
            else if (isGhostBerry)
            {
                color = 1;
            }
            else if (Golden)
            {
                color = 2;
            }
            Audio.Play(strawberryGetSound, Position, "colour", color, "count", collectIndex);
            Input.Rumble(RumbleStrength.Medium, RumbleLength.Medium);
            sprite.Play("collect");
            while (sprite.Animating)
            {
                yield return(null);
            }
            Scene.Add(new StrawberryPoints(Position, isGhostBerry, collectIndex, Moon));
            RemoveSelf();
        }
示例#10
0
        public override void OnShown()
        {
            scene = new Scene(kernel);

            var camera = new EntityDescription(kernel);

            camera.AddProperty <Camera>("camera");
            camera.AddProperty <Viewport>("viewport");
            camera.AddBehaviour <View>();
            var cameraEntity = camera.Create();

            cameraEntity.GetProperty <Camera>("camera").Value     = new Camera();
            cameraEntity.GetProperty <Viewport>("viewport").Value = new Viewport()
            {
                Width = 1280, Height = 720
            };
            scene.Add(camera.Create());

            var renderer = scene.GetService <Renderer>();

            renderer.StartPlan()
            .Then(new ClearPhase()
            {
                Colour = Color.Black
            })
            .Then(new Phase(device)
            {
                Font = content.Load <SpriteFont>("Consolas")
            })
            .Apply();

            base.OnShown();
        }
示例#11
0
        private void addPipeSolids(int pipeWidth)
        {
            Vector2 previousNode    = Vector2.Zero;
            bool    hasPreviousNode = false;

            int i = 0;

            float halfPipeWidth = pipeWidth / 2f;

            foreach (Vector2 node in nodes)
            {
                if (hasPreviousNode)
                {
                    bool startNodeExit = i == 1;
                    bool endNodeExit   = i == nodes.Count() - 1;

                    Vector2 nextNode = nodes.ElementAtOrDefault(i + 1);

                    MarioClearPipeSolid pipeSolid = MarioClearPipeSolid.FromNodes(previousNode, node, nextNode, startNodeExit, endNodeExit, pipeWidth, texturePath, surfaceSound);

                    pipeSolids.Add(pipeSolid);
                    Scene.Add(pipeSolid);
                }

                hasPreviousNode = true;
                previousNode    = node;
                i++;
            }
        }
示例#12
0
        public Main()
        {
            mGraphics = new GraphicsDeviceManager(this)
            {
                GraphicsProfile = GraphicsProfile.HiDef, PreferredBackBufferWidth = 1920, PreferredBackBufferHeight = 1080
            };

            mCamera = new Camera(fieldOfView: 55.0f, aspectRatio: 2.0f, nearPlane: 1.0f, farPlane: 400.0f);
            mCamera.UpdatePerspective();

            mViewport = new Viewport(0, 0, 1920, 1080);

            mCamera.mLocation = new Vector3(0.0f, 20.0f, -10.0f);

            mScene = new Scene();
            mLight = new Light();

            mLight.mAmbient  = 0.1f;
            mLight.mLocation = new Vector3(1.0f, 1.0f, 0.0f) * 2000.0f;

            mCameraHandler  = new CameraHandler(mCamera, 4.0f, 2.0f, .05f);
            mFrustumCulling = new FrustumCulling();

            mScene.Add(mLight);

            IsMouseVisible = true;

            Content.RootDirectory = "Content";
        }
示例#13
0
        public override IEnumerator Enter(Oui from)
        {
            Everest.Loader.AutoLoadNewMods = false;

            menu = new TextMenu();

            // display the title and a dummy "Fetching" button
            menu.Add(new TextMenu.Header(Dialog.Clean("MODUPDATECHECKER_MENU_TITLE")));

            menu.Add(subHeader = new TextMenuExt.SubHeaderExt(Dialog.Clean("MODUPDATECHECKER_MENU_HEADER")));

            fetchingButton          = new TextMenu.Button(Dialog.Clean("MODUPDATECHECKER_FETCHING"));
            fetchingButton.Disabled = true;
            menu.Add(fetchingButton);

            Scene.Add(menu);

            currentCheckForUpdates = new CheckForUpdates();
            task = new Task(() => currentCheckForUpdates.Fetch());
            task.Start();

            menu.Visible = Visible = true;
            menu.Focused = false;

            for (float p = 0f; p < 1f; p += Engine.DeltaTime * 4f)
            {
                menu.X = offScreenX + -1920f * Ease.CubeOut(p);
                alpha  = Ease.CubeOut(p);
                yield return(null);
            }

            menu.Focused = true;
            menuOnScreen = true;
        }
示例#14
0
        public void LinkUseBItem()
        {
            switch (GetBKey())
            {
            case UseInventory.BOMB:
                if (useInventory[(int)UseInventory.BOMB].amount.current > 0)
                {
                    Sound.PlaySound(Sound.SoundEffects.Bomb_Drop, entity, !Sound.SOUND_LOOPS);     // No way to tell if it's a bomb from item class, so we play it from here
                    Item bomb = new Item(ItemSpriteFactory.Instance.CreateBomb(), entity.GetComponent <Transform>().WorldPosition + bombAdd);
                    bomb.AddComponent(new BombBehaviorScript());
                    Scene.Add(bomb);
                    useInventory[(int)UseInventory.BOMB].amount.AddCurrent(-1);

                    // Console.WriteLine("Bomb Amount = " + inventory.useInventory[(int)LinkInventory.UseInventory.BOMB].amount);
                }
                break;

            case UseInventory.BOOMERANG:
                if (useInventory[(int)UseInventory.BOOMERANG].amount.current > 0)
                {
                    new Boomerang(LinkBehavior.linkDirection, entity);
                    useInventory[(int)UseInventory.BOOMERANG].amount.AddCurrent(-1);

                    // Console.WriteLine("Bomb Amount = " + inventory.useInventory[(int)LinkInventory.UseInventory.BOMB].amount);
                }
                break;

            default:
                Console.WriteLine("Invalid Inventory BKey or item behavior not implemented.");
                break;
            }
        }
示例#15
0
        public DashCollisionResults OnDashed(Player player, Vector2 direction)
        {
            if (!_activated && (direction == _pressDirection))
            {
                if (_startCutscene)
                {
                    Scene.Add(new CS01_FactoryHelper_BreakFirstFuse(player));
                }
                _activated = true;

                _doorSprite.Active  = true;
                _doorSprite.Visible = true;
                _mainSprite.Play("chaos", true, true);
                (Scene as Level).Displacement.AddBurst(Center, 0.35f, 8f, 32f, 0.25f);
                SetBustedCollider();

                Audio.Play("event:/new_content/game/10_farewell/fusebox_hit_2", Position);
                SetSessionTags();
                SendOutSignals();

                player?.RefillDash();

                Sparkle(20);

                Add(new Coroutine(SparkleSequence()));

                return(DashCollisionResults.Rebound);
            }
            return(DashCollisionResults.NormalCollision);
        }
示例#16
0
        public static void Init()
        {
            Console.Log("Init()");
            // Game Layer
            mapRoot = new LevelParent();
            cache   = new Dictionary <string, Level>();
            initial = true;
            //currentLevelPath = null;
            currentLevel  = null;
            previousLevel = currentLevel;

            // UI Layer
            pausedText       = new TextShadowEntity(new Vector2(340, 540), "Paused", Color.White);
            pausedText.State = EntityStates.Disabled;

            deadText       = new TextShadowEntity(new Vector2(340, 540), "Defeat", Color.White);
            deadText.State = EntityStates.Disabled;

            winText       = new TextShadowEntity(new Vector2(340, 540), "Victory", Color.White);
            winText.State = EntityStates.Disabled;

            retryDialog       = new RetryDialog();
            retryDialog.State = EntityStates.Disabled;

            // UI Backdrop
            backdrop = new Backdrop();
            Scene.Add(backdrop);
            var backdropTransform = backdrop.GetComponent <Transform>();

            backdropTransform.AddChild(mapRoot);
        }
示例#17
0
        protected override void BeginTransitionOn()
        {
            spriteBatch = new SpriteBatch(device);
            font = content.Load<SpriteFont>("Consolas");

            scene = new Scene(kernel);

            var camera = new EntityDescription(kernel);
            camera.AddProperty(new TypedName<Camera>("camera"));
            camera.AddProperty(new TypedName<Viewport>("viewport"));
            camera.AddBehaviour<View>();
            var cameraEntity = camera.Create();
            cameraEntity.GetProperty(new TypedName<Camera>("camera")).Value = new Camera();
            cameraEntity.GetProperty(new TypedName<Viewport>("viewport")).Value = new Viewport() { Height = 1920, Width = 1080 };
            scene.Add(camera.Create());

            var renderer = scene.GetService<Renderer>();
            renderer.StartPlan()
                .Then<A>()
                .Then<B>()
                .Then<C>()
                .Then<D>()
                .Apply();

            base.OnShown();
        }
示例#18
0
        private void PrepareRender()
        {
            // Add to scene after building a mesh

            vertices = new List <Vertex>();
            indices  = new List <int>();

            for (int i = 0; i < navMesh.getMaxTiles(); ++i)
            {
                Detour.dtMeshTile tile = navMesh.getTile(i);

                if (tile.header != null)
                {
                    AddMeshTile(tile);
                }
            }

            var geom = new Mesh();

            geom.Load(vertices, indices, indices.Count / 3);

            var mat = new MaterialDiffuse()
            {
                ShaderProgram = "diffuse", Tex = ""
            };

            node = new Scene.Node()
            {
                Name = "NaviMesh", Material = mat, Mesh = geom
            };
            scene.Add(node);
        }
示例#19
0
        public Link LoadPlayer(Vector2 pos)
        {
            Link entity = new Link(pos);

            Scene.Add(entity);
            return(entity);
        }
示例#20
0
        public override void Added(Scene scene)
        {
            base.Added(scene);

            if (spawnedByOtherBumper)
            {
                // this bumper was spawned by another bumper that spawned the platform. so we have nothing to do!
                return;
            }

            // add a multi-node moving platform, pass the bumper settings to it, and attach the bumper to it.
            StaticMover staticMover = MakeWobbleStaticMover();

            Add(staticMover);
            animatingPlatform = new MultiNodeMovingPlatform(thisEntityData, thisOffset, otherPlatform => {
                if (otherPlatform != animatingPlatform)
                {
                    // another multi-node moving platform was spawned (because of the "count" setting), spawn another bumper...
                    MultiNodeBumper otherBumper      = new MultiNodeBumper(thisEntityData, thisOffset);
                    otherBumper.spawnedByOtherBumper = true;
                    Scene.Add(otherBumper);

                    // ... and attach it to that new platform.
                    StaticMover otherStaticMover = otherBumper.MakeWobbleStaticMover();
                    otherBumper.Add(otherStaticMover);
                    otherPlatform.AnimateObject(otherStaticMover);
                }
            });
            animatingPlatform.AnimateObject(staticMover);
            scene.Add(animatingPlatform);
        }
示例#21
0
        public void AddControlToScene(Control control)
        {
            Control newControl = null;

            if (control.GetType() == typeof(Picture))
            {
                newControl = new Picture(control.Get <Theme>(), control.Get <Material>(), control.DrawArea);
            }
            else if (control.GetType() == typeof(Label))
            {
                newControl = new Label(control.Get <Theme>(), control.DrawArea, (control as Label).Text);
                newControl.Set(control.Get <BlendMode>());
                newControl.Set(control.Get <Material>());
            }
            else if (control.GetType() == typeof(Button))
            {
                newControl = new Button(control.Get <Theme>(), control.DrawArea, (control as Button).Text);
            }
            else if (control.GetType() == typeof(InteractiveButton))
            {
                newControl = new InteractiveButton(control.Get <Theme>(), control.DrawArea,
                                                   (control as Button).Text);
            }
            else if (control.GetType() == typeof(Slider))
            {
                newControl = new Slider(control.Get <Theme>(), control.DrawArea);
            }
            newControl.RenderLayer = control.RenderLayer;
            if (!newControl.Contains <AnchoringState>())
            {
                newControl.Add(new AnchoringState());                 //ncrunch: no coverage
            }
            CheckIfAnyMaterialIsCorrupt(newControl);
            Scene.Add(newControl);
        }
示例#22
0
        private void ReloadMenu()
        {
            Vector2 position = Vector2.Zero;

            int selected = -1;

            if (menu != null)
            {
                position = menu.Position;
                selected = menu.Selection;
                Scene.Remove(menu);
            }

            menu = CreateMenu(false, null);

            if (selected >= 0)
            {
                menu.Selection = selected;
                menu.Position  = position;
            }
            IEnumerable <TextMenu> menus = Scene.Entities.OfType <TextMenu>();

            Scene.Remove(menus);
            Scene.Add(menu);
        }
示例#23
0
        void UpdatePlaying()
        {
            if (GameStateMachine.Timer % 75 == 0)
            {
                float wallY = 0, secondWallY = 0;
                wallY       = Rand.Float(-430, -210);
                secondWallY = wallY + CurrentGap + 480;

                if (CurrentGap > 60)
                {
                    CurrentGap -= 5;
                }
                else
                {
                    CurrentGap -= 2;
                }

                CurrentGap = (int)Util.Clamp(CurrentGap, MinGap, MaxGap);

                Scene.Add(new Wall(700, wallY));
                Scene.Add(new Wall(700, secondWallY));
            }
            if (GameStateMachine.Timer % 60 == 0)
            {
                Score++;
            }

            EventRouter.Publish(Events.ScoreUpdated, Score, ScoreMultiplier);
        }
        public async Task Run(Scene worldScene)
        {
            using (Disposable.Create(() => worldScene.Remove(ColoredChessboard)))
            using (Disposable.Create(() => Circles.Run(circle => worldScene.Remove(circle))))
            {
                Projector.Scene.Add(ColoredChessboard);
                worldScene.Add(Circles);

                var imagePoints = Chessboard.Saddles;
                WorldToProjectorHom.ProjectPoints(imagePoints);

                await new CalibrateTask(Window, Projector, Chessboard).Run(async () => 
                {
                    var captureCameraPoints = await new ChessboardSearchTask(Window, CaptureCameras.First(), Chessboard).Run();
                    if (captureCameraPoints == null)
                        return null;

                    var worldPoints = CaptureCameras.First().ToWorld(captureCameraPoints);

                    for (var i = 0; i < worldPoints.Length; ++i)
                        Circles[i].Position = worldPoints[i].ToVector3(z: 0.01f);

                    return new CalibrateTask.ImageAndWorldPoints()
                    {
                        ImagePoints = imagePoints,
                        WorldPoints = worldPoints,
                    };
                });

                var whenTrigger = Program.WhenInput
                                         .Where(input => input.KeyDown(Keys.Space) || input.KeyDown(Keys.Enter) || input.KeyDown(Keys.Escape));
            }
        }
示例#25
0
 public void SetsSceneRef()
 {
     Scene s = new Scene();
     Actor a = new Actor();
     s.Add(a);
     Assert.AreSame(s, a.Scene);
 }
示例#26
0
        public override Scene CreateScene(GraphicsDevice graphics, ContentLoader content)
        {
            var scene = new Scene();
            //scene = new Scene(new PassThroughSceneManager(), null);
            //scene = new Scene(new BruteForceSceneManager());
            var cube = content.Load <Microsoft.Xna.Framework.Graphics.Model>("Models/Cube/Cube.fbx");

            scene.Add(new Nine.Graphics.DirectionalLight(graphics)
            {
                DiffuseColor = Vector3.UnitX, Direction = -Vector3.UnitX
            });
            scene.Add(new Nine.Graphics.DirectionalLight(graphics)
            {
                DiffuseColor = Vector3.UnitY, Direction = -Vector3.UnitY
            });
            scene.Add(new Nine.Graphics.DirectionalLight(graphics)
            {
                DiffuseColor = Vector3.UnitZ, Direction = -Vector3.UnitZ
            });

#if WINDOWS_PHONE
            var size = 4;
#else
            var size = 20;
#endif
            var step = 2;
            for (var y = 0; y < size; y++)
            {
                for (var x = 0; x < size; x++)
                {
                    for (var z = 0; z < size; z++)
                    {
                        scene.Add(new Nine.Graphics.Model(cube)
                                  //scene.Add(new Box(graphics)
                        {
                            Material = new BasicMaterial(graphics)
                            {
                                LightingEnabled = true
                            },
                            Transform = Matrix.CreateTranslation(x * step, y * step, z * step)
                        });
                    }
                }
            }

            return(scene);
        }
示例#27
0
        public void UpdateNormal()
        {
            //Check for movement
            if (Global.player.Controller.Axis(Global.Controls.Axis).X != 0 || Global.player.Controller.Axis(Global.Controls.Axis).Y != 0)
            {
                if (sprite.CurrentAnimation.Name != "walk")
                {
                    sprite.Play("walk");
                }
                sprite.Flip = Global.player.Controller.Axis(Global.Controls.Axis).X < 0;
            }
            else
            {
                sprite.Play("idle");
            }

            //Check for input
            if (Input.MouseButtonPressed(MouseButton.Left))
            {
                state.ChangeState(States.Attack);
            }

            if (Global.player.Controller.Button(Global.Controls.Action).Pressed) // DRINK THE BLOOOOOD
            {
                var others = Collider.CollideEntities <Enemy>(X, Y, Global.Tags.Enemy);
                foreach (var e in others)
                {
                    var corpse = e.GetComponent <Corpse>();
                    if (corpse != null && !corpse.Drained)
                    {
                        corpse.Drained        = true;
                        Stats.instance.thirst = 1;

                        if (Stats.instance.drain == 0) // First drink
                        {
                            Stats.instance.drain = 0.25f;
                            if (!Sfx.instance.gameMusic.IsPlaying)
                            {
                                Sfx.instance.gameMusic.Play();
                            }
                            if (!Sfx.instance.tenseMusic.IsPlaying)
                            {
                                Sfx.instance.tenseMusic.Play();
                            }
                        }
                        Stats.instance.drain += 0.06f;
                        Stats.instance.injuries--;
                        if (Stats.instance.injuries < 0)
                        {
                            Stats.instance.injuries = 0;
                        }

                        Scene.Add(new FadeOut(0.8f, 0, 30, Color.White));
                        Sfx.instance.drink.Play();
                    }
                }
            }
            CheckForDamage();
        }
示例#28
0
        public override Scene CreateScene(GraphicsDevice graphics, ContentLoader content)
        {
            var scene = new Scene();
            var bits  = content.Load <Texture2D>("Textures/Bits.bmp");

            scene.Add(new Camera2D(graphics));
            scene.Add(new FullScreenQuad(graphics)
            {
                Texture = bits, Material = new BasicMaterial(graphics)
                {
                    SamplerState = SamplerState.PointClamp
                }
            });
            //scene.Add(new Sprite(graphics) { Texture = bits, Size = new Vector2(graphics.Viewport.Width / 2, graphics.Viewport.Height / 2), Material = new BasicMaterial(graphics) { SamplerState = SamplerState.PointClamp }, Anchor = Vector2.Zero });
            //scene.Add(new Sprite(graphics) { Texture = bits, Anchor = Vector2.Zero });
            return(scene);
        }
示例#29
0
        private Entity createExplosionFull(Vector2 pos)
        {
            Entity explosion = new Item(LinkItemSpriteFactory.Instance.CreateExplosionFull(), pos);

            explosion.GetComponent <Sprite>().SetVisible(false);
            Scene.Add(explosion);
            return(explosion);
        }
示例#30
0
 private void GenerateCoin()
 {
     Audio.Play("event:/new_content/char/badeline/booster_first_appear", Position);
     Scene.Add(new TouchSwitch(switchPosition1));
     Scene.Add(new TouchSwitch(switchPosition2));
     Scene.Add(new TouchSwitch(switchPosition3));
     Scene.Add(new TouchSwitch(switchPosition4));
 }
 public override void Awake(Scene scene)
 {
     foreach (Gem entity in gems)
     {
         scene.Add(entity);
     }
     base.Awake(scene);
 }
示例#32
0
        static void Main(string[] args)
        {
            var play  = new GameManager();
            var scene = new Scene();

            scene.Add(new Laboratory(350, 350, @"C:\Vs\GameJamSenac\AlchemistJam\Asset\chemical-laboratory.png"));
            play.StartGame(scene);
        }
        public override void Added(Scene scene)
        {
            base.Added(scene);

            // track the barrier on our own renderer, instead of the vanilla global one.
            scene.Tracker.GetEntity <SeekerBarrierRenderer>().Untrack(this);
            scene.Add(renderer);
        }
示例#34
0
        public static void CreateFromXML(Scene scene, XmlAttributeCollection attributes)
        {
            Brick brick = new Brick();
            brick.SetPosition(attributes.Int("x", 0), attributes.Int("y", 0));
            brick.Graphic = new Image("Assets/Images/grasses.png", new Rectangle(256, 0, Global.GridSize, Global.GridSize));

            scene.Add(brick);
        }
示例#35
0
 private void SpawnLaser(IGameObject turret, Scene world, Vector2f laserSpeed)
 {
     var gunPosition = turret.Body.Incircle.Radius * turret.Body.Rotation.Normalize();
     var shotPosition = turret.Body.Incircle.Center + gunPosition;
     var laser = ObjectsManager.Build((uint)ObjectID.Laser, shotPosition);
     var laserScript = new LaserScript(laserSpeed, ObjectID.Turret);
     laser.BindScript(laserScript);
     laser.Lighting.Add(new Light(new Vector2f(0.1f, 0.1f), Color.Magenta, LightMode.Flashlight));
     world.Add(laser);
 }
示例#36
0
文件: Program.cs 项目: JOCP9733/tank
        static void Main(string[] args)
        {
            // Create an Otter game with default parameters.
            var game = new Game();
            // Set the background color.
            game.Color = new Color(0.2f, 0.2f, 0.5f);
            // Want to show the mouse for this example.
            game.MouseVisible = true;

            // Create a new scene.
            var scene = new Scene();

            // Add some text edit boxes to the scene at various positions.
            scene.Add(new TextEditBox(100, 100));
            scene.Add(new TextEditBox(100, 200));
            scene.Add(new TextEditBox(100, 300));

            // Start up the game using the scene we just made.
            game.Start(scene);
        }
示例#37
0
文件: Game.cs 项目: jtdubs/VoxelLand
        public void Initialize(IntPtr handle, Viewport viewport)
        {
            this.viewport = viewport;

            gl = new OpenGL();
            gl.Create(RenderContextType.NativeWindow, viewport.Width, viewport.Height, 32, handle);
            gl.MakeCurrent();

            ShaderManager.Initialize(gl);
            MaterialManager.Initialize(gl);

            renderer = new Renderer();
            renderer.Initialize(gl);

            camera = new PerspectiveCamera();
            camera.LocalTranslate(new Vector(0, 0, 3));

            var mesh = new Mesh(gl, MeshType.Points);
            mesh.AddBuffer(
                new Buffer<Point>(gl,
                    new Point(-2, -2, 0),
                    new Point(-1, -1, 0),
                    new Point( 0,  0, 0),
                    new Point( 1, -1, 0),
                    new Point( 2, -2, 0)));

            scene = new Scene();
            scene.Add(camera);

            for (int j = -10; j < 10; j++)
            for (int i = -10; i < 10; i++)
            {
                var e = new PhysicalEntity(mesh, MaterialManager.GetMaterial("Voxels"));
                e.GlobalTranslate(Vector.UnitZ * -5 * i);
                e.GlobalTranslate(Vector.UnitX * -5 * j);
                scene.Add(e);
            }

            gl.MakeNothingCurrent();
        }
示例#38
0
 public static Scene LoadFromStream(Stream input)
 {
     using (BinaryReader reader = new BinaryReader(input))
     {
         Scene scene = new Scene(new Vector2f(reader.ReadSingle(), reader.ReadSingle()));
         while (reader.PeekChar() > -1)
             scene.Add(BuildObject(scene, reader));
         reader.Close();
         if (scene.Camera == null) scene.CreateCamera();
         scene.Commit();
         return scene;
     }
 }
示例#39
0
        static void Main(string[] args)
        {
            var game = new Game("Sakurai Plz");
          
            var scene = new Scene();
            var testEntity = new Entity(350, 240);
            // comment
           
            testEntity.AddGraphic(Image.CreateCircle( 100,Color.Red));
            
          
            
           
            scene.Add(testEntity);

           
            game.Start(scene);
        }
示例#40
0
        protected override void BeginTransitionOn()
        {
            base.BeginTransitionOn();

            _scene = _kernel.Get<Scene>();
            _scene.GetService<Renderer>()
                  .StartPlan()
                  .Then(new CreateTargetComponent(new RenderTargetInfo(1024, 768, SurfaceFormat.Color, DepthFormat.None , 0, false, RenderTargetUsage.PreserveContents), "name"))
                  .Then<SpriteComponent>()
                  .Show("name")
                  .Apply();

            var camera = new Camera();
            camera.NearClip = 1;
            camera.FarClip = 700;
            camera.View = Matrix.CreateLookAt(new Vector3(100, 50, 0), new Vector3(0, 50, 0), Vector3.Up);
            camera.Projection = Matrix.CreatePerspectiveFieldOfView(MathHelper.ToRadians(60), 16f / 9f, camera.NearClip, camera.FarClip);

            var cameraDesc = _kernel.Get<EntityDescription>();
            cameraDesc.AddProperty(new TypedName<Camera>("camera"));
            cameraDesc.AddProperty(new TypedName<Viewport>("viewport"));
            cameraDesc.AddBehaviour<View>();
            var cameraEntity = cameraDesc.Create();
            cameraEntity.GetProperty(new TypedName<Camera>("camera")).Value = camera;
            cameraEntity.GetProperty(new TypedName<Viewport>("viewport")).Value = new Viewport() {Width = _device.PresentationParameters.BackBufferWidth, Height = _device.PresentationParameters.BackBufferHeight};
            _scene.Add(cameraEntity);

            var spriteDesc = _kernel.Get<EntityDescription>();
            spriteDesc.AddBehaviour<Sprite>();

            Random r = new Random();
            for (int i = 0; i < 50; i++)
            {
                var e = spriteDesc.Create();

                _scene.Add(e, new NamedBoxCollection {
                    { Sprite.TextureName, _content.Load<Texture2D>("Chrysanthemum") },
                    { Sprite.PositionName, new Vector2(r.Next(0, 1000), r.Next(0, 1000)) },
                    { Sprite.ColorName, Color.White },
                    { Sprite.ScaleName, new Vector2(0.1f) }
                });
            }
        }
示例#41
0
        public override void OnShown()
        {
            scene = new Scene(kernel);

            var camera = new EntityDescription(kernel);
            camera.AddProperty<Camera>("camera");
            camera.AddProperty<Viewport>("viewport");
            camera.AddBehaviour<View>();
            var cameraEntity = camera.Create();
            cameraEntity.GetProperty<Camera>("camera").Value = new Camera();
            cameraEntity.GetProperty<Viewport>("viewport").Value = new Viewport() { Width = 1280, Height = 720 };
            scene.Add(camera.Create());

            var renderer = scene.GetService<Renderer>();
            renderer.StartPlan()
                .Then(new ClearPhase() { Colour = Color.Black })
                .Then(new Phase(device) { Font = content.Load<SpriteFont>("Consolas") })
                .Apply();

            base.OnShown();
        }
示例#42
0
        public AnimatedDude(IKernel kernel, ContentManager content, GraphicsDevice device)
            : base("Animated Dude", kernel)
        {
            _scene = kernel.Get<Scene>();

            var model = content.Load<ModelData>(@"models/zoe");
            var dude = kernel.Get<EntityDescription>();
            dude.AddProperty(new TypedName<ModelData>("model"), model);
            dude.AddProperty(new TypedName<Matrix>("transform"), Matrix.CreateScale(50f) * Matrix.CreateTranslation(0, 0, -150));
            dude.AddProperty(new TypedName<bool>("is_static"), false);
            dude.AddBehaviour<ModelInstance>();
            dude.AddBehaviour<Animated>();
            dude.AddBehaviour<AnimationQueue>();
            var dudeEntity = dude.Create();
            _scene.Add(dudeEntity);
            _animationQueue = dudeEntity.GetBehaviour<AnimationQueue>(null);
            _animationQueue.EnableRootBoneTranslationY = false;
            _animationQueue.EnableRootBoneTranslationX = false;
            _animationQueue.EnableRootBoneTranslationZ = false;
            _animationQueue.EnableRootBoneScale = false;

            _dude = dudeEntity.GetBehaviour<ModelInstance>(null);

            _animationQueue.DefaultClip = new AnimationQueue.ClipPlaybackParameters
            {
                Clip = content.Load<Clip>("Models/ZoeAnimations/t-pose"),
                FadeInTime = TimeSpan.FromSeconds(0.25f),
                FadeOutTime = TimeSpan.FromSeconds(0.25f),
                Loop = true,
            };

            foreach (var name in _sequence)
            {
                _animationQueue.EnqueueClip(new AnimationQueue.ClipPlaybackParameters
                {
                    Clip = content.Load<Clip>("Models/ZoeAnimations/" + name),
                    FadeInTime = TimeSpan.FromSeconds(0.1f),
                    FadeOutTime = TimeSpan.FromSeconds(0.0f),
                    Loop = false,
                });
            }

            var camera = new Camera { NearClip = 1, FarClip = 7000, View = Matrix.CreateLookAt(new Vector3(100, 50, -200), new Vector3(0, 20, 0), Vector3.Up) };
            camera.Projection = Matrix.CreatePerspectiveFieldOfView(MathHelper.ToRadians(60), 16f / 9f, camera.NearClip, camera.FarClip);
            var cameraDesc = kernel.Get<EntityDescription>();
            cameraDesc.AddProperty(new TypedName<Camera>("camera"));
            cameraDesc.AddProperty(new TypedName<Viewport>("viewport"));
            cameraDesc.AddBehaviour<View>();
            var cameraEntity = cameraDesc.Create();
            cameraEntity.GetProperty(new TypedName<Camera>("camera")).Value = camera;
            cameraEntity.GetProperty(new TypedName<Viewport>("viewport")).Value = new Viewport() { Width = device.PresentationParameters.BackBufferWidth, Height = device.PresentationParameters.BackBufferHeight };
            _scene.Add(cameraEntity);

            var ambientLight = kernel.Get<EntityDescription>();
            ambientLight.AddProperty(new TypedName<Vector3>("sky_colour"), new Vector3(0.44f, 0.44f, 0.74f));
            ambientLight.AddProperty(new TypedName<Vector3>("ground_colour"), new Vector3(0.24f, 0.35f, 0.24f));
            ambientLight.AddProperty(new TypedName<Vector3>("up"), Vector3.Up);
            ambientLight.AddBehaviour<AmbientLight>();
            _scene.Add(ambientLight.Create());

            var sponza = kernel.Get<EntityDescription>();
            sponza.AddProperty(new TypedName<ModelData>("model"), content.Load<ModelData>(@"Sponza"));
            sponza.AddProperty(new TypedName<Matrix>("transform"), Matrix.CreateScale(0.5f) * Matrix.CreateTranslation(-350, 0, 0));
            sponza.AddProperty(new TypedName<bool>("is_static"), true);
            sponza.AddBehaviour<ModelInstance>();
            _scene.Add(sponza.Create());

            var spotLight = kernel.Get<EntityDescription>();
            spotLight.AddProperty(new TypedName<Vector3>("position"), new Vector3(150, 50, -50));
            spotLight.AddProperty(new TypedName<Vector3>("colour"), new Vector3(1));
            spotLight.AddProperty(new TypedName<Vector3>("direction"), new Vector3(-1, 0, 0.25f));
            spotLight.AddProperty(new TypedName<float>("angle"), MathHelper.PiOver2);
            spotLight.AddProperty(new TypedName<float>("range"), 1000);
            spotLight.AddProperty(new TypedName<int>("shadow_resolution"), 1024);
            spotLight.AddBehaviour<SpotLight>();
            var spotLightEntity = spotLight.Create();
            _scene.Add(spotLightEntity);

            _scene.GetService<Renderer>().StartPlan()
                  .Then<GeometryBufferComponent>()
                  .Then<EdgeDetectComponent>()
                  .Then<Ssao>()
                  .Then<LightingComponent>()
                  .Then<TranslucentComponent>()
                  .Then<ToneMapComponent>()
                  .Then<AntiAliasComponent>()
                  .Apply();
        }
示例#43
0
        void CreateEntity(XmlElement e, Scene scene) {
            Type entityType = Util.GetTypeFromAllAssemblies(e.Name);

            object[] arguments = new object[2];
            arguments[0] = scene;
            arguments[1] = e.Attributes;

            if (entityType != null) {
                MethodInfo method = entityType.GetMethod(CreationMethodName, BindingFlags.Static | BindingFlags.Public);
                if (method != null) {
                    method.Invoke(null, arguments);
                }
                else {
                    // Attempt to create with just constructor
                    var x = e.AttributeInt("x");
                    var y = e.AttributeInt("y");
                    var entity = (Entity)Activator.CreateInstance(entityType, x, y);
                    scene.Add(entity);
                }
            }
        }
示例#44
0
        protected override void BeginTransitionOn()
        {
            _scene = _kernel.Get<Scene>();

            //Camera
            _cameraPosition = new Vector3(5, 0, -50);
            _camera = new Camera
            {
                NearClip = 1,
                FarClip = 700,
                View = Matrix4x4.CreateLookAt(_cameraPosition, new Vector3(0, 0, 0), Vector3.UnitY)
            };
            _camera.Projection = Matrix4x4.CreatePerspectiveFieldOfView(MathHelper.ToRadians(60), 16f / 9f, _camera.NearClip, _camera.FarClip);
            _cameraRotation = new Vector3(0, MathHelper.Pi, 0);

            //Camera entity
            var cameraDesc = _kernel.Get<EntityDescription>();
            cameraDesc.AddProperty(new TypedName<Camera>("camera"));
            cameraDesc.AddProperty(new TypedName<Viewport>("viewport"));
            cameraDesc.AddBehaviour<View>();
            var cameraEntity = cameraDesc.Create();
            cameraEntity.GetProperty(new TypedName<Camera>("camera")).Value = _camera;
            cameraEntity.GetProperty(new TypedName<Viewport>("viewport")).Value = new Viewport() { Width = _device.PresentationParameters.BackBufferWidth, Height = _device.PresentationParameters.BackBufferHeight };
            _scene.Add(cameraEntity);

            _view = cameraEntity.GetBehaviour<View>();

            //Skybox
            var skyboxDesc = _kernel.Get<EntityDescription>();
            skyboxDesc.AddBehaviour<Skybox>();
            var skybox = skyboxDesc.Create();
            skybox.GetProperty(new TypedName<TextureCube>("texture")).Value = _content.Load<TextureCube>("StormCubeMap");
            skybox.GetProperty(new TypedName<float>("brightness")).Value = 0.5f;
            skybox.GetProperty(new TypedName<bool>("gamma_correct")).Value = false;
            _scene.Add(skybox);

            //Sphere
            for (int i = 1; i < 7; i++)
            {
                var sphereModel = _content.Load<ModelData>(@"Models\sphere");
                var sphere = _kernel.Get<EntityDescription>();
                sphere.AddProperty(new TypedName<ModelData>("model"));
                sphere.AddProperty(new TypedName<Matrix4x4>("transform"));
                sphere.AddProperty(new TypedName<bool>("is_static"));
                sphere.AddBehaviour<ModelInstance>();
                var sphereEntity = sphere.Create();
                sphereEntity.GetProperty(new TypedName<ModelData>("model")).Value = sphereModel;
                sphereEntity.GetProperty(new TypedName<Matrix4x4>("transform")).Value = Matrix4x4.CreateScale(4 / sphereModel.Meshes.First().BoundingSphere.Radius)
                                                                                        * Matrix4x4.CreateRotationY(MathHelper.PiOver2)
                                                                                        * Matrix4x4.CreateTranslation(0, 0, i * 20);
                sphereEntity.GetProperty(new TypedName<bool>("is_static")).Value = true;
                _scene.Add(sphereEntity);

                var smodel = sphereEntity.GetBehaviour<ModelInstance>();
                smodel.Opacity = 0.15f;
                smodel.SubSurfaceScattering = 0.5f;
                smodel.Attenuation = 0.2f;
            }

            //Particles
            var particleEntityDesc = _scene.Kernel.Get<EntityDescription>();
            particleEntityDesc.AddProperty(new TypedName<Vector3>("position"));
            particleEntityDesc.AddBehaviour<ParticleEmitter>();
            var entity = particleEntityDesc.Create();
            NamedBoxCollection initData = new NamedBoxCollection();
            initData.Set(new TypedName<ParticleEmitterDescription>("particlesystem"), _content.Load<ParticleEmitterDescription>("Particles/TestEmitter1"));
            _scene.Add(entity, initData);

            _scene.GetService<Renderer>()
                  .StartPlan()
                  .Then<GeometryBufferComponent>()
                  .Then<EdgeDetectComponent>()
                  .Then<Ssao>()
                  .Then<LightingComponent>()
                  .Then<DeferredTransparency>()
                  .Then<ToneMapComponent>()
                  .Then<AntiAliasComponent>()
                  .Show("antialiased")
                  .Apply();

            _game.DisplayUI = true;

            base.BeginTransitionOn();
        }
示例#45
0
        protected override void LoadContent()
        {
            scene = new Scene();

            arrow = new GameObject();
            arrow.model = contentManager.Load<Model>("Models/Arrow");
            arrow.position = new Coords(0, 0, -50);

            scene.Add(arrow);

            camera = new GameObject();
            camera.position = new Coords(0, 0, 0);

            audio.MusicTrack("AdaptiveTest");

            base.LoadContent();
        }
示例#46
0
        public TestScene(IKernel kernel, Game game, ContentManager content, GraphicsDevice device)
        {
            scene = new Scene(kernel);
            this.game = game;

            sb = new SpriteBatch(device);
            basic = content.Load<Effect>("Basic");

            cameraPosition = new Vector3(100, 50, 0);

            camera = new Camera();
            camera.NearClip = 1;
            camera.FarClip = 700;
            camera.View = Matrix.CreateLookAt(cameraPosition, new Vector3(0, 50, 0), Vector3.Up);
            camera.Projection = Matrix.CreatePerspectiveFieldOfView(MathHelper.ToRadians(60), 16f / 9f, camera.NearClip, camera.FarClip);

            var cameraDesc = kernel.Get<EntityDescription>();
            cameraDesc.AddProperty<Camera>("camera");
            cameraDesc.AddProperty<Viewport>("viewport");
            cameraDesc.AddBehaviour<View>();
            var cameraEntity = cameraDesc.Create();
            cameraEntity.GetProperty<Camera>("camera").Value = camera;
            cameraEntity.GetProperty<Viewport>("viewport").Value = new Viewport() { Width = device.PresentationParameters.BackBufferWidth, Height = device.PresentationParameters.BackBufferHeight };
            scene.Add(cameraEntity);

            var skyboxDesc = kernel.Get<EntityDescription>();
            skyboxDesc.AddBehaviour<Skybox>();
            var skybox = skyboxDesc.Create();
            skybox.GetProperty<TextureCube>("texture").Value= content.Load<TextureCube>("StormCubeMap");
            skybox.GetProperty<float>("brightness").Value = 0.5f;
            skybox.GetProperty<bool>("gamma_correct").Value = false;
            scene.Add(skybox);

            //var sunEntity = kernel.Get<EntityDescription>();
            //sunEntity.AddProperty<Vector3>("direction", Vector3.Normalize(new Vector3(-.2f, -1f, .3f)));
            //sunEntity.AddProperty<Vector3>("colour", new Vector3(5f));
            //sunEntity.AddProperty<int>("shadow_resolution", 4096);
            //sunEntity.AddBehaviour<SunLight>();
            //sun = sunEntity.Create();
            //scene.Add(sun);

            //var sun2 = sunEntity.Create();
            //sun2.GetProperty<Vector3>("direction").Value = Vector3.Normalize(new Vector3(1, -1, 0));
            //sun2.GetProperty<Vector3>("colour").Value = new Vector3(1, 0, 0);
            //scene.Add(sun2);

            var pointLight = kernel.Get<EntityDescription>();
            pointLight.AddProperty<Vector3>("position");
            pointLight.AddProperty<Vector3>("colour");
            pointLight.AddProperty<float>("range");
            pointLight.AddBehaviour<PointLight>();
            //scene.Add(pointLight.Create());

            lights = new List<PointLight>();
            var rng = new Random();
            for (int i = 0; i < 0; i++)
            {
                var entity = pointLight.Create();
                scene.Add(entity);

                entity.GetProperty<Vector3>("position").Value = new Vector3(0, 10, 0);
                entity.GetProperty<Vector3>("colour").Value = new Vector3(0, 5, 0);
                entity.GetProperty<float>("range").Value = 200;

                var light = entity.GetBehaviour<PointLight>();
                light.Colour = Vector3.Normalize(new Vector3(0.1f + (float)rng.NextDouble(), 0.1f + (float)rng.NextDouble(), 0.1f + (float)rng.NextDouble())) * 10;
                lights.Add(light);
            }

            var spotLight = kernel.Get<EntityDescription>();
            spotLight.AddProperty<Vector3>("position");
            spotLight.AddProperty<Vector3>("colour");
            spotLight.AddProperty<Vector3>("direction");
            spotLight.AddProperty<float>("angle");
            spotLight.AddProperty<float>("range");
            spotLight.AddProperty<Texture2D>("mask");
            spotLight.AddProperty<int>("shadow_resolution");
            spotLight.AddBehaviour<SpotLight>();
            var spotLightEntity = spotLight.Create();
            spotLightEntity.GetProperty<Vector3>("position").Value = new Vector3(-180, 250, 0);
            spotLightEntity.GetProperty<Vector3>("colour").Value = new Vector3(10);
            spotLightEntity.GetProperty<Vector3>("direction").Value = new Vector3(0, -1, 0);
            spotLightEntity.GetProperty<float>("angle").Value = MathHelper.PiOver2;
            spotLightEntity.GetProperty<float>("range").Value = 500;
            spotLightEntity.GetProperty<Texture2D>("mask").Value = null; //content.Load<Texture2D>("Chrysanthemum"));
            spotLightEntity.GetProperty<int>("shadow_resolution").Value = 512; //content.Load<Texture2D>("Chrysanthemum"));
            this.spotLight = spotLightEntity.GetBehaviour<SpotLight>();
            scene.Add(spotLightEntity);

            var ambientLight = kernel.Get<EntityDescription>();
            ambientLight.AddProperty<Vector3>("sky_colour");
            ambientLight.AddProperty<Vector3>("ground_colour");
            ambientLight.AddProperty<Vector3>("up");
            ambientLight.AddBehaviour<AmbientLight>();
            var ambientLightEntity = ambientLight.Create();
            ambientLightEntity.GetProperty<Vector3>("sky_colour").Value = new Vector3(0.04f);
            ambientLightEntity.GetProperty<Vector3>("ground_colour").Value = new Vector3(0.04f, 0.05f, 0.04f);
            ambientLightEntity.GetProperty<Vector3>("up").Value = Vector3.Up;
            scene.Add(ambientLightEntity);

            //var floor = content.Load<ModelData>(@"Models\Ground");
            //var floorEntity = kernel.Get<EntityDescription>();
            //floorEntity.AddProperty<ModelData>("model", floor);
            //floorEntity.AddProperty<Matrix>("transform", Matrix.CreateScale(2));
            //floorEntity.AddProperty<bool>("isstatic", true);
            //floorEntity.AddBehaviour<ModelInstance>();
            //scene.Add(floorEntity.Create());

            var lizardModel = content.Load<ModelData>(@"Models\lizard");
            var lizard = kernel.Get<EntityDescription>();
            lizard.AddProperty<ModelData>("model");
            lizard.AddProperty<Matrix>("transform");
            lizard.AddProperty<bool>("is_static");
            var lizardEntity = lizard.Create();
            lizardEntity.GetProperty<ModelData>("model").Value = lizardModel;
            lizardEntity.GetProperty<Matrix>("transform").Value = Matrix.CreateScale(50 / 700f) * Matrix.CreateTranslation(150, 0, 0);
            lizardEntity.GetProperty<bool>("is_static").Value = true;
            lizard.AddBehaviour<ModelInstance>();

            scene.Add(lizardEntity);

            //var ship1 = content.Load<ModelData>(@"Models\Ship1");
            //var ship1Entity = kernel.Get<EntityDescription>();
            //ship1Entity.AddProperty<ModelData>("model", ship1);
            //ship1Entity.AddProperty<Matrix>("transform", Matrix.CreateTranslation(30, 0, 0));
            //ship1Entity.AddProperty<bool>("is_static", true);
            //ship1Entity.AddBehaviour<ModelInstance>();
            //scene.Add(ship1Entity.Create());

            var hebeModel = content.Load<ModelData>(@"Models\Hebe2");
            var hebe = kernel.Get<EntityDescription>();
            hebe.AddProperty<ModelData>("model");
            hebe.AddProperty<Matrix>("transform");
            hebe.AddProperty<bool>("is_static");
            hebe.AddBehaviour<ModelInstance>();
            var hebeEntity = hebe.Create();
            hebeEntity.GetProperty<ModelData>("model").Value = hebeModel;
            hebeEntity.GetProperty<Matrix>("transform").Value = Matrix.CreateScale(25 / hebeModel.Meshes[0].BoundingSphere.Radius)
                                                                    * Matrix.CreateRotationY(MathHelper.PiOver2)
                                                                    * Matrix.CreateTranslation(-150, 20, 0);
            hebeEntity.GetProperty<bool>("is_static").Value = true;
            scene.Add(hebeEntity);

            var lightBlocker = hebe.Create();
            hebeTransform = lightBlocker.GetProperty<Matrix>("transform");
            lightBlocker.GetProperty<ModelData>("model").Value = hebeModel;
            lightBlocker.GetProperty<Matrix>("transform").Value = Matrix.CreateScale(25 / hebeModel.Meshes[0].BoundingSphere.Radius)
                                                                    * Matrix.CreateRotationY(MathHelper.PiOver2)
                                                                    * Matrix.CreateTranslation(-150, 20, 0);
            lightBlocker.GetProperty<bool>("is_static").Value = true;
            scene.Add(lightBlocker);

            var sponzaModel = content.Load<ModelData>(@"Sponza");
            var sponza = kernel.Get<EntityDescription>();
            sponza.AddProperty<ModelData>("model");
            sponza.AddProperty<Matrix>("transform");
            sponza.AddProperty<bool>("is_static");
            sponza.AddBehaviour<ModelInstance>();
            var sponzaEntity = sponza.Create();
            sponzaEntity.GetProperty<ModelData>("model").Value = sponzaModel;
            sponzaEntity.GetProperty<Matrix>("transform").Value = Matrix.Identity * Matrix.CreateScale(1);
            sponzaEntity.GetProperty<bool>("is_static").Value = true;
            scene.Add(sponzaEntity);

            var renderer = scene.GetService<Renderer>();
            resolution = renderer.Data.Get<Vector2>("resolution");

            var console = kernel.Get<CommandConsole>();
            renderer.Settings.BindCommandEngine(console.Engine);

            //var fire1 = Fire.Create(kernel, content, new Vector3(123.5f, 30f, -55f));
            //var fire2 = Fire.Create(kernel, content, new Vector3(123.5f, 30f, 35f));
            //var fire3 = Fire.Create(kernel, content, new Vector3(-157f, 30f, 35f));
            //var fire4 = Fire.Create(kernel, content, new Vector3(-157f, 30f, -55f));

            //scene.Add(fire1);
            //scene.Add(fire2);
            //scene.Add(fire3);
            //scene.Add(fire4);

            cameraScript = new CameraScript(camera);
            cameraScript.AddWaypoint(0, new Vector3(218, 160, 104), new Vector3(0, 150, 0));
            cameraScript.AddWaypoint(10, new Vector3(-195, 160, 104), new Vector3(-150, 150, 0));
            cameraScript.AddWaypoint(12, new Vector3(-270, 160, 96), new Vector3(-150, 150, 0));
            cameraScript.AddWaypoint(14, new Vector3(-302, 160, 45), new Vector3(-150, 150, 0));
            cameraScript.AddWaypoint(16, new Vector3(-286, 160, 22), new Vector3(-150, 150, 0));
            cameraScript.AddWaypoint(18, new Vector3(-276, 160, 22), new Vector3(-150, 100, 0));
            cameraScript.AddWaypoint(20, new Vector3(-158, 42, 19), new Vector3(-150, 40, 0));
            cameraScript.AddWaypoint(21, new Vector3(-105, 24, -7), new Vector3(-150, 40, 0));
            cameraScript.AddWaypoint(23, new Vector3(-105, 44, -7), new Vector3(-150, 40, 0));
            cameraScript.AddWaypoint(27, new Vector3(-105, 50, -7), new Vector3(-80, 50, -100));
            cameraScript.AddWaypoint(32, new Vector3(100, 50, -7), new Vector3(150, 40, 0));
            cameraScript.AddWaypoint(34, new Vector3(100, 50, -7), new Vector3(150, 40, 100));
            cameraScript.AddWaypoint(36, new Vector3(100, 50, -7), new Vector3(0, 60, 0));
            //cameraScript.AddWaypoint(1000, new Vector3(100, 50, -7), new Vector3(0, 60, 0));
            cameraScript.Initialise();
        }
示例#47
0
        protected override void BeginTransitionOn()
        {
            _scene = new Scene(_kernel);

            var camera = new EntityDescription(_kernel);
            camera.AddProperty(new TypedName<Camera>("camera"));
            camera.AddProperty(new TypedName<Viewport>("viewport"));
            camera.AddBehaviour<View>();
            var cameraEntity = camera.Create();
            cameraEntity.GetProperty(new TypedName<Camera>("camera")).Value = new Camera();
            cameraEntity.GetProperty(new TypedName<Viewport>("viewport")).Value = new Viewport() { Width = 1280, Height = 720 };
            _scene.Add(cameraEntity);

            var renderer = _scene.GetService<Renderer>();
            renderer.StartPlan()
                .Then(new Phase(_device) { Font = _content.Load<SpriteFont>("Consolas") })
                .Then(new ClearPhase() { Colour = Color.Black })
                .Apply();

            base.OnShown();
        }
示例#48
0
        /// <summary>
        /// Load data into a scene from a source .oel file.
        /// </summary>
        /// <param name="source">The oel to load.</param>
        /// <param name="scene">The scene to load into.</param>
        public void LoadLevel(string source, Scene scene)
        {
            Entities.Clear();

            var xmlDoc = new XmlDocument();
            xmlDoc.Load(source);

            var xmlLevel = xmlDoc["level"];

            scene.Width = int.Parse(xmlDoc["level"].Attributes["width"].Value);
            scene.Height = int.Parse(xmlDoc["level"].Attributes["height"].Value);

            int i = 0;

            foreach (var layer in Layers.Values) {

                if (layer.Type == "GridLayerDefinition") {
                    var Entity = new Entity();

                    var grid = new GridCollider(scene.Width, scene.Height, layer.GridWidth, layer.GridHeight);

                    grid.LoadString(xmlLevel[layer.Name].InnerText);
                    if (ColliderTags.ContainsKey(layer.Name)) {
                        grid.AddTag(ColliderTags[layer.Name]);
                    }

                    if (DisplayGrids) {
                        var tilemap = new Tilemap(scene.Width, scene.Height, layer.GridWidth, layer.GridHeight);
                        tilemap.LoadString(xmlLevel[layer.Name].InnerText, layer.Color);
                        Entity.AddGraphic(tilemap);
                    }

                    Entity.AddCollider(grid);

                    scene.Add(Entity);
                    Entities.Add(layer.Name, Entity);
                }
                if (layer.Type == "TileLayerDefinition") {
                    var Entity = new Entity();

                    var xmlTiles = xmlLevel[layer.Name];

                    var tileset = xmlTiles.Attributes["tileset"].Value;

                    var tilemap = new Tilemap(ImagePath + TileMaps[tileset], scene.Width, scene.Height, layer.GridWidth, layer.GridHeight);

                    foreach (XmlElement t in xmlTiles) {
                        tilemap.SetTile(t);
                    }

                    tilemap.Update();

                    Entity.AddGraphic(tilemap);

                    Entity.Layer = BaseTileDepth - i * TileDepthIncrement;
                    i++;

                    scene.Add(Entity);
                    Entities.Add(layer.Name, Entity);
                }
                if (layer.Type == "EntityLayerDefinition") {
                    var xmlEntities = xmlLevel[layer.Name];

                    foreach (XmlElement e in xmlEntities) {
                        CreateEntity(e, scene);
                    }
                }

            }

            if (UseCameraBounds) {
                scene.CameraBounds = new Rectangle(0, 0, scene.Width, scene.Height);
                scene.UseCameraBounds = true;
            }
        }
示例#49
0
        public TestScene(IKernel kernel, Game game, ContentManager content, GraphicsDevice device, [Optional]SceneConfiguration config)
        {
            config = config ?? new SceneConfiguration();

            _scene = new Scene(kernel);
            _game = game;

            _cameraPosition = new Vector3(100, 50, 0);

            _camera = new Camera();
            _camera.NearClip = 1;
            _camera.FarClip = 700;
            _camera.View = Matrix4x4.CreateLookAt(_cameraPosition, new Vector3(0, 50, 0), Vector3.UnitY);
            _camera.Projection = Matrix4x4.CreatePerspectiveFieldOfView(MathHelper.ToRadians(60), 16f / 9f, _camera.NearClip, _camera.FarClip);

            if (config.View)
            {
                var cameraDesc = kernel.Get<EntityDescription>();
                cameraDesc.AddProperty(new TypedName<Camera>("camera"));
                cameraDesc.AddProperty(new TypedName<Viewport>("viewport"));
                cameraDesc.AddBehaviour<View>();
                var cameraEntity = cameraDesc.Create();
                cameraEntity.GetProperty(new TypedName<Camera>("camera")).Value = _camera;
                cameraEntity.GetProperty(new TypedName<Viewport>("viewport")).Value = new Viewport() {Width = device.PresentationParameters.BackBufferWidth, Height = device.PresentationParameters.BackBufferHeight};
                _scene.Add(cameraEntity);
            }

            if (config.Skybox)
            {
                var skyboxDesc = kernel.Get<EntityDescription>();
                skyboxDesc.AddBehaviour<Skybox>();
                var skybox = skyboxDesc.Create();
                skybox.GetProperty(new TypedName<TextureCube>("texture")).Value = content.Load<TextureCube>("StormCubeMap");
                skybox.GetProperty(new TypedName<float>("brightness")).Value = 0.5f;
                skybox.GetProperty(new TypedName<bool>("gamma_correct")).Value = false;
                _scene.Add(skybox);
            }

            var pointLight = kernel.Get<EntityDescription>();
            pointLight.AddProperty(new TypedName<Vector3>("position"));
            pointLight.AddProperty(new TypedName<Vector3>("colour"));
            pointLight.AddProperty(new TypedName<float>("range"));
            pointLight.AddBehaviour<PointLight>();
            //scene.Add(pointLight.Create());

            _lights = new List<PointLight>();
            var rng = new Random();
            for (int i = 0; i < config.RandomPointLights; i++)
            {
                var entity = pointLight.Create();
                _scene.Add(entity);

                entity.GetProperty(new TypedName<Vector3>("position")).Value = new Vector3(0, 10, 0);
                entity.GetProperty(new TypedName<Vector3>("colour")).Value = new Vector3(0, 5, 0);
                entity.GetProperty(new TypedName<float>("range")).Value = 200;

                var light = entity.GetBehaviour<PointLight>(null);
                light.Colour = Vector3.Normalize(new Vector3(0.1f + (float)rng.NextDouble(), 0.1f + (float)rng.NextDouble(), 0.1f + (float)rng.NextDouble())) * 10;
                _lights.Add(light);
            }

            if (config.Spotlight)
            {
                var spotLight = kernel.Get<EntityDescription>();
                spotLight.AddProperty(new TypedName<Vector3>("position"));
                spotLight.AddProperty(new TypedName<Vector3>("colour"));
                spotLight.AddProperty(new TypedName<Vector3>("direction"));
                spotLight.AddProperty(new TypedName<float>("angle"));
                spotLight.AddProperty(new TypedName<float>("range"));
                spotLight.AddProperty(new TypedName<Texture2D>("mask"));
                spotLight.AddProperty(new TypedName<int>("shadow_resolution"));
                spotLight.AddBehaviour<SpotLight>();
                var spotLightEntity = spotLight.Create();
                spotLightEntity.GetProperty(new TypedName<Vector3>("position")).Value = new Vector3(-180, 250, 0);
                spotLightEntity.GetProperty(new TypedName<Vector3>("colour")).Value = new Vector3(10);
                spotLightEntity.GetProperty(new TypedName<Vector3>("direction")).Value = new Vector3(0, -1, 0);
                spotLightEntity.GetProperty(new TypedName<float>("angle")).Value = MathHelper.PiOver2;
                spotLightEntity.GetProperty(new TypedName<float>("range")).Value = 500;
                spotLightEntity.GetProperty(new TypedName<Texture2D>("mask")).Value = content.Load<Texture2D>("Chrysanthemum");
                spotLightEntity.GetProperty(new TypedName<int>("shadow_resolution")).Value = 1024;
                _spotLight = spotLightEntity.GetBehaviour<SpotLight>(null);
                _scene.Add(spotLightEntity);
            }

            if (config.AmbientLight)
            {
                var ambientLight = kernel.Get<EntityDescription>();
                ambientLight.AddProperty(new TypedName<Vector3>("sky_colour"));
                ambientLight.AddProperty(new TypedName<Vector3>("ground_colour"));
                ambientLight.AddProperty(new TypedName<Vector3>("up"));
                ambientLight.AddBehaviour<AmbientLight>();
                var ambientLightEntity = ambientLight.Create();
                ambientLightEntity.GetProperty(new TypedName<Vector3>("sky_colour")).Value = new Vector3(0.04f);
                ambientLightEntity.GetProperty(new TypedName<Vector3>("ground_colour")).Value = new Vector3(0.04f, 0.05f, 0.04f);
                ambientLightEntity.GetProperty(new TypedName<Vector3>("up")).Value = Vector3.UnitY;
                _scene.Add(ambientLightEntity);
            }

            if (config.SunLight)
            {
                var sunlight = kernel.Get<EntityDescription>();
                sunlight.AddBehaviour<SunLight>();
                var sunlightEntity = sunlight.Create();
                sunlightEntity.GetProperty(new TypedName<Vector3>("colour")).Value = new Vector3(1, 0.75f, 0.6f);
                sunlightEntity.GetProperty(new TypedName<Vector3>("direction")).Value = -Vector3.UnitY;
                sunlightEntity.GetProperty(new TypedName<int>("shadow_resolution")).Value = 1024;
                _scene.Add(sunlightEntity);

                //var sunEntity = kernel.Get<EntityDescription>();
                //sunEntity.AddProperty(SunLight.DirectionName, Vector3.Normalize(new Vector3(-.2f, -1f, .3f)));
                //sunEntity.AddProperty(SunLight.ColourName, new Vector3(1, 0.3f, 0.01f) * 5);
                //sunEntity.AddProperty(SunLight.ShadowResolutionName, 4096);
                //sunEntity.AddProperty(SunLight.ActiveName, true);
                //sunEntity.AddBehaviour<SunLight>();
                //Entity sun = sunEntity.Create();
                //_scene.Add(sun);

                //var sun2 = sunEntity.Create();
                //sun2.GetProperty<Vector3>("direction").Value = Vector3.Normalize(new Vector3(1, -1, 0));
                //sun2.GetProperty<Vector3>("colour").Value = new Vector3(1, 0, 0);
                //scene.Add(sun2);
            }

            //var floor = content.Load<ModelData>(@"Models\Ground");
            //var floorEntity = kernel.Get<EntityDescription>();
            //floorEntity.AddProperty<ModelData>("model", floor);
            //floorEntity.AddProperty<Matrix>("transform", Matrix.CreateScale(2));
            //floorEntity.AddProperty<bool>("isstatic", true);
            //floorEntity.AddBehaviour<ModelInstance>();
            //scene.Add(floorEntity.Create());

            //var ship1 = content.Load<ModelData>(@"Models\Ship1");
            //var ship1Entity = kernel.Get<EntityDescription>();
            //ship1Entity.AddProperty<ModelData>("model", ship1);
            //ship1Entity.AddProperty<Matrix>("transform", Matrix.CreateTranslation(30, 0, 0));
            //ship1Entity.AddProperty<bool>("is_static", true);
            //ship1Entity.AddBehaviour<ModelInstance>();
            //scene.Add(ship1Entity.Create());

            //var hebeModel = content.Load<ModelData>(@"Models\Hebe2");
            //var hebe = kernel.Get<EntityDescription>();
            //hebe.AddProperty(new TypedName<ModelData>("model"));
            //hebe.AddProperty(new TypedName<Matrix4x4>("transform"));
            //hebe.AddProperty(new TypedName<bool>("is_static"));
            //hebe.AddBehaviour<ModelInstance>();
            //var hebeEntity = hebe.Create();
            //hebeEntity.GetProperty(new TypedName<ModelData>("model")).Value = hebeModel;
            //hebeEntity.GetProperty(new TypedName<Matrix4x4>("transform")).Value = Matrix4x4.CreateScale(25 / hebeModel.Meshes.First().BoundingSphere.Radius)
            //                                                        * Matrix4x4.CreateRotationY(MathHelper.PiOver2)
            //                                                        * Matrix4x4.CreateTranslation(-150, 20, 0);
            //hebeEntity.GetProperty(new TypedName<bool>("is_static")).Value = true;
            //hebeEntity.GetProperty(ModelInstance.OpacityName).Value = 0.5f;
            //_scene.Add(hebeEntity);

            var sphereModel = content.Load<ModelData>(@"Models\sphere");
            var sphere = kernel.Get<EntityDescription>();
            sphere.AddProperty(new TypedName<ModelData>("model"));
            sphere.AddProperty(new TypedName<Matrix4x4>("transform"));
            sphere.AddProperty(new TypedName<bool>("is_static"));
            sphere.AddBehaviour<ModelInstance>();
            var sphereEntity = sphere.Create();
            sphereEntity.GetProperty(new TypedName<ModelData>("model")).Value = sphereModel;
            sphereEntity.GetProperty(new TypedName<Matrix4x4>("transform")).Value = Matrix4x4.CreateScale(5 / sphereModel.Meshes.First().BoundingSphere.Radius)
                                                                    * Matrix4x4.CreateRotationY(MathHelper.PiOver2)
                                                                    * Matrix4x4.CreateTranslation(-150, 20, 0);
            sphereEntity.GetProperty(new TypedName<bool>("is_static")).Value = true;
            _scene.Add(sphereEntity);

            var smodel = sphereEntity.GetBehaviour<ModelInstance>(null);
            smodel.Opacity = 0.5f;
            smodel.SubSurfaceScattering = 0.5f;
            smodel.Attenuation = 0.3f;

            //var dudeModel = content.Load<ModelData>(@"dude");
            //var dude = kernel.Get<EntityDescription>();
            //dude.AddProperty<ModelData>("model", dudeModel);
            //dude.AddProperty<Matrix>("transform", Matrix.CreateScale(0.75f) * Matrix.CreateTranslation(-50, 0, 0));
            //dude.AddProperty<bool>("is_static", true);
            //dude.AddBehaviour<ModelInstance>();
            //dude.AddBehaviour<Animated>();
            //var dudeEntity = dude.Create();
            //scene.Add(dudeEntity);

            var sponzaModel = content.Load<ModelData>(@"Sponza");
            var sponza = kernel.Get<EntityDescription>();
            sponza.AddProperty(new TypedName<ModelData>("model"));
            sponza.AddProperty(new TypedName<Matrix4x4>("transform"));
            sponza.AddProperty(new TypedName<bool>("is_static"));
            sponza.AddBehaviour<ModelInstance>();
            var sponzaEntity = sponza.Create();
            sponzaEntity.GetProperty(new TypedName<ModelData>("model")).Value = sponzaModel;
            sponzaEntity.GetProperty(new TypedName<Matrix4x4>("transform")).Value = Matrix4x4.Identity * Matrix4x4.CreateScale(1);
            sponzaEntity.GetProperty(new TypedName<bool>("is_static")).Value = true;
            _scene.Add(sponzaEntity);

            var renderer = _scene.GetService<Renderer>();
            _resolution = renderer.Data.Get<Vector2>("resolution");

            var console = kernel.Get<CommandConsole>();
            renderer.Settings.BindCommandEngine(console.Engine);

            if (config.Fire)
            {
                //var fire1 = Fire.Create(kernel, content, new Vector3(123.5f, 30f, -55f));
                //var fire2 = Fire.Create(kernel, content, new Vector3(123.5f, 30f, 35f));
                //var fire3 = Fire.Create(kernel, content, new Vector3(-157f, 30f, 35f));
                //var fire4 = Fire.Create(kernel, content, new Vector3(-157f, 30f, -55f));

                //scene.Add(fire1);
                //scene.Add(fire2);
                //scene.Add(fire3);
                //scene.Add(fire4);
            }

            _cameraScript = new CameraScript(_camera);
            _cameraScript.AddWaypoint(0, new Vector3(218, 160, 104), new Vector3(0, 150, 0));
            _cameraScript.AddWaypoint(10, new Vector3(-195, 160, 104), new Vector3(-150, 150, 0));
            _cameraScript.AddWaypoint(12, new Vector3(-270, 160, 96), new Vector3(-150, 150, 0));
            _cameraScript.AddWaypoint(14, new Vector3(-302, 160, 45), new Vector3(-150, 150, 0));
            _cameraScript.AddWaypoint(16, new Vector3(-286, 160, 22), new Vector3(-150, 150, 0));
            _cameraScript.AddWaypoint(18, new Vector3(-276, 160, 22), new Vector3(-150, 100, 0));
            _cameraScript.AddWaypoint(20, new Vector3(-158, 42, 19), new Vector3(-150, 40, 0));
            _cameraScript.AddWaypoint(21, new Vector3(-105, 24, -7), new Vector3(-150, 40, 0));
            _cameraScript.AddWaypoint(23, new Vector3(-105, 44, -7), new Vector3(-150, 40, 0));
            _cameraScript.AddWaypoint(27, new Vector3(-105, 50, -7), new Vector3(-80, 50, -100));
            _cameraScript.AddWaypoint(32, new Vector3(100, 50, -7), new Vector3(150, 40, 0));
            _cameraScript.AddWaypoint(34, new Vector3(100, 50, -7), new Vector3(150, 40, 100));
            _cameraScript.AddWaypoint(36, new Vector3(100, 50, -7), new Vector3(0, 60, 0));
            //cameraScript.AddWaypoint(1000, new Vector3(100, 50, -7), new Vector3(0, 60, 0));
            _cameraScript.Initialise();
        }
示例#50
0
        public virtual void AddToScene(Scene scene)
        {
            if (scene != null)
            {
                // Add this way for now
                scene.Add(this);

                // Save which scene it has been added to
                m_SceneAddedTo = scene;
            }
        }
示例#51
0
        public DecalTest(IKernel kernel, ContentManager content, GraphicsDevice device)
            : base("Decal Test", kernel)
        {
            _scene = kernel.Get<Scene>();

            _scene.GetService<Renderer>().StartPlan()
                  .Then<GeometryBufferComponent>()
                  .Then<DecalComponent>()
                  .Then<DecalMixComponent>()
                  .Then<Ssao>()
                  .Then<LightingComponent>()
                  .Then<TranslucentComponent>()
                  .Then<ToneMapComponent>()
                  .Then<AntiAliasComponent>()
                  //.Show("gbuffer_normals")
                  .Apply();

            _camera = new Camera { NearClip = 1, FarClip = 7000, View = Matrix4x4.CreateLookAt(new Vector3(100, 50, -200), new Vector3(0, 0, 0), Vector3.UnitY) };
            _camera.Projection = Matrix4x4.CreatePerspectiveFieldOfView(MathHelper.ToRadians(60), 16f / 9f, _camera.NearClip, _camera.FarClip);
            var cameraDesc = kernel.Get<EntityDescription>();
            cameraDesc.AddProperty(new TypedName<Camera>("camera"));
            cameraDesc.AddProperty(new TypedName<Viewport>("viewport"));
            cameraDesc.AddBehaviour<View>();
            var cameraEntity = cameraDesc.Create();
            cameraEntity.GetProperty(new TypedName<Camera>("camera")).Value = _camera;
            cameraEntity.GetProperty(new TypedName<Viewport>("viewport")).Value = new Viewport() { Width = device.PresentationParameters.BackBufferWidth, Height = device.PresentationParameters.BackBufferHeight };
            _scene.Add(cameraEntity);

            var ambientLight = kernel.Get<EntityDescription>();
            ambientLight.AddProperty(new TypedName<Vector3>("sky_colour"), new Vector3(0.44f, 0.44f, 0.74f));
            ambientLight.AddProperty(new TypedName<Vector3>("ground_colour"), new Vector3(0.24f, 0.35f, 0.24f));
            ambientLight.AddProperty(new TypedName<Vector3>("up"), Vector3.UnitY);
            ambientLight.AddBehaviour<AmbientLight>();
            _scene.Add(ambientLight.Create());

            var sponza = kernel.Get<EntityDescription>();
            sponza.AddProperty(new TypedName<ModelData>("model"), content.Load<ModelData>(@"Sponza"));
            sponza.AddProperty(new TypedName<Matrix4x4>("transform"), Matrix4x4.CreateScale(0.5f) * Matrix4x4.CreateTranslation(-350, 0, 0));
            sponza.AddProperty(new TypedName<bool>("is_static"), true);
            sponza.AddBehaviour<ModelInstance>();
            _scene.Add(sponza.Create());

            var spotLight = kernel.Get<EntityDescription>();
            spotLight.AddProperty(new TypedName<Vector3>("position"), new Vector3(150, 50, -50));
            spotLight.AddProperty(new TypedName<Vector3>("colour"), new Vector3(1));
            spotLight.AddProperty(new TypedName<Vector3>("direction"), new Vector3(-1, 0, 0.25f));
            spotLight.AddProperty(new TypedName<float>("angle"), MathHelper.PiOver2);
            spotLight.AddProperty(new TypedName<float>("range"), 1000);
            spotLight.AddProperty(new TypedName<int>("shadow_resolution"), 1024);
            spotLight.AddBehaviour<SpotLight>();
            var spotLightEntity = spotLight.Create();
            _scene.Add(spotLightEntity);

            var decal = kernel.Get<EntityDescription>();
            decal.AddBehaviour<Decal>();

            //Random r = new Random(2);
            //for (int i = 0; i < 150; i++)
            //{
            //    _scene.Add(decal.Create(), new NamedBoxCollection {
            //        { Decal.NormalName, content.Load<Texture2D>("randomnormals") },
            //        { Decal.DiffuseName, content.Load<Texture2D>("Splatter") },
            //        { Decal.TransformName, Matrix.CreateScale(30, 5, 30) * Matrix.CreateRotationX(MathHelper.PiOver2) * Matrix.CreateRotationY(MathHelper.PiOver2) * Matrix.CreateTranslation(-130, r.Next(-100, 100), r.Next(-100, 100)) },
            //        { Decal.AngleCutoffName, MathHelper.PiOver4 }
            //    });
            //}

            _scene.Add(decal.Create(), new NamedBoxCollection {
                { Decal.NormalName, content.Load<Texture2D>("randomnormals") },
                { Decal.DiffuseName, content.Load<Texture2D>("Splatter") },
                { Decal.TransformName, Matrix4x4.CreateScale(30, 30, 30) * Matrix4x4.CreateRotationX(MathHelper.PiOver2 + MathHelper.PiOver4) * Matrix4x4.CreateRotationY(MathHelper.PiOver2) * Matrix4x4.CreateTranslation(-135, -10, 0) },
                { Decal.AngleCutoffName, MathHelper.Pi / 3.65f }
            });

            _scene.Add(decal.Create(), new NamedBoxCollection {
                { Decal.NormalName, content.Load<Texture2D>("randomnormals") },
                { Decal.DiffuseName, content.Load<Texture2D>("Splatter") },
                { Decal.TransformName, Matrix4x4.CreateScale(30, 30, 30) * Matrix4x4.CreateRotationX(MathHelper.PiOver2 + MathHelper.PiOver4) * Matrix4x4.CreateRotationY(MathHelper.PiOver2) * Matrix4x4.CreateTranslation(-135, -10, 40) },
                { Decal.AngleCutoffName, MathHelper.Pi / 3 }
            });

            _scene.Add(decal.Create(), new NamedBoxCollection {
                { Decal.NormalName, content.Load<Texture2D>("randomnormals") },
                { Decal.DiffuseName, content.Load<Texture2D>("Splatter") },
                { Decal.TransformName, Matrix4x4.CreateScale(30, 30, 30) * Matrix4x4.CreateRotationX(MathHelper.PiOver2 + MathHelper.PiOver4) * Matrix4x4.CreateRotationY(MathHelper.PiOver2) * Matrix4x4.CreateTranslation(-135, -10, 80) },
                { Decal.AngleCutoffName, MathHelper.Pi / 2 }
            });

            _scene.Add(decal.Create(), new NamedBoxCollection {
                { Decal.NormalName, content.Load<Texture2D>("randomnormals") },
                { Decal.DiffuseName, content.Load<Texture2D>("Splatter") },
                { Decal.TransformName, Matrix4x4.CreateScale(30, 30, 30) * Matrix4x4.CreateRotationX(MathHelper.PiOver2 + MathHelper.PiOver4) * Matrix4x4.CreateRotationY(MathHelper.PiOver2) * Matrix4x4.CreateTranslation(-135, -10, 120) },
                { Decal.AngleCutoffName, MathHelper.Pi }
            });
        }
示例#52
0
        private async Task GetBlackWhiteAndMask(Scene scene)
        {
            Util.Dispose(ref Black);
            Util.Dispose(ref White);
            Util.Dispose(ref Colored);
            Util.Dispose(ref Mask);

            var clearBlack = new Clear(Color.Black);
            var clearWhite = new Clear(Color.White);
            var clearLightish = new Clear(Color.WhiteSmoke);

            scene.Clear();
            scene.Add(clearBlack);
            Black = await RenderThenCapture("Black");

            scene.Clear();
            scene.Add(clearWhite);
            White = await RenderThenCapture("White");

            scene.Clear();
            scene.Add(clearLightish);
            Colored = await RenderThenCaptureColored("Colored");

            var maskThreshold = new Gray(75);
            var maskOn = new Gray(255);
            Mask = new Picture<Gray, byte>(White.Width, White.Height);
            (White.Emgu - Black.Emgu).ThresholdBinary(maskThreshold, maskOn).CopyTo(Mask.Emgu);

            Black.Emgu.Save(Global.TmpFileName("black", "png"));
            White.Emgu.Save(Global.TmpFileName("white", "png"));
            Mask.Emgu.Save(Global.TmpFileName("mask", "png"));
            Colored.Emgu.Convert<Bgr, byte>().Save(Global.TmpFileName("colored", "png"));
        }
示例#53
0
        private async Task Make(int[] horAccum, int[] verAccum, Scene scene)
        {
            await Program.SwitchToCompute();

            var projectorSize = Projector.Intrinsics.ImageSize;
            var captureCameraSize = CaptureCamera.Intrinsics.ImageSize;

            var horSweptPlanes = Enumerable.Range(0, projectorSize.Width)
                                           .Select(x => Projector.Frustum.BoundingFrustum.SweepVerticalThroughX(Projector.World.Translation, x, projectorSize.Width))
                                           .ToArray();

            var verSweptPlanes = Enumerable.Range(0, projectorSize.Height)
                                           .Select(y => Projector.Frustum.BoundingFrustum.SweepHorizontalThroughY(Projector.World.Translation, y, projectorSize.Height))
                                           .ToArray();

            var zPlane = new Plane(Vector3.UnitZ, 0);
            var vertices = new VertexPositionNormalTexture[captureCameraSize.Area()];
            for (int y = 0; y < captureCameraSize.Height; ++y)
                for (int x = 0; x < captureCameraSize.Width; ++x)
                {
                    var pixel = y * captureCameraSize.Width + x;

                    var ray = CaptureCamera.Frustum.BoundingFrustum.ThroughPixel(CaptureCamera.World.Translation, x, y, captureCameraSize.Width, captureCameraSize.Height);
                        
                    Vector3? horPos = null;
                    Vector3? verPos = null;

                    var hor = horAccum[pixel];
                    if (hor >= 0 && hor < horSweptPlanes.Length)
                    {
                        var swep = horSweptPlanes[hor];
                        var intersect = ray.Intersects(swep);
                        if (intersect.HasValue && intersect.Value > 0.0f)
                        {
                            var position = ray.Position + intersect.Value * ray.Direction;
                            if (position.Z > -0.6f && position.Z < 70.0f)
                            {
                                horPos = position;
                            }
                        }
                    }

                    var ver = verAccum[pixel];
                    if (ver >= 0 && ver < verSweptPlanes.Length)
                    {
                        var swep = verSweptPlanes[ver];                        
                        var intersect = ray.Intersects(swep);
                        if (intersect.HasValue && intersect.Value > 0.0f)
                        {
                            var position = ray.Position + intersect.Value * ray.Direction;
                            if (position.Z > -0.6f && position.Z < 70.0f)
                            {
                                verPos = position;
                            }
                        }
                    }
                    
                    var failed = new Vector3(float.MinValue, float.MinValue, float.MinValue);
                    var fusedPos3 = horPos.HasValue ? horPos.Value : failed;
                    var fusedPos = verPos.HasValue ? verPos.Value : failed;
                    var fusedPos2 = horPos.HasValue
                                 ? (verPos.HasValue
                                    ? (horPos.Value + verPos.Value) / 2.0f
                                    : horPos.Value)
                                 : verPos.HasValue
                                 ? verPos.Value
                                 : failed;

                    // if (fusedPos3 != failed)
                    // if ((ver >= 0 && ver < verSweptPlanes.Length)
                    // || (hor >= 0 && hor < horSweptPlanes.Length))
                    if (verPos.HasValue)
                    {
                        fusedPos = verPos.Value;// new Vector3(x / 100.0f, (captureCameraSize.Height - y) / 100.0f, 0.1f);
                        vertices[pixel] = new VertexPositionNormalTexture(fusedPos, Vector3.UnitZ, new Vector2(x / (float)captureCameraSize.Width, y / (float)captureCameraSize.Height));
                    }
                }

            CalculateNormals(vertices, captureCameraSize.Width, captureCameraSize.Height);

            await Program.SwitchToRender();

            var texture2D = Program.Renderer.LeaseFor(Colored);
            texture2D.SetData(Colored.Bytes);
                
            // Program.Monitor.Scene.Remove(Program.Monitor.Scene.First(v => v is Picture2D));
            // Program.Monitor.Scene.Remove(Program.Monitor.Scene.First(v => v is Clear));
            
            scene.Add(new Clear(Color.DarkGray));
            for (int i = 0; i < horSweptPlanes.Length; i += 230)
                scene.Add(Projector.Frustum.BoundingFrustum.QuadVerticalThroughX(Projector.World.Translation, i, 1280));
            for (int i = 0; i < verSweptPlanes.Length; i += 174)
                scene.Add(Projector.Frustum.BoundingFrustum.QuadHorizontalThroughY(Projector.World.Translation, i, 800));
            
            
            scene.Add(new Cloud(Color.White, CaptureCamera.Intrinsics.ImageSize) { Points = vertices, Texture2D = texture2D });
        }
示例#54
0
        /// <summary>
        /// Creates an Otter scene based on the data in the tiled map file.
        /// </summary>
        /// <param name="scene">
        /// The scene that all of the map data will be added to 
        /// </param>
        public void LoadLevel(Scene scene)
        {
            foreach(var layer in Layers)
            {
                var tileLayer = layer as TiledTileLayer;
                if(tileLayer != null)
                {
                    var entity = new Entity();
                    if(ColliderTags.ContainsKey(tileLayer.Name))
                    {
                        var tag = ColliderTags[tileLayer.Name];
                        var grid = CreateGridCollider(tileLayer, tag);
                        entity.SetCollider(grid);
                    }
                    else
                    {
                        var tilemap = CreateTilemap(tileLayer);
                        entity.SetGraphic(tilemap);
                    }

                    scene.Add(entity);
                }
                else if(layer is TiledObjectGroup)
                {
                    var objectGroup = (TiledObjectGroup)layer;
                    foreach(var @object in objectGroup.Objects)
                    {
                        var entity = CreateEntity(@object);
                        scene.Add(entity);
                    }
                }
            }
        }
示例#55
0
        protected override void BeginTransitionOn()
        {
            if (_scene != null)
                return;

            _scene = _kernel.Get<Scene>();

            var renderer = _scene.GetService<Renderer>();
            renderer.StartPlan()
                    .Then(new CreateTargetComponent(new RenderTargetInfo(0, 0, SurfaceFormat.Color, DepthFormat.Depth24Stencil8, 1, false, default(RenderTargetUsage))))
                    .Then<TranslucentComponent>()
                    .Apply();

            var cameraPosition = new Vector3(0, 25, -200);

            _camera = new Camera
            {
                NearClip = 1,
                FarClip = 3000,
                View = Matrix4x4.CreateLookAt(cameraPosition, new Vector3(0, 0, 0), Vector3.UnitY)
            };
            _camera.Projection = Matrix4x4.CreatePerspectiveFieldOfView(MathHelper.ToRadians(60), 16f / 9f, _camera.NearClip, _camera.FarClip);

            var cameraDescription = _kernel.Get<EntityDescription>();
            cameraDescription.AddProperty(new TypedName<Viewport>("viewport"));
            cameraDescription.AddBehaviour<View>();
            var cameraEntity = cameraDescription.Create();
            cameraEntity.GetProperty(new TypedName<Camera>("camera")).Value = _camera;
            cameraEntity.GetProperty(new TypedName<Viewport>("viewport")).Value = new Viewport() { Width = _device.PresentationParameters.BackBufferWidth, Height = _device.PresentationParameters.BackBufferHeight };
            _scene.Add(cameraEntity);

            var particleEntityDesc = _kernel.Get<EntityDescription>();
            particleEntityDesc.AddProperty(new TypedName<Vector3>("position"));
            particleEntityDesc.AddBehaviour<ParticleEmitter>();
            var entity = particleEntityDesc.Create();
            entity.GetProperty(new TypedName<Vector3>("position")).Value = Vector3.Zero;
            NamedBoxCollection initData = new NamedBoxCollection();
            initData.Set(new TypedName<ParticleEmitterDescription>("particlesystem"), _content.Load<ParticleEmitterDescription>("Particles/TestEmitter1"));
            _scene.Add(entity, initData);

            base.OnShown();
        }
示例#56
0
        public static void CreateFromXML(Scene scene, XmlAttributeCollection attributes)
        {
            int playerNumber = attributes.Int("player", 0);

            Session playerSession;
            Color color = Color.None;

            if (playerNumber == 0)
            {
                playerSession = Global.PlayerOneSession;
                color = Color.White;
            }
            else if (playerNumber == 1)
            {
                playerSession = Global.PlayerTwoSession;
                color = Color.Yellow;
            }
            else if (playerNumber == 2)
            {
                playerSession = Global.PlayerThreeSession;
                color = Color.Blue;
            }
            else
            {
                playerSession = Global.PlayerFourSession;
                color = Color.Grey;
            }

            Bomberman player = new Bomberman(playerSession, color);

            player.SetPosition(attributes.Int("x", 0), attributes.Int("y", 0));

            scene.Add(player);
        }
示例#57
0
文件: TextTest.cs 项目: xoxota99/Myre
        protected override void BeginTransitionOn()
        {
            base.BeginTransitionOn();

            _scene = _kernel.Get<Scene>();

            //Start renderer
            var renderer = _scene.GetService<Renderer>();
            renderer.StartPlan()
                .Then<GeometryBufferComponent>()
                .Then<EdgeDetectComponent>()
                .Then<Ssao>()
                .Then<LightingComponent>()
                .Then<RestoreDepthPhase>()
                .Then<ToneMapComponent>()
                .Then<AntiAliasComponent>()
                .Show("antialiased")
                .Apply();
            _resolution = renderer.Data.Get<Vector2>("resolution");

            //Create camera
            _camera = new Camera { NearClip = 1, FarClip = 7000, View = Matrix4x4.CreateLookAt(new Vector3(-100, 300, 10), new Vector3(300, 0, 0), -Vector3.UnitZ) };
            _camera.Projection = Matrix4x4.CreatePerspectiveFieldOfView(MathHelper.ToRadians(60), 16f / 9f, _camera.NearClip, _camera.FarClip);
            var cameraDesc = _kernel.Get<EntityDescription>();
            cameraDesc.AddProperty(new TypedName<Camera>("camera"));
            cameraDesc.AddProperty(new TypedName<Viewport>("viewport"));
            cameraDesc.AddBehaviour<View>();
            var cameraEntity = cameraDesc.Create();
            cameraEntity.GetProperty(new TypedName<Camera>("camera")).Value = _camera;
            cameraEntity.GetProperty(new TypedName<Viewport>("viewport")).Value = new Viewport() { Width = _device.PresentationParameters.BackBufferWidth, Height = _device.PresentationParameters.BackBufferHeight };
            _scene.Add(cameraEntity);

            //create ambient light
            var ambientLight = _kernel.Get<EntityDescription>();
            ambientLight.AddProperty(new TypedName<Vector3>("sky_colour"));
            ambientLight.AddProperty(new TypedName<Vector3>("ground_colour"));
            ambientLight.AddProperty(new TypedName<Vector3>("up"));
            ambientLight.AddBehaviour<AmbientLight>();
            var ambientLightEntity = ambientLight.Create();
            ambientLightEntity.GetProperty(new TypedName<Vector3>("sky_colour")).Value = new Vector3(0.08f);
            ambientLightEntity.GetProperty(new TypedName<Vector3>("ground_colour")).Value = new Vector3(0.04f, 0.05f, 0.04f);
            ambientLightEntity.GetProperty(new TypedName<Vector3>("up")).Value = Vector3.UnitY;
            _scene.Add(ambientLightEntity);

            //Create text
            var textDesc = _kernel.Get<EntityDescription>();
            textDesc.AddBehaviour<ModelInstance>();
            textDesc.AddProperty(ModelInstance.TransformName, Matrix4x4.Identity);
            textDesc.AddBehaviour<StringModelData>();
            var textEnt = textDesc.Create();
            var init = new NamedBoxCollection {
                { StringModelData.FontName, _content.Load<VertexFont>("Fonts/Cousine-Regular-Latin") },
                { StringModelData.StringName, "Hello, World" },
                { StringModelData.ThicknessName, 25 },
            };

            _scene.Add(textEnt, init);
        }
 private void MexicanHatDemo(Scene scene, Derivation derivation)
 {
     if (scene == null) return;
     var mathExpression = MathExpression.CreateDefault("sin(sqrt(x^2+y^2))", "x", "y");
     //var aproximationFunction = InterpolativeMathFunction.FromExpression("x^4+y^4", "x", "y");
     var shape = new BiquarticHermiteSpline(new SurfaceDimension(-3, 3, 7), new SurfaceDimension(-3, 3, 7),
         //var shape = HermiteSurfaceFactoryHolder.CreateBiquartic(-3, 1, 7, -3, 1, 7,
         mathExpression, derivation);
     shape.ColoredByShades(_colorWheel.Next);
     scene.Add(shape);
 }
示例#59
0
        public ProgramTask()
        {
            Monitor.ClientSize = new Size(640, 480);
            ColoredChessboard = new ColoredChessboard(Chessboard, Color.CornflowerBlue.Alpha(0.9f), Color.Orange.Alpha(0.3f));

            var maybeSecondaryScreen = Screen.AllScreens.Where(s => s != Screen.PrimaryScreen).FirstOrDefault() ?? Screen.PrimaryScreen;

            // Projector = new RealProjector("Optoma EW1610", "1018", maybeSecondaryScreen.Bounds.Size, maybeSecondaryScreen);
            var virtualProjectorOrbit = new OrbitCamera("Virtual Projector Orbit", "N/A", new Size(1280, 800), new PointF(640, 850), 100, 2, 134);
            Projector = new VirtualProjector(Monitor, virtualProjectorOrbit);

            WorldCamera = new OrbitCamera("World Orbit", "1018", Monitor.Size, Monitor.Size.CenterF(), Monitor.Size.Width, 0.1f, 100)
            {
                Center = Chessboard.VertexCenter,
                Distance = 56,
                YawPitch = new Vector2(0.2f, -0.2f),
            };

            WorldScene = new Scene(WorldCamera)
            {
                // MakeColoredAxisOfLength(Vector3.UnitX, Color.Red, length: 20.0f),
                // MakeColoredAxisOfLength(Vector3.UnitY, Color.Green, length: 20.0f),
                // MakeColoredAxisOfLength(Vector3.UnitZ, Color.Blue, length: 20.0f),
                
                // ColoredChessboard,

                // new Grid(Matrix.CreateRotationX(MathHelper.PiOver2),  Color.Red.Lerp(Color.White, 0.9f).Alpha(0.3f), Color.Red.Alpha(0.5f)),
                // new Grid(Matrix.CreateRotationY(-MathHelper.PiOver2), Color.Green.Lerp(Color.White, 0.9f).Alpha(0.1f), Color.Green.Alpha(0.3f)),
                // new Grid(Matrix.Identity,                             Color.Blue.Lerp(Color.White, 0.9f).Alpha(0.1f), Color.Blue.Alpha(0.4f)),

                new MeshModel("ManStanding", Matrix.CreateScale(0.1f) * Matrix.CreateRotationY(-MathHelper.PiOver2) * Matrix.CreateTranslation(4, 0, 2)) { ProjectorViewProject = Projector },
                new MeshModel("MutantStanding", Matrix.CreateScale(0.4f) * Matrix.CreateRotationY(0) * Matrix.CreateTranslation(8, 0, 1)) { ProjectorViewProject = Projector },
                new MeshModel("HeadFemale", Matrix.CreateScale(0.2f) * Matrix.CreateRotationX(-MathHelper.PiOver2) * Matrix.CreateTranslation(-3, 6, 0)) { ProjectorViewProject = Projector },
            };

            CaptureCameras = CreateCaptureCameras().ToList();
            if (CaptureCameras.IsEmpty())
                AddVirtualCaptureCamera("VirCam 1", "1018", Color.Red);

            CaptureCameraSelectionPictureGray = new Picture2D(CaptureCameraSelected.Intrinsics.ImageSize.LimitProportional(290, 290).AnchorWithin(Monitor.ClientRectangle, AnchorPoints.BottomLeft), CaptureCameraSelected.Capture.GrayTexture2D);
            CaptureCameraSelectionPictureRgba = new Picture2D(CaptureCameraSelected.Intrinsics.ImageSize.LimitProportional(290, 290).ToRect(CaptureCameraSelectionPictureGray.Rectangle.Left, CaptureCameraSelectionPictureGray.Rectangle.Top, AnchorPoints.BottomLeft), CaptureCameraSelected.Capture.RgbaTexture2D);
            CaptureCameraSelected.Highlight = true;

            WorldScene.Add(CaptureCameras);
            WorldScene.Add(Projector);

            Monitor.Scene = new Scene(new ScreenCamera(Monitor))
            {
                new Clear(Color.LightGray),
                WorldScene,
                CaptureCameraSelectionPictureGray,
                CaptureCameraSelectionPictureRgba,
            };

            LocateTrigger = new Trigger(() => new LocateTask(Monitor, CaptureCameraSelected, Chessboard).Run(), Keys.L);
            CalibrateTrigger = new Trigger(() => new CalibrateTask(Monitor, CaptureCameraSelected, Chessboard).Run(CaptureCameraSelected), Keys.C);
            ChessboardShapeTrigger = new Trigger(() => new ChessboardShapeTask(Monitor, Projector, Chessboard).Run(), Keys.S);
            CalibrateIndirectlyTrigger = new Trigger(() => { WorldScene.Remove(ColoredChessboard); return new CalibrateIndirectlyTask(Monitor, CaptureCameras, Projector, Chessboard).Run(WorldScene); }, Keys.I);
            GrayScanTrigger = new Trigger(() => new GrayScanTask(Monitor, CaptureCameras.First(), Projector).Run(WorldScene), Keys.G);

            AttachInputToCamera(Program.WhenInput.Where(input => !input.KeyPressed(Keys.LeftAlt)), Monitor, WorldCamera);
            AttachInputToCamera(Program.WhenInput.Where(input => input.KeyPressed(Keys.LeftAlt)), Monitor, virtualProjectorOrbit);

            AttachPerformanceBar();

            Program.WhenInput.Where(input => input.KeyDown(Keys.Tab)).Subscribe(input =>
                {
                    CaptureCameraSelected.Highlight = false;
                    CaptureCameraSelectionIdx = (CaptureCameraSelectionIdx + 1) % CaptureCameras.Count;
                    CaptureCameraSelected.Highlight = true;
                    CaptureCameraSelectionPictureGray.Texture2D = CaptureCameraSelected.Capture.GrayTexture2D;
                    CaptureCameraSelectionPictureRgba.Texture2D = CaptureCameraSelected.Capture.RgbaTexture2D;

                });
        }
示例#60
0
        static void Main(string[] args)
        {
            // Create a Game
            var game = new Game("Input Example");

            // Create a Scene
            var scene = new Scene();
            // Add an Entity that will use Block.png as its Image

            for (int x = 43; x < 6800; x += 96)
            {
                scene.Add(new ImageEntity(x , 434, "Floor.bmp"));
                scene.Add(new ImageEntity(x , 338, "Floor.bmp"));
                scene.Add(new ImageEntity(x, 242, "Floor.bmp"));
                scene.Add(new ImageEntity(x, 158, "Floor.bmp"));
            }
            for (int x = 75; x < 6800; x += 150)
            {
                scene.Add(new ImageEntity(x, 65, "stock-vector-cartoon-brick-wall-79588576.bmp"));
            }

            // Add a PlayerEntity to the Scene at half of the Game's width, and half of the Game's height (centered)
            scene.Add(new PlayerEntity(Game.Instance.HalfWidth, Game.Instance.HalfHeight));

            // Start the game using the created Scene.
            game.Start(scene);
        }