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


C# Scene.GetService方法代码示例

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


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

示例1: 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

示例2: RemovedFromScene

 /// <summary>
 /// Called when this object is removed from the scene
 /// </summary>
 /// <param name="scene">Scene object</param>
 public void RemovedFromScene( Scene scene )
 {
     if ( m_Light != null )
     {
         scene.GetService< ILightingService >( ).RemoveLight( m_Light );
     }
     m_Scene = null;
 }
开发者ID:johann-gambolputty,项目名称:robotbastards,代码行数:12,代码来源:LightSocket.cs

示例3: RemovedFromScene

        /// <summary>
        /// Called when this object is removed from the specified scene
        /// </summary>
        /// <param name="scene">Scene object</param>
        public virtual void RemovedFromScene( Scene scene )
        {
            //	Remove from renderable list
            scene.Renderables.Remove( this );

            //	Unsubscribe from the update clock
            scene.GetService< IUpdateService >( )[ "updateClock" ].Unsubscribe( Update );
        }
开发者ID:johann-gambolputty,项目名称:robotbastards,代码行数:12,代码来源:Entity.cs

示例4: AddedToScene

        /// <summary>
        /// Called when this object is added to the specified scene
        /// </summary>
        /// <param name="scene">Scene object</param>
        public virtual void AddedToScene( Scene scene )
        {
            m_Scene = scene;
            scene.Renderables.Add( this );

            //	Subscribe to the update clock
            scene.GetService< IUpdateService >( )[ "updateClock" ].Subscribe( Update );
        }
开发者ID:johann-gambolputty,项目名称:robotbastards,代码行数:12,代码来源:Entity.cs

示例5: AddedToScene

 /// <summary>
 /// Sets the scene context
 /// </summary>
 /// <param name="scene">Scene context</param>
 public void AddedToScene( Scene scene )
 {
     m_Scene = scene;
     if ( m_Light != null )
     {
         scene.GetService< ILightingService >( ).AddLight( m_Light );
     }
 }
开发者ID:johann-gambolputty,项目名称:robotbastards,代码行数:12,代码来源:LightSocket.cs

示例6: AddedToScene

        /// <summary>
        /// Called when this object is added to the specified scene
        /// </summary>
        /// <param name="scene">Scene object</param>
        public virtual void AddedToScene( Scene scene )
        {
            ILightingService lighting = scene.GetService< ILightingService >( );
            if ( lighting == null )
            {
                throw new InvalidOperationException( "LightMeter requires that an ILightingService be present in the scene" );
            }

            lighting.AddLightMeter( this );
        }
开发者ID:johann-gambolputty,项目名称:robotbastards,代码行数:14,代码来源:LightMeter.cs

示例7: Projectile

        public Projectile( Scene scene, Point3 start, Vector3 dir, float speed )
        {
            m_Pos.Set( start );
            m_Dir = dir;
            m_Speed = speed;
            m_Scene = scene;

            m_Scene.Renderables.Add( this );

            IUpdateService updater = scene.GetService< IUpdateService >( );
            updater[ "updateClock" ].Subscribe( Update );
        }
开发者ID:johann-gambolputty,项目名称:robotbastards,代码行数:12,代码来源:Projectile.cs

示例8: ModelContext

        public ModelContext( Scene owner, string path )
            : base(owner)
        {
            if( path == null )
                throw new ArgumentNullException( "path" );

            this.path = path;

            IGraphicsDeviceService gds =
                owner.GetService<IGraphicsDeviceService>();

            this.model = new Libx42.Model( path );
        }
开发者ID:pdjonov,项目名称:x42view,代码行数:13,代码来源:ModelContext.cs

示例9: 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 {
                NearClip = 1,
                FarClip = 700,
                View = Matrix4x4.CreateLookAt(new Vector3(100, 50, 0), new Vector3(0, 50, 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 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:xoxota99,项目名称:Myre,代码行数:44,代码来源:SpriteTest.cs

示例10: BeginTransitionOn

        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, default(SurfaceFormat), DepthFormat.Depth24Stencil8, default(int), default(bool), default(RenderTargetUsage))))
                    .Then<TranslucentComponent>()
                    .Apply();

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

            _camera = new Camera
            {
                NearClip = 1,
                FarClip = 3000,
                View = Matrix.CreateLookAt(cameraPosition, new Vector3(0, 25, 0),
                Vector3.Up)
            };
            _camera.Projection = Matrix.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<ParticleEmitterDescription>("particlesystem", _content.Load<ParticleEmitterDescription>("Particles/TestEmitter1"));
            _scene.Add(entity, initData);

            base.OnShown();
        }
开发者ID:ylyking,项目名称:Myre,代码行数:43,代码来源:ParticlesTest.cs

示例11: AddedToScene

        /// <summary>
        /// Called when this object is added to the scene
        /// </summary>
        public void AddedToScene( Scene scene )
        {
            IHost host = scene.GetService< IHost >( );
            if ( ( host == null ) || ( host.HostType == HostType.Local ) )
            {
                //  Local hosts can't receive commands from remote controllers, so the controller
                //  must be created locally
                LoadController( );
            }
            else if ( host.Id == m_HostId )
            {
                //  The scene host is the local controller host - create away
                LoadController( );

                //  Also need listeners and so forth
            }
            else
            {
            }
        }
开发者ID:johann-gambolputty,项目名称:robotbastards,代码行数:23,代码来源:EntityRemoteControl.cs

示例12: ModelRenderBuffers

        public ModelRenderBuffers( Scene scene, Libx42.Model model )
            : base(scene.GetService<IGraphicsDeviceService>())
        {
            if( model == null )
                throw new ArgumentNullException( "model" );

            Libx42.AnimationFlags flags = Libx42.AnimationFlags.None;

            if( model.HasNormalData )
                flags |= Libx42.AnimationFlags.IncludeNormals;

            if( model.HasTangentBasisData )
            {
                flags |= Libx42.AnimationFlags.IncludeNormals;
                flags |= Libx42.AnimationFlags.IncludeTangentBasis;
            }

            this.model = model;
            this.animBuf = model.CreateAnimationBuffer( flags );
        }
开发者ID:pdjonov,项目名称:x42view,代码行数:20,代码来源:ModelRenderBuffers.cs

示例13: BeginTransitionOn

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

示例14: TestScene


//.........这里部分代码省略.........
            //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();
        }
开发者ID:xoxota99,项目名称:Myre,代码行数:101,代码来源:TestScene.cs

示例15: BeginTransitionOn

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


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