예제 #1
0
        private static List <Gk3Main.Game.NounVerbCase> getNounVerbCasesUnderCursor(Gk3Main.Graphics.Camera camera, int mx, int my)
        {
            if (camera == null)
            {
                throw new ArgumentNullException("camera");
            }

            Gk3Main.Math.Vector3 unprojected = camera.Unproject(new Gk3Main.Math.Vector3(mx, my, 0));


            string model = Gk3Main.SceneManager.GetCollisionModel(camera.Position, (unprojected - camera.Position).Normalize(), 1000.0f);

            if (model != null)
            {
                Gk3Main.Game.Nouns noun = Gk3Main.SceneManager.GetModelNoun(model);

                if (noun != Gk3Main.Game.Nouns.N_NONE)
                {
                    List <Gk3Main.Game.NounVerbCase> nvcs = Gk3Main.Game.NvcManager.GetNounVerbCases(noun, true);

                    if (nvcs.Count > 0)
                    {
                        return(nvcs);
                    }
                }
            }

            return(null);
        }
예제 #2
0
        public static void RenderProperCursor(Gk3Main.Graphics.SpriteBatch sb, Gk3Main.Graphics.Camera camera, int mx, int my, Gk3Main.Gui.CursorResource point, Gk3Main.Gui.CursorResource zoom)
        {
            if (_vbs != null || camera == null)
            {
                point.Render(sb, mx, my);
                return;
            }

            int count = getNounVerbCaseCountUnderCursor(camera, mx, my);

            if (count == 0)
            {
                point.Render(sb, mx, my);
            }
            else
            {
                zoom.Render(sb, mx, my);
            }
        }
예제 #3
0
        private static int getNounVerbCaseCountUnderCursor(Gk3Main.Graphics.Camera camera, int mx, int my)
        {
            if (camera == null)
            {
                throw new ArgumentNullException("camera");
            }

            Gk3Main.Math.Vector3 unprojected = camera.Unproject(new Gk3Main.Math.Vector3(mx, my, 0));


            string model = Gk3Main.SceneManager.GetCollisionModel(camera.Position, (unprojected - camera.Position).Normalize(), 1000.0f);

            Gk3Main.Game.Nouns noun;

            if (model != null)
            {
                noun = Gk3Main.SceneManager.GetModelNoun(model);

                if (_lastNoun != noun)
                {
                    _lastNoun = noun;

                    if (noun != Gk3Main.Game.Nouns.N_NONE)
                    {
                        int count = Gk3Main.Game.NvcManager.GetNounVerbCases(noun, true).Count;
                        _lastNounVerbCount = count;
                    }
                    else
                    {
                        _lastNounVerbCount = 0;
                    }
                }
            }
            else
            {
                _lastNoun          = Gk3Main.Game.Nouns.N_NONE;
                _lastNounVerbCount = 0;
            }

            return(_lastNounVerbCount);
        }
예제 #4
0
        public void OnMouseUp(int button, int x, int y)
        {
            Gk3Main.Graphics.Camera camera = Gk3Main.SceneManager.CurrentCamera;
            if (camera != null && button == 0)
            {
                if (_vbs != null)
                {
                    _vbs.OnMouseUp(x, y);
                }
                else if (x == _mouseDownX && y == _mouseDownY && camera != null)
                {
                    List <Gk3Main.Game.NounVerbCase> nvcs = getNounVerbCasesUnderCursor(camera, x, y);

                    if (nvcs != null)
                    {
                        _vbs = new Gk3Main.Gui.VerbButtonSet(_content, x, y, nvcs, true);
                        _vbs.KeepInsideViewport(Gk3Main.Graphics.RendererManager.CurrentRenderer.Viewport);
                    }
                }
            }
        }
