示例#1
0
        public void SetupLandmark(ILandmarkController landmark)
        {
            // Use MARS session camera as the default target for "closest" landmark
            if (landmark.landmarkDefinition.GetEnumName <BasicPolygonLandmarks>() == BasicPolygonLandmarks.Closest)
            {
                var settings = landmark.settings as ClosestLandmarkSettings;
                if (settings != null)
                {
                    if (settings.target != null)
                    {
                        return;
                    }

                    var sessionCamera = MarsRuntimeUtils.GetSessionAssociatedCamera();
                    if (sessionCamera != null)
                    {
                        settings.target = sessionCamera.transform;
                    }
                }
                else
                {
                    Debug.LogError("Closest landmark is missing valid settings component", gameObject);
                }
            }
        }
        static void ScaleClippingPlanes(float scaleFactor)
        {
            // Need to modify the clip planes of the mars session camera in the main scene as we scale the camera parent
            var camera = MarsRuntimeUtils.GetSessionAssociatedCamera();

            Undo.RecordObject(camera, "WorldScale");
            camera.nearClipPlane *= scaleFactor;
            camera.farClipPlane  *= scaleFactor;
        }
        static ProxyForces EditorEnsureCameraProxy()
        {
            var cam = MarsRuntimeUtils.GetSessionAssociatedCamera(true);

            if (cam == null)
            {
                return(null);
            }

            var proxy = cam.GetComponent <ProxyForces>();

            if (proxy)
            {
                return(proxy);
            }

            proxy = cam.GetComponentInChildren <ProxyForces>();
            if (proxy)
            {
                return(proxy);
            }

            var gm = new GameObject {
                name = "MainCameraProxy"
            };

            gm.transform.parent        = cam.transform;
            gm.transform.localPosition = Vector3.zero;
            gm.transform.localRotation = Quaternion.identity;
            gm.transform.localScale    = Vector3.one;
            Undo.RegisterCreatedObjectUndo(gm, gm.name);
            proxy = Undo.AddComponent <ProxyForces>(gm);
            proxy.allowedMotion   = ProxyForceMotionType.NotForced;
            proxy.continuousSolve = true;
            AfterConfiguredComponent(proxy);

            return(proxy);
        }