コード例 #1
0
 public OutdoorCamFacade()
 {
     ImgP      = new ImageProcessor();
     CamDriver = new CameraDriver();
     CamLight  = new CameraLight();
     MotSensor = new MotionSensor();
 }
コード例 #2
0
        public static void Adjust(CameraDriver driver, float rootSize)
        {
            if (!Settings.Get().zoomToMouse)
            {
                rootSizeInfo.SetValue(driver, rootSize);
                return;
            }
            //Find what old position is
            Vector3 rootPos = (Vector3)rootPosInfo.GetValue(driver);

            //update the Camera Object (for previously-done scrolling movement) and get old mouse pos
            ApplyInfo.Invoke(driver, null);
            Vector3 oldMousePos = UI.MouseMapPosition();

            //apply new zoom
            rootSizeInfo.SetValue(driver, rootSize);

            //update the Camera Object for the zoom, and get NEW mouse pos
            ApplyInfo.Invoke(driver, null);
            Vector3 newMousePos = UI.MouseMapPosition();

            //adjust for mouse pos difference: keep mousepos at the same spot.
            rootPos += oldMousePos - newMousePos;

            rootPosInfo.SetValue(driver, rootPos);
        }
コード例 #3
0
        public static void Adjust(CameraDriver driver, float rootSize)
        {
            if (!Mod.settings.zoomToMouse || Event.current.shift)
            {
                RootSize(driver) = rootSize;
                return;
            }
            //Find what old position is
            Vector3 rootPos = RootPos(driver);

            //update the Camera Object (for previously-done scrolling movement) and get old mouse pos
            ApplyPositionToGameObject(driver);
            Vector3 oldMousePos = UI.MouseMapPosition();

            //apply new zoom
            RootSize(driver) = rootSize;

            //update the Camera Object for the zoom, and get NEW mouse pos
            ApplyPositionToGameObject(driver);
            Vector3 newMousePos = UI.MouseMapPosition();

            //adjust for mouse pos difference: keep mousepos at the same spot.
            rootPos += oldMousePos - newMousePos;

            RootPos(driver) = rootPos;
        }
コード例 #4
0
 /// <summary>
 /// Domyślny konstruktor głównego okna aplikacji.
 /// </summary>
 public MainWindow()
 {
     cameraDriver   = new CameraDriver(MovementDetected, MovementDetectionFinished);
     ipCameraDriver = new IPCameraDriver(MovementDetected, MovementDetectionFinished);
     TCPCon         = new TCPConnection();
     InitializeComponent();
 }
コード例 #5
0
 public static void Postfix(CameraDriver __instance)
 {
     if (__instance.MouseDrag() != Vector2.zero)
     {
         velocity.SetValue(__instance, Vector3.zero);
     }
 }
コード例 #6
0
        static void CameraDriver_OnGUI_Postfix(CameraDriver __instance)
        {
            if (!Enabled)
            {
                return;
            }

            if (Find.Camera == null || Find.TickManager.Paused || Find.TickManager.NotPlaying)
            {
                return;
            }

            var modifer = 0f;

            switch (Find.CameraDriver.CurrentZoom)
            {
            case CameraZoomRange.Furthest: modifer = 150f; break;

            case CameraZoomRange.Far: modifer = 80f; break;

            case CameraZoomRange.Middle: modifer = 40f; break;

            case CameraZoomRange.Close: modifer = 5f; break;
            }

            if (KeyBindingDefOf.MapDolly_Left.IsDown || KeyBindingDefOf.MapDolly_Up.IsDown || KeyBindingDefOf.MapDolly_Right.IsDown || KeyBindingDefOf.MapDolly_Down.IsDown)
            {
                panNorm = modifer;
            }
            else if (KeyBindingDefOf.MapZoom_Out.KeyDownEvent || KeyBindingDefOf.MapZoom_In.KeyDownEvent)
            {
                panNorm = modifer;
            }
        }
コード例 #7
0
        private GameManager()
        {
            GameManager.terrain = CameraDriver.GetAttachedTerain();
            ai         = new WiccanRede.AI.AICore(terrain);
            this.logic = new GameLogic(this, ai);

            Initialization();
        }
