Exemplo n.º 1
0
 /// <summary>
 /// Creates a member-wise copy of the specified TerrainPage.
 /// </summary>
 /// <param name="page">The TerrainPage to copy.</param>
 public TerrainPage(TerrainPage page)
 {
     if (page != null)
     {
         _name            = page._name;
         _position        = page._position;
         _scale           = page._scale;
         _rotation        = page._rotation;
         _renderable      = page._renderable;
         _maxVertexHeight = page._maxVertexHeight;
         _patch           = new TerrainPatch(page._patch);
     }
     else
     {
         Dispose();
         _patch = new TerrainPatch();
     }
 }
Exemplo n.º 2
0
 /// <summary>
 /// Creates a member-wise copy of the specified TerrainPage.
 /// </summary>
 /// <param name="page">The TerrainPage to copy.</param>
 public TerrainPage( TerrainPage page )
 {
     if ( page != null )
     {
         _name = page._name;
         _position = page._position;
         _scale = page._scale;
         _rotation = page._rotation;
         _renderable = page._renderable;
         _maxVertexHeight = page._maxVertexHeight;
         _patch = new TerrainPatch( page._patch );
     }
     else
     {
         Dispose();
         _patch = new TerrainPatch();
     }
 }
Exemplo n.º 3
0
        /// <summary>
        /// Shifts the currently selected texture by the indicated distance.
        /// </summary>
        public void ShiftTexture()
        {
            if ( _pageCopy == null )
                _pageCopy = new TerrainPage( _page );

            _page.TerrainPatch.SetTextureCoordinates();
        }
Exemplo n.º 4
0
 public void SetTerrain( TerrainPage page )
 {
     _page = page;
 }
