Esempio n. 1
0
        public WWorld(string worldName, EditorCore editorCore)
        {
            m_worldName  = worldName;
            m_editorCore = editorCore;

            m_componentList = new List <WComponent>();
            m_dtStopwatch   = new Stopwatch();
            m_input         = new Input();

            m_gizmos         = new DebugDrawing();
            m_renderSystem   = new RenderSystem(this);
            SelectedEntities = new ObservableCollection <MapEntity>();
        }
Esempio n. 2
0
        public WWorld(string worldName, EditorCore editorCore)
        {
            m_worldName = worldName;
            m_editorCore = editorCore;

            m_componentList = new List<WComponent>();
            m_dtStopwatch = new Stopwatch();
            m_input = new Input();

            m_gizmos = new DebugDrawing();
            m_renderSystem = new RenderSystem(this);
            SelectedEntities = new ObservableCollection<MapEntity>();
        }
Esempio n. 3
0
        internal void OnGraphicsContextInitialized(GLControl context, WindowsFormsHost host)
        {
            m_control = context;

            m_editorCore = new EditorCore();
            m_intervalTimer = new System.Windows.Forms.Timer();
            m_intervalTimer.Interval = 16; // 60 FPS roughly
            m_intervalTimer.Enabled = true;
            m_intervalTimer.Tick += (args, o) =>
            {
                Vector2 mousePosGlobal = new Vector2(System.Windows.Forms.Control.MousePosition.X, System.Windows.Forms.Control.MousePosition.Y);
                Vector2 glControlPosGlobal = new Vector2((float)host.PointToScreen(new Point(0, 0)).X, (float)host.PointToScreen(new Point(0, 0)).Y);

                var delta = mousePosGlobal - glControlPosGlobal;

                delta.X = MathE.Clamp(delta.X, 0, m_control.Width);
                delta.Y = MathE.Clamp(delta.Y, 0, m_control.Height);

                ((MainWindow)Application.Current.MainWindow).Tick();

                m_editorCore.GetWorldByName("main").Input.SetMousePosition(delta);
                m_editorCore.Tick();

                if (m_control != null)
                    m_control.SwapBuffers();
            };

            m_editorCore.PropertyChanged += OnEditorPropertyChanged;
            EntityOutliner.m_world = m_editorCore.GetWorldByName("main");
        }