Skip to content

Instantly share code, notes, and snippets.

@maluoi
Created July 4, 2025 17:13
Show Gist options
  • Save maluoi/6eb7088fe0ab907d3caebfc1fe28dd9b to your computer and use it in GitHub Desktop.
Save maluoi/6eb7088fe0ab907d3caebfc1fe28dd9b to your computer and use it in GitHub Desktop.
private static void LogModelInfo(Model m)
{
Log.Info($"Model: {m.Id}");
int vertCount = 0;
int triCount = 0;
foreach (ModelNode n in m.Visuals)
{
Mesh mesh = n.Mesh;
vertCount += mesh.VertCount;
triCount += mesh.IndCount / 3;
}
Log.Info($"[stats: {vertCount} verts, {triCount} tris]");
ModelNode node = m.RootNode;
int depth = 0;
while (node != null)
{
string tabs = new string(' ', depth * 2);
Log.Info($"{tabs}- {node.Name} {(node.Visible?"(Visible)":"(Invisible)")}{(node.Solid ? "(Solid)":"(Intangible)")}");
if (node.Mesh != null) { Log.Info($"{tabs} [mesh: {node.Mesh.Id}, {node.Mesh.VertCount} verts {node.Mesh.IndCount / 3} tris]"); }
if (node.Material != null) {
Log.Info($"{tabs} [mat: {node.Material.Id}, {node.Material.Shader.Id}]");
Log.Info($"{tabs} [ - double sided: {(node.Material.FaceCull == Cull.None ? "YES" : "no")}");
Log.Info($"{tabs} [ - transparency: {node.Material.Transparency}");
Log.Info($"{tabs} [ - depth test: {node.Material.DepthTest}");
Log.Info($"{tabs} [ - depth write: {node.Material.DepthWrite}");
foreach (var p in node.Material.GetAllParamInfo())
{
switch(p.type)
{
case MaterialParam.Float: { float v = node.Material.GetFloat (p.name); Log.Info($"{tabs} [ - {p.name,-15} = {v}"); break; };
case MaterialParam.Int: { int v = node.Material.GetInt (p.name); Log.Info($"{tabs} [ - {p.name,-15} = {v}"); break; };
case MaterialParam.Color128: { Color v = node.Material.GetColor (p.name); Log.Info($"{tabs} [ - {p.name,-15} = {v}"); break; };
case MaterialParam.Texture: { Tex v = node.Material.GetTexture(p.name); Log.Info($"{tabs} [ - {p.name,-15} = {v.Id}"); break; };
case MaterialParam.Vector2: { Vec2 v = node.Material.GetVector2(p.name); Log.Info($"{tabs} [ - {p.name,-15} = {v}"); break; };
case MaterialParam.Vector3: { Vec3 v = node.Material.GetVector3(p.name); Log.Info($"{tabs} [ - {p.name,-15} = {v}"); break; };
case MaterialParam.Vector4: { Vec4 v = node.Material.GetVector4(p.name); Log.Info($"{tabs} [ - {p.name,-15} = {v}"); break; };
default: Log.Info($"{tabs} [ - {p.name}"); break;
}
}
}
foreach(var inf in node.Info) { Log.Info($"{tabs} [data: {inf.Key,-15}, {inf.Value}]"); }
if (node.Child != null) { node = node.Child; depth++; }
else if (node.Sibling != null) { node = node.Sibling; }
else
{
while (node != null)
{
if (node.Sibling != null)
{
node = node.Sibling;
break;
}
depth--;
node = node.Parent;
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment