コード例 #1
0
        /// <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;
        }
コード例 #2
0
        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 );
            }
        }