fix: .gitignore + add 44 language JSON files

This commit is contained in:
shuiyu1123 committed 2026-07-14 01:17:33 +08:00
1 parent e8fd68e27b
commit 8de545dd2c
227 files changed
+22603

No files matched your search

+56
View File
@@ -0,0 +1,56 @@
using System.Globalization;
namespace Lity3DEditor;
public static class SceneIO
{
public static List<SceneNode> Load(string path)
{
var nodes = new List<SceneNode>();
using var reader = new StreamReader(path);
string? header = reader.ReadLine();
if (header == null || !header.StartsWith("LITY3D_SCENE"))
throw new InvalidDataException("不是有效的 Lity3D 场景文件");
int lineIdx = 1;
string? line;
while ((line = reader.ReadLine()) != null)
{
if (string.IsNullOrWhiteSpace(line)) continue;
var parts = line.Split(new[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
if (parts.Length < 13) continue;
var node = new SceneNode
{
Name = parts[0],
ParentIndex = int.Parse(parts[1]),
Mesh = Enum.Parse<MeshType>(parts[2], true),
MeshPath = parts[3],
PosX = float.Parse(parts[4], CultureInfo.InvariantCulture),
PosY = float.Parse(parts[5], CultureInfo.InvariantCulture),
PosZ = float.Parse(parts[6], CultureInfo.InvariantCulture),
RotX = float.Parse(parts[7], CultureInfo.InvariantCulture),
RotY = float.Parse(parts[8], CultureInfo.InvariantCulture),
RotZ = float.Parse(parts[9], CultureInfo.InvariantCulture),
ScaleX = float.Parse(parts[10], CultureInfo.InvariantCulture),
ScaleY = float.Parse(parts[11], CultureInfo.InvariantCulture),
ScaleZ = float.Parse(parts[12], CultureInfo.InvariantCulture),
LineIndex = lineIdx
};
nodes.Add(node);
lineIdx++;
}
return nodes;
}
public static void Save(string path, List<SceneNode> nodes)
{
using var writer = new StreamWriter(path);
writer.WriteLine("LITY3D_SCENE 1");
foreach (var node in nodes)
{
int parent = node.ParentIndex;
writer.WriteLine(node.ToSceneLine(parent));
}
}
}