コード例 #1
0
        private void LocalTexturePatchTestForm_Load( object sender, System.EventArgs e )
        {
            IRenderable scene = new RenderableList( new PlanetSurface( planetRadius ), new AtmosphereSurface( model ) );

            Viewer viewer = new Viewer( this, CreateCamera( CommandUser.Default ), scene );
            display1.AddViewer( viewer );
        }
コード例 #2
0
        private void MainForm_Shown( object sender, System.EventArgs e )
        {
            Viewer viewer = new Viewer( );
            psDisplay.AddViewer( viewer );

            viewer.Camera = CreateCamera( new CommandUser( "me", 0 ) );
            viewer.Renderable = new RenderableList( new Grid( 8, 8 ), m_ParticleSystems );
        }
コード例 #3
0
        private void BuilderForm_Shown( object sender, EventArgs e )
        {
            if ( DesignMode )
            {
                return;
            }

            Viewer viewer = new Viewer( );
            try
            {
                SolarSystem system = new SolarSystem( );
                system.Planets.Add( BuilderState.Instance.Planet );

                viewer.Renderable = new RenderableList( new FpsDisplay( ), system );
            }
            catch ( Exception ex )
            {
                //	TODO: AP: Remove exception handler
                //	This is a bodge of an exception handler. Accessing BuilderState.Instance creates
                //	the planet, which can throw. So this try-catch assumes that this is the first access...
                AppLog.Exception( ex, "Error accessing planet instance" );
                ShowExceptionForm.Display( this, ex, "Error accessing planet instance ({0})", ex.Message );
                Close( );
                return;
            }
            viewer.PreRender +=
                delegate
                {
                    DebugText.Write( "Camera(m): {0}", ( ( IUniCamera )viewer.Camera ).Position.ToMetresString( ) );
                    DebugText.Write( "Camera Z: {0}", ( ( IUniCamera )viewer.Camera ).Frame.ZAxis );
                    DebugText.Write( "Camera 'Z: {0}", ( ( IUniCamera )viewer.Camera ).InverseFrame.ZAxis );
                };

            //	Control focusControl = ActiveControl;
            //	testDisplay.MouseEnter += delegate { testDisplay.Focus( ); };
            //	testDisplay.MouseLeave += delegate { testDisplay.Focus( ); };
            testDisplay.AddViewer( viewer );

            ICommandUser user = CommandUser.Default;
            viewer.Camera = CreateCamera( user );
        }
コード例 #4
0
        private void AtmosphereTestForm_Load( object sender, System.EventArgs e )
        {
            float planetRadius = 1000.0f;
            float atmosphereThickness = 10.0f;

            AtmosphereCalculatorModel model = new AtmosphereCalculatorModel( );
            model.PlanetRenderRadius = planetRadius;
            model.AtmosphereRenderRadius = planetRadius + atmosphereThickness;
            model.Samples = 10;

            propertyGrid1.SelectedObject = model;

            IRenderable scene = new RenderableList( new PlanetSurface( planetRadius ), new AtmosphereSurface( model ) );

            Viewer viewer = new Viewer( this, CreateCamera( CommandUser.Default ), scene );
            viewer.ClearColour = Color.Black;
            display.AddViewer( viewer );

            //	TODO: AP: Horrible bodge to work around InteractionUpdateTimer not working properly without manual intervention
            display.OnBeginRender += delegate { InteractionUpdateTimer.Instance.OnUpdate( ); };
        }
コード例 #5
0
 /// <summary>
 /// Called from the form Load handler. Creates the main viewer, loading it from the source specified by ViewerSetupPath
 /// </summary>
 /// <returns>Return the main viewer object</returns>
 protected virtual Viewer CreateMainViewer( )
 {
     Viewer viewer = null;
     ISource viewerSource = ViewerSetupPath;
     if ( viewerSource != null )
     {
         try
         {
             //	Load viewer
             ComponentLoadParameters loadParams = new ComponentLoadParameters( );
             loadParams.Properties[ "User" ] = m_User;
             viewer = ( Viewer )AssetManager.Instance.Load( viewerSource, loadParams );
         }
         catch ( Exception ex )
         {
             AppLog.Exception( ex, "Failed to load viewer from \"{0}\"", viewerSource );
         }
     }
     if ( viewer == null )
     {
         AppLog.Info( "Creating default viewer" );
         viewer = new Viewer( );
     }
     return viewer;
 }
コード例 #6
0
 /// <summary>
 /// Removes a viewer
 /// </summary>
 /// <param name="viewer">Viewer to remove</param>
 public void RemoveViewer( Viewer viewer )
 {
     Arguments.CheckNotNull( viewer, "viewer" );
     m_Viewers.Remove( viewer );
     viewer.Control = null;
 }