コード例 #8
0
ファイル: Program.cs プロジェクト: ImCheesecake/CMS18
 public Camera(int id)
 {
     this.Id   = id;
     ImgP      = new ImageProcessor();
     SoundP    = new SoundProcessor();
     CamDriver = new CameraDriver();
     CamLight  = new CameraLight();
     MotSensor = new MotionSensor();
 }
コード例 #9
0
        public void Restart()
        {
            this.ai.Dispose();

            this.ai    = new WiccanRede.AI.AICore(terrain);
            this.logic = new GameLogic(this, ai);
            Initialization();

            CameraDriver.MoveToStartPosition();
        }
コード例 #10
0
    public void Start()
    {
        var audioSource = GetComponent <AudioSource>();

        if (audioSource)
        {
            audioSource.Play();
        }
        CameraDriver.SetSceenShake(deathShake);
    }
コード例 #11
0
        public Terrain(int level, Device device, Bitmap heightMap, Texture mask, Texture layer1, Texture layer2, Texture layer3)
            : base(level, GenerateVertexes(device, heightMap), GenerateIndexes(device, heightMap), Terrain.minPosition, Terrain.maxPosition, Matrix.Identity, new Texture[] { layer1 }, new Texture[] { layer2 }, new Texture[] { layer3 }, null)
        {
            this.heightMap = BitmapOperation.BitmapToColorArray(heightMap);
            blocked        = new List <Point>();

            base.SetIsEveryWhere(true);

            CameraDriver.SetAttachedTerain(this);
        }
コード例 #12
0
        public static float ChangeHitch(float result)
        {
            CameraDriver driver = Find.CameraDriver;

            if (driver.MouseDrag() != Vector2.zero)
            {
                return(1 / RealTime.deltaTime / 60f);
            }
            return(result);
        }
コード例 #13
0
        public async Task <string> Handle(LuisResult param)
        {
            var cameraDriver  = new CameraDriver();
            var capturedPhoto = await cameraDriver.TakeShot();

            var storageFile = await cameraDriver.Save(capturedPhoto, ApplicationData.Current.TemporaryFolder);

            var imageAnalyzer = new ImageAnalyzer(AppConfiguration.VisionApiSubscriptionKey, AppConfiguration.VisionApiEndPoint);
            var imageAnalysis = await imageAnalyzer.Describe(storageFile);

            var description = GetDescription(imageAnalysis);

            return(description);
        }
コード例 #14
0
ファイル: CameraDriver.cs プロジェクト: zr3/crankship-courier
 public static void SetSceenShake(float amount)
 {
     if (!instance)
     {
         instance = GameObject.FindWithTag("MainCamera").GetComponent <CameraDriver>();
         if (!instance)
         {
             return;
         }
     }
     if (amount > instance.shakeAmount)
     {
         instance.shakeAmount = amount;
     }
 }
コード例 #15
0
 public IndoorController()
 {
     CamDriver = new CameraDriver();
     ImgP      = new ImageProcessor();
     SoundP    = new SoundProcessor();
 }
コード例 #16
0
 public IndoorCamFacade()
 {
     ImgP      = new ImageProcessor();
     SoundP    = new SoundProcessor();
     CamDriver = new CameraDriver();
 }
