Esempio n. 1
0
        public TerrainWindow(string modelPath, BackgroundWorker renderWorker)
            : base(1920, 1080, new OpenTK.Graphics.GraphicsMode(32, 24, 0, 8), "Terrain test", GameWindowFlags.Default, DisplayDevice.Default, 3, 0, OpenTK.Graphics.GraphicsContextFlags.Default)
        {
            if (renderWorker == null)
            {
                renderWorker = new BackgroundWorker();
                renderWorker.WorkerReportsProgress = true;
            }

            worker = renderWorker;

            dragX = 0;
            dragY = 0;
            dragZ = 0;
            angle = 0.0f;

            Keyboard.KeyDown += Keyboard_KeyDown;

            ActiveCamera = new OldCamera(Width, Height);
            //ActiveCamera.Pos = new Vector3(10.0f, -10.0f, -7.5f);

            Console.WriteLine(modelPath);

            string[] adt = modelPath.Split('_');

            Console.WriteLine("MAP {0}, X {1}, Y {2}", adt[0], adt[1], adt[2]);
            //LoadADT(adt[0], adt[1], adt[2]);
            LoadMap(adt[0], int.Parse(adt[1]), int.Parse(adt[2]), 1);
        }
Esempio n. 2
0
 protected override void OnResize(EventArgs e)
 {
     GL.Viewport(0, 0, Width, Height);
     ActiveCamera     = new OldCamera(Width, Height);
     ActiveCamera.Pos = new Vector3(dragX, dragY, dragZ);
     ActiveCamera.setupGLRenderMatrix();
 }
Esempio n. 3
0
        public TerrainWindow(string modelPath, BackgroundWorker renderWorker)
            : base(1920, 1080, new OpenTK.Graphics.GraphicsMode(32, 24, 0, 8), "Terrain test", GameWindowFlags.Default, DisplayDevice.Default, 3, 0, OpenTK.Graphics.GraphicsContextFlags.Default)
        {
            if(renderWorker == null)
            {
                renderWorker = new BackgroundWorker();
                renderWorker.WorkerReportsProgress = true;
            }

            worker = renderWorker;

            dragX = 0;
            dragY = 0;
            dragZ = 0;
            angle = 0.0f;

            Keyboard.KeyDown += Keyboard_KeyDown;

            ActiveCamera = new OldCamera(Width, Height);
            //ActiveCamera.Pos = new Vector3(10.0f, -10.0f, -7.5f);

            Console.WriteLine(modelPath);

            string[] adt = modelPath.Split('_');

            Console.WriteLine("MAP {0}, X {1}, Y {2}", adt[0], adt[1], adt[2]);
            //LoadADT(adt[0], adt[1], adt[2]);
            LoadMap(adt[0], int.Parse(adt[1]), int.Parse(adt[2]), 1);
        }
Esempio n. 4
0
        public Render(string ModelPath, BackgroundWorker worker = null)
        {
            dragX = 0.0f;
            dragY = 0.0f;
            dragZ = 0.0f;

            if (worker == null)
            {
                this.worker = new BackgroundWorker();
            }
            else
            {
                this.worker = worker;
            }

            filename = ModelPath;

            System.Windows.Forms.Integration.WindowsFormsHost wfc = MainWindow.winFormControl;

            ActiveCamera     = new OldCamera((int)wfc.ActualWidth, (int)wfc.ActualHeight);
            ActiveCamera.Pos = new Vector3(-15.0f, 0.0f, 4.0f);

            if (filename.EndsWith(".m2"))
            {
                M2Loader.LoadM2(filename, cache);

                ActiveCamera.Pos = new Vector3(-15.0f, 0.0f, 4.0f);

                gLoaded = true;
            }
            else if (filename.EndsWith(".wmo"))
            {
                WMOLoader.LoadWMO(filename, cache);

                gLoaded = true;
                isWMO   = true;
            }

            glControl             = new GLControl(new OpenTK.Graphics.GraphicsMode(32, 24, 0, 8), 3, 0, OpenTK.Graphics.GraphicsContextFlags.Default);
            glControl.Width       = (int)wfc.ActualWidth;
            glControl.Height      = (int)wfc.ActualHeight;
            glControl.Left        = 0;
            glControl.Top         = 0;
            glControl.Load       += glControl_Load;
            glControl.Paint      += RenderFrame;
            glControl.MouseEnter += glControl_MouseEnter;
            glControl.MouseLeave += glControl_MouseLeave;
            glControl.Resize     += glControl_Resize;
            glControl.MakeCurrent();
            glControl.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right | System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left;

            sw.Start();

            spentTime = 0.00;

            wfc.Child = glControl;
        }
