示例#1
0
        /// <summary>
        /// 'FrameProc' is automatically called once per frame if at all possible. Here you put the things you definitely
        /// need to do periodically, like sprite movement that needs to be smooth, critical timing operations,
        /// etc. If you put that stuff in the FrameDraw() method, then behavior might be choppy because the FrameDraw()
        /// method is not called periodically if there isn't enough CPU.
        /// </summary>
        /// <param name="timeInfo"></param>
        protected override void FrameProc(GameTime timeInfo)
        {
            // handle the standard mouse and key commands for controlling the 3D view
            var mouseRay = Graphics.DoDefaultGui();

            if (Graphics.Zoom > 150)
            {
                Graphics.Zoom = 150;
            }

            // Did user CTRL-leftClick in the 3D display?
            if (mouseRay != null)
            {
                // search the sprite tree for sprites that had a radius within the selection ray
                var sprites = TopSprite.GetRayIntersections((Ray)mouseRay);
                foreach (var s in sprites)
                {
                    Console.WriteLine(s);
                }
            }
        }
示例#2
0
        /// <summary>
        /// 'FrameDraw' is automatically called once per frame if there is enough CPU. Otherwise its called more slowly.
        /// This is where you would typically draw the scene.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void FrameDraw(GameTime timeInfo)
        {
            // handle the standard mouse and key commands for controlling the 3D view
            var mouseRay = Graphics.DoDefaultGui();

            if (Graphics.Zoom > 150)
            {
                Graphics.Zoom = 150;
            }

            // Did user CTRL-leftClick in the 3D display?
            if (mouseRay != null)
            {
                // search the sprite tree for sprites that had a radius within the selection ray
                var sprites = TopSprite.GetRayIntersections((Ray)mouseRay);
                foreach (var s in sprites)
                {
                    Console.WriteLine(s);
                }
            }

            Skybox.Draw();

            var hudDist = (float)-(Graphics.CurrentNearClip + Graphics.CurrentFarClip) / 2;

            HudBackground.Matrix = Matrix.CreateScale(.4f, .4f, .4f) * Matrix.CreateTranslation(0, 0, hudDist);

            TopSprite.Draw();

            Graphics.SetSpriteToCamera(TopHudSprite);
            Graphics.GraphicsDevice.DepthStencilState = DepthStencilState.None;
            TopHudSprite.Draw();
            Graphics.GraphicsDevice.DepthStencilState = DepthStencilState.Default;

            var MyMenuText = String.Format("{0}\nEye: {1}\nLookAt: {2}\nMaxDistance: {3}\nMinDistance: {4}\nViewAngle: {5}\nModelLod: {6}\nModelApparentSize: {7}",
                                           Help,
                                           Graphics.Eye,
                                           Graphics.LookAt,
                                           Graphics.MaxCamDistance,
                                           Graphics.MinCamDistance,
                                           Graphics.Zoom,
                                           Model.LodTarget,
                                           Model.ApparentSize
                                           );

            try
            {
                // handle undrawable characters for the specified font(like the infinity symbol)
                try
                {
                    Graphics.DrawText(MyMenuText, Font, new Vector2(50, 50));
                }
                catch { }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }

            /*
             * Console.WriteLine("{0}  {1}  {2}  {3}  {4}",
             *      graphics.CurrentNearClip,
             *      graphics.CurrentFarClip,
             *      graphics.MinCamDistance,
             *      graphics.MaxCamDistance,
             *      hudDist
             * );
             */
            //Console.WriteLine(model.LodCurrentIndex);
        }