コード例 #17
0
        public void Update()
        {
            if (LongEventHandler.ShouldWaitForEvent)
            {
                return;
            }
            if (Find.World == null)
            {
                MyCamera.gameObject.SetActive(value: false);
                return;
            }
            if (!Find.WorldInterface.everReset)
            {
                Find.WorldInterface.Reset();
            }
            Vector2 lhs = CalculateCurInputDollyVect();

            if (lhs != Vector2.zero)
            {
                float d = (altitude - 125f) / 975f * 0.85f + 0.15f;
                rotationVelocity = new Vector2(lhs.x, lhs.y) * d;
            }
            if (!Input.GetMouseButton(2) && dragTimeStamps.Any())
            {
                rotationVelocity += CameraDriver.GetExtraVelocityFromReleasingDragButton(dragTimeStamps, 5f);
                dragTimeStamps.Clear();
            }
            if (!AnythingPreventsCameraMotion)
            {
                float num = Time.deltaTime * CameraDriver.HitchReduceFactor;
                sphereRotation *= Quaternion.AngleAxis(rotationVelocity.x * num * config.rotationSpeedScale, MyCamera.transform.up);
                sphereRotation *= Quaternion.AngleAxis((0f - rotationVelocity.y) * num * config.rotationSpeedScale, MyCamera.transform.right);
                if (desiredRotationRaw != Vector2.zero)
                {
                    sphereRotation *= Quaternion.AngleAxis(desiredRotationRaw.x, MyCamera.transform.up);
                    sphereRotation *= Quaternion.AngleAxis(0f - desiredRotationRaw.y, MyCamera.transform.right);
                }
                dragTimeStamps.Add(new CameraDriver.DragTimeStamp
                {
                    posDelta = desiredRotationRaw,
                    time     = Time.time
                });
            }
            desiredRotationRaw = Vector2.zero;
            int num2 = Gen.FixedTimeStepUpdate(ref fixedTimeStepBuffer, 60f);

            for (int i = 0; i < num2; i++)
            {
                if (rotationVelocity != Vector2.zero)
                {
                    rotationVelocity *= config.camRotationDecayFactor;
                    if (rotationVelocity.magnitude < 0.05f)
                    {
                        rotationVelocity = Vector2.zero;
                    }
                }
                if (config.smoothZoom)
                {
                    float num3 = Mathf.Lerp(altitude, desiredAltitude, 0.05f);
                    desiredAltitude += (num3 - altitude) * config.zoomPreserveFactor;
                    altitude         = num3;
                }
                else
                {
                    float num4 = (desiredAltitude - altitude) * 0.4f;
                    desiredAltitude += config.zoomPreserveFactor * num4;
                    altitude        += num4;
                }
            }
            rotationAnimation_lerpFactor += Time.deltaTime * 8f;
            if (Find.PlaySettings.lockNorthUp)
            {
                RotateSoNorthIsUp(interpolate: false);
                ClampXRotation(ref sphereRotation);
            }
            for (int j = 0; j < num2; j++)
            {
                config.ConfigFixedUpdate_60(ref rotationVelocity);
            }
            ApplyPositionToGameObject();
        }
コード例 #18
0
ファイル: CameraDriver.cs プロジェクト: zr3/crankship-courier
 private void Start()
 {
     instance = this;
 }
