Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!


1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!


Landi20

Member Since 14 Feb 2012
Offline Last Active Oct 17 2014 11:27 AM

Posts I've Made

In Topic: Convert Xna Game to Sharpdx

30 September 2014 - 07:04 AM

what you suggest to learn sharpdx

some the sample its for directx 3D 11.1 and Directx 3D 11.2

i using Directx 11 becouse my SO don´t support directx 3D 11.1 and Directx 3D 11.2


In Topic: Convert Xna Game to Sharpdx

29 September 2014 - 09:14 AM

i thiking buy this book Direct3D Rendering Cookbook to learn how use the sharpdx

my problem its i can´t transform the 2d image in 3d

like sample the xna make


In Topic: problem with sample TiledResources

26 September 2014 - 11:40 AM

i enter in contact who create the sample and say the error it is becouse i using library of Directx11 and i have to use the directx 11.2 but my s.o only support the directx 11

i don´t know how create a Height Maps with shardx 2.6.2


In Topic: problem with sample TiledResources

26 September 2014 - 07:59 AM

i add the library sharpdx to my project

and i have the same error


In Topic: how remove a model

15 August 2014 - 09:46 AM

when i use this Game.GameSystems.Remove(this);

the game gets completely crazy

my buttons start flashing for wile and stop

this is code for world class

using System;
using SharpDX;
using SharpDX.Toolkit;
using System.Collections.Generic;
using SharpDX.Toolkit.Input;
using TomShane.Neoforce.Controls;
using SharpDX.Direct3D;
using SharpDX.Direct3D11;
using SharpDX.Toolkit.Content;
using SharpDX.Toolkit.Graphics;
using System.Text;
using SharpDX.Windows;



namespace TomShane.Neoforce.Central
{
    internal sealed class World : GameSystem
    {
        private Manager NeoManager;
        string texto;
        private SpriteBatch spriteBatch;
        private SpriteFont arial16BMFont;
       // private PointerManager pointer;
        private Model model;
        private List<Model> models;
        private BoundingSphere modelBounds;
        private Matrix world;
        private Matrix view;
        private Matrix projection;
        private Window inventory;
        private Window Charactersstatus;
        private Window gameexit;
        TomShane.Neoforce.Controls.Console con1;
        TomShane.Neoforce.Controls.Console con2;
        private Game _game=null;
        int i = 0;

        private TomShane.Neoforce.Controls.TabControl tbc;
        public World(Game game, Manager ola, string text)
            : base(game)
        {
            _game =game;
            NeoManager = ola;
            texto = text;
            System.Console.Write(texto);
           // pointer = new PointerManager(game);
           

            // this game system has something to draw - enable drawing by default
            // this can be disabled to make objects drawn by this system disappear
            Visible = true;

            // this game system has logic that needs to be updated - enable update by default
            // this can be disabled to simulate a "pause" in logic update
            Enabled = true;

            // add the system itself to the systems list, so that it will get initialized and processed properly
            // this can be done after game initialization - the Game class supports adding and removing of game systems dynamically
            _game.GameSystems.Add(this);

           // NeoManager = new Manager(game);
        }

