egametang/ET · error · Exception
0 vertex index
Error message
0 vertex index
What it means
Thrown by ObjImporter.GetIndex when a face vertex reference resolves to index 0. OBJ indices are 1-based positive or negative (relative to end); 0 is explicitly invalid. This happens when a face references '0' or a component ('0/0/0') that decodes to zero.
Source
Thrown at Packages/cn.etetet.recast/Scripts/Core/Share/Recast/ObjImporter.cs:134
private static int ReadFaceVertex(string face, ObjImporterContext context)
{
string[] v = face.Split("/");
return GetIndex(int.Parse(v[0]), context.vertexPositions.Count);
}
private static int GetIndex(int posi, int size)
{
if (posi > 0)
{
posi--;
}
else if (posi < 0)
{
posi = size + posi;
}
else
{
throw new Exception("0 vertex index");
}
return posi;
}
}
}View on GitHub (pinned to 5cab01f7a8)
Solutions
- Locate the 'f' line referencing 0 and correct it to a valid 1-based (or valid negative) index.
- Re-export from the source tool with correct OBJ 1-based indexing.
- Pre-scan face tokens and reject any that equal 0 before importing.
Example fix
// before f 0 1 2 // after f 1 2 3
Defensive patterns
Strategy: validation
Validate before calling
foreach (var line in lines)
if (line.StartsWith("f "))
foreach (var tok in line.Substring(2).Split(' ', StringSplitOptions.RemoveEmptyEntries))
{
int slash = tok.IndexOf('/');
int pos = int.Parse(slash < 0 ? tok : tok.Substring(0, slash));
if (pos == 0) throw new InvalidDataException($"Zero OBJ index in: {line}");
} Type guard
static bool HasNoZeroIndex(string faceToken)
{ var p = faceToken.Split('/')[0]; return int.TryParse(p, out int i) && i != 0; } Try / catch
try { ObjImporter.Load(chunk); }
catch (Exception e) when (e.Message.Contains("0 vertex index"))
{ /* correct the offending face reference */ } Prevention
- OBJ indices are 1-based; never use 0.
- Re-export with a 1-based OBJ exporter.
- Pre-scan face tokens for 0 references.
When it happens
Trigger: An 'f' line containing a literal 0 vertex reference (e.g., 'f 0 1 2'); a face vertex like '0/1/1' whose position index is 0.
Common situations: Exporters that zero-index instead of 1-indexing; hand-authored faces with a typo'd 0; corrupted face data.
Related errors
- Invalid vector, expected 3 coordinates, found {v.Length - 1}
- Invalid number of face vertices: 3 coordinates expected, fou
- {e.Message}
- 如果项非string类型,则必需设置解析器
- condition number parse error: {text}
AI-assisted analysis of egametang/ET@5cab01f7a8 (2026-08-13).
Data as JSON: /api/errors/cf3893226855da6d.
Report an issue: GitHub.