コード例 #7
0
 /// <summary>
 /// Adds a viewer
 /// </summary>
 /// <param name="viewer">Viewer to add</param>
 public void AddViewer( Viewer viewer )
 {
     Arguments.CheckNotNull( viewer, "viewer" );
     m_Viewers.Add( viewer );
     viewer.Control = this;
 }
コード例 #8
0
        /// <summary>
        /// Handles loading this control. Creates a viewer that can render the terrain model
        /// </summary>
        private void UniCameraViewControl_Load( object sender, EventArgs e )
        {
            m_Camera = CreateCamera( );

            Viewer viewer = new Viewer( );
            display.AddViewer( viewer );

            display.AllowArrowKeyInputs = true;

            viewer.Camera = m_Camera;

            CommandControlInputSource.StartMonitoring( CommandUser.Default, display, FirstPersonCameraCommands.DefaultBindings );
            CommandUser.Default.CommandTriggered += OnCommandTriggered;

            //	If planet was already assigned prior to Load, add it to all views
            AddRenderableToViewers( );

            //	TODO: AP: Horrible bodge to work around InteractionUpdateTimer not working properly without manual intervention
            display.OnBeginRender += delegate { InteractionUpdateTimer.Instance.OnUpdate( ); };

            if ( InitializeRendering != null )
            {
                InitializeRendering( this, EventArgs.Empty );
            }
        }
コード例 #9
0
        private void GameViewForm_Load( object sender, EventArgs e )
        {
            //	Add a performance display
            Scene.Objects.Add( new PerformanceDisplay( ) );
            DebugInfo.ShowFps = true;
            DebugInfo.ShowMemoryWorkingSet = true;
            DebugInfo.ShowMemoryPeakWorkingSet = true;

            //	Load in the game viewer
            LoadParameters loadArgs = new LoadParameters( );
            loadArgs.Properties.Add( "Users", m_Users );
            m_Viewer = ( Viewer )AssetManager.Instance.Load( m_Setup.ViewerSource, loadArgs );
            gameDisplay.AddViewer( m_Viewer );

            //	Get start points
            IEnumerable< PlayerStart > startPoints = Scene.Objects.GetAllOfType<PlayerStart>( );

            //	Setup players
            InputContext inputContext = new InputContext( m_Viewer );
            m_Users = new CommandUser[ m_Setup.NumberOfPlayers ];
            for ( int playerIndex = 0; playerIndex < m_Setup.NumberOfPlayers; ++playerIndex )
            {
                PlayerSetup player = m_Setup.Players[ playerIndex ];

                //	Find the start position for this player
                PlayerStart playerStart = null;
                foreach ( PlayerStart startPoint in startPoints )
                {
                    if ( startPoint.PlayerIndex == playerIndex )
                    {
                        playerStart = startPoint;
                        break;
                    }
                }
                if ( playerStart == null )
                {
                    throw new InvalidOperationException( "No player start available for player " + playerIndex );
                }

                //	Load game inputs
                m_Users[ playerIndex ] = new CommandUser( );
                CommandInputTemplateMap gameInputs = ( CommandInputTemplateMap )AssetManager.Instance.Load( player.CommandSource );
                gameInputs.BindToInput( inputContext, m_Users[ playerIndex ] );

                //	Load the player's character
                object character = AssetManager.Instance.Load( player.CharacterSource );
                Scene.Objects.Add( ( IUnique )character );

                //	Place the character at the start position
                IPlaceable placeable = Rb.Core.Components.Parent.GetType<IPlaceable>( character );
                if ( placeable != null )
                {
                    placeable.Position = playerStart.Position;
                }

                //	Hack... if the viewer camera is a follow camera, force it to look at the player
                if ( ( m_Setup.NumberOfPlayers == 1 ) && ( m_Viewer.Camera is FollowCamera ) )
                {
                    FollowCamera camera = ( FollowCamera )m_Viewer.Camera;

                    //	Follow the player
                    camera.Target = ( IPlaceable )character;

                    //	Add a camera controller
                    FollowCameraControl cameraControl = new FollowCameraControl( camera, m_Users[ 0 ] );
                    m_Viewer.Camera.AddChild( cameraControl );
                }

                IParent characterParent = ( IParent )character;
                characterParent.AddChild( new UserController( m_Users[ playerIndex ], ( IMessageHandler )character ) );
            }

            //	Start rendering the scene
            m_Viewer.Renderable = Scene;

            //	Kick off the update service... (TODO: AP: Not a very good hack)
            IUpdateService updater = Scene.GetService< IUpdateService >( );
            if ( updater != null )
            {
                updater.Start( );
            }
            playButton.Enabled = false;
        }