コード例 #19
0
        private IEnumerator DoRendering(bool forceRenderFullMap = false)
        {
            yield return(new WaitForFixedUpdate());

            if (Rendering)
            {
                Log.Error("Progress Renderer is still rendering an image while a new rendering was requested. This can lead to missing or wrong data. (This can also happen in rare situations when you trigger manual rendering the exact same time as an automatic rendering happens. If you did that, just check your export folder if both renderings were done corrently and ignore this error.)");
            }
            Rendering = true;

            // Temporary switch to this map for rendering
            bool switchedMap   = false;
            Map  rememberedMap = Find.CurrentMap;

            if (map != rememberedMap)
            {
                switchedMap             = true;
                Current.Game.CurrentMap = map;
            }

            // Close world view if needed
            bool rememberedWorldRendered = WorldRendererUtility.WorldRenderedNow;

            if (rememberedWorldRendered)
            {
                CameraJumper.TryHideWorld();
            }

            // Calculate rendered area
            float startX = 0;
            float startZ = 0;
            float endX   = map.Size.x;
            float endZ   = map.Size.z;

            if (!forceRenderFullMap)
            {
                List <Designation> cornerMarkers = map.designationManager.allDesignations.FindAll(des => des.def == DesignationDefOf.CornerMarker);
                if (cornerMarkers.Count > 1)
                {
                    startX = endX;
                    startZ = endZ;
                    endX   = 0;
                    endZ   = 0;
                    foreach (Designation des in cornerMarkers)
                    {
                        IntVec3 cell = des.target.Cell;
                        if (cell.x < startX)
                        {
                            startX = cell.x;
                        }
                        if (cell.z < startZ)
                        {
                            startZ = cell.z;
                        }
                        if (cell.x > endX)
                        {
                            endX = cell.x;
                        }
                        if (cell.z > endZ)
                        {
                            endZ = cell.z;
                        }
                    }
                    endX += 1;
                    endZ += 1;
                }
            }

            // Only use smoothing when rendering was not triggered manually
            if (!manuallyTriggered)
            {
                // Test if target render area changed to reset smoothing
                if (rsTargetStartX != startX || rsTargetStartZ != startZ || rsTargetEndX != endX || rsTargetEndZ != endZ)
                {
                    // Check if area was manually reset or uninitialized (-1) to not smooth
                    if (rsTargetStartX == -1f && rsTargetStartZ == -1f && rsTargetEndX == -1f && rsTargetEndZ == -1f)
                    {
                        rsCurrentPosition = 1f;
                    }
                    else
                    {
                        rsCurrentPosition = 1f / (PRModSettings.smoothRenderAreaSteps + 1);
                    }
                    rsOldStartX    = rsTargetStartX;
                    rsOldStartZ    = rsTargetStartZ;
                    rsOldEndX      = rsTargetEndX;
                    rsOldEndZ      = rsTargetEndZ;
                    rsTargetStartX = startX;
                    rsTargetStartZ = startZ;
                    rsTargetEndX   = endX;
                    rsTargetEndZ   = endZ;
                }
                // Apply smoothing to render area
                if (rsCurrentPosition < 1f)
                {
                    startX             = rsOldStartX + (rsTargetStartX - rsOldStartX) * rsCurrentPosition;
                    startZ             = rsOldStartZ + (rsTargetStartZ - rsOldStartZ) * rsCurrentPosition;
                    endX               = rsOldEndX + (rsTargetEndX - rsOldEndX) * rsCurrentPosition;
                    endZ               = rsOldEndZ + (rsTargetEndZ - rsOldEndZ) * rsCurrentPosition;
                    rsCurrentPosition += 1f / (PRModSettings.smoothRenderAreaSteps + 1);
                }
            }

            float distX = endX - startX;
            float distZ = endZ - startZ;

            // Calculate basic values that are used for rendering
            int imageWidth;
            int imageHeight;

            if (PRModSettings.scaleOutputImage)
            {
                imageHeight = PRModSettings.outputImageFixedHeight;
                imageWidth  = (int)((float)imageHeight / distZ * distX);
            }
            else
            {
                imageWidth  = (int)(distX * PRModSettings.pixelPerCell);
                imageHeight = (int)(distZ * PRModSettings.pixelPerCell);
            }

            int renderCountX = (int)Math.Ceiling((float)imageWidth / RenderTextureSize);
            int renderCountZ = (int)Math.Ceiling((float)imageHeight / RenderTextureSize);
            int renderWidth  = (int)Math.Ceiling((float)imageWidth / renderCountX);
            int renderHeight = (int)Math.Ceiling((float)imageHeight / renderCountZ);

            float cameraPosX       = (float)distX / 2 / renderCountX;
            float cameraPosZ       = (float)distZ / 2 / renderCountZ;
            float orthographicSize = Math.Min(cameraPosX, cameraPosZ);

            orthographicSize = cameraPosZ;
            Vector3 cameraBasePos = new Vector3(cameraPosX, 15f + (orthographicSize - 11f) / 49f * 50f, cameraPosZ);

            RenderTexture renderTexture = RenderTexture.GetTemporary(renderWidth, renderHeight, 24);

            imageTexture = new Texture2D(imageWidth, imageHeight, TextureFormat.RGB24, false);

            Camera       camera    = Find.Camera;
            CameraDriver camDriver = camera.GetComponent <CameraDriver>();

            camDriver.enabled = false;

            // Store current camera data
            Vector3 rememberedRootPos      = map.rememberedCameraPos.rootPos;
            float   rememberedRootSize     = map.rememberedCameraPos.rootSize;
            float   rememberedFarClipPlane = camera.farClipPlane;

            // Overwrite current view rect in the camera driver
            CellRect camViewRect       = camDriver.CurrentViewRect;
            int      camRectMinX       = Math.Min((int)startX, camViewRect.minX);
            int      camRectMinZ       = Math.Min((int)startZ, camViewRect.minZ);
            int      camRectMaxX       = Math.Max((int)Math.Ceiling(endX), camViewRect.maxX);
            int      camRectMaxZ       = Math.Max((int)Math.Ceiling(endZ), camViewRect.maxZ);
            Traverse camDriverTraverse = Traverse.Create(camDriver);

            camDriverTraverse.Field("lastViewRect").SetValue(CellRect.FromLimits(camRectMinX, camRectMinZ, camRectMaxX, camRectMaxZ));
            camDriverTraverse.Field("lastViewRectGetFrame").SetValue(Time.frameCount);
            yield return(new WaitForEndOfFrame());

            // Set camera values needed for rendering
            camera.orthographicSize = orthographicSize;
            camera.farClipPlane     = cameraBasePos.y + 6.5f;

            // Create a temporary camera for rendering

            /*Camera tmpCam = Camera.Instantiate(camera);
             * tmpCam.orthographicSize = orthographicSize;
             * tmpCam.farClipPlane = cameraPos.y + 6.5f;*/

            // Set render textures
            //tmpCam.targetTexture = renderTexture;
            camera.targetTexture = renderTexture;
            RenderTexture.active = renderTexture;

            // Render the image texture
            try
            {
                if (PRModSettings.renderWeather)
                {
                    map.weatherManager.DrawAllWeather();
                }
                for (int i = 0; i < renderCountZ; i++)
                {
                    for (int j = 0; j < renderCountX; j++)
                    {
                        camera.transform.position = new Vector3(startX + cameraBasePos.x * (2 * j + 1), cameraBasePos.y, startZ + cameraBasePos.z * (2 * i + 1));
                        camera.Render();
                        imageTexture.ReadPixels(new Rect(0, 0, renderWidth, renderHeight), renderWidth * j, renderHeight * i, false);
                    }
                }
            } catch (Exception e)
            {
                Log.Error(e.Message, true);
            }

            // Restore camera and viewport
            RenderTexture.active = null;
            //tmpCam.targetTexture = null;
            camera.targetTexture = null;
            camera.farClipPlane  = rememberedFarClipPlane;
            camDriver.SetRootPosAndSize(rememberedRootPos, rememberedRootSize);
            camDriver.enabled = true;

            RenderTexture.ReleaseTemporary(renderTexture);

            // Switch back to world view if needed
            if (rememberedWorldRendered)
            {
                CameraJumper.TryShowWorld();
            }

            // Switch back to remembered map if needed
            if (switchedMap)
            {
                Current.Game.CurrentMap = rememberedMap;
            }

            // Sinal finished rendering
            Rendering = false;
            yield return(null);

            // Start encoding
            DoEncoding();

            yield break;
        }
コード例 #20
0
 public static void Prefix(CameraDriver __instance)
 {
     __instance.SetMouseDrag(Vector2.zero);
 }
コード例 #21
0
 public static void SetMouseDrag(this CameraDriver driver, Vector2 val) => mouseDragInfo.SetValue(driver, val);
コード例 #22
0
 public static Vector2 MouseDrag(this CameraDriver driver) => (Vector2)mouseDragInfo.GetValue(driver);
コード例 #23
0
ファイル: CameraDriver_Patch.cs プロジェクト: kbatbouta/Soyuz
 public static void Postfix(CameraDriver __instance)
 {
     Context.zoomRange = __instance.CurrentZoom;
     Context.curViewRect = __instance.CurrentViewRect;
     if (Finder.debug && Finder.statLogging) Log.Message($"SOYUZ: Zoom range is {Context.zoomRange}");
 }