使用unity創建項目,進行動畫制作

1. 創建unity項目

error:

error CS0006: Metadata file 'Library/PackageCache/com.unity.collab-proxy@2.8.2/Lib/Editor/PlasticSCM/log4netPlastic.dll' could not be found


error CS0006: Metadata file 'Library/PackageCache/com.unity.collab-proxy@2.8.2/Lib/Editor/PlasticSCM/Unity.Plastic.Antlr3.Runtime.dll' could not be found


error CS0006: Metadata file 'Library/PackageCache/com.unity.collab-proxy@2.8.2/Lib/Editor/PlasticSCM/Unity.Plastic.Newtonsoft.Json.dll' could not be found

刪除項目文件夾下的library,然后重新打開項目,解決錯誤

2. 根據文本生成動畫代碼

AnimationClipFromCSV.cs

using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text.RegularExpressions;
using UnityEngine;
using Newtonsoft.Json.Linq;
using System.Text;
using static System.Net.Mime.MediaTypeNames;//[RequireComponent(typeof(Animation))]
public class AnimationClipFromCSV : MonoBehaviour
{AnimationClip animationClip;public List<List<string>> data;public List<LineData> fileData;private Regex fieldPattern = new Regex("(?:^|,)(\"(?:[^\"]+|\"\")*\"|[^,]*)");private Dictionary<string, string> field_mapping = new Dictionary<string, string>();public List<string> curve_names;public List<string> root_motion_curve_names;private int num_curves_on_single_joint;private int num_curves_root_motion;// legacyprivate int num_keys = 10; //number of keys to keep *in addition to* the initial keyprivate int num_meta_columns = 3;private string inputPath = "C:\\Bill\\temp/whale_excited2.txt";private string outputPath;private GameObject joint_hierarchy_root;[TextArea(10, 30)]private string object_JSON;private Animation anim;private string clip_name;//public GameObject obj;//public GameObject root_obj;void Awake(){num_curves_on_single_joint = curve_names.Count;num_curves_root_motion = root_motion_curve_names.Count;//anim = GetComponent<Animation>();define animation curve//animationClip = new AnimationClip();set animation clip to be legacy//animationClip.legacy = true;//ConfigurateAnimationCurvesTxt();post-processing for visual quality//animationClip.EnsureQuaternionContinuity();add clip to the animator//anim.AddClip(animationClip, clip_name);play it on loop//AnimationState state = anim[clip_name];//state.wrapMode = WrapMode.Loop;//anim.Play(clip_name);}List<LineData> ParseTxtFileToData(string animation_txt){List<LineData> data = new List<LineData>();string[] lines = animation_txt.Split('\n');// the first line is root motionstring root_motion_line = lines[0];data.Add(ParseRootMotionData(RemoveWhiteSpaces(root_motion_line)));// other animation curvesfor (int i = 1; i < lines.Length; i++){string line = lines[i];//data.Add(ParseString(line));data.Add(ParseString(RemoveWhiteSpaces(line)));}return data;}public AnimationClip GetClipFromTxt(string animation_txt){AnimationClip clip = new AnimationClip();clip.legacy = true;List<LineData> animation_data = ParseTxtFileToData(animation_txt);the first data is root motion//LineData root_motion_data = animation_data[0];//List<AnimationCurve> root_motion_curves = new List<AnimationCurve>();//string root_name = root_motion_data.name;//List<float[]> root_values = root_motion_data.values;//for (int k = 0; k < num_curves_root_motion; k++)//{//    AnimationCurve new_curve = new AnimationCurve();//    root_motion_curves.Add(new_curve);//}//for (int j = 0; j < root_values.Count; j++) // loop over keys at different times//{//    float[] key_values = root_values[j];//    for (int k = 0; k < num_curves_root_motion; k++) // loop over property curves//    {//        float key_time = key_values[0];//        float key_value = key_values[k + 1];//        root_motion_curves[k].AddKey(key_time, key_value);//        //print(root_name);//        //print(key_time);//        //print(key_value);//    }//}//for (int k = 0; k < num_curves_root_motion; k++)//{//    clip.SetCurve(root_name, typeof(Transform), root_motion_curve_names[k], root_motion_curves[k]);//}// other animation curvesfor (int i = 0; i < animation_data.Count; i++) // loop through gameObjects (different joints){LineData row = animation_data[i];string obj_name = row.name.Trim();List<float[]> values = row.values;// the same GO has many animation curvesList<AnimationCurve> ani_curves = new List<AnimationCurve>();int num_curves = (i == 0 ? num_curves_root_motion : num_curves_on_single_joint);List<string> property_curve_names = (i == 0 ? root_motion_curve_names : curve_names);for (int k = 0; k < num_curves; k++) // create all animation curves for this GO (ex: rotation in x,y,z){AnimationCurve new_curve = new AnimationCurve();ani_curves.Add(new_curve);}for (int j = 0; j < values.Count; j++) // loop over keys at different times{float[] key_values = values[j];for (int k = 0; k < num_curves; k++) // loop over property curves{//print(key_values.Length);float key_time = key_values[0];float key_value = key_values[k + 1];ani_curves[k].AddKey(key_time, key_value);}}for (int k = 0; k < num_curves; k++) // create all animation curves for this GO (ex: rotation in x,y,z){clip.SetCurve(obj_name, typeof(Transform), property_curve_names[k], ani_curves[k]); // first entry is GO name}}return clip;}A class to represent a node in the scene hierarchy//[System.Serializable]//public class ObjectNode//{//    public string name; // The name of the gameObject//    public string position;//    //public string scale;//    //public string rotation;//    public List<ObjectNode> children; // The list of child nodes//    // A constructor that takes a gameObject and recursively creates child nodes//    public ObjectNode(GameObject gameObject)//    {//        name = gameObject.name;//        position = gameObject.transform.localPosition.ToString("F4");//        //scale = gameObject.transform.localScale.ToString("F1");//        //rotation = gameObject.transform.rotation.ToString("F1");//        // recurse on its children//        children = new List<ObjectNode>();//        foreach (Transform child in gameObject.transform)//        {//            children.Add(new ObjectNode(child.gameObject));//        }//    }//}public string RemoveQuotesAndSpacesIgnoringSummary(string input){string pattern = @"Summary.*\n";var matches = Regex.Matches(input, pattern);// Use a string builder to append the matched parts and remove the quotes, spaces, and new lines from the restvar output = new StringBuilder();// Keep track of the last index of the matched partint lastIndex = 0;// Loop through the matchesforeach (Match match in matches){//print (match.Value);// Remove the quotes, spaces, and new lines from the substring before the matchoutput.Append(Regex.Replace(input.Substring(lastIndex, match.Index - lastIndex), @"[""\s]", ""));// Append the matched part, remove the new line at the end.output.Append(match.Value.Remove(match.Value.Length - 1, 1));//output.Append(match.Value);// Update the last indexlastIndex = match.Index + match.Length;}// Remove the quotes, spaces, and new lines from the remaining substringoutput.Append(Regex.Replace(input.Substring(lastIndex), @"[""\s]", ""));// Return the output stringreturn output.ToString();}public string RemoveEmptyChildren(string json){// Use regular expressions to match the patterns and replace them with empty strings or "}"string output = Regex.Replace(json, @",children:\[\]", "");return output;}public string RemoveBracesFromString(string input){// If the input is null or empty, return it as it isif (string.IsNullOrEmpty(input)){return input;}// Use a StringBuilder to store the output without bracesStringBuilder output = new StringBuilder();// Loop through each character in the inputforeach (char c in input){// If the character is not a brace, append it to the outputif (c != '{' && c != '}'){output.Append(c);}}// Return the output as a stringreturn output.ToString();}string GetRelativeGOName(GameObject obj, GameObject root_obj){string name = "";while (obj.transform.parent != null && obj != root_obj) {name = obj.name + "/" + name;obj = obj.transform.parent.gameObject;}// remove the last "/"name = name.Remove(name.Length-1, 1);return name;}void ProcessCSVFiles(){char separator = ',';string[] keepNames = { "Name", "ParentName", "HierarchyIndex" };// The substring to check for rotation columnsstring rotationSubstring = "Rotation";// Read the input file as an array of linesstring[] lines = File.ReadAllLines(inputPath);// Assume the first line is the header and split it by the separatorstring[] header = lines[0].Split(separator);// trim names with white spacesheader = header.Select(p => p.Trim()).ToArray();// Find the indices of the columns to keep by checking the names and the substringint[] keepIndices = header.Select((name, index) => new { name, index }).Where(x => keepNames.Contains(x.name) || x.name.Contains(rotationSubstring)).Select(x => x.index).ToArray();// downsample the frames//int startIdx = GetFirstSubstringIdx(header, rotationSubstring);//int endIdx = GetEndSubstringIdx(header, rotationSubstring);keepIndices = DownsampleFrames(keepIndices);// Create a new array of lines for the output filestring[] outputLines = new string[lines.Length];// For each line, keep only the values at the keep indices and join them by the separatorfor (int i = 0; i < lines.Length; i++){string[] values = lines[i].Split(separator);string[] outputValues = keepIndices.Select(index => values[index]).ToArray();outputLines[i] = string.Join(separator.ToString(), outputValues);}// Write the output lines to the output fileFile.WriteAllLines(outputPath, outputLines);}int[] DownsampleFrames(int[] indices){Calculate the interval to skip rotations//int interval = indices.Length / num_curves_on_single_joint / num_keys;Create a list to store the selected rotations//List<int> selected = new List<int>();Loop through the indices and add every interval-th rotation to the list//for (int i = num_meta_columns; i < indices.Length; i += num_curves_on_single_joint)//{//    if ((i-num_meta_columns) % (interval * num_curves_on_single_joint) == 0)//    {//        for (int j = 0; j < num_curves_on_single_joint; j++)//        {//            selected.Add(indices[i + j]);//        }//    }//}//return selected.ToArray();// Copy the first four elements (name, parent name, hier, and first rotation)List<int> idx_list = new List<int>(indices);List<int> output = new List<int>(idx_list.GetRange(0, num_meta_columns+1));// Calculate the interval between rotations to keepint interval = (idx_list.Count - num_meta_columns-1) / (num_curves_on_single_joint * num_keys);// Loop through the remaining rotations and add them to the output if they match the intervalfor (int i = num_meta_columns+1; i < idx_list.Count; i += num_curves_on_single_joint){if ((i - num_meta_columns-1) % (interval * num_curves_on_single_joint) == 0){output.AddRange(idx_list.GetRange(i, num_curves_on_single_joint-1));}}return output.ToArray();}int GetFirstSubstringIdx(string[] str_list, string sub_string){for (int i = 0; i < str_list.Length; i++){string s = str_list[i]; // Check if the current string contains "Rotation" as a substringif (s.Contains(sub_string)){// If yes, assign it to the result variable and break the loopreturn i;}}return -1;}void ConfigurateAnimationCurvesTxt(){ParseTxtFile();for (int i = 0; i < fileData.Count; i++) // loop through gameObjects (different joints){LineData row = fileData[i];string obj_name = row.name;List<float[]> values = row.values;// the same GO has many animation curvesList<AnimationCurve> ani_curves = new List<AnimationCurve>();for (int k = 0; k < num_curves_on_single_joint; k++) // create all animation curves for this GO (ex: rotation in x,y,z){AnimationCurve new_curve = new AnimationCurve();ani_curves.Add(new_curve);}for (int j = 0; j < values.Count; j++) // loop over keys at different times{ float[] key_values = values[j];for (int k = 0; k < num_curves_on_single_joint; k++) // loop over property curves{float key_time = key_values[0];float key_value = key_values[k+1];ani_curves[k].AddKey(key_time, key_value);}}for (int k = 0; k < num_curves_on_single_joint; k++) // create all animation curves for this GO (ex: rotation in x,y,z){//animationClip.SetCurve("", typeof(Transform), row[0], ani_curves[k]); // first entry is GO nameanimationClip.SetCurve(obj_name, typeof(Transform), curve_names[k], ani_curves[k]); // first entry is GO name}}}void ConfigurateAnimationCurves(){ParseCSV(inputPath);// loop through gameObjects (different joints)for (int i = 0; i < data.Count; i++) {List<string> row = data[i];// the same GO has many animation curves//Dictionary<string, AnimationCurve> ani_curves = new Dictionary<string, AnimationCurve>();List<AnimationCurve> ani_curves = new List<AnimationCurve>();for (int k = 0; k < num_curves_on_single_joint; k++) // create all animation curves for this GO (ex: rotation in x,y,z){AnimationCurve new_curve = new AnimationCurve();ani_curves.Add(new_curve);}// loop through different frames for the same GO// skip the first few columns, which are metadataint j = num_meta_columns;while (j < row.Count - num_curves_on_single_joint){// assume the first entry in each block is the timefloat time_stamp = 0f;float.TryParse(row[j], out time_stamp);for (int k = 0; k < num_curves_on_single_joint; k++){float animation_key_value = 0f;float.TryParse(row[j + k], out animation_key_value);ani_curves[k].AddKey(time_stamp, animation_key_value);}j += num_curves_on_single_joint;}for (int k = 0; k < num_curves_on_single_joint; k++) // create all animation curves for this GO (ex: rotation in x,y,z){//animationClip.SetCurve("", typeof(Transform), row[0], ani_curves[k]); // first entry is GO nameanimationClip.SetCurve(row[0], typeof(Transform), curve_names[k], ani_curves[k]); // first entry is GO name}}}void ConfigurateAnimationCurvesExample(){//AnimationCurve translateX = AnimationCurve.Linear(0.0f, 0.0f, 2.0f, 2.0f);AnimationCurve translateX = new AnimationCurve();translateX.AddKey(0f, 0f);translateX.AddKey(2f, 2f);translateX.AddKey(3f, -2f);animationClip.SetCurve("", typeof(Transform), "localPosition.x", translateX);}public string RemoveWhiteSpaces(string json){// Use a regular expression to match and replace any sequence of white space charactersreturn Regex.Replace(json, @"\s+", "");}public class LineData{public string name; // The first elementpublic List<float[]> values; // The rest of the elements as float arrayspublic LineData(string name, List<float[]> values){this.name = name;this.values = values;}}void ParseTxtFile(){fileData = new List<LineData>();using (StreamReader reader = new StreamReader(inputPath)){string line;while ((line = reader.ReadLine()) != null){// Split the line by commasfileData.Add(ParseString(line));}}}// A method to parse a single stringpublic LineData ParseString(string input){// Split the string by the first (, assuming it is the separator between the name and the valuesstring[] split = input.Split(new char[] { '(' }, 2);// If the split length is not 2, the input is invalidif (split.Length != 2){Debug.LogError("Invalid input: " + input);return null;}// Store the name as the first element of the splitstring name = split[0].TrimEnd(',');// Trim the trailing ) from the second element of the splitchar[] charsToTrim = { ')', ' ', '\n' };string valuesString = split[1].Trim().TrimEnd(charsToTrim);//foreach(char c in valuesString.ToCharArray()) { print(c); }// Split the values string by ),(, assuming they are the separators between the value groupsstring[] valueGroups = valuesString.Split(new string[] { "),(" }, StringSplitOptions.None);// Create a list to store the float arraysList<float[]> values = new List<float[]>();// Loop through each value groupforeach (string valueGroup in valueGroups){// Split the value group by ,, assuming they are the separators between the float valuesstring[] valueStrings = valueGroup.Split(',');// Create a float array to store the parsed valuesfloat[] valueArray = new float[valueStrings.Length];// Loop through each value stringfor (int i = 0; i < valueStrings.Length; i++){// Try to parse the value string as a float and store it in the array// If the parsing fails, log an error and return nullif (!float.TryParse(valueStrings[i], out valueArray[i])){Debug.LogError("Invalid value: " + valueStrings[i]);return null;}}//foreach(var v in valueArray) { print(v); }// Add the float array to the listvalues.Add(valueArray);}// Create and return a ParsedData object with the name and the valuesreturn new LineData(name, values);}// A method to parse multiple strings and store them in the listpublic void ParseStrings(string[] inputs){// Clear the listfileData.Clear();// Loop through each input stringforeach (string input in inputs){// Parse the string and add the result to the listLineData parsedData = ParseString(input);if (parsedData != null){fileData.Add(parsedData);}}}public LineData ParseRootMotionData(string input){// Split the string by the first (, assuming it is the separator between the name and the valuesstring[] split = input.Split(new char[] { '[' }, 2);// If the split length is not 2, the input is invalidif (split.Length != 2){Debug.LogError("Invalid input: " + input);return null;}// Store the name as the first element of the splitstring name = split[0].TrimEnd(',');// Trim the trailing ) from the second element of the splitchar[] charsToTrim = { ']', ' ', '\n' };string valuesString = split[1].Trim().TrimEnd(charsToTrim);//foreach(char c in valuesString.ToCharArray()) { print(c); }// Split the values string by ),(, assuming they are the separators between the value groupsstring[] valueGroups = valuesString.Split(new string[] { "],[" }, StringSplitOptions.None);// Create a list to store the float arraysList<float[]> values = new List<float[]>();// Loop through each value groupforeach (string valueGroup in valueGroups){// Split the value group by ,, assuming they are the separators between the float valuesstring[] valueStrings = valueGroup.Split(',');// Create a float array to store the parsed valuesfloat[] valueArray = new float[valueStrings.Length];// Loop through each value stringfor (int i = 0; i < valueStrings.Length; i++){// Try to parse the value string as a float and store it in the array// If the parsing fails, log an error and return nullif (!float.TryParse(valueStrings[i], out valueArray[i])){Debug.LogError("Invalid value: " + valueStrings[i]);return null;}}//foreach(var v in valueArray) { print(v); }// Add the float array to the listvalues.Add(valueArray);}// Create and return a ParsedData object with the name and the valuesreturn new LineData(name, values);}void ParseTxt(){// Initialize the file data listfileData = new List<LineData>();// Read the text file line by lineusing (StreamReader reader = new StreamReader(inputPath)){string line;while ((line = reader.ReadLine()) != null){// Split the line by commasstring[] elements = line.Split(',');// The first element is the namestring name = elements[0];// The rest of the elements are float arraysList<float[]> values = new List<float[]>();for (int i = 1; i < elements.Length; i++){// Remove the parentheses and split by spacesstring[] numbers = elements[i].Trim('(', ')').Split(' ');//print(string.Join(", ", numbers));// Parse the numbers as floats and store them in an arrayfloat[] value = new float[numbers.Length];for (int j = 0; j < numbers.Length; j++){value[j] = float.Parse(numbers[j]);}// Add the array to the values listvalues.Add(value);}// Create a new line data object and add it to the file data listLineData lineData = new LineData(name, values);fileData.Add(lineData);}}Print the file data for testing//foreach (LineData lineData in fileData)//{//    Debug.Log("Name: " + lineData.name);//    Debug.Log("Values: ");//    foreach (float[] value in lineData.values)//    {//        Debug.Log(string.Join(", ", value));//    }//}}// A method to load and parse a CSV file from a given pathpublic void ParseCSV(string path){// Initialize the data listdata = new List<List<string>>();// Try to open the file with a stream readertry{using (StreamReader reader = new StreamReader(path)){// Read each line until the end of the filewhile (!reader.EndOfStream){// Get the current linestring line = reader.ReadLine();// Initialize a list to store the fieldsList<string> fields = new List<string>();// Match the fields with the regular expressionMatchCollection matches = fieldPattern.Matches(line);// Loop through the matchesforeach (Match match in matches){// Get the field valuestring field = match.Value;// Trim the leading and trailing commasfield = field.TrimStart(',').TrimEnd(',');// Trim the leading and trailing quotesfield = field.TrimStart('"').TrimEnd('"');// Replace any escaped quotes with single quotesfield = field.Replace("\"\"", "\"");// Add the field to the listfields.Add(field);}// Add the list of fields to the data listdata.Add(fields);}}}// Catch any exceptions and log themcatch (Exception e){Debug.LogError("Error loading CSV file: " + e.Message);}}
}

