コード例 #1
0
    /// <summary>
    /// Import XML data into this camera path overwriting the current data
    /// </summary>
    /// <param name="XMLPath">An XML file path</param>
    public void FromXML(XmlNode xml)
    {
        if (xml == null)
        {
            return;
        }

        GameObject animationObjectGO = GameObject.Find(xml["animationObject"].FirstChild.Value);

        if (animationObjectGO != null)
        {
            animationObject = animationObjectGO.transform;
        }


        GameObject orientationTargetGO = GameObject.Find(xml["orientationTarget"].FirstChild.Value);

        if (orientationTargetGO != null)
        {
            orientationTarget = orientationTargetGO.transform;
        }

        _animateSceneObjectInEditor = bool.Parse(xml["animateSceneObjectInEditor"].FirstChild.Value);
        playOnStart = bool.Parse(xml["playOnStart"].FirstChild.Value);

        animationMode   = (animationModes)Enum.Parse(typeof(animationModes), xml["animationMode"].FirstChild.Value);
        orientationMode = (orientationModes)Enum.Parse(typeof(orientationModes), xml["orientationMode"].FirstChild.Value);

        normalised = bool.Parse(xml["normalised"].FirstChild.Value);
        _pathSpeed = float.Parse(xml["pathSpeed"].FirstChild.Value);
    }
コード例 #2
0
    /// <summary>
    /// Import XML data into this camera path overwriting the current data
    /// </summary>
    /// <param name="XMLPath">An XML file path</param>
    public void FromXML(XmlNode xml)
    {
        if(xml == null)
            return;

        GameObject animationObjectGO = GameObject.Find(xml["animationObject"].FirstChild.Value);
        if(animationObjectGO != null)
            animationObject = animationObjectGO.transform;


        GameObject orientationTargetGO = GameObject.Find(xml["orientationTarget"].FirstChild.Value);
        if (orientationTargetGO != null)
            orientationTarget = orientationTargetGO.transform;

        _animateSceneObjectInEditor = bool.Parse(xml["animateSceneObjectInEditor"].FirstChild.Value);
        playOnStart = bool.Parse(xml["playOnStart"].FirstChild.Value);

        animationMode = (animationModes)Enum.Parse(typeof(animationModes), xml["animationMode"].FirstChild.Value);
        orientationMode = (orientationModes)Enum.Parse(typeof(orientationModes), xml["orientationMode"].FirstChild.Value);

        normalised = bool.Parse(xml["normalised"].FirstChild.Value);
        _pathSpeed = float.Parse(xml["pathSpeed"].FirstChild.Value);
    }