Esempio n. 5
0
        public Render(string ModelPath, BackgroundWorker worker = null)
        {
            dragX = 0.0f;
            dragY = 0.0f;
            dragZ = -7.5f;

            if (worker == null)
            {
                Console.WriteLine("Didn't get a backgroundworker, creating one!");
                this.worker = new BackgroundWorker();
            }
            else
            {
                this.worker = worker;
            }

            System.Windows.Forms.Integration.WindowsFormsHost wfc = MainWindow.winFormControl;

            ActiveCamera     = new OldCamera((int)wfc.ActualWidth, (int)wfc.ActualHeight);
            ActiveCamera.Pos = new Vector3(10.0f, -10.0f, -7.5f);

            if (ModelPath.EndsWith(".m2", StringComparison.OrdinalIgnoreCase))
            {
                modelLoaded = true;
                LoadM2(ModelPath);
            }
            else if (ModelPath.EndsWith(".wmo", StringComparison.OrdinalIgnoreCase))
            {
                modelLoaded = true;
                LoadWMO(ModelPath);
            }
            else
            {
                modelLoaded = false;
            }

            glControl         = new GLControl(new OpenTK.Graphics.GraphicsMode(32, 24, 0, 8), 3, 0, OpenTK.Graphics.GraphicsContextFlags.Default);
            glControl.Width   = (int)wfc.ActualWidth;
            glControl.Height  = (int)wfc.ActualHeight;
            glControl.Left    = 0;
            glControl.Top     = 0;
            glControl.Load   += glControl_Load;
            glControl.Paint  += RenderFrame;
            glControl.Resize += glControl_Resize;
            glControl_Resize(glControl, EventArgs.Empty);
            glControl.MakeCurrent();

            wfc.Child = glControl;
        }
Esempio n. 6
0
        public Render(string ModelPath)
        {
            dragX = 0.0f;
            dragY = 0.0f;
            dragZ = -7.5f;

            System.Windows.Forms.Integration.WindowsFormsHost wfc = MainWindow.winFormControl;

            ActiveCamera = new OldCamera((int)wfc.ActualWidth, (int)wfc.ActualHeight);
            ActiveCamera.Pos = new Vector3(10.0f, -10.0f, -7.5f);
            Console.WriteLine(ModelPath);

            if (ModelPath.EndsWith(".m2", StringComparison.OrdinalIgnoreCase))
            {
                modelLoaded = true;
                LoadM2(ModelPath);
            }
            else if (ModelPath.EndsWith(".wmo", StringComparison.OrdinalIgnoreCase))
            {
                modelLoaded = true;
                LoadWMO(ModelPath);
            }
            else
            {
                modelLoaded = false;
            }

            glControl = new GLControl(new OpenTK.Graphics.GraphicsMode(32, 24, 0, 8), 3, 0, OpenTK.Graphics.GraphicsContextFlags.Default);
            glControl.Width = (int)wfc.ActualWidth;
            glControl.Height = (int)wfc.ActualHeight;
            glControl.Left = 0;
            glControl.Top = 0;
            glControl.Load += glControl_Load;
            glControl.Paint += RenderFrame;
            glControl.Resize += glControl_Resize;
               /*glControl.MouseMove += new MouseEventHandler(glControl_MouseMove);
            glControl.MouseDown += new MouseEventHandler(glControl_MouseDown);
            glControl.MouseUp += new MouseEventHandler(glControl_MouseUp);
            */
            glControl_Resize(glControl, EventArgs.Empty);
            glControl.MakeCurrent();

            wfc.Child = glControl;

            Console.WriteLine(glControl.Width + "x" + glControl.Height);
        }
Esempio n. 7
0
 protected override void OnResize(EventArgs e)
 {
     GL.Viewport(0, 0, Width, Height);
     ActiveCamera = new OldCamera(Width, Height);
     ActiveCamera.Pos = new Vector3(dragX, dragY, dragZ);
     ActiveCamera.setupGLRenderMatrix();
 }
