Ejemplo n.º 1
0
    public string[] GetNodeNameList()
    {
        List <string> nodeNames = new List <string>();

        for (int i = 0; i < nodeList.Length; i++)
        {
            CameraSplineNode node = nodeList[i];
            nodeNames.Add(node.gameObject.name);
        }
        return(nodeNames.ToArray());
    }
Ejemplo n.º 2
0
	void Update () {
        float iV = Input.GetAxis("Vertical");
        if (iV < 0) {
            farAngleFlag = true;        
        } else if (iV > 0) {
            farAngleFlag = false;
        }
   
        // Vector3 pos = Camera.main.transform.position;
        // pos.z = Crash.S.transform.position.z - offset;
        // pos.y = Crash.S.transform.position.y + 6.0f;
        // pos.x = Crash.S.transform.position.x;
        // Camera.main.transform.position = pos;
        float sectorDistance = Mathf.Abs(currentNode.transform.position.z - currentNode.nextNode.transform.position.z);
        float moveDistance = Mathf.Abs(Crash.S.transform.position.z - currentNode.transform.position.z);
        float movePercentage = moveDistance / sectorDistance;
        followDistance = Mathf.Lerp(currentNode.followDistance, currentNode.nextNode.followDistance, movePercentage);
        
        if (farAngleFlag) {
            offset += tweenSpeed * Time.deltaTime;
            if (offset >= followDistance + backOffset) {
                offset = followDistance + backOffset;
            }
        } else {
            offset -= tweenSpeed * Time.deltaTime;
            if (offset < followDistance) {
                offset = followDistance;
            }
        }
        
        Vector3 newPosition = Vector3.Lerp(currentNode.transform.position, currentNode.nextNode.transform.position, movePercentage);
        // Debug.Log(movePercentage);
        newPosition.z = Crash.S.transform.position.z - offset;
        Camera.main.transform.position = newPosition;
        
        Quaternion newRotation = Quaternion.Lerp(currentNode.transform.rotation, currentNode.nextNode.transform.rotation, movePercentage);
        Camera.main.transform.rotation = newRotation;
        
        // check next node
        if (Crash.S.transform.position.z > currentNode.nextNode.transform.position.z) {
            currentNode = currentNode.nextNode;
        } else if (Crash.S.transform.position.z < currentNode.transform.position.z) {
            currentNode = currentNode.previousNode;
        }
	}
Ejemplo n.º 3
0
    void Update()
    {
        CameraSplineNode tmpNode = rightNode;

        if (Crash.S.transform.position.x > transform.position.x)
        {
            tmpNode = rightNode;
        }
        else
        {
            tmpNode = leftNode;
        }

        if (splitAfter)
        {
            nextNode = tmpNode;
        }
        else
        {
            previousNode = tmpNode;
        }
    }