ERROR:F:\desktop\Animation\Assets\Scripts\AnimationClipFromCSV.cs(10,7): error CS0246: 未能找到類型或命名空間名“Newtonsoft”(是否缺少 using 指令或程序集引用?)

solve: 使用 Unity 的 Package Manager 安裝(如果可用) ? ?- 打開 Package Manager (Window > Package Manager) ? ?- 點擊左上角的 "+" 號,選擇 "Add package from git URL..." ? ?- 輸入:`com.unity.nuget.newtonsoft-json`

3.代碼仔細閱讀

using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text.RegularExpressions;
using UnityEngine;
using Newtonsoft.Json.Linq;
using System.Text;
using static System.Net.Mime.MediaTypeNames;//[RequireComponent(typeof(Animation))]
public class AnimationClipFromCSV : MonoBehaviour
{AnimationClip animationClip;public List<List<string>> data;public List<LineData> fileData;private Regex fieldPattern = new Regex("(?:^|,)(\"(?:[^\"]+|\"\")*\"|[^,]*)");private Dictionary<string, string> field_mapping = new Dictionary<string, string>();public List<string> curve_names;public List<string> root_motion_curve_names;private int num_curves_on_single_joint;private int num_curves_root_motion;// legacyprivate int num_keys = 10; //number of keys to keep *in addition to* the initial keyprivate int num_meta_columns = 3;private string inputPath = "C:\\Bill\\temp/whale_excited2.txt";private string outputPath;private GameObject joint_hierarchy_root;[TextArea(10, 30)]private string object_JSON;private Animation anim;private string clip_name;//public GameObject obj;//public GameObject root_obj;void Awake(){num_curves_on_single_joint = curve_names.Count;num_curves_root_motion = root_motion_curve_names.Count;//anim = GetComponent<Animation>();define animation curve//animationClip = new AnimationClip();set animation clip to be legacy//animationClip.legacy = true;//ConfigurateAnimationCurvesTxt();post-processing for visual quality//animationClip.EnsureQuaternionContinuity();add clip to the animator//anim.AddClip(animationClip, clip_name);play it on loop//AnimationState state = anim[clip_name];//state.wrapMode = WrapMode.Loop;//anim.Play(clip_name);}List<LineData> ParseTxtFileToData(string animation_txt){List<LineData> data = new List<LineData>();string[] lines = animation_txt.Split('\n');// the first line is root motionstring root_motion_line = lines[0];data.Add(ParseRootMotionData(RemoveWhiteSpaces(root_motion_line)));// other animation curvesfor (int i = 1; i < lines.Length; i++){string line = lines[i];//data.Add(ParseString(line));data.Add(ParseString(RemoveWhiteSpaces(line)));}return data;}public AnimationClip GetClipFromTxt(string animation_txt){AnimationClip clip = new AnimationClip();// 是Unity中表示動畫數據的類(包含關鍵幀、曲線等)clip.legacy = true;List<LineData> animation_data = ParseTxtFileToData(animation_txt);the first data is root motion//LineData root_motion_data = animation_data[0];//List<AnimationCurve> root_motion_curves = new List<AnimationCurve>();//string root_name = root_motion_data.name;//List<float[]> root_values = root_motion_data.values;//for (int k = 0; k < num_curves_root_motion; k++)//{//    AnimationCurve new_curve = new AnimationCurve();//    root_motion_curves.Add(new_curve);//}//for (int j = 0; j < root_values.Count; j++) // loop over keys at different times//{//    float[] key_values = root_values[j];//    for (int k = 0; k < num_curves_root_motion; k++) // loop over property curves//    {//        float key_time = key_values[0];//        float key_value = key_values[k + 1];//        root_motion_curves[k].AddKey(key_time, key_value);//        //print(root_name);//        //print(key_time);//        //print(key_value);//    }//}//for (int k = 0; k < num_curves_root_motion; k++)//{//    clip.SetCurve(root_name, typeof(Transform), root_motion_curve_names[k], root_motion_curves[k]);//}/*整體功能動態創建骨骼動畫:解析動畫數據(如BVH、FBX等格式導出的數據)為每個關節創建動畫曲線(位置、旋轉等)將曲線綁定到動畫片段(AnimationClip)支持根運動(root motion)和普通關節的差異化處理*/// other animation curvesfor (int i = 0; i < animation_data.Count; i++) // loop through gameObjects (different joints){LineData row = animation_data[i];string obj_name = row.name.Trim();//.Trim():移除名稱首尾的空白字符(空格、制表符、換行符等)List<float[]> values = row.values;// the same GO has many animation curvesList<AnimationCurve> ani_curves = new List<AnimationCurve>();//創建了一個動畫曲線(AnimationCurve)的集合容器int num_curves = (i == 0 ? num_curves_root_motion : num_curves_on_single_joint);List<string> property_curve_names = (i == 0 ? root_motion_curve_names : curve_names);for (int k = 0; k < num_curves; k++) // create all animation curves for this GO (ex: rotation in x,y,z){AnimationCurve new_curve = new AnimationCurve();//創建指定數量的空動畫曲線ani_curves.Add(new_curve);}// 負責將原始動畫數據填充到動畫曲線for (int j = 0; j < values.Count; j++) // loop over keys at different times{float[] key_values = values[j];for (int k = 0; k < num_curves; k++) // loop over property curves{//print(key_values.Length);float key_time = key_values[0];float key_value = key_values[k + 1];ani_curves[k].AddKey(key_time, key_value);}}//綁定到動畫片段for (int k = 0; k < num_curves; k++) // create all animation curves for this GO (ex: rotation in x,y,z){clip.SetCurve(obj_name, typeof(Transform), property_curve_names[k], ani_curves[k]); // first entry is GO name}}return clip;}A class to represent a node in the scene hierarchy//[System.Serializable]//public class ObjectNode//{//    public string name; // The name of the gameObject//    public string position;//    //public string scale;//    //public string rotation;//    public List<ObjectNode> children; // The list of child nodes//    // A constructor that takes a gameObject and recursively creates child nodes//    public ObjectNode(GameObject gameObject)//    {//        name = gameObject.name;//        position = gameObject.transform.localPosition.ToString("F4");//        //scale = gameObject.transform.localScale.ToString("F1");//        //rotation = gameObject.transform.rotation.ToString("F1");//        // recurse on its children//        children = new List<ObjectNode>();//        foreach (Transform child in gameObject.transform)//        {//            children.Add(new ObjectNode(child.gameObject));//        }//    }//}//用于處理特殊格式的文本,保留"Summary"段落內容的同時移除其他部分的引號、空格和換行符public string RemoveQuotesAndSpacesIgnoringSummary(string input){// 匹配所有"Summary"開頭的段落(包括結尾換行符)string pattern = @"Summary.*\n";var matches = Regex.Matches(input, pattern);// Use a string builder to append the matched parts and remove the quotes, spaces, and new lines from the restvar output = new StringBuilder();// Keep track of the last index of the matched partint lastIndex = 0;// Loop through the matchesforeach (Match match in matches){//處理Summary之前的內容:移除引號、空格和換行符//print (match.Value);// Remove the quotes, spaces, and new lines from the substring before the matchoutput.Append(Regex.Replace(input.Substring(lastIndex, match.Index - lastIndex), @"[""\s]", ""));// 保留Summary內容,但移除結尾換行符// Append the matched part, remove the new line at the end.output.Append(match.Value.Remove(match.Value.Length - 1, 1));//output.Append(match.Value);// Update the last indexlastIndex = match.Index + match.Length;}// 處理最后一個Summary之后的內容// Remove the quotes, spaces, and new lines from the remaining substringoutput.Append(Regex.Replace(input.Substring(lastIndex), @"[""\s]", ""));// Return the output stringreturn output.ToString();}public string RemoveEmptyChildren(string json)//移除 JSON 字符串中空的 children 數組{// Use regular expressions to match the patterns and replace them with empty strings or "}"string output = Regex.Replace(json, @",children:\[\]", "");return output;}public string RemoveBracesFromString(string input) //移除輸入字符串中的所有花括號({ 和 }),返回處理后的字符串{// If the input is null or empty, return it as it isif (string.IsNullOrEmpty(input)){return input;}// Use a StringBuilder to store the output without bracesStringBuilder output = new StringBuilder();// Loop through each character in the inputforeach (char c in input){// If the character is not a brace, append it to the outputif (c != '{' && c != '}'){output.Append(c);}}// Return the output as a stringreturn output.ToString();}string GetRelativeGOName(GameObject obj, GameObject root_obj)//獲取一個 GameObject 相對于另一個 root_obj 的層級路徑(用 / 分隔){string name = "";while (obj.transform.parent != null && obj != root_obj){name = obj.name + "/" + name;obj = obj.transform.parent.gameObject;}// remove the last "/"name = name.Remove(name.Length - 1, 1);return name;}void ProcessCSVFiles(){//處理 CSV 文件,提取指定列(如 "Name", "ParentName", "HierarchyIndex" 及包含 "Rotation" 的列),//并對列進行降采樣(DownsampleFrames),最后輸出新 CSV 文件char separator = ',';string[] keepNames = { "Name", "ParentName", "HierarchyIndex" };// The substring to check for rotation columnsstring rotationSubstring = "Rotation";// Read the input file as an array of linesstring[] lines = File.ReadAllLines(inputPath);// Assume the first line is the header and split it by the separatorstring[] header = lines[0].Split(separator);// trim names with white spacesheader = header.Select(p => p.Trim()).ToArray();// Find the indices of the columns to keep by checking the names and the substringint[] keepIndices = header.Select((name, index) => new { name, index }).Where(x => keepNames.Contains(x.name) || x.name.Contains(rotationSubstring)).Select(x => x.index).ToArray();// downsample the frames//int startIdx = GetFirstSubstringIdx(header, rotationSubstring);//int endIdx = GetEndSubstringIdx(header, rotationSubstring);keepIndices = DownsampleFrames(keepIndices);// Create a new array of lines for the output filestring[] outputLines = new string[lines.Length];// For each line, keep only the values at the keep indices and join them by the separatorfor (int i = 0; i < lines.Length; i++){string[] values = lines[i].Split(separator);string[] outputValues = keepIndices.Select(index => values[index]).ToArray();outputLines[i] = string.Join(separator.ToString(), outputValues);}// Write the output lines to the output fileFile.WriteAllLines(outputPath, outputLines);}int[] DownsampleFrames(int[] indices){Calculate the interval to skip rotations//int interval = indices.Length / num_curves_on_single_joint / num_keys;Create a list to store the selected rotations//List<int> selected = new List<int>();Loop through the indices and add every interval-th rotation to the list//for (int i = num_meta_columns; i < indices.Length; i += num_curves_on_single_joint)//{//    if ((i-num_meta_columns) % (interval * num_curves_on_single_joint) == 0)//    {//        for (int j = 0; j < num_curves_on_single_joint; j++)//        {//            selected.Add(indices[i + j]);//        }//    }//}//return selected.ToArray();// Copy the first four elements (name, parent name, hier, and first rotation)List<int> idx_list = new List<int>(indices);List<int> output = new List<int>(idx_list.GetRange(0, num_meta_columns + 1));// Calculate the interval between rotations to keepint interval = (idx_list.Count - num_meta_columns - 1) / (num_curves_on_single_joint * num_keys);// Loop through the remaining rotations and add them to the output if they match the intervalfor (int i = num_meta_columns + 1; i < idx_list.Count; i += num_curves_on_single_joint){if ((i - num_meta_columns - 1) % (interval * num_curves_on_single_joint) == 0){output.AddRange(idx_list.GetRange(i, num_curves_on_single_joint - 1));}}return output.ToArray();}int GetFirstSubstringIdx(string[] str_list, string sub_string){//在字符串數組 str_list 中查找第一個包含指定子字符串 sub_string 的元素,//并返回其索引。如果未找到,返回 -1。for (int i = 0; i < str_list.Length; i++){string s = str_list[i];// Check if the current string contains "Rotation" as a substringif (s.Contains(sub_string)){// If yes, assign it to the result variable and break the loopreturn i;}}return -1;}void ConfigurateAnimationCurvesTxt(){ParseTxtFile();for (int i = 0; i < fileData.Count; i++) // loop through gameObjects (different joints){LineData row = fileData[i];string obj_name = row.name;List<float[]> values = row.values;// the same GO has many animation curvesList<AnimationCurve> ani_curves = new List<AnimationCurve>();for (int k = 0; k < num_curves_on_single_joint; k++) // create all animation curves for this GO (ex: rotation in x,y,z){AnimationCurve new_curve = new AnimationCurve();ani_curves.Add(new_curve);}for (int j = 0; j < values.Count; j++) // loop over keys at different times{float[] key_values = values[j];for (int k = 0; k < num_curves_on_single_joint; k++) // loop over property curves{float key_time = key_values[0];float key_value = key_values[k + 1];ani_curves[k].AddKey(key_time, key_value);}}for (int k = 0; k < num_curves_on_single_joint; k++) // create all animation curves for this GO (ex: rotation in x,y,z){//animationClip.SetCurve("", typeof(Transform), row[0], ani_curves[k]); // first entry is GO nameanimationClip.SetCurve(obj_name, typeof(Transform), curve_names[k], ani_curves[k]); // first entry is GO name}}}void ConfigurateAnimationCurves(){ParseCSV(inputPath);// loop through gameObjects (different joints)for (int i = 0; i < data.Count; i++){List<string> row = data[i];// the same GO has many animation curves//Dictionary<string, AnimationCurve> ani_curves = new Dictionary<string, AnimationCurve>();List<AnimationCurve> ani_curves = new List<AnimationCurve>();for (int k = 0; k < num_curves_on_single_joint; k++) // create all animation curves for this GO (ex: rotation in x,y,z){AnimationCurve new_curve = new AnimationCurve();ani_curves.Add(new_curve);}// loop through different frames for the same GO// skip the first few columns, which are metadataint j = num_meta_columns;while (j < row.Count - num_curves_on_single_joint){// assume the first entry in each block is the timefloat time_stamp = 0f;float.TryParse(row[j], out time_stamp);for (int k = 0; k < num_curves_on_single_joint; k++){float animation_key_value = 0f;float.TryParse(row[j + k], out animation_key_value);ani_curves[k].AddKey(time_stamp, animation_key_value);}j += num_curves_on_single_joint;}for (int k = 0; k < num_curves_on_single_joint; k++) // create all animation curves for this GO (ex: rotation in x,y,z){//animationClip.SetCurve("", typeof(Transform), row[0], ani_curves[k]); // first entry is GO nameanimationClip.SetCurve(row[0], typeof(Transform), curve_names[k], ani_curves[k]); // first entry is GO name}}}void ConfigurateAnimationCurvesExample(){//AnimationCurve translateX = AnimationCurve.Linear(0.0f, 0.0f, 2.0f, 2.0f);AnimationCurve translateX = new AnimationCurve();translateX.AddKey(0f, 0f);translateX.AddKey(2f, 2f);translateX.AddKey(3f, -2f);animationClip.SetCurve("", typeof(Transform), "localPosition.x", translateX);}public string RemoveWhiteSpaces(string json)//該方法用于從字符串中移除所有空白字符:{// Use a regular expression to match and replace any sequence of white space charactersreturn Regex.Replace(json, @"\s+", "");}public class LineData{public string name; // The first elementpublic List<float[]> values; // The rest of the elements as float arrayspublic LineData(string name, List<float[]> values){this.name = name;this.values = values;}}void ParseTxtFile(){fileData = new List<LineData>();using (StreamReader reader = new StreamReader(inputPath)){string line;while ((line = reader.ReadLine()) != null){// Split the line by commasfileData.Add(ParseString(line));}}}// A method to parse a single stringpublic LineData ParseString(string input){// Split the string by the first (, assuming it is the separator between the name and the valuesstring[] split = input.Split(new char[] { '(' }, 2);// If the split length is not 2, the input is invalidif (split.Length != 2){Debug.LogError("Invalid input: " + input);return null;}// Store the name as the first element of the splitstring name = split[0].TrimEnd(',');// Trim the trailing ) from the second element of the splitchar[] charsToTrim = { ')', ' ', '\n' };string valuesString = split[1].Trim().TrimEnd(charsToTrim);//移除首尾所有空白字符//foreach(char c in valuesString.ToCharArray()) { print(c); }// Split the values string by ),(, assuming they are the separators between the value groupsstring[] valueGroups = valuesString.Split(new string[] { "),(" }, StringSplitOptions.None);// Create a list to store the float arraysList<float[]> values = new List<float[]>();// Loop through each value groupforeach (string valueGroup in valueGroups){// Split the value group by ,, assuming they are the separators between the float valuesstring[] valueStrings = valueGroup.Split(',');// Create a float array to store the parsed valuesfloat[] valueArray = new float[valueStrings.Length];// Loop through each value stringfor (int i = 0; i < valueStrings.Length; i++){// Try to parse the value string as a float and store it in the array// If the parsing fails, log an error and return nullif (!float.TryParse(valueStrings[i], out valueArray[i])){Debug.LogError("Invalid value: " + valueStrings[i]);return null;}}//foreach(var v in valueArray) { print(v); }// Add the float array to the listvalues.Add(valueArray);}// Create and return a ParsedData object with the name and the valuesreturn new LineData(name, values);}// A method to parse multiple strings and store them in the listpublic void ParseStrings(string[] inputs){// Clear the listfileData.Clear();// Loop through each input stringforeach (string input in inputs){// Parse the string and add the result to the listLineData parsedData = ParseString(input);if (parsedData != null){fileData.Add(parsedData);}}}public LineData ParseRootMotionData(string input){// Split the string by the first (, assuming it is the separator between the name and the valuesstring[] split = input.Split(new char[] { '[' }, 2);// 將一個字符串(`input`)按照第一個出現的左方括號字符 `[` 進行分割,并且最多分割成兩個子字符// If the split length is not 2, the input is invalidif (split.Length != 2){Debug.LogError("Invalid input: " + input);return null;}// Store the name as the first element of the splitstring name = split[0].TrimEnd(',');//移除字符串 末尾的逗號(,)// Trim the trailing ) from the second element of the splitchar[] charsToTrim = { ']', ' ', '\n' }; //創建待刪除字符數組,包含三個字符:string valuesString = split[1].Trim().TrimEnd(charsToTrim);//foreach(char c in valuesString.ToCharArray()) { print(c); }// Split the values string by ),(, assuming they are the separators between the value groupsstring[] valueGroups = valuesString.Split(new string[] { "],[" }, StringSplitOptions.None);//StringSplitOptions.None):確保空字符串能被識別// Create a list to store the float arraysList<float[]> values = new List<float[]>();// Loop through each value groupforeach (string valueGroup in valueGroups){// Split the value group by ,, assuming they are the separators between the float valuesstring[] valueStrings = valueGroup.Split(','); //將一個包含逗號分隔值的字符串拆分成字符串數組// Create a float array to store the parsed valuesfloat[] valueArray = new float[valueStrings.Length];// Loop through each value stringfor (int i = 0; i < valueStrings.Length; i++){// Try to parse the value string as a float and store it in the array// If the parsing fails, log an error and return nullif (!float.TryParse(valueStrings[i], out valueArray[i])){Debug.LogError("Invalid value: " + valueStrings[i]);return null;}}//foreach(var v in valueArray) { print(v); }// Add the float array to the listvalues.Add(valueArray);}// Create and return a ParsedData object with the name and the valuesreturn new LineData(name, values);}void ParseTxt(){// Initialize the file data listfileData = new List<LineData>();// Read the text file line by lineusing (StreamReader reader = new StreamReader(inputPath)){string line;while ((line = reader.ReadLine()) != null){// Split the line by commasstring[] elements = line.Split(',');// The first element is the namestring name = elements[0];// The rest of the elements are float arraysList<float[]> values = new List<float[]>();for (int i = 1; i < elements.Length; i++){// Remove the parentheses and split by spacesstring[] numbers = elements[i].Trim('(', ')').Split(' ');//print(string.Join(", ", numbers));// Parse the numbers as floats and store them in an arrayfloat[] value = new float[numbers.Length];for (int j = 0; j < numbers.Length; j++){value[j] = float.Parse(numbers[j]);}// Add the array to the values listvalues.Add(value);}// Create a new line data object and add it to the file data listLineData lineData = new LineData(name, values);fileData.Add(lineData);}}Print the file data for testing//foreach (LineData lineData in fileData)//{//    Debug.Log("Name: " + lineData.name);//    Debug.Log("Values: ");//    foreach (float[] value in lineData.values)//    {//        Debug.Log(string.Join(", ", value));//    }//}}// A method to load and parse a CSV file from a given pathpublic void ParseCSV(string path){// Initialize the data listdata = new List<List<string>>();// Try to open the file with a stream readertry{using (StreamReader reader = new StreamReader(path)){// Read each line until the end of the filewhile (!reader.EndOfStream){// Get the current linestring line = reader.ReadLine();// Initialize a list to store the fieldsList<string> fields = new List<string>();// Match the fields with the regular expressionMatchCollection matches = fieldPattern.Matches(line);// Loop through the matchesforeach (Match match in matches){// Get the field valuestring field = match.Value;// Trim the leading and trailing commasfield = field.TrimStart(',').TrimEnd(',');// Trim the leading and trailing quotesfield = field.TrimStart('"').TrimEnd('"');// Replace any escaped quotes with single quotesfield = field.Replace("\"\"", "\"");// Add the field to the listfields.Add(field);}// Add the list of fields to the data listdata.Add(fields);}}}// Catch any exceptions and log themcatch (Exception e){Debug.LogError("Error loading CSV file: " + e.Message);}}
}

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/diannao/89929.shtml
繁體地址,請注明出處:http://hk.pswp.cn/diannao/89929.shtml
英文地址,請注明出處:http://en.pswp.cn/diannao/89929.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