Exemplo n.º 5
0
        /// <summary>
        /// Restores the last TerrainPage pushed onto the "redo" history stack.
        /// </summary>
        public void RedoLastPageAction()
        {
            if ( _redoHistory.PageHistoryCount > 0 )
            {
                if ( _page != null )
                    _history.PushPage( new TerrainPage( _page ), _redoHistory.LastPageAction() );
                else
                    _history.PushPage( null, _redoHistory.LastPageAction() );

                _page = _redoHistory.PopPage();
                RefreshIndexBuffer();

                if ( _page != null )
                    _page.TerrainPatch.RefreshBuffers = true;
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// Moves the selected vertices.
        /// </summary>
        /// <param name="endMovement">Whether to end vertex movement.</param>
        /// <param name="distChange">The change in distance to move selected vertices.</param>
        public void MoveVertices( bool endMovement, float distChange )
        {
            if ( _moveVertex )
            {
                // Movement is done; store page history
                if ( endMovement )
                {
                    if ( _pageCopy != null )
                    {
                        StoreGenericPage( _pageCopy, "Vertex Movement" );
                        _pageCopy.Dispose();
                        _pageCopy = null;
                    }
                }
                else // Vertices are still being moved
                {
                    if ( _pageCopy == null )
                        _pageCopy = new TerrainPage( _page );

                    _page.MoveSelectedVertices( _softSelection, distChange, _falloff,
                        _softDistanceSquared );
                }
            }
        }
Exemplo n.º 7
0
 /// <summary>
 /// Loads the specified TerrainPage and refreshes vertex/index buffers.
 /// </summary>
 /// <param name="page">The TerrainPage to load.</param>
 public void LoadTerrain( TerrainPage page )
 {
     StoreLastPage( page, "Load New Terrain" );
     _page.TerrainPatch.RefreshBuffers = true;
     _buffers.RefreshIndexBuffer_Page();
     _buffers.RefreshIndexBuffer_Vertices();
 }
Exemplo n.º 8
0
        /// <summary>
        /// Disposes of all data being used.
        /// </summary>
        public void Dispose()
        {
            // Clear terrain pages
            if ( _page != null )
            {
                _page.Dispose();
                _page = null;
            }

            if ( _pageCopy != null )
            {
                _pageCopy.Dispose();
                _pageCopy = null;
            }

            _buffers.ClearBuffers();

            // Clear history
            _history.ClearHistory();
            _redoHistory.ClearHistory();

            // Clear plug-ins
            foreach ( PlugIn p in _plugins.VertexPlugIns )
                p.Dispose();

            foreach ( PlugIn p in _plugins.TexturePlugIns )
                p.Dispose();

            foreach ( PlugIn p in _plugins.FileImportPlugIns )
                p.Dispose();

            foreach ( PlugIn p in _plugins.FileExportPlugIns )
                p.Dispose();

            _plugins.VertexPlugIns.Clear();
            _plugins.TexturePlugIns.Clear();
            _plugins.FileImportPlugIns.Clear();
            _plugins.FileExportPlugIns.Clear();
        }
Exemplo n.º 9
0
        /// <summary>
        /// Creates a TerrainPatch.
        /// </summary>
        /// <param name="rows">The number of rows in the TerrainPatch.</param>
        /// <param name="columns">The number of columns in the TerrainPatch.</param>
        /// <param name="height">The total height of the TerrainPatch.</param>
        /// <param name="width">The total width of the TerrainPatch.</param>
        /// <param name="name">The name of the TerrainPage.</param>
        /// <returns>The created TerrainPage.</returns>
        public TerrainPage CreateTerrain( int rows, int columns, float height, float width, string name )
        {
            if ( _page != null )
                _page.Dispose();
            else
                _page = new TerrainPage();

            _page.TerrainPatch.CreatePatch( rows, columns, height, width );
            _page.TerrainPatch.RefreshBuffers = true;
            _page.Name = name;
            _buffers.RefreshIndexBuffer_Page();
            _buffers.RefreshIndexBuffer_Vertices();

            return _page;
        }
Exemplo n.º 10
0
        /// <summary>
        /// Updates the number of rows and columns in a TerrainPatch by creating
        /// a new version of the TerrainPatch.
        /// </summary>
        /// <param name="rows">Number of rows in the new TerrainPatch.</param>
        /// <param name="columns">Number of columns in the new TerrainPatch.</param>
        public void UpdateTerrainSize( int rows, int columns )
        {
            float height = _page.TerrainPatch.Height;
            float width = _page.TerrainPatch.Width;

            StoreCurrentPage( "Update Terrain Size" );

            if ( _page != null )
                _page.Dispose();
            else
                _page = new TerrainPage();

            _page.TerrainPatch.CreatePatch( rows, columns, height, width );
            RefreshIndexBuffer();
            _page.TerrainPatch.RefreshBuffers = true;
        }
Exemplo n.º 11
0
        public void StoreLastPage( TerrainPage page, string action )
        {
            if ( _page != null )
                _history.PushPage( _page, action );
            else
                _history.PushPage( null, action );

            _redoHistory.ClearHistory();
            _page = page;
        }
Exemplo n.º 12
0
        public void StoreGenericPage( TerrainPage page, string action )
        {
            if ( page != null )
                _history.PushPage( new TerrainPage( page ), action );
            else
                _history.PushPage( null, action );

            _redoHistory.ClearHistory();
        }
Exemplo n.º 13
0
        /// <summary>
        /// Loads XML data from the chosen file in the OpenFileDialog.
        /// </summary>
        private void LoadXML()
        {
            if ( _dlgOpen.FileName != null )
            {
                try
                {
                    XmlNodeList xmlNodes;
                    StreamReader reader = new StreamReader( _dlgOpen.FileName );

                    _xmlDoc.Load( reader.BaseStream );
                    xmlNodes = _xmlDoc.GetElementsByTagName( "TerrainPage" );

                    // Load the TerrainPage(s)
                    _page = new TerrainPage();
                    LoadTerrainPage( xmlNodes.Item( 0 ) );
                    reader.Close();
                }
                catch ( Exception e )
                {
                    string message = "The XML file is not properly formed!\n\n";

                    message += "Source: " + e.Source + "\n";
                    message += "Error: " + e.Message;

                    MessageBox.Show( null, message, "Error Running Application", MessageBoxButtons.OK,
                        MessageBoxIcon.Error );
                }
            }
        }
Exemplo n.º 14
0
 /// <summary>
 /// Sets the TerrainPage used by the plug-in.
 /// </summary>
 /// <param name="page">The TerrainPage to modify.</param>
 public virtual void SetPage( TerrainPage page )
 {
     _page = page;
 }
Exemplo n.º 15
0
 /// <summary>
 /// Initialize the data of the base element.
 /// </summary>
 public virtual void InitializeBase()
 {
     _owner = null;
     _page = null;
     _success = false;
     _modifiedTextures = false;
     _textures = new ArrayList();
     _desiredData = new ArrayList();
     _receivedData = new ArrayList();
 }
Exemplo n.º 16
0
 /// <summary>
 /// Pushes the specified TerrainPage onto the history stack.  If the maximum
 /// stack size has been reached, only the latest additions are kept.
 /// </summary>
 /// <param name="page">The TerrainPage to push onto the history stack.</param>
 /// <param name="action">The description for the action causing the TerrainPage change.</param>
 public void PushPage( TerrainPage page, string action )
 {
     if ( _pageHistory.Count < _maxPages )
     {
         // Push the latest TerrainPage onto the history stack
         _pageHistory.Push( page );
         _pageAction.Push( action );
     }
     else
     {
         // Maximum stack size has been reached.
         // Only store the latest TerrainPages in the history stack.
         CopyPageHistory( _maxPages - 1 );
         _pageHistory.Push( page );
         _pageAction.Push( action );
     }
 }