예제 #5
0
파일: MainForm.cs 프로젝트: shff/gk3tools
        public MainForm(string[] args)
        {
            ProgramArguments arguments = null;

            try
            {
                arguments = new ProgramArguments(args);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Unable to parse arguments: " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            InitializeComponent();

#if !D3D_DISABLED
            if (Settings.Default.Renderer.Equals("Direct3D 9", StringComparison.OrdinalIgnoreCase))
            {
                direct3D9ToolStripMenuItem.Checked = true;
                openGLToolStripMenuItem.Checked    = false;
                _window = new Direct3D9RenderWindow(pbRenderWindow);
            }
            else
#endif
            {
                direct3D9ToolStripMenuItem.Checked = false;
                openGLToolStripMenuItem.Checked    = true;
                _window = new OpenGLRenderWindow(pbRenderWindow);
            }
            Gk3Main.Graphics.RendererManager.CurrentRenderer = _window.CreateRenderer();

            _pathEditor = new SearchPathEditor();
            _pathEditor.Hide();

            _consoleForm = new ConsoleForm();
            _consoleForm.Show();

            _resourceViewerForm = new ResourceViewer();
            _resourceViewerForm.Show();

            Gk3Main.Console.CurrentConsole = new FormConsole(_consoleForm);
            Gk3Main.Console.CurrentConsole.AddCommand("run", new Gk3Main.ConsoleCommand(run));
            Gk3Main.Console.CurrentConsole.AddCommand("look", new Gk3Main.ConsoleCommand(look));
            Gk3Main.Console.CurrentConsole.AddCommand("viewSurfaceLightmap", new Gk3Main.ConsoleCommand(viewSurfaceLightmap));

            if (Settings.Default.SearchPath == String.Empty)
            {
                Gk3Main.FileSystem.AddPathToSearchPath(System.IO.Directory.GetCurrentDirectory());
                Gk3Main.FileSystem.AddPathToSearchPath("Shaders");
            }
            else
            {
                string[] paths = Settings.Default.SearchPath.Split(';');
                foreach (string path in paths)
                {
                    if (path != string.Empty)
                    {
                        try
                        {
                            if (System.IO.Directory.Exists(path))
                            {
                                Gk3Main.FileSystem.AddPathToSearchPath(path);
                            }
                            else
                            {
                                Gk3Main.FileSystem.AddBarnToSearchPath(path);
                            }
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show("Error when attempting to add to the search path: " + ex.Message,
                                            "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                }
            }

            // handle any search paths passed in as arguments
            if (arguments != null)
            {
                foreach (string path in arguments.SearchPaths)
                {
                    Gk3Main.FileSystem.AddPathToSearchPath(path, true);
                }

                foreach (string barn in arguments.SearchBarns)
                {
                    Gk3Main.FileSystem.AddBarnToSearchPath(barn, true);
                }
            }

            _globalContent = new Gk3Main.Resource.ResourceManager();

            Gk3Main.Resource.ResourceManager.AddResourceLoader(new Gk3Main.Game.NvcResourceLoader(), typeof(Gk3Main.Game.NvcResource));
            Gk3Main.Resource.ResourceManager.AddResourceLoader(new Gk3Main.Game.ScnResourceLoader(), typeof(Gk3Main.Game.ScnResource));
            Gk3Main.Resource.ResourceManager.AddResourceLoader(new Gk3Main.Game.SifResourceLoader(), typeof(Gk3Main.Game.SifResource));
            Gk3Main.Resource.ResourceManager.AddResourceLoader(new Gk3Main.Game.MomLoader(), typeof(Gk3Main.Game.MomResource));
            Gk3Main.Resource.ResourceManager.AddResourceLoader(new Gk3Main.Game.GasResourceLoader(), typeof(Gk3Main.Game.GasResource));
            Gk3Main.Resource.ResourceManager.AddResourceLoader(new Gk3Main.Graphics.BspResourceLoader(), typeof(Gk3Main.Graphics.BspResource));
            Gk3Main.Resource.ResourceManager.AddResourceLoader(new Gk3Main.Graphics.TextureResourceLoader(), typeof(Gk3Main.Graphics.TextureResource));
            Gk3Main.Resource.ResourceManager.AddResourceLoader(new Gk3Main.Graphics.LightmapResourceLoader(), typeof(Gk3Main.Graphics.LightmapResource));
            Gk3Main.Resource.ResourceManager.AddResourceLoader(new Gk3Main.Graphics.ModelResourceLoader(), typeof(Gk3Main.Graphics.ModelResource));
            Gk3Main.Resource.ResourceManager.AddResourceLoader(new Gk3Main.Graphics.ActResourceLoader(), typeof(Gk3Main.Graphics.ActResource));
            Gk3Main.Resource.ResourceManager.AddResourceLoader(new Gk3Main.Graphics.EffectLoader(), typeof(Gk3Main.Graphics.Effect));
            Gk3Main.Resource.ResourceManager.AddResourceLoader(new Gk3Main.Sound.SoundTrackLoader(), typeof(Gk3Main.Sound.SoundTrackResource));
            Gk3Main.Resource.ResourceManager.AddResourceLoader(new Gk3Main.Sound.SoundLoader(), typeof(Gk3Main.Sound.AudioEngine.SoundEffect));

            try
            {
                Gk3Main.Sheep.SheepMachine.Initialize();
            }
            catch (Gk3Main.Sheep.SheepException ex)
            {
                Gk3Main.Console.CurrentConsole.ReportError(ex.Message);
            }



            bool zNegOne = (Gk3Main.Graphics.RendererManager.CurrentRenderer.ZClipMode == Gk3Main.Graphics.ZClipMode.NegativeOne);
            _camera = new Gk3Main.Graphics.Camera(1.04719755f, (float)pbRenderWindow.Width / pbRenderWindow.Height, 1.0f, 5000.0f, zNegOne);

            Gk3Main.SceneManager.LightmapsEnabled     = true;
            Gk3Main.SceneManager.DoubleLightmapValues = true;
            Gk3Main.SceneManager.CurrentShadeMode     = Gk3Main.ShadeMode.Textured;
            Gk3Main.Graphics.RendererManager.CurrentRenderer.CullMode         = Gk3Main.Graphics.CullMode.CounterClockwise;
            Gk3Main.Graphics.RendererManager.CurrentRenderer.DepthTestEnabled = true;

            // check the arguments to see if we need to load anything
            if (arguments != null)
            {
                foreach (string model in arguments.ModelsToLoad)
                {
                    loadInitialData();
                    Gk3Main.SceneManager.AddModel(model, true);
                }

                if (string.IsNullOrEmpty(arguments.BspToLoad) == false)
                {
                    loadInitialData();
                    Gk3Main.SceneManager.LoadBsp(arguments.BspToLoad);
                }
            }
        }