-
Notifications
You must be signed in to change notification settings - Fork 44
Open
Description
Found on some exports from Blender that the Object format isn't completely parsed correctly.
Where a USEMTL keyword appears in the facelist, it sets the texture in the current group. But, because that material applies to all the faces it parses after, not the current group. As such, all faces have the material applied of the last USEMTL encountered. To fix this.
I updated the class to push a new group.
public class UseMaterialParser : TypeParserBase, IUseMaterialParser
{
private readonly IElementGroup _elementGroup;
private readonly IGroupDataStore _groupDataStore;
public UseMaterialParser(IElementGroup elementGroup, IGroupDataStore groupDataStore)
{
_elementGroup = elementGroup;
_groupDataStore = groupDataStore;
}
protected override string Keyword
{
get { return "usemtl"; }
}
public override void Parse(string line)
{
_groupDataStore.PushGroup(line); // create a new group
_elementGroup.SetMaterial(line);
}
I also added to the datastore class some changes
public void PushGroup(string groupName)
{
if (_currentGroup != null)
{
if (_currentGroup.Faces.Count == 0) // if there are no faces, we dont need to create a new group/
{
return;
}
}
_currentGroup = new Group(groupName);
_groups.Add(_currentGroup);
}
private void PushGroupIfNeeded()
{
if (_currentGroup == null)
{
PushGroup("default");
}
}
Just highlighting that the parser currently doesn't create enough groups.
Also, highlight that the exports where it uses the keyword "o" instead of "g" should also create a new group.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels