当前位置: 首页>>代码示例>>C#>>正文


C# Scene.Add方法代码示例

本文整理汇总了C#中Scene.Add方法的典型用法代码示例。如果您正苦于以下问题:C# Scene.Add方法的具体用法?C# Scene.Add怎么用?C# Scene.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Scene的用法示例。


在下文中一共展示了Scene.Add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Run

        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));
            }
        }
开发者ID:JaapSuter,项目名称:Pentacorn,代码行数:33,代码来源:CalibrateIndirectlyTask.cs

示例2: SetsSceneRef

 public void SetsSceneRef()
 {
     Scene s = new Scene();
     Actor a = new Actor();
     s.Add(a);
     Assert.AreSame(s, a.Scene);
 }
开发者ID:BackupTheBerlios,项目名称:flatfour-svn,代码行数:7,代码来源:Test_Scene.cs

示例3: BeginTransitionOn

        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();
        }
开发者ID:ylyking,项目名称:Myre,代码行数:26,代码来源:RenderPhaseDependancyTest.cs

示例4: CreateFromXML

        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);
        }
开发者ID:patHyatt,项目名称:Frenemey,代码行数:8,代码来源:Brick.cs

示例5: SpawnLaser

 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);
 }
开发者ID:niemandkun,项目名称:MiraiEngine,代码行数:10,代码来源:TurretScript.cs

示例6: Main

        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);
        }
开发者ID:JOCP9733,项目名称:tank,代码行数:20,代码来源:Program.cs

示例7: Initialize

        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();
        }
开发者ID:jtdubs,项目名称:VoxelLand,代码行数:40,代码来源:Game.cs

示例8: LoadFromStream

 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;
     }
 }
开发者ID:niemandkun,项目名称:MiraiEngine,代码行数:13,代码来源:SceneManager.cs

示例9: Main

        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);
        }
开发者ID:sjvcompsci,项目名称:SakuraiPlease,代码行数:18,代码来源:Program.cs

示例10: BeginTransitionOn

        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) }
                });
            }
        }
开发者ID:ylyking,项目名称:Myre,代码行数:43,代码来源:SpriteTest.cs

示例11: LoadLevel

        /// <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;
            }
        }
开发者ID:holymoo,项目名称:OtterSpaceInvaders,代码行数:80,代码来源:OgmoProject.cs

示例12: MexicanHatDemo

 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);
 }
开发者ID:vilorez,项目名称:VKDiplom-master,代码行数:11,代码来源:MainPage_OnLoaded.cs

示例13: GetBlackWhiteAndMask

        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"));
        }
开发者ID:JaapSuter,项目名称:Pentacorn,代码行数:33,代码来源:GrayScanTask.cs

示例14: Make

        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 });
        }
开发者ID:JaapSuter,项目名称:Pentacorn,代码行数:97,代码来源:GrayScanTask.cs

示例15: LoadLevel

        /// <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);
                    }
                }
            }
        }
开发者ID:holymoo,项目名称:Otter.TiledLoader,代码行数:39,代码来源:TiledProject.cs


注:本文中的Scene.Add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。