Esempio n. 8
0
        public Render(string ModelPath, BackgroundWorker worker = null)
        {
            dragX = 0.0f;
            dragY = 0.0f;
            dragZ = 0.0f;

            if (worker == null)
            {
                Console.WriteLine("Didn't get a backgroundworker, creating one!");
                this.worker = new BackgroundWorker();
            }
            else
            {
                this.worker = worker;
            }

            filename = ModelPath;

            System.Windows.Forms.Integration.WindowsFormsHost wfc = MainWindow.winFormControl;

            ActiveCamera = new OldCamera((int)wfc.ActualWidth, (int)wfc.ActualHeight);
            ActiveCamera.Pos = new Vector3(-15.0f, 0.0f, 4.0f);

            if (filename.EndsWith(".m2"))
            {
                M2Loader.LoadM2(filename, cache);

                ActiveCamera.Pos = new Vector3(-15.0f, 0.0f, 4.0f);

                // The next few hackfixes can be removed once WMOs are done as well
                renderbatches = cache.doodadBatches[filename].submeshes;
                materials = cache.doodadBatches[filename].mats;

                VBOid = new uint[2];

                VBOid[0] = (uint)cache.doodadBatches[filename].vertexBuffer;
                VBOid[1] = (uint)cache.doodadBatches[filename].indiceBuffer;

                gLoaded = true;
            }
            else if (filename.EndsWith(".wmo"))
            {
                WMOLoader.LoadWMO(filename, cache);
                
                //TODO

                //gLoaded = true;
                isWMO = true;
            }

            glControl = new GLControl(new OpenTK.Graphics.GraphicsMode(32, 24, 0, 8), 3, 0, OpenTK.Graphics.GraphicsContextFlags.Default);
            glControl.Width = (int)wfc.ActualWidth;
            glControl.Height = (int)wfc.ActualHeight;
            glControl.Left = 0;
            glControl.Top = 0;
            glControl.Load += glControl_Load;
            glControl.Paint += RenderFrame;
            glControl.MouseEnter += glControl_MouseEnter;
            glControl.MouseLeave += glControl_MouseLeave;
            glControl.Resize += glControl_Resize;
            glControl.MakeCurrent();
            glControl.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right | System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left;

            sw.Start();

            spentTime = 0.00;

            wfc.Child = glControl;
        }
Esempio n. 9
0
        public Render(string ModelPath, BackgroundWorker worker = null)
        {
            dragX = 0.0f;
            dragY = 0.0f;
            dragZ = 0.0f;

            if (worker == null)
            {
                Console.WriteLine("Didn't get a backgroundworker, creating one!");
                this.worker = new BackgroundWorker();
            }
            else
            {
                this.worker = worker;
            }

            filename = ModelPath;

            System.Windows.Forms.Integration.WindowsFormsHost wfc = MainWindow.winFormControl;

            ActiveCamera     = new OldCamera((int)wfc.ActualWidth, (int)wfc.ActualHeight);
            ActiveCamera.Pos = new Vector3(-15.0f, 0.0f, 4.0f);

            if (filename.EndsWith(".m2"))
            {
                M2Loader.LoadM2(filename, cache);

                ActiveCamera.Pos = new Vector3(-15.0f, 0.0f, 4.0f);

                // The next few hackfixes can be removed once WMOs are done as well
                renderbatches = cache.doodadBatches[filename].submeshes;
                materials     = cache.doodadBatches[filename].mats;

                VBOid = new uint[2];

                VBOid[0] = (uint)cache.doodadBatches[filename].vertexBuffer;
                VBOid[1] = (uint)cache.doodadBatches[filename].indiceBuffer;

                gLoaded = true;
            }
            else if (filename.EndsWith(".wmo"))
            {
                WMOLoader.LoadWMO(filename, cache);

                //TODO

                //gLoaded = true;
                isWMO = true;
            }

            glControl             = new GLControl(new OpenTK.Graphics.GraphicsMode(32, 24, 0, 8), 3, 0, OpenTK.Graphics.GraphicsContextFlags.Default);
            glControl.Width       = (int)wfc.ActualWidth;
            glControl.Height      = (int)wfc.ActualHeight;
            glControl.Left        = 0;
            glControl.Top         = 0;
            glControl.Load       += glControl_Load;
            glControl.Paint      += RenderFrame;
            glControl.MouseEnter += glControl_MouseEnter;
            glControl.MouseLeave += glControl_MouseLeave;
            glControl.Resize     += glControl_Resize;
            glControl.MakeCurrent();
            glControl.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right | System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left;

            sw.Start();

            spentTime = 0.00;

            wfc.Child = glControl;
        }