Esempio n. 1
0
        private void updateSimulation()
        {
            CameraSetting nearestcameraSetting = cameraPath.getNearestCameraSetting(proxyPosition);

            if (nearestcameraSetting != null)
            {
                simulatedCameraSetting = nearestcameraSetting;
            }
        }
Esempio n. 2
0
        public CameraSetting(CameraSetting setting)
        {
            cameraTarget = setting.cameraTarget;

            smoothTime     = setting.smoothTime;
            scale          = setting.scale;
            positionOffset = setting.positionOffset;
            rotationOffset = setting.rotationOffset;
            min            = setting.min;
            max            = setting.max;
        }
Esempio n. 3
0
        public void updateSetting()
        {
            if (isSettingLocked || !proxyObject)
            {
                return;
            }

            CameraSetting nearestcameraSetting = CameraPath.shared().getNearestCameraSetting(proxyObject.position);

            if (nearestcameraSetting != null)
            {
                currentSetting = nearestcameraSetting;
            }
        }
Esempio n. 4
0
        public CameraSetting getNearestCameraSetting(Vector3 position)
        {
            lastNearestNode = null;
            lastNearestEdge = null;

            // Find Volume Node first
            for (int i = 0; i < nodes.Length; i++)
            {
                CameraPathNode node = nodes[i];
                if (node.enabled && node.gameObject.activeInHierarchy && node.type == CameraPathNode.CameraPathNodeType.Volume)
                {
                    if (node.isInside(position))
                    {
                        lastNearestNode = node;
                        return(new CameraSetting(node.cameraSetting));
                    }
                }
            }

            float minDist = float.MaxValue;
            float ratio   = 0;

            for (int i = 0; i < edges.Length; i++)
            {
                CameraPathEdge edge = edges[i];
                if (edge.n1 != null && edge.n2 != null)
                {
                    float dist;
                    float r;
                    if (edge.project(position, out r, out dist))
                    {
                        if (dist < minDist)
                        {
                            minDist         = dist;
                            ratio           = r;
                            lastNearestEdge = edge;
                        }
                    }
                }
            }
            if (lastNearestEdge)
            {
                return(CameraSetting.Lerp(lastNearestEdge.n1.cameraSetting, lastNearestEdge.n2.cameraSetting, lastNearestEdge.weight.Evaluate(ratio)));
            }

            minDist = float.MaxValue;
            for (int i = 0; i < nodes.Length; i++)
            {
                CameraPathNode node = nodes[i];
                if (node.enabled && node.gameObject.activeInHierarchy && node.type == CameraPathNode.CameraPathNodeType.Point)
                {
                    float dist = Vector3.Distance(position, node.transform.position);
                    if (dist < minDist)
                    {
                        minDist         = dist;
                        lastNearestNode = node;
                    }
                }
            }
            if (lastNearestNode)
            {
                return(new CameraSetting(lastNearestNode.cameraSetting));
            }

            return(null);
        }
Esempio n. 5
0
        public static CameraSetting Lerp(CameraSetting a, CameraSetting b, float t)
        {
            CameraSetting newCameraSetting = new CameraSetting();

            if (t < 0.5f)
            {
                newCameraSetting.cameraTarget = a.cameraTarget;
            }
            else
            {
                newCameraSetting.cameraTarget = b.cameraTarget;
            }

            newCameraSetting.smoothTime     = Mathf.Lerp(a.smoothTime, b.smoothTime, t);
            newCameraSetting.scale          = Mathf.Lerp(a.scale, b.scale, t);
            newCameraSetting.positionOffset = Vector3.Lerp(a.positionOffset, b.positionOffset, t);
            newCameraSetting.rotationOffset = Vector3.Lerp(a.rotationOffset, b.rotationOffset, t);

            if (!float.IsNegativeInfinity(a.min.x) && !float.IsNegativeInfinity(b.min.x))
            {
                newCameraSetting.min.x = Mathf.Lerp(a.min.x, b.min.x, t);
            }
            else if (t < 0.5f)
            {
                newCameraSetting.min.x = a.min.x;
            }
            else
            {
                newCameraSetting.min.x = b.min.x;
            }

            if (!float.IsNegativeInfinity(a.min.y) && !float.IsNegativeInfinity(b.min.y))
            {
                newCameraSetting.min.y = Mathf.Lerp(a.min.y, b.min.y, t);
            }
            else if (t < 0.5f)
            {
                newCameraSetting.min.y = a.min.y;
            }
            else
            {
                newCameraSetting.min.y = b.min.y;
            }

            if (!float.IsNegativeInfinity(a.min.z) && !float.IsNegativeInfinity(b.min.z))
            {
                newCameraSetting.min.z = Mathf.Lerp(a.min.z, b.min.z, t);
            }
            else if (t < 0.5f)
            {
                newCameraSetting.min.z = a.min.z;
            }
            else
            {
                newCameraSetting.min.z = b.min.z;
            }

            if (!float.IsPositiveInfinity(a.max.x) && !float.IsPositiveInfinity(b.max.x))
            {
                newCameraSetting.max.x = Mathf.Lerp(a.max.x, b.max.x, t);
            }
            else if (t < 0.5f)
            {
                newCameraSetting.max.x = a.max.x;
            }
            else
            {
                newCameraSetting.max.x = b.max.x;
            }

            if (!float.IsPositiveInfinity(a.max.y) && !float.IsPositiveInfinity(b.max.y))
            {
                newCameraSetting.max.y = Mathf.Lerp(a.max.y, b.max.y, t);
            }
            else if (t < 0.5f)
            {
                newCameraSetting.max.y = a.max.y;
            }
            else
            {
                newCameraSetting.max.y = b.max.y;
            }

            if (!float.IsPositiveInfinity(a.max.z) && !float.IsPositiveInfinity(b.max.z))
            {
                newCameraSetting.max.z = Mathf.Lerp(a.max.z, b.max.z, t);
            }
            else if (t < 0.5f)
            {
                newCameraSetting.max.z = a.max.z;
            }
            else
            {
                newCameraSetting.max.z = b.max.z;
            }

            return(newCameraSetting);
        }