Ejemplo n.º 4
0
        public CameraSplineNode[] GetSplineNodesNew()
        {
            var result = GetSplineNodesOriginal();

            if (!FreeCameraOptions.FarEnabled && !FreeCameraOptions.NearEnabled)
            {
                return result;
            }

            #if false
            for (var i = 0; i < result.Length; ++i)
            {
                var node = result[i];
                Helper.W2ModDebug.Log("node before {0}:{6} time={1} fov={2} rotation={3} euler={5} {8} position={4} {7}", i, node.time, node.fov, node.transform.rotation, node.transform.position, node.transform.rotation.eulerAngles, node.name, node.transform.localPosition, node.transform.localRotation.eulerAngles);
            }
            #endif
            if (result != null && result.Length == 3)
            {
                Helper.W2ModDebug.Log("adjusting camera spline");

                /* Add a node between the middle node and the minimum node, as a clone of the current minimum zoom
                 * Adjust the minimum zoom to have an almost horizontal angle and really close to the target
                 * Adjust the maximum zoom to have a bit more of an angle to it than the default
                 * Adjust the new node to be like the original minimum zoom and set its time very close to the minimum zoom (0.10)
                 * Adjust the old middle node to be in between the maximum and the new node
                 */
                var newResult = new CameraSplineNode[4];
                newResult[0] = result[0];
                newResult[1] = GameObject.Instantiate(result[0]);
                newResult[2] = result[1];
                newResult[3] = result[2];
                newResult[0].name = "1";
                newResult[1].name = "2";
                newResult[2].name = "3";
                newResult[3].name = "4";

                result = newResult;

                if (FreeCameraOptions.NearEnabled)
                {
                    result[0].transform.localRotation = Quaternion.Euler(10.0f, 0.0f, 0.0f); // original: (36, 0, 0)
                    result[1].transform.localRotation = Quaternion.Euler(36.0f, 0.0f, 0.0f);
                }
                else
                {
                    result[0].transform.localRotation = Quaternion.Euler(36.0f, 0.0f, 0.0f);
                    result[1].transform.localRotation = Quaternion.Euler(38.0f, 0.0f, 0.0f);
                }

                if (FreeCameraOptions.FarEnabled)
                {
                    result[2].transform.localRotation = Quaternion.Euler(46.0f, 0.0f, 0.0f); // original: (53.0, 0.0, 0.0)
                    result[3].transform.localRotation = Quaternion.Euler(53.0f, 0.0f, 0.0f); // original: (67.0, 0.0, 0.0)
                }
                else
                {
                    result[2].transform.localRotation = Quaternion.Euler(53.0f, 0.0f, 0.0f); // original: (53.0, 0.0, 0.0)
                    result[3].transform.localRotation = Quaternion.Euler(67.0f, 0.0f, 0.0f); // original: (67.0, 0.0, 0.0)
                }

                /* y is height above the ground
                 * y = 0 puts camera a few feet above the head
                 *
                 * z is lateral distance away from target
                 * z = 0 puts camera a few feed behind the target
                 */

                if (FreeCameraOptions.NearEnabled)
                {
                    result[0].transform.localPosition = new Vector3(0f, -1.0f, 0.0f); // original: (0.0,  8.0, -10.0)
                    result[1].transform.localPosition = new Vector3(0f, 8.0f, -10.0f);
                }
                else
                {
                    result[0].transform.localPosition = new Vector3(0f, 8.0f, -10.0f); // original: (0.0,  8.0, -10.0)
                    result[1].transform.localPosition = new Vector3(0f, 11.0f, -11.0f);
                }

                if (FreeCameraOptions.FarEnabled)
                {
                    result[2].transform.localPosition = new Vector3(0f, 23.7f, -14.2f); // original: (0.0, 23.7, -14.2)
                    result[3].transform.localPosition = new Vector3(0f, 43.7f, -22.0f); // original: (0.0, 43.7, -14.2)
                }
                else
                {
                    result[2].transform.localPosition = new Vector3(0f, 23.7f, -14.2f); // original: (0.0, 23.7, -14.2)
                    result[3].transform.localPosition = new Vector3(0f, 43.7f, -14.2f); // original: (0.0, 43.7, -14.2)
                }

                result[0].time = 0.00f;
                result[1].time = 0.10f;
                result[2].time = 0.50f;
                result[3].time = 1.00f;

                result[1].transform.SetParent(result[0].transform.parent, false);
            }

            #if false
            for (var i = 0; i < result.Length; ++i)
            {
                var node = result[i];
                Helper.W2ModDebug.Log("node after {0}:{6} time={1} fov={2} rotation={3} euler={5} {8} position={4} {7}", i, node.time, node.fov, node.transform.rotation, node.transform.position, node.transform.rotation.eulerAngles, node.name, node.transform.localPosition, node.transform.localRotation.eulerAngles);
            }
            #endif
            return result;
        }
Ejemplo n.º 5
0
    void Update()
    {
        float iV = Input.GetAxis("Vertical");

        if (iV < 0)
        {
            farAngleFlag = true;
        }
        else if (iV > 0)
        {
            farAngleFlag = false;
        }

        // Vector3 pos = Camera.main.transform.position;
        // pos.z = Crash.S.transform.position.z - offset;
        // pos.y = Crash.S.transform.position.y + 6.0f;
        // pos.x = Crash.S.transform.position.x;
        // Camera.main.transform.position = pos;
        float sectorDistance = Mathf.Abs(currentNode.transform.position.z - currentNode.nextNode.transform.position.z);
        float moveDistance   = Mathf.Abs(Crash.S.transform.position.z - currentNode.transform.position.z);
        float movePercentage = moveDistance / sectorDistance;

        followDistance = Mathf.Lerp(currentNode.followDistance, currentNode.nextNode.followDistance, movePercentage);

        if (farAngleFlag)
        {
            offset += tweenSpeed * Time.deltaTime;
            if (offset >= followDistance + backOffset)
            {
                offset = followDistance + backOffset;
            }
        }
        else
        {
            offset -= tweenSpeed * Time.deltaTime;
            if (offset < followDistance)
            {
                offset = followDistance;
            }
        }

        Vector3 newPosition = Vector3.Lerp(currentNode.transform.position, currentNode.nextNode.transform.position, movePercentage);

        // Debug.Log(movePercentage);
        newPosition.z = Crash.S.transform.position.z - offset;
        Camera.main.transform.position = newPosition;

        Quaternion newRotation = Quaternion.Lerp(currentNode.transform.rotation, currentNode.nextNode.transform.rotation, movePercentage);

        Camera.main.transform.rotation = newRotation;

        // check next node
        if (Crash.S.transform.position.z > currentNode.nextNode.transform.position.z)
        {
            currentNode = currentNode.nextNode;
        }
        else if (Crash.S.transform.position.z < currentNode.transform.position.z)
        {
            currentNode = currentNode.previousNode;
        }
    }