        /// <summary>
        /// Initialize here anything that depends on other services
        /// </summary>
        public override void Initialize()
        {


          //  NeoManager.Initialize();
            base.Initialize();

            // get the camera service from service registry

        }
        private void HandlePlayerInput()
        {
            KeyboardState currentKeyboardState = NeoManager.KeyboardManager.GetState();


            if (currentKeyboardState.IsKeyDown(Keys.A))
            {

            }
            if (currentKeyboardState.IsKeyDown(Keys.D))
            {

            }

            if (currentKeyboardState.IsKeyDown(Keys.W))
            {

            }

            if (currentKeyboardState.IsKeyDown(Keys.S))
            {

            }
            if (currentKeyboardState.IsKeyPressed(Keys.I))
            {
                inventory.Show();


            }
            if (currentKeyboardState.IsKeyDown(Keys.C))
            {
                Charactersstatus.Show();


            }
            if (currentKeyboardState.IsKeyDown(Keys.Escape))
            {

                gameexit.Show();

            }
            if (currentKeyboardState.IsKeyDown(Keys.Space))
            {


            }
            if (currentKeyboardState.IsKeyDown(Keys.M))
            {

            }



        }
        private void Inventory()
        {
            inventory = new Window(NeoManager);
            inventory.Init();
            inventory.Text = "Inventory";
            inventory.Width = 450;
            inventory.Height = 250;
            inventory.Center();
            inventory.Visible = true;
            inventory.CloseButtonVisible = true;
            inventory.Resizable = false;
            inventory.Movable = true;
            inventory.IconVisible = false;
            inventory.Close();
            NeoManager.Add(inventory);

        }
        private void ExitGamer()
        {
            gameexit = new Window(NeoManager);
            gameexit.Init();
            gameexit.Text = "Game Exit";
            gameexit.Width = 200;
            gameexit.Height = 220;
            gameexit.Center();
            gameexit.Visible = true;
            gameexit.CloseButtonVisible = true;
            gameexit.Resizable = false;
            gameexit.Movable = true;
            gameexit.Close();
            gameexit.IconVisible = false;
            Button Sair = new Button(NeoManager);
            Sair = new Button(NeoManager);
            Sair.Init();
            Sair.Width = 80;
            Sair.Parent = gameexit;
            Sair.Left = 50;
            Sair.Top = 0;
            Sair.Text = "Quit";
            Sair.TextColor = new SharpDX.Color(250, 250, 250);
            Sair.Click += new Controls.EventHandler(btnExit_Click1);
            Button Logout = new Button(NeoManager);
            Logout = new Button(NeoManager);
            Logout.Init();
            Logout.Width = 80;
            Logout.Parent = gameexit;
            Logout.Left = 50;
            Logout.Top = 40;
            Logout.Text = "Logout";
            Logout.TextColor = new SharpDX.Color(250, 250, 250);
            Logout.Click += new Controls.EventHandler(Logout_Click1);

            Button Characters = new Button(NeoManager);
            Characters = new Button(NeoManager);
            Characters.Init();
            Characters.Width = 80;
            Characters.Parent = gameexit;
            Characters.Left = 50;
            Characters.Top = 80;
            Characters.Text = "Characters";
            Characters.TextColor = new SharpDX.Color(250, 250, 250);


            Button Options = new Button(NeoManager);
            Options = new Button(NeoManager);
            Options.Init();
            Options.Width = 80;
            Options.Parent = gameexit;
            Options.Left = 50;
            Options.Top = 120;
            Options.Text = " Options";
            Options.TextColor = new SharpDX.Color(250, 250, 250);

            Button Canceling = new Button(NeoManager);
            Canceling = new Button(NeoManager);
            Canceling.Init();
            Canceling.Width = 80;
            Canceling.Parent = gameexit;
            Canceling.Left = 50;
            Canceling.Top = 160;
            Canceling.Text = "Cancel";
            Canceling.ModalResult = ModalResult.Cancel;
            Canceling.TextColor = new SharpDX.Color(250, 250, 250);
            NeoManager.Add(gameexit);
        }
        private void charactersstatus()
        {
            Charactersstatus = new Window(NeoManager);
            Charactersstatus.Init();
            Charactersstatus.Text = "Characters Status";
            Charactersstatus.Width = 450;
            Charactersstatus.Height = 250;
            Charactersstatus.Center();
            Charactersstatus.Visible = true;
            Charactersstatus.CloseButtonVisible = true;
            Charactersstatus.Resizable = false;
            Charactersstatus.Movable = true;
            Charactersstatus.Close();
            Charactersstatus.IconVisible = false;
            NeoManager.Add(Charactersstatus);


        }
        /// <summary>
        /// Load all graphics content here.
        /// </summary>
        protected override void LoadContent()
        {

            arial16BMFont = Content.Load<SpriteFont>("Arial16");

            // Load the model (by default the model is loaded with a BasicEffect. Use ModelContentReaderOptions to change the behavior at loading time.
            models = new List<Model>();
            foreach (var modelName in new[] { "helmet" })
            {
                model = Content.Load<Model>(modelName);

                // Enable default lighting  on model.
                BasicEffect.EnableDefaultLighting(model, true);

                models.Add(model);
            }
            model = models[0];

            // Instantiate a SpriteBatch
            spriteBatch = ToDisposeContent(new SpriteBatch(GraphicsDevice));

            Inventory();
            charactersstatus();
            InitConsole(texto);
            ExitGamer();
            base.LoadContent();

            // InitRes();
            // initialize the basic effect (shader) to draw the geometry, the BasicEffect class is similar to one from XNA

        }
        void btnExit_Click1(object sender, Controls.EventArgs e)
        {
            gameexit.Hide();
            System.Windows.Forms.DialogResult dialogResult = System.Windows.Forms.MessageBox.Show("Do you really want to exit ", "", System.Windows.Forms.MessageBoxButtons.YesNo, System.Windows.Forms.MessageBoxIcon.Question);
            if (dialogResult == System.Windows.Forms.DialogResult.Yes)
            {

                Game.Exit();
            }



        }

      
        /// <summary>
        /// Draw the scene content.
        /// </summary>
        /// <param name="gameTime">Structure containing information about elapsed game time.</param>


