示例#1
0
        public Camera()
        {
            RendererFactory.GetInstance().PreDrawEvent  += new PreDrawCallback(renderer_PreDrawEvent);
            IMouseFilterMouseCache mousefiltermousecache = MouseFilterMouseCacheFactory.GetInstance();

            mousemove = MouseMoveConfigMappings.GetInstance();
            config    = Config.GetInstance();

            KeyFilterConfigMappingsFactory.GetInstance().RegisterCommand(OverheadOTAConfigName, new KeyCommandHandler(CameraModeOverheadTAHandler));
            KeyFilterConfigMappingsFactory.GetInstance().RegisterCommand(OverheadOTAOrbitConfigName, new KeyCommandHandler(CameraModeOverheadTAHandlerOrbit));

            /*
             * KeyFilterComboKeys.GetInstance().RegisterCombo(
             *  new string[]{"cameramode"}, null, new KeyComboHandler( CameraModeZoomHandler ) );
             * KeyFilterComboKeys.GetInstance().RegisterCombo(
             *  new string[]{"cameramode","cameraorbit"}, null, new KeyComboHandler( CameraModeOrbitHandler ) );
             * KeyFilterComboKeys.GetInstance().RegisterCombo(
             *  new string[]{"cameramode","camerapan"}, null, new KeyComboHandler( CamerModePanHandler ) );
             */

            KeyFilterConfigMappingsFactory.GetInstance().RegisterCommand("toggleviewpoint", new KeyCommandHandler(ToggleViewpointHandler));

            //mousefiltermousecache.MouseDown += new MouseEventHandler( MouseDown );
            mousefiltermousecache.MouseMove += new MouseMoveHandler(mousefiltermousecache_MouseMove);
            //mousefiltermousecache.MouseUp += new MouseEventHandler( MouseUp );
            UpdateRoamingCameraRotAndPosFromOverheadOTA();
        }
示例#2
0
        public Camera()
        {
            RendererFactory.GetInstance().PreDrawEvent  += new PreDrawCallback(renderer_PreDrawEvent);
            IMouseFilterMouseCache mousefiltermousecache = MouseFilterMouseCacheFactory.GetInstance();

            mousemove = MouseMoveConfigMappings.GetInstance();
            config    = Config.GetInstance();

            KeyFilterConfigMappingsFactory.GetInstance().RegisterCommand(OverheadOTATranslateConfigName, new KeyCommandHandler(CameraModeOverheadTAHandlerTranslate));
            KeyFilterConfigMappingsFactory.GetInstance().RegisterCommand(OverheadOTAOrbitConfigName, new KeyCommandHandler(CameraModeOverheadTAHandlerOrbit));
            KeyFilterConfigMappingsFactory.GetInstance().RegisterCommand(OverheadOTAZoomConfigName, new KeyCommandHandler(CameraModeOverheadTAHandlerZoom));

            KeyFilterConfigMappingsFactory.GetInstance().RegisterCommand("toggleviewpoint", new KeyCommandHandler(ToggleViewpointHandler));

            mousefiltermousecache.MouseMove += new MouseMoveHandler(mousefiltermousecache_MouseMove);
            UpdateRoamingCameraRotAndPosFromOverheadOTA();
        }
示例#3
0
 /// <summary>
 /// Return current mouse intersect point to x-y plane on map, in display coordinates
 /// </summary>
 /// <returns></returns>
 public static Vector3 GetIntersectPoint()
 {
     // intersect mousevector with x-z plane.
     Terrain terrain = Terrain.GetInstance();
     Vector3 mousevector = GraphicsHelperFactory.GetInstance().GetMouseVector(
         Camera.GetInstance().RoamingCameraPos, 
         Camera.GetInstance().RoamingCameraRot, 
         MouseFilterMouseCacheFactory.GetInstance().MouseX, 
         MouseFilterMouseCacheFactory.GetInstance().MouseY);
     Vector3 camerapos = Camera.GetInstance().RoamingCameraPos;
     int width = terrain.HeightMapWidth;
     int height = terrain.HeightMapHeight;
     //Vector3 planenormal = mvMath.ZAxis;
     mousevector.Normalize();
     if (mousevector.z < -0.0005)
     {
         //Vector3 intersectionpoint = camerapos + mousevector * (Vector3.DotProduct(camerapos, planenormal) + 0) /
         //  (Vector3.DotProduct(mousevector, planenormal));
         Vector3 intersectpoint = camerapos - mousevector * (camerapos.z / mousevector.z);
         //Console.WriteLine("intersection: " + intersectionpoint.ToString());
         double heightmapx = intersectpoint.x / Terrain.SquareSize;
         double heightmapy = intersectpoint.y / Terrain.SquareSize;
         if (heightmapx >= 0 && heightmapy >= 0 &&
             heightmapx < width && heightmapy < height)
         {
             intersectpoint.z = Terrain.GetInstance().Map[(int)heightmapx, (int)heightmapy];
             return intersectpoint;
         }
         else
         {
             return null;
         }
     }
     else
     {
         //                Console.WriteLine("no intersection");
         return null;
     }
 }
示例#4
0
 MouseMoveConfigMappings() // protected constructor, to enforce singleton
 {
     MouseMoveConfigsByName = Config.GetInstance().MouseMoveConfigsByName;
     mousefiltermousecache  = MouseFilterMouseCacheFactory.GetInstance();
     config = Config.GetInstance();
 }