Centos系統及國產麒麟系統設置自己寫的go服務的開機啟動項完整教程

1、創建服務文件 在 /etc/systemd/system/ 下新建服務配置文件&#xff08;需sudo權限&#xff09;&#xff0c;例如&#xff1a; sudo nano /etc/systemd/system/mygo.service 如下圖&#xff0c;創建的mygo.service 2、創建內容如下&#xff1a; DescriptionThe go HTTP a…

Java面試寶典: IO流

1. 下面哪個流類屬于面向字符的輸入流() 選項: A. BufferedWriter B. FileInputStream C. ObjectInputStream D. InputStreamReader 答案:D 詳細分析: 字符流與字節流的本質區別: 字符流(Character Streams)以Unicode字符為單位操作數據,適用于文本處理字節流(Byte…

黑馬python(二十五)

目錄&#xff1a;1.數據輸出-輸出為Python對象2.數據輸出-輸出到文件中3.綜合案例1.數據輸出-輸出為Python對象2.數據輸出-輸出到文件中移動文件到文件夾&#xff1a;生成了好多文件&#xff0c;因為Rdd是有分區的 &#xff0c;會把數據分散到各個分區去存儲&#xff0c;因為電…

【LeetCode 熱題 100】41. 缺失的第一個正數——(解法一)暴力解

Problem: 41. 缺失的第一個正數 題目&#xff1a;給你一個未排序的整數數組 nums &#xff0c;請你找出其中沒有出現的最小的正整數。 請你實現時間復雜度為 O(n) 并且只使用常數級別額外空間的解決方案。 文章目錄整體思路完整代碼時空復雜度時間復雜度&#xff1a;O(N log N)…

在運行 Laravel Sail 前,需安裝 Docker Desktop 并完成基礎配置/具體步驟

一、安裝 Docker Desktop&#xff08;必備環境&#xff09; Windows 系統 &#xff08;windows安裝包 有兩個版本&#xff09; 架構版本查看 1. Win R? 輸入 ?cmd? 打開命令提示符&#xff1b; 2. ?輸入命令?&#xff1a; bash echo %PROCESSOR_ARCHITECTURE% 3. ?結果…

AI 應用于進攻性安全

一、引言 大語言模型&#xff08;LLM&#xff09;和 AI 智能體的出現推動進攻性安全變革&#xff0c;其在偵察、掃描、漏洞分析、利用、報告五個階段展現出數據分析、代碼生成、攻擊場景規劃等能力&#xff0c;能提升安全團隊效率與擴展性&#xff0c;但存在 “幻覺” 等局限性…

微控制器中的EXTI0(External Interrupt 0)中斷是什么?

微控制器中的EXTI0(External Interrupt 0)中斷是什么? EXTI0(External Interrupt 0) 是微控制器(如STM32等ARM Cortex-M系列芯片)中的一個外部中斷線,專門用于處理來自特定GPIO引腳的外部信號觸發中斷。以下是詳細說明: 1. 基本概念 EXTI(External Interrupt/Event …

EasyGBS平臺內置AI算法了,算法成為了視頻平臺的標配

今年五一的時候立了個flag&#xff08;《國標GB28181平臺EasyGBS未來研發方向在哪&#xff1f;》&#xff09;&#xff0c;我想不能再局限在只是滿足于傳統視頻平臺的功能&#xff0c;傳統的EasyGBS也就是接入幾種視頻協議&#xff0c;什么RTSP、ONVIF、RTMP、GB28181這些&…

C# 常量與變量

在 C# 中&#xff0c;常量和變量是存儲數據的基本方式&#xff1a; // 常量&#xff1a;使用 const 關鍵字聲明&#xff0c;必須在聲明時初始化&#xff0c;且值不能改變 const double Pi 3.14159; const string Message "Hello, World!"; ? // 變量&#xff1a;…

TensorRT-LLM:大模型推理加速的核心技術與實踐優勢

大型語言模型推理就像讓一頭300公斤的大熊貓玩平衡木——顯存消耗和計算效率這對雙胞胎問題隨時可能讓表演翻車。以主流的7B參數模型為例&#xff0c;FP16精度下僅模型權重就吃掉14GB顯存&#xff0c;這還沒算上推理過程中不斷膨脹的KV Cache——當處理2048長度的對話時&#x…

免費棱光 PDF:免安裝 加水印 去水印 批量格式轉換

各位辦公小能手們&#xff0c;今天給大家介紹一款超棒的PDF處理工具——棱光PDF&#xff01;它完全免費&#xff0c;專門解決咱對PDF文件的常見操作需求。綠色免安裝&#xff0c;體積小得跟顆花生米似的&#xff0c;打開就能用。它有三大核心功能&#xff0c;分別是水印管理、格…

(二)復習(Error Pattern/Result Pattern/)

文章目錄 項目地址一、Error Pattern1.1 定義Error類1. ErrorType 可發生的錯誤類型2. Error類3. ValidataionError1.2 給每個實體創建Error類1. CategoryError類2. TicketErrror類3. EventErrror類二、Result Pattern1.1 自定義返回Result1. 泛型類2. 泛型方法1.2 Api層的Resu…

20250705-day6

NATO&#xff1a;北大西洋公約組織 Software Crisis&#xff1a;軟件危機 Paradigm&#xff1a;設計范型 Waterfall Model&#xff1a;瀑布模型 Prototype Model&#xff1a;原型模型&#xff08;又稱快速模型&#xff09; Spiral Model&#xff1a;螺旋模型 Agile&#xff1a;…

視頻播放中時鐘的概念及音視頻同步概念

author: hjjdebug date: 2025年 07月 05日 星期六 18:20:45 CST descrip: 視頻播放中時鐘的概念及音視頻同步概念 文章目錄 1.前言: 視頻播放:1. 固定延時時間2. 根據frame的duration來延時.3. 根據frame的PTS 來播放3.1. 時鐘是什么?3.2. 時鐘的用途. 2.音視頻同步: 1.前言: …

Python基礎之字符串操作全解析

在 Python 中&#xff0c;字符串是最常用的數據類型之一&#xff0c;掌握字符串的各種操作對于日常編程至關重要。本文將詳細介紹 Python 字符串的類型特性、編碼轉換、常用運算符及方法&#xff0c;幫助你全面掌握字符串處理技巧。 一、字符串的基本類型 Python 中的字符串屬…

【爬蟲】逆向爬蟲初體驗之爬取音樂

尋找數據 打開F12中的網絡頁面&#xff0c;播放音樂后&#xff0c;篩選媒體&#xff0c;會發現當前這首歌曲音頻鏈接地址&#xff0c;打開后&#xff0c;點擊“標頭”就能能看到請求URL 截取“.mp3”前面的一部分進行搜索&#xff0c;搜索出來了很多數據包&#xff0c;但都是…

CppCon 2018 學習:Fancy Pointers for Fun and Profit

“Fancy Pointers for Fun and Profit” 這個標題聽起來像是在討論**“高級指針用法”**&#xff0c;尤其是在C里&#xff0c;如何利用智能指針、定制指針類型&#xff0c;或者其他高級指針技巧來寫更安全、更高效、更優雅的代碼。 可能的理解和內容方向&#xff1a; 1. 什么是…

思辨場域丨數字信號技術重塑農林牧漁:從“靠天吃飯”到“靠數吃飯”

凌晨三點&#xff0c;山東萊蕪的養豬戶老李被手機震動驚醒。屏幕顯示&#xff1a;3號豬舍&#xff0c;母豬即將分娩。他輕點屏幕啟動遠程監控&#xff0c;翻身繼續入睡——而在幾年前&#xff0c;這樣的夜晚他只能在豬圈里守著。 清晨的茶園里&#xff0c;興業縣的茶農王大姐掏…

文心大模型及百度大模型內容安全平臺齊獲信通院大模型安全認證

近日&#xff0c;文心大模型與百度大模型內容安全平臺——紅線大模型雙雙榮獲中國信息通信研究院泰爾認證中心頒發的“大規模預訓練模型&#xff08;文本生成功能&#xff09;安全認證證書”&#xff0c;且二者的認證級別皆“增強級”的最高級別。 大規模預訓練模型&#xff08…

香港服務器查詢緩存禁用-性能優化關鍵技術解析

在香港服務器運維過程中&#xff0c;查詢緩存禁用是提升數據庫性能的關鍵操作。本文將深入解析禁用查詢緩存的原理、操作步驟、適用場景及注意事項&#xff0c;幫助管理員優化MySQL服務器配置&#xff0c;解決高并發環境下的性能瓶頸問題。香港服務器查詢緩存禁用-性能優化關鍵…