        /// <summary>
        /// Update the scene logic.
        /// </summary>
        /// <param name="gameTime">Structure containing information about elapsed game time.</param>
        public override void Update(GameTime gameTime)
        {
          // NeoManager.Update(gameTime);
            //var pointerState = pointer.GetState();
            //if (pointerState.Points.Count > 0 && pointerState.Points[0].EventType == PointerEventType.Released)
            //{
            //    // Go to next model when pressing key space
            //    model = models[(models.IndexOf(model) + 1) % models.Count];
            //}
           // Update(gameTime);
           /// Calculate the bounds of this model
            modelBounds = model.CalculateBounds();

            // Calculates the world and the view based on the model size
            const float MaxModelSize = 10.0f;
            var scaling = MaxModelSize / modelBounds.Radius;
            view = Matrix.LookAtRH(new Vector3(0, 0, MaxModelSize * 2.5f), new Vector3(0, 0, 0), Vector3.UnitY);
            projection = Matrix.PerspectiveFovRH(0.9f, (float)GraphicsDevice.BackBuffer.Width / GraphicsDevice.BackBuffer.Height, 0.1f, MaxModelSize * 10.0f);
            world = Matrix.Translation(-modelBounds.Center.X, -modelBounds.Center.Y, -modelBounds.Center.Z) * Matrix.Scaling(scaling) * Matrix.RotationY((float)gameTime.TotalGameTime.TotalSeconds);

            //if (con1.TextBoxVisible == true)
            //{
            //}
            //else {
            HandlePlayerInput();
           // model.Meshes.
            //}
             
         //   HandleInput();
            base.Update(gameTime);
            //  NeoManager.Update(gameTime);

            // get the total elapsed seconds since the start of the game

        }

        private void HandleInput()
        {
            
          // if (!con1.TextBoxVisible)
            //{
                HandlePlayerInput();
           // }
           // else
           // {
             //   con1.Focused = true;
               
                //Focused Input
           // }
            /**/
        }
        public override void Draw(GameTime gameTime)
        {

           
           NeoManager.BeginDraw(gameTime);
          // GraphicsDevice.BlendStates.Opaque(gameTime);
          GraphicsDevice.Clear(SharpDX.Color.CornflowerBlue);
            model.Draw(GraphicsDevice, world, view, projection);
            spriteBatch.Begin();

            spriteBatch.DrawString(arial16BMFont, "Press the pointer to switch models...\r\nCurrent Model: " + model.Name, new Vector2(16, 16), Color.White);

            spriteBatch.End();

           NeoManager.EndDraw();


            base.Draw(gameTime);

        }

