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


C# Scene.AddService方法代码示例

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


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

示例1: CreateScene

        /// <summary>
        /// Creates a new scene
        /// </summary>
        public static Scene CreateScene( )
        {
            Scene scene = new Scene( );

            //	Add raycast service to scene
            IRayCastService rayCaster = new RayCastService( );
            rayCaster.AddIntersector( RayCastLayers.Grid, new Plane3( new Vector3( 0, 1, 0 ), 0 ) );
            scene.AddService( rayCaster );

            //	Add material set service to scene
            ISource materialSetSource = Locations.NewLocation( "Editor/DefaultMaterialSet.components.xml" );
            MaterialSet materials = MaterialSet.Load( materialSetSource, false );

            scene.AddService( materials );

            //	TODO: AP: Fix Z order rendering cheat
            scene.Objects.Add( Guid.NewGuid( ), Graphics.Factory.CustomTypes.Create<GroundPlaneGrid>( ) );
            scene.Objects.Add( Guid.NewGuid( ), Graphics.Factory.CustomTypes.Create<LevelGeometry>( ) );

            return scene;
        }
开发者ID:johann-gambolputty,项目名称:robotbastards,代码行数:24,代码来源:EditorSceneBuilder.cs

示例2: HostForm_Load

        private void HostForm_Load( object sender, EventArgs e )
        {
            //	Load input bindings
            CommandInputTemplateMap map = ( CommandInputTemplateMap )ResourceManager.Instance.Load( m_Setup.InputFile );
            m_User.InitialiseAllCommandListBindings( );

            //	Test load a scene
            Scene scene = new Scene( );

            //	Add a scene host
            scene.AddService( new Host( m_Setup.HostType, m_Setup.HostGuid ) );
            if ( m_Setup.HostType != HostType.Local )
            {
                IConnections connections = new Connections( );
                scene.AddService( connections );
                scene.AddService( new UpdateTarget( connections ) );
                scene.AddService( new UpdateSource( connections ) );

                RemoteHostAddress server = m_Setup.ServerAddress;
                if ( m_Setup.HostType == HostType.Client )
                {
                    TcpSocketConnection connection = new TcpSocketConnection( server.Address, server.Port );
                    connection.OpenConnection( );
                    connections.Add( connection );
                }
                else
                {
                    TcpConnectionListener listener = new TcpConnectionListener( server.Address, server.Port );
                    listener.Listen( connections );
                    scene.AddService( listener );
                }
            }

            //	Create a viewer for the scene
            try
            {
                ComponentLoadParameters loadParams = new ComponentLoadParameters( scene.Objects, scene.Builder, scene );
                loadParams.Properties[ "User" ] = m_User;
                ResourceManager.Instance.Load( m_Setup.SceneFile, loadParams );

                //	Naughty, just reuse loadParams (null out target because we don't want to load -into- the scene)
                loadParams.Target = null;
                loadParams.Properties[ "Subject" ] = scene;
                Viewer viewer = ( Viewer )ResourceManager.Instance.Load( m_Setup.ViewerFile, loadParams );
                display1.AddViewer( viewer );
            }
            catch ( Exception ex )
            {
                ExceptionUtils.ToLog( AppLog.GetSource( Severity.Error ), ex );
            }

            scene.GetClock( "inputClock" ).Subscribe( UpdateUser );

            //	Test load a command list
            try
            {
                //	TODO: AP: May need to move
                map.AddContextInputsToUser( new InputContext( display1.Viewers[ 0 ], display1 ), m_User );
            }
            catch ( Exception ex )
            {
                ExceptionUtils.ToLog( AppLog.GetSource( Severity.Error ), ex );
            }
        }
开发者ID:johann-gambolputty,项目名称:robotbastards,代码行数:64,代码来源:HostForm.cs


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