Click here to Skip to main content
15,884,810 members
Articles / Programming Languages / C#

Triangulation of Arbitrary Polygons

Rate me:
Please Sign up or sign in to vote.
4.54/5 (7 votes)
22 Nov 2009CPOL4 min read 57.9K   5K   31  
This article describes a way of triangulating polygons that is intuitively easy to understand and explain diagrammatically
using FarseerGames.Triangulation.GamePlay.PhysicsHelper;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using FarseerGames.Triangulation.GamePlay.MainDemo;
using Microsoft.Xna.Framework.Audio;

using FarseerGames.Triangulation.ScreenSystem;

namespace FarseerGames.Triangulation.ScreenSystem
{
    /// <summary>
    /// The main menu screen is the first thing displayed when the game starts up.
    /// </summary>
    internal class MainMenuScreen : MenuScreen
    {
        /// <summary>
        /// Constructor fills in the menu contents.
        /// </summary>
        public MainMenuScreen()
        {
            MenuEntries.Add("Triangulate");
            MenuEntries.Add("Exit");
            LeftBorder = 100;
        }

        public override void LoadContent()
        {
            base.LoadContent();
        }

        /// <summary>
        /// Responds to user menu selections.
        /// </summary>
        protected override void OnSelectEntry(int entryIndex)
        {
            switch (entryIndex)
            {

                case 0:
                    ScreenManager.AddScreen(new TriangulateScreen());
                    break;
                default:
                    // Default to exit
                    ScreenManager.Game.Exit();
                    break;
            }

            ExitScreen();
        }

        public override void Update(GameTime gameTime, bool otherScreenHasFocus, bool coveredByOtherScreen)
        {
            base.Update(gameTime, otherScreenHasFocus, coveredByOtherScreen);
        }

        public override void Draw(GameTime gameTime)
        {
            ScreenManager.SpriteBatch.Begin();
            base.Draw(gameTime);
            ScreenManager.SpriteBatch.End();
        }
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Singapore Singapore
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions