public static void SetCamera(CameraLocation camera, bool isPlayerInvisible) { Vector3 position = new Vector3(); Vector3 rotation = new Vector3(); if (camera == CameraLocation.DesertGarage) { //position = ; MoveCamera( Garage.DesertGarageCameraPosition, out position, Garage.DesertGarageCameraRotation, out rotation ); } if (isPlayerInvisible) { Game.Player.CanControlCharacter = false; Game.Player.IgnoredByEveryone = true; Game.Player.IsInvincible = true; } // Teleport player to load world CurrentCamera = World.CreateCamera(position, rotation, 90.0f); World.RenderingCamera = CurrentCamera; }
private void PositionCamera(CameraLocation loc) { switch (loc) { case CameraLocation.LEFT: m_objectCam.transform.localPosition = m_leftPos * Distance; m_objectCam.transform.localRotation = Quaternion.Euler(m_leftRot); break; case CameraLocation.RIGHT: m_objectCam.transform.localPosition = m_rightPos * Distance; m_objectCam.transform.localRotation = Quaternion.Euler(m_rightRot); break; case CameraLocation.TOP: m_objectCam.transform.localPosition = m_topPos * Distance; m_objectCam.transform.localRotation = Quaternion.Euler(m_topRot); break; case CameraLocation.BACK: m_objectCam.transform.localPosition = m_backPos * Distance; m_objectCam.transform.localRotation = Quaternion.Euler(m_backRot); break; } }
public Camera() { this.SetUpVector(Vector3.Up); this.SetNearPlaneDistance(1.0f); this.SetFarPlaneDistance(100.0f); allowableCameraPositions = new Vector3[4]; _ringPosition = new Vector3(_cameraBoxSize, _cameraBoxSize, -_cameraBoxSize); // Velocities _turnSpeed = MathHelper.ToRadians((float)(45.0 / (60.0 / 4.0))); _turnMatrix = Matrix.CreateRotationY(_turnSpeed); _moveSpeed = (float)(10.0 / 60.0); _zoomSpeed = (float)(10.0 / 60.0); _futureCameraLocation = _currentCameraLocation = CameraLocation.LowerLeft; _currentTarget = new Vector3(0, 0, 0); _futureTarget = new Vector3(0, 0, 0); _currentPosition = new Vector3(8, 8, 8); _futurePosition = new Vector3(8, 8, 8); this._isAcceptingCommands = true; calculateCameraBox(_currentTarget); _currentPosition = _currentTarget + _ringPosition; calculateRelativeDirectionOffset(); recalculateProjectionMatrix(); recalculateViewMatrix(); }
/// <summary> /// Move the CombatCamera to another location /// </summary> /// <param name="goRight">When true, camera will shift to the right. False for left</param> public void MoveCamera(bool goRight) { // Only allow a camera move if the camera is stationary if (!isMoving) { if (!goRight) { if (_currentLocation == CameraLocation.RowMaxColZero3) _preferedLocation = CameraLocation.RowZeroColZero0; else _preferedLocation++; } else { if (_currentLocation == CameraLocation.RowZeroColZero0) _preferedLocation = CameraLocation.RowMaxColZero3; else _preferedLocation--; } _preferedPosition = _validCameraLocations[(int)_preferedLocation]; isMoving = true; Debug.LogFormat("Prefered location set: {0} at {1}", _preferedLocation, _preferedPosition); Debug.LogFormat("Pref: {0} / Curr: {1}", _preferedLocation, _currentLocation); } }
/// <summary> /// Load the list of Project Files for Recipe /// </summary> public void LoadRecipe(string fileName, CameraLocation cameraLocation) { ToolBlockFileName = fileName; if (System.IO.File.Exists(ToolBlockFileName)) { // upper as index 0 this.cogToolRun = CogSerializer.LoadObjectFromFile(fileName) as CogToolBlock; this.cogToolRun.Name = Path.GetFileNameWithoutExtension(fileName); } else { switch (cameraLocation) { case CameraLocation.InputStation: Seagate.AAS.Parsel.Equipment.Machine.DisplayStartupError(string.Format("Failed to load vision recipe file for input station camera: [{0}]", fileName)); break; case CameraLocation.PrecisorStation: Seagate.AAS.Parsel.Equipment.Machine.DisplayStartupError(string.Format("Failed to load vision recipe file for precisor station camera: [{0}]", fileName)); break; case CameraLocation.OutputStation: Seagate.AAS.Parsel.Equipment.Machine.DisplayStartupError(string.Format("Failed to load vision recipe file for output station camera: [{0}]", fileName)); break; } } }
void Start() { currentLocation = new CameraLocation(0f, 0f, -10f, 5f); previousLocation = currentLocation; instance = this; GetComponent <Camera>().orthographicSize = 5; }
// Skips to the current goto position and starts the next one public void SkipToNextPosition() { // If there's no position left to goto if (gotoPositions_.Count <= 0) { // Stop moving camera isMoving_ = false; finishedMovement_ = true; } else { // Calculate the new move direction, rotation direction and rotation speed // Calculate direction from current position and next goto position Vector3 moveDirection = gotoPositions_.Peek().position_ - transform.position; moveDirection.Normalize(); // Calculate rotation direction from current rotation and new goto rotation Vector3 rotationDirection = gotoPositions_.Peek().rotation_ - transform.rotation.eulerAngles; rotationDirection.Normalize(); // Calculate the speed of the rotation based on the amount of time taken to move to the next location float time = ((gotoPositions_.Peek().position_ - transform.position) / gotoPositions_.Peek().moveSpeed_).magnitude; float rotationSpeed = (gotoPositions_.Peek().rotation_ - transform.rotation.eulerAngles).magnitude / time; // Set the current goto position to the next one in the queue currentGotoPosition_ = gotoPositions_.Dequeue(); // Set the new directions and rotation speed to the new current goto position currentGotoPosition_.moveDirection_ = moveDirection; currentGotoPosition_.rotationDirection_ = rotationDirection; currentGotoPosition_.rotationSpeed_ = rotationSpeed; } }
// Use this for initialization void Start() { // Set the last location added to the queue to the cameras current position isMoving_ = false; finishedMovement_ = true; lastLocation_ = new CameraLocation(transform.position, transform.rotation.eulerAngles, defaultSpeed_, new Vector3(0, 0, 0), new Vector3(0, 0, 0), 0); gotoPositions_ = new Queue <CameraLocation>(); }
void Update() { if (previousLocation.changeLocation(currentLocation, instance)) { previousLocation = currentLocation; } GetComponent <Camera>().orthographicSize = currentSize; }
/// <summary> /// Camera location has changed /// </summary> public virtual void OnCameraLocationChanged(CameraLocation newCameraLocation) { // Note, this call is called on some IPC thread - dispatch to the UI thread before doing anything else Debug.WriteLine("[BaseViewModel] OnCameraLocationChanged. New location = {0}", newCameraLocation); this.Page.Dispatcher.BeginInvoke(() => { // Update the base cached copy this.cameraLocation = newCameraLocation; }); }
void CameraLocationValueChanged(object sender, RoutedPropertyChangedEventArgs <double> e) { if (!isConnected) { return; } CameraLocation cl = new CameraLocation(); cl.angle = (int)camLocSlider.Value; cl.id = PacketHandler.FrontCameraID; logger.Write(LoggerLevel.Info, "Setting front cam to angle " + cl.angle); byte[] buffer = handler.GetSetCameraLocationPacket(cl); packetSocket.Send(buffer, buffer.Length, robotPacketEndpoint); }
public async Task <Stream> TakePhoto(CameraLocation cameraLocation, int maxSize, int quality = 50) { try { StoreCameraMediaOptions cameraOptions = new StoreCameraMediaOptions(); cameraOptions.AllowCropping = true; cameraOptions.PhotoSize = PhotoSize.MaxWidthHeight; cameraOptions.MaxWidthHeight = Math.Max(0, maxSize); cameraOptions.CompressionQuality = Math.Min(Math.Max(quality, 0), 100); cameraOptions.DefaultCamera = cameraLocation == CameraLocation.FRONT ? CameraDevice.Front : CameraDevice.Rear; MediaFile file = await CrossMedia.Current.TakePhotoAsync(cameraOptions); return(file == null ? null : file.GetStream()); } catch (MediaPermissionException ex) { return(null); } }
// Method for going to next movement in the move queue private void GotoNextPosition() { // Set the camera position and rotation to the end of the last movement transform.position = currentGotoPosition_.position_; transform.eulerAngles = currentGotoPosition_.rotation_; // If there's no positions left to goto if (gotoPositions_.Count <= 0) { // Stop moving camera isMoving_ = false; finishedMovement_ = true; } else { // Set next goto position currentGotoPosition_ = gotoPositions_.Dequeue(); } }
// Adds a new Goto position to the goto position queue public void AddGotoPosition(Vector3 newPos, Vector3 newRot, bool startMoving = false) { // Calculate the new move direction, rotation direction and rotation speed from the new position/rotation // And the last location added to the queue // Calculate move direction Vector3 moveDirection = newPos - lastLocation_.position_; moveDirection.Normalize(); // Calculate rotation direction Vector3 rotationDirection = newRot - lastLocation_.rotation_; rotationDirection.Normalize(); // Calculate the speed of the rotation based on the amount of time taken to move to the next location float time = ((newPos - lastLocation_.position_) / defaultSpeed_).magnitude; float rotationSpeed = (newRot - lastLocation_.rotation_).magnitude / time; // Create the struct for the new location CameraLocation newLocation = new CameraLocation(newPos, newRot, defaultSpeed_, moveDirection, rotationDirection, rotationSpeed); // If the camera has no movements to do if (finishedMovement_) { // Set current goto to the new location currentGotoPosition_ = newLocation; } else { // Add new location to goto queue gotoPositions_.Enqueue(newLocation); } // Set isMoving bool isMoving_ = startMoving; // New movement added so camera cannot have finished movement finishedMovement_ = false; lastLocation_ = newLocation; }
public bool changeLocation(CameraLocation pos, CameraPos camera) { if (!pos.Equals(this)) { frameCount++; double posDiff = frameCount / ZOOM_RATE; float newX = (float)(this.x - ((this.x - pos.x) * posDiff)); float newY = (float)(this.y - ((this.y - pos.y) * posDiff)); float newZ = (float)(this.z - ((this.z - pos.z) * posDiff)); float newSize = (float)(this.size - ((this.size - pos.size) * posDiff)); camera.transform.position = new Vector3(newX, newY, newZ); camera.currentSize = newSize; if (frameCount % ZOOM_RATE == 0) { frameCount = 0; return(true); } } return(false); }
public void PrevCameraView() { if (_isAcceptingCommands) { _isAcceptingCommands = false; } else { return; } int temp = (int)_currentCameraLocation; temp--; temp += Camera.NUM_CAMERA_LOCATIONS; temp %= Camera.NUM_CAMERA_LOCATIONS; _futureCameraLocation = (CameraLocation)temp; _futurePosition = allowableCameraPositions[(int)_futureCameraLocation]; _turnMatrix = Matrix.CreateRotationY(-_turnSpeed); }
void OnValidate() { if (Load == true) { if (Filename.Equals(string.Empty)) { Filename = defaultFilename; } CameraLocation camLoc = CameraLocation.Load(Constants.Folders.CameraLocationFolderPath + Constants.Names.CameraLocationAutoName + Filename + Constants.Suffixes.FileSuffix_CameraLocation); // ERROR TESTING REMOVE //CameraLocation camLoc = CameraLocation.Load(Constants.Folders.CameraLocationFolderPath + "Debug_CamLoc" + Constants.Suffixes.FileSuffix_CameraLocation); WorldToCamera = camLoc.WorldToCameraTransform; ProjectionMatrix = camLoc.ProjectionTransform; NearClipPlane = camLoc.NearClipPlane; FarClipPlane = camLoc.FarClipPlane; Load = false; } }
void FixedUpdate() { if (Texture != null && !Texture.name.Equals(lastTextureLoaded)) { if (tempObj != null) { Destroy(tempObj); } lastTextureLoaded = Texture.name; #if UNITY_EDITOR string textureFilePath = AssetDatabase.GetAssetPath(Texture); #else // ERROR TESTING - THIS IS A PRETTY HEFTY ASSUMPTION, BUT THIS SHOULDN'T EVEN BE USED OUTSIDE OF THE EDITOR ANYWAYS string textureFilePath = Constants.Folders.ClippedRoomTextureFolderPath + Texture.name + Constants.Suffixes.FileSuffix_PNG; #endif Texture.wrapMode = TextureWrapMode.Clamp; tempObj = new GameObject(); tempObj.name = "Temp Projector Object"; if (!CameraLocationFileName.Equals(string.Empty) && lastCameraLoadedName.Equals(CameraLocationFileName)) { lastCameraLoadedName = CameraLocationFileName; lastCameraLoaded = CameraLocation.Load(CameraLocationFileName); TextureProjector.GenerateProjector(tempObj, CameraLocationFileName, textureFilePath); } else { Projector proj = tempObj.AddComponent <Projector>(); proj.material = MaterialMaker.GenerateRoomMaterial(Texture); } } }
public void Update(GameTime gameTime) { if (_currentCameraLocation != _futureCameraLocation) { rotateAlongRing(); if (_currentPosition.AlmostEquals(_futurePosition, _turnSpeed)) { _currentCameraLocation = _futureCameraLocation; _currentPosition = this.allowableCameraPositions[(int)_currentCameraLocation]; calculateRelativeDirectionOffset(); _isAcceptingCommands = true; } } else if (_currentTarget != _futureTarget) { moveSmoothly(); if (_currentTarget.AlmostEquals(_futureTarget, _moveSpeed)) { _currentTarget = _futureTarget; _currentPosition = this.allowableCameraPositions[(int)_currentCameraLocation]; _isAcceptingCommands = true; } } else if (_cameraBoxSize != _futureCameraBoxSize) { zoomSmoothly(); if (_cameraBoxSize.AlmostEquals(_futureCameraBoxSize, _zoomSpeed)) { _currentPosition = this.allowableCameraPositions[(int)_currentCameraLocation]; _cameraBoxSize = _futureCameraBoxSize; _isAcceptingCommands = true; } } recalculateViewMatrix(); recalculateProjectionMatrix(); }
public Feature ToFeature(bool includeSpatialReference = false, int?outSR = null) { return(new Feature { geometry = CameraLocation.ToPoint(includeSpatialReference, outSR), attributes = new { CameraID = CameraID, CameraOwner = CameraOwner, Description = Description, ImageWidth = ImageWidth, ImageHeight = ImageHeight, IsActive = IsActive, OwnerUrl = OwnerUrl, Region = Region, SortOrder = SortOrder, Title = Title, LocationDescription = CameraLocation.Description, RoadName = CameraLocation.RoadName, Direction = CameraLocation.Direction, MilePost = CameraLocation.MilePost } }); }
void OnValidate() { if (Save == true) { CameraLocation camLoc = new CameraLocation(); camLoc.WorldToCameraTransform = WorldToCamera; camLoc.ProjectionTransform = ProjectionMatrix; camLoc.NearClipPlane = NearClipPlane; camLoc.FarClipPlane = FarClipPlane; camLoc.HasLocationData = CameraHasLocationData; if (Filename.Equals(string.Empty)) { Filename = defaultFilename; } CameraLocation.Save(camLoc, Constants.Names.CameraLocationAutoName + Filename); //CameraLocation.Save(camLoc, "Debug_CamLoc"); // ERROR TESTING REMOVE //File.WriteAllText(Constants.Folders.CameraLocationFolderPath + "Debug_CamLoc" + Constants.Suffixes.FileSuffix_CameraLocation, "This is a test"); Save = false; } }
//Must be public public void ChangePos2() { currentLocation = new CameraLocation(0f, 0f, -10f, 5f); }
//Must be public public void ChangePos1() { currentLocation = new CameraLocation(2f, -0.75f, -10f, 2f); }
// Adds a new Goto position to the goto position queue public void AddGotoPosition(CameraGoto newCameraPos) { // Calculate the new move direction, rotation direction and rotation speed from the new position/rotation // And the last location added to the queue Vector3 lastPosition_; Vector3 lastRotation_; if (finishedMovement_) { lastPosition_ = transform.position; lastRotation_ = transform.eulerAngles; } else { lastPosition_ = lastLocation_.position_; lastRotation_ = lastLocation_.rotation_; } // Calculate move direction Vector3 moveDirection = newCameraPos.position_ - lastPosition_; moveDirection.Normalize(); // Calculate rotation direction Vector3 rotationDirection = newCameraPos.rotation_ - lastRotation_; rotationDirection.Normalize(); // Calculate the speed of the rotation based on the amount of time taken to move to the next location float speed = defaultSpeed_; if (newCameraPos.speed_ > 0) { speed = newCameraPos.speed_; } float time = ((newCameraPos.position_ - lastPosition_) / speed).magnitude; float rotationSpeed = (newCameraPos.rotation_ - lastRotation_).magnitude / time; // Create the struct for the new location CameraLocation newLocation = new CameraLocation(newCameraPos.position_, newCameraPos.rotation_, speed, moveDirection, rotationDirection, rotationSpeed); // If the camera has no movements to do if (finishedMovement_) { // Set current goto to the new location currentGotoPosition_ = newLocation; } else { // Add new location to goto queue gotoPositions_.Enqueue(newLocation); } // Set isMoving bool isMoving_ = newCameraPos.startMoving_; // New movement added so camera cannot have finished movement finishedMovement_ = false; lastLocation_ = newLocation; }
// Update is called once per frame void Update() { truckY = truck.transform.eulerAngles.y; //pan camera left and right if (Mathf.Abs(Input.GetAxis("Mouse X" + PlayerNum)) > 0.1f) { scrollY += Input.GetAxis("Mouse X" + PlayerNum) * 3; } //if not panning, return to origional position else { scrollY = scrollY / 1.2f; } //remove asymptote as scrollY approaches 0 if (Mathf.Abs(scrollY) < 0.05) { scrollY = 0; } //swiches camera to right or left side when it passes in front of camera if (Mathf.Abs(scrollY) > 180) { scrollY -= 360 * Mathf.Sign(scrollY); } //pan camera up and down if (Mathf.Abs(Input.GetAxis("Mouse Y" + PlayerNum)) > 0.1f) { scrollX += Input.GetAxis("Mouse Y" + PlayerNum) * 1.5f; } //Debug.Log(cam.transform.localPosition); //Debug.Log(cam.transform.localRotation); //camera views locations and rotations if (Input.GetButtonDown("LeftButton" + PlayerNum)) { switch (location) { case CameraLocation.TopView: cam.transform.localPosition = new Vector3(0.0f, 5.6f, -6.2f); cam.transform.localRotation = new Quaternion(0.27f, 0.0f, 0.0f, 1.0f); location = CameraLocation.DriverView; break; case CameraLocation.DriverView: cam.transform.localPosition = new Vector3(0.0f, -0.5f, 0.75f); cam.transform.localRotation = new Quaternion(0.20f, 0.0f, 0.0f, 1.0f); location = CameraLocation.RearView; break; case CameraLocation.RearView: cam.transform.localPosition = new Vector3(0.1f, 1.85f, 5.0f); cam.transform.localRotation = new Quaternion(0.0f, 1.0f, -0.2f, 0.0f); location = CameraLocation.TopView; break; } } //lock camera rotation transform.eulerAngles = new Vector3(scrollX, truckY + scrollY, 0.0f); }
private void Start() { _camera = GetComponent<Camera>(); _lookAtTargetComponent = GetComponent<LookatTarget>(); _lookAtTargetComponentTarget = _lookAtTargetComponent.Target; // !!! Will get these values from somewhere better, some time... _validCameraLocations[(int)CameraLocation.RowZeroColZero0] = new Vector3(0.0f, cameraHeight, 0.0f); _validCameraLocations[(int)CameraLocation.RowZeroColMax1] = new Vector3(0.0f, cameraHeight, 50.0f); _validCameraLocations[(int)CameraLocation.RowMaxColMax2] = new Vector3(50.0f, cameraHeight, 50.0f); _validCameraLocations[(int)CameraLocation.RowMaxColZero3] = new Vector3(50.0f, cameraHeight, 0.0f); _camera.transform.position = _validCameraLocations[(int)CameraLocation.RowZeroColZero0]; _currentPosition = _camera.transform.position; _preferedPosition = _currentPosition; _currentLocation = CameraLocation.RowZeroColZero0; BakeCurrentLocation(_currentLocation); // Set prefered location to current at the start _preferedLocation = _currentLocation; }
public void SetLocation(CameraLocation loc) { nextIndex = (int)loc; //Debug.Log(nextIndex); }
private void CameraLocation_OnTriggerEnter(On.CameraLocation.orig_OnTriggerEnter orig, CameraLocation self, Collider Col) { if (SceneManager.GetActiveScene().name == "void" && !gotAllPep() && Vector3.Distance(self.transform.position, camPos) < 10f) { cheeseAttempt = true; Manager.Player.GetComponent <PlayerMachine>().transform.position = npcPos; } else { orig(self, Col); } }
/// <summary> /// Sets the previous and next camera locations, based on the input location /// </summary> /// <param name="currentCameraLocation">What the camera location currently is</param> private void BakeCurrentLocation(CameraLocation inputCameraLocation) { _currentLocation = inputCameraLocation; if (_currentLocation == CameraLocation.RowZeroColZero0) _nextLocation = CameraLocation.RowMaxColZero3; else _nextLocation = _currentLocation + 1; if (_currentLocation == CameraLocation.RowZeroColZero0) _prevLocation = CameraLocation.RowMaxColZero3; else _prevLocation = _currentLocation - 1; Debug.LogFormat("Locations Baked! prev:{0} curr:{1} / pref:{2} next:{3}", _prevLocation, _currentLocation, _preferedLocation, _nextLocation); }
private void CameraLocation_OnTriggerExit(On.CameraLocation.orig_OnTriggerExit orig, CameraLocation self, Collider Col) { if (SceneManager.GetActiveScene().name == "void" && !gotAllPep() && Vector3.Distance(self.transform.position, camPos) < 10f) { return; } orig(self, Col); }