コード例 #3
0
    /// <summary>
    /// Import XML data into this camera path overwriting the current data
    /// </summary>
    /// <param name="XMLPath">An XML file path</param>
    public void FromXML(XmlNode xml)
    {
        if (xml == null)
        {
            return;
        }

        GameObject animationObjectGO = GameObject.Find(xml["animationObject"].FirstChild.Value);

        if (animationObjectGO != null)
        {
            animationObject = animationObjectGO.transform;
        }


        GameObject orientationTargetGO = GameObject.Find(xml["orientationTarget"].FirstChild.Value);

        if (orientationTargetGO != null)
        {
            orientationTarget = orientationTargetGO.transform;
        }

        _animateSceneObjectInEditor = bool.Parse(xml["animateSceneObjectInEditor"].FirstChild.Value);
        playOnStart = bool.Parse(xml["playOnStart"].FirstChild.Value);

        animationMode    = (animationModes)Enum.Parse(typeof(animationModes), xml["animationMode"].FirstChild.Value);
        _orientationMode = (orientationModes)Enum.Parse(typeof(orientationModes), xml["orientationMode"].FirstChild.Value);

        normalised = bool.Parse(xml["normalised"].FirstChild.Value);
        _pathSpeed = float.Parse(xml["pathSpeed"].FirstChild.Value);

        if (xml["smoothOrientationModeChanges"] != null)
        {
            smoothOrientationModeChanges = bool.Parse(xml["smoothOrientationModeChanges"].FirstChild.Value);
        }
        if (xml["orientationModeLerpTime"] != null)
        {
            orientationModeLerpTime = float.Parse(xml["orientationModeLerpTime"].FirstChild.Value);
        }


        if (xml["fixedOrientaionx"] != null)
        {
            Vector3 newOrientation = new Vector3();
            newOrientation.x = float.Parse(xml["fixedOrientaionx"].FirstChild.Value);
            newOrientation.y = float.Parse(xml["fixedOrientaiony"].FirstChild.Value);
            newOrientation.z = float.Parse(xml["fixedOrientaionz"].FirstChild.Value);
            fixedOrientaion  = newOrientation;
        }

        if (xml["fixedPositionx"] != null)
        {
            Vector3 newPosition = new Vector3();
            newPosition.x = float.Parse(xml["fixedPositionx"].FirstChild.Value);
            newPosition.y = float.Parse(xml["fixedPositiony"].FirstChild.Value);
            newPosition.z = float.Parse(xml["fixedPositionz"].FirstChild.Value);
            fixedPosition = newPosition;
        }


        if (xml["sensitivity"] != null)
        {
            sensitivity = float.Parse(xml["sensitivity"].FirstChild.Value);
        }
        if (xml["minX"] != null)
        {
            minX = float.Parse(xml["minX"].FirstChild.Value);
        }
        if (xml["maxX"] != null)
        {
            maxX = float.Parse(xml["maxX"].FirstChild.Value);
        }
    }
コード例 #4
0
    public virtual Quaternion GetOrientation(orientationModes mode, float percent, bool ignoreNormalisation)
    {
        Quaternion output = Quaternion.identity;
        Vector3    currentPosition, forward;

        switch (mode)
        {
        case orientationModes.custom:
            output = cameraPath.GetPathRotation(percent, ignoreNormalisation);
            break;

        case orientationModes.target:
            currentPosition = cameraPath.GetPathPosition(percent);    //transform.TransformPoint(cameraPath.GetPathPosition(percent));
            if (orientationTarget != null)
            {
                forward = orientationTarget.transform.position - currentPosition;
            }
            else
            {
                forward = Vector3.forward;
            }
            output = Quaternion.LookRotation(forward, targetModeUp);
            break;

        case orientationModes.followpath:
            output  = Quaternion.LookRotation(cameraPath.GetPathDirection(percent));
            output *= Quaternion.Euler(transform.forward * -cameraPath.GetPathTilt(percent));
            break;

        case orientationModes.reverseFollowpath:
            output  = Quaternion.LookRotation(-cameraPath.GetPathDirection(percent));
            output *= Quaternion.Euler(transform.forward * -cameraPath.GetPathTilt(percent));
            break;

        case orientationModes.mouselook:
            if (!Application.isPlaying)
            {
                output  = Quaternion.LookRotation(cameraPath.GetPathDirection(percent));
                output *= Quaternion.Euler(transform.forward * -cameraPath.GetPathTilt(percent));
            }
            else
            {
                //                    output = GetMouseLook();
                output  = Quaternion.LookRotation(cameraPath.GetPathDirection(percent));
                output *= GetMouseLook();
            }
            break;

        case orientationModes.followTransform:
            if (orientationTarget == null)
            {
                return(Quaternion.identity);
            }
            float nearestPerc = cameraPath.GetNearestPoint(orientationTarget.position);
            nearestPerc     = Mathf.Clamp01(nearestPerc + nearestOffset);
            currentPosition = cameraPath.GetPathPosition(nearestPerc);
            forward         = orientationTarget.transform.position - currentPosition;
            output          = Quaternion.LookRotation(forward);
            break;

        case orientationModes.twoDimentions:
            output = Quaternion.LookRotation(Vector3.forward);
            break;

        case orientationModes.fixedOrientation:
            output = Quaternion.LookRotation(fixedOrientaion);
            break;

        case orientationModes.none:
            output = animationObject.rotation;
            break;
        }
        return(output);
    }