     /*   public override void Draw3(GameTime gameTime)
        {


           // NeoManager.BeginDraw(gameTime);
            GraphicsDevice.Clear(SharpDX.Color.CornflowerBlue);
          ///  model.Draw(GraphicsDevice, world, view, projection);
          //  spriteBatch.Begin();

          //  spriteBatch.DrawString(arial16BMFont, "Press the pointer to switch models...\r\nCurrent Model: " + model.Name, new Vector2(16, 16), Color.White);

          //  spriteBatch.End();

          //  NeoManager.EndDraw();


            base.Draw(gameTime);

        }
        */
        private void InitConsole(string texto)
        {
            tbc = new TomShane.Neoforce.Controls.TabControl(NeoManager);
            con1 = new TomShane.Neoforce.Controls.Console(NeoManager);
            con2 = new TomShane.Neoforce.Controls.Console(NeoManager);


            tbc.Visible = true;
            //  con2.BackColor
            // Setup of TabControl, which will be holding both consoles
            tbc.Init();
            tbc.AddPage("Global");
            tbc.AddPage("Guild");
            tbc.AddPage("PARTY");
            tbc.AddPage("TRADE");

            tbc.Alpha = 220;
            tbc.Left = 0;
            tbc.Height = 220;
            tbc.Width = 450;
            tbc.Top = NeoManager.TargetHeight - tbc.Height - 32;

            tbc.Movable = true;
            tbc.Resizable = true;
            tbc.MinimumHeight = 96;
            tbc.MinimumWidth = 160;
           // tbc.TextColor= 
            tbc.TextColor = Color.White;
            tbc.TabPages[0].Add(con1);
            tbc.TabPages[1].Add(con2);
         //   NeoManager.Add(tbc);
            con1.Init();
           
            con1.Sender = texto;
            con2.Init();
            con2.Sender = texto;




            con2.Width = con1.Width = tbc.TabPages[0].ClientWidth;
            con2.Height = con1.Height = tbc.TabPages[0].ClientHeight;
            con2.Anchor = con1.Anchor = Anchors.All;

            con1.Channels.Add(new ConsoleChannel(0, "General", SharpDX.Color.Orange));
            con1.Channels.Add(new ConsoleChannel(1, "Private", SharpDX.Color.White));
            con1.Channels.Add(new ConsoleChannel(2, "System", SharpDX.Color.Yellow));
            con1.Channels.Add(new ConsoleChannel(3, "Guild", SharpDX.Color.Green));
            con1.Channels.Add(new ConsoleChannel(4, "Trade", SharpDX.Color.Red));

            // We want to share channels and message buffer in both consoles
            con2.Channels = con1.Channels;
            con2.MessageBuffer = con1.MessageBuffer;

            // In the second console we display only "Private" messages
            con2.ChannelFilter.Add(3);

            // Select default channels for each tab
            con1.SelectedChannel = 0;
            con2.SelectedChannel = 3;

            // Do we want to add timestamp or channel name at the start of every message?
            con1.MessageFormat = ConsoleMessageFormats.All;
            con2.MessageFormat = ConsoleMessageFormats.All;


            // Handler for altering incoming message
            con1.MessageSent += new ConsoleMessageEventHandler(con1_MessageSent);

            // We send initial welcome message to System channel
            con1.MessageBuffer.Add(new ConsoleMessage("System", "WELCOME TO THE SERVER! " + texto, 2));
            con1.Color = Color.Transparent;
            NeoManager.Add(tbc);
        }
        ////////////////////////////////////////////////////////////////////////////

        ////////////////////////////////////////////////////////////////////////////
        void con1_MessageSent(object sender, ConsoleMessageEventArgs e)
        {
            if (e.Message.Channel == 0)
            {
                //e.Message.Text = "(!) " + e.Message.Text;
            }
        }
        void Logout_Click1(object sender, Controls.EventArgs e)
        {

            //gameexit.Hide();
            System.Windows.Forms.DialogResult dialogResult = System.Windows.Forms.MessageBox.Show("Do you really want to exit ", "", System.Windows.Forms.MessageBoxButtons.YesNo, System.Windows.Forms.MessageBoxIcon.Question);
            if (dialogResult == System.Windows.Forms.DialogResult.Yes)
            {
            
               
                NeoManager.Remove(tbc);
                NeoManager.Remove(inventory);
                NeoManager.Remove(Charactersstatus);
                NeoManager.Remove(gameexit);
                model.Meshes.TrimExcess();
               GC.Collect();
            
                Login ola = new Login(Game, NeoManager);
                ola.Visible = true;
         
               
           
            }

        }
    }

}

PARTNERS