public void UpdateCamera(Camera camera) { if (camera == null) { return; } bool isMainCam = camera.CompareTag("MainCamera"); var trans = camera.transform; this.Position = trans.position; this.LookAt = trans.forward; this.Up = trans.up; this.IsMainCamera = isMainCam; this.Depth = (int)camera.depth; if (camera.orthographic) { OCameraInfo info = OCameraInfo.Create(); info.Size = camera.orthographicSize; info.nearPlane = camera.nearClipPlane; info.farPlane = camera.farClipPlane; this.SetOCamera(info); } else { PCameraInfo info = PCameraInfo.Create(); info.nearPlane = camera.nearClipPlane; info.farPlane = camera.farClipPlane; info.fieldOfView = camera.fieldOfView; this.SetPCamera(info); } }
public static PCameraInfo Create() { PCameraInfo ret = new PCameraInfo(); ret.ResetDefault(); return(ret); }
private static bool Compare(PCameraInfo f1, PCameraInfo f2) { bool ret = SoftMath.FloatEqual(f1.fieldOfView, f2.fieldOfView) && SoftMath.FloatEqual(f1.nearPlane, f2.nearPlane) && SoftMath.FloatEqual(f1.farPlane, f2.farPlane); return(ret); }
// 添加UNITY摄影机 public SoftCamera AddCamera(UnityEngine.Camera cam) { if (cam != null) { bool isMainCamera = cam.CompareTag("MainCamera"); if (cam.orthographic) { OCameraInfo info = OCameraInfo.Create(); info.Size = cam.orthographicSize; info.nearPlane = cam.nearClipPlane; info.farPlane = cam.farClipPlane; var trans = cam.transform; return(AddOCamera(info, trans.position, trans.up, trans.forward, (int)cam.depth, isMainCamera)); } else { PCameraInfo info = PCameraInfo.Create(); info.nearPlane = cam.nearClipPlane; info.farPlane = cam.farClipPlane; info.fieldOfView = cam.fieldOfView; var trans = cam.transform; return(AddPCamera(info, trans.position, trans.up, trans.forward, (int)cam.depth, isMainCamera)); } } return(null); }
public void SetPCamera(PCameraInfo info) { if (m_PCameraInfo != info) { m_PCameraInfo = info; this.CameraType = SoftCameraType.P; DoMustUpdatePlanes(); DoMustGlobalToLocalMatrixChg(); } }
public SoftCamera AddPCamera(PCameraInfo info, Vector3 pos, Vector3 up, Vector3 lookAt, int depth, bool isMainCamera = false) { SoftCamera cam = new SoftCamera(this); cam.Position = pos; cam.Up = up; cam.LookAt = lookAt; cam.Depth = depth; cam.SetPCamera(info); if (AddCamera(cam)) { cam.IsMainCamera = isMainCamera; return(cam); } return(null); }