Ejemplo n.º 6
0
        public CameraSplineNode[] GetSplineNodesNew()
        {
            var result = GetSplineNodesOriginal();

            if (!FreeCameraOptions.FarEnabled && !FreeCameraOptions.NearEnabled)
            {
                return(result);
            }

#if false
            for (var i = 0; i < result.Length; ++i)
            {
                var node = result[i];
                Helper.W2ModDebug.Log("node before {0}:{6} time={1} fov={2} rotation={3} euler={5} {8} position={4} {7}", i, node.time, node.fov, node.transform.rotation, node.transform.position, node.transform.rotation.eulerAngles, node.name, node.transform.localPosition, node.transform.localRotation.eulerAngles);
            }
#endif
            if (result != null && result.Length == 3)
            {
                Helper.W2ModDebug.Log("adjusting camera spline");

                /* Add a node between the middle node and the minimum node, as a clone of the current minimum zoom
                 * Adjust the minimum zoom to have an almost horizontal angle and really close to the target
                 * Adjust the maximum zoom to have a bit more of an angle to it than the default
                 * Adjust the new node to be like the original minimum zoom and set its time very close to the minimum zoom (0.10)
                 * Adjust the old middle node to be in between the maximum and the new node
                 */
                var newResult = new CameraSplineNode[4];
                newResult[0]      = result[0];
                newResult[1]      = GameObject.Instantiate(result[0]);
                newResult[2]      = result[1];
                newResult[3]      = result[2];
                newResult[0].name = "1";
                newResult[1].name = "2";
                newResult[2].name = "3";
                newResult[3].name = "4";

                result = newResult;

                if (FreeCameraOptions.NearEnabled)
                {
                    result[0].transform.localRotation = Quaternion.Euler(10.0f, 0.0f, 0.0f); // original: (36, 0, 0)
                    result[1].transform.localRotation = Quaternion.Euler(36.0f, 0.0f, 0.0f);
                }
                else
                {
                    result[0].transform.localRotation = Quaternion.Euler(36.0f, 0.0f, 0.0f);
                    result[1].transform.localRotation = Quaternion.Euler(38.0f, 0.0f, 0.0f);
                }

                if (FreeCameraOptions.FarEnabled)
                {
                    result[2].transform.localRotation = Quaternion.Euler(46.0f, 0.0f, 0.0f); // original: (53.0, 0.0, 0.0)
                    result[3].transform.localRotation = Quaternion.Euler(53.0f, 0.0f, 0.0f); // original: (67.0, 0.0, 0.0)
                }
                else
                {
                    result[2].transform.localRotation = Quaternion.Euler(53.0f, 0.0f, 0.0f); // original: (53.0, 0.0, 0.0)
                    result[3].transform.localRotation = Quaternion.Euler(67.0f, 0.0f, 0.0f); // original: (67.0, 0.0, 0.0)
                }

                /* y is height above the ground
                 * y = 0 puts camera a few feet above the head
                 *
                 * z is lateral distance away from target
                 * z = 0 puts camera a few feed behind the target
                 */

                if (FreeCameraOptions.NearEnabled)
                {
                    result[0].transform.localPosition = new Vector3(0f, -1.0f, 0.0f); // original: (0.0,  8.0, -10.0)
                    result[1].transform.localPosition = new Vector3(0f, 8.0f, -10.0f);
                }
                else
                {
                    result[0].transform.localPosition = new Vector3(0f, 8.0f, -10.0f); // original: (0.0,  8.0, -10.0)
                    result[1].transform.localPosition = new Vector3(0f, 11.0f, -11.0f);
                }

                if (FreeCameraOptions.FarEnabled)
                {
                    result[2].transform.localPosition = new Vector3(0f, 23.7f, -14.2f); // original: (0.0, 23.7, -14.2)
                    result[3].transform.localPosition = new Vector3(0f, 43.7f, -22.0f); // original: (0.0, 43.7, -14.2)
                }
                else
                {
                    result[2].transform.localPosition = new Vector3(0f, 23.7f, -14.2f); // original: (0.0, 23.7, -14.2)
                    result[3].transform.localPosition = new Vector3(0f, 43.7f, -14.2f); // original: (0.0, 43.7, -14.2)
                }

                result[0].time = 0.00f;
                result[1].time = 0.10f;
                result[2].time = 0.50f;
                result[3].time = 1.00f;

                result[1].transform.SetParent(result[0].transform.parent, false);
            }

#if false
            for (var i = 0; i < result.Length; ++i)
            {
                var node = result[i];
                Helper.W2ModDebug.Log("node after {0}:{6} time={1} fov={2} rotation={3} euler={5} {8} position={4} {7}", i, node.time, node.fov, node.transform.rotation, node.transform.position, node.transform.rotation.eulerAngles, node.name, node.transform.localPosition, node.transform.localRotation.eulerAngles);
            }
#endif
            return(result);
        }