Exemplo n.º 1
0
    Vector3 GetVector3(string nodeKey, YamlMappingNode valueNode)
    {
        YamlMappingNode vNode   = EasyYaml.FindMapNodeByKey(nodeKey, valueNode) as YamlMappingNode;
        Vector3         vector3 = new Vector3();

        vector3.x = float.Parse(EasyYaml.FindMapNodeByKey("x", vNode).ToString());
        vector3.y = float.Parse(EasyYaml.FindMapNodeByKey("y", vNode).ToString());
        vector3.z = float.Parse(EasyYaml.FindMapNodeByKey("z", vNode).ToString());
        return(vector3);
    }
Exemplo n.º 2
0
    Quaternion GetQuaternion(string nodeKey, YamlMappingNode valueNode)
    {
        YamlMappingNode vNode      = EasyYaml.FindMapNodeByKey(nodeKey, valueNode) as YamlMappingNode;
        Quaternion      quaternion = new Quaternion();

        quaternion.x = float.Parse(EasyYaml.FindMapNodeByKey("x", vNode).ToString());
        quaternion.y = float.Parse(EasyYaml.FindMapNodeByKey("y", vNode).ToString());
        quaternion.z = float.Parse(EasyYaml.FindMapNodeByKey("z", vNode).ToString());
        quaternion.w = float.Parse(EasyYaml.FindMapNodeByKey("w", vNode).ToString());
        return(quaternion);
    }
Exemplo n.º 3
0
    void ParseSQTInfo(string sqtKey, Action <YamlSequenceNode, string> parseCallBack)
    {
        YamlSequenceNode rootNode = EasyYaml.FindMapNodeByKey(sqtKey, animationNode) as YamlSequenceNode;

        foreach (YamlNode mapNode in rootNode.Children)
        {
            YamlMappingNode  mNode = EasyYaml.FindMapNodeByKey(KEY_CURVE, mapNode) as YamlMappingNode;
            string           key   = EasyYaml.FindMapNodeByKey(KEY_PATH, mapNode).ToString();
            YamlSequenceNode value = EasyYaml.FindMapNodeByKey(KEY_M_CURVE, mNode) as YamlSequenceNode;
            parseCallBack(value, key);
        }
    }
Exemplo n.º 4
0
    void ParseScaleInfoToList(YamlSequenceNode node, string key)
    {
        IList <YamlNode>   nodeList = node.Children;
        List <YamlSQTData> list     = new List <YamlSQTData>();

        foreach (YamlMappingNode valueNode in nodeList)
        {
            YamlScaleData scaleData = new YamlScaleData();
            scaleData.time        = float.Parse(EasyYaml.FindMapNodeByKey("time", valueNode).ToString());
            scaleData.value       = GetVector3("value", valueNode);
            scaleData.inSlope     = GetVector3("inSlope", valueNode);
            scaleData.outSlope    = GetVector3("outSlope", valueNode);
            scaleData.tangentMode = float.Parse(EasyYaml.FindMapNodeByKey("tangentMode", valueNode).ToString());
            list.Add(scaleData);
        }
        scaleInfo.Add(key, list);
    }
Exemplo n.º 5
0
    void ParseRotationDataToList(YamlSequenceNode node, string key)
    {
        IList <YamlNode>   nodeList = node.Children;
        List <YamlSQTData> list     = new List <YamlSQTData>();

        foreach (YamlMappingNode valueNode in nodeList)
        {
            YamlRotationData rotationData = new YamlRotationData();
            rotationData.time        = float.Parse(EasyYaml.FindMapNodeByKey("time", valueNode).ToString());
            rotationData.value       = GetQuaternion("value", valueNode);
            rotationData.inSlope     = GetQuaternion("inSlope", valueNode);
            rotationData.outSlope    = GetQuaternion("outSlope", valueNode);
            rotationData.tangentMode = float.Parse(EasyYaml.FindMapNodeByKey("tangentMode", valueNode).ToString());
            list.Add(rotationData);
        }
        rotationInfo.Add(key, list);
    }
Exemplo n.º 6
0
    /// <summary>
    /// 解析YAML动画文件
    /// </summary>
    /// <param name="sr">Sr.</param>
    void ParseStreamToYaml(StreamReader sr)
    {
        YamlStream yaml = new YamlStream();

        yaml.Load(sr);
        YamlMappingNode map = (YamlMappingNode)yaml.Documents[0].RootNode;

        animationNode = EasyYaml.FindMapNodeByKey("AnimationClip", map);
        //获取关节的旋转信息.
        ParseSQTInfo(KEY_ROTATION, ParseRotationDataToList);
        //获取关节的位置信息.
        ParseSQTInfo(KEY_POSITION, ParsePositionDataToList);
        //获取关节的缩放信息.
        ParseSQTInfo(KEY_SCALE, ParseScaleInfoToList);
        //获取动画长度和循环状态.
        YamlMappingNode settingMapNode = EasyYaml.FindMapNodeByKey(KEY_SETTING, animationNode) as YamlMappingNode;

        startTime = float.Parse(EasyYaml.FindMapNodeByKey(KEY_STARTTIME, settingMapNode).ToString());
        stopTime  = float.Parse(EasyYaml.FindMapNodeByKey(KEY_STOPTIME, settingMapNode).ToString());
        loop      = EasyYaml.FindMapNodeByKey(KEY_LOOPTIME, settingMapNode).ToString() == "0"?false:true;
    }