Skip to content

Instantly share code, notes, and snippets.

@camden-smallwood-zz
Created October 29, 2015 04:56
Show Gist options
  • Select an option

  • Save camden-smallwood-zz/226c7496dede75e8ab57 to your computer and use it in GitHub Desktop.

Select an option

Save camden-smallwood-zz/226c7496dede75e8ab57 to your computer and use it in GitHub Desktop.
var resourceContext = new ResourceSerializationContext(sbsp.Resource2);
var definition = _info.Deserializer.Deserialize<RenderGeometryResourceDefinition>(resourceContext);
var resourceStream = new MemoryStream();
resourceManager.Extract(sbsp.Resource2, resourceStream);
using (var objFile = new StreamWriter(File.Open("D:\\Halo\\bsp_test.obj", FileMode.Create, FileAccess.Write)))
{
var objExtractor = new ObjExtractor(objFile);
for (var i = 0; i < sbsp.Sections2.Count; i++)
{
var section = sbsp.Sections2[i];
var meshReader = new MeshReader(_info.Version, section, definition);
CompressionInfo compression = new CompressionInfo();
if (i < sbsp.Compression2.Count)
compression = sbsp.Compression2[i];
var vertexCompressor = new VertexCompressor(compression);
objExtractor.ExtractMesh(meshReader, vertexCompressor, resourceStream);
}
objExtractor.Finish();
}
@camden-smallwood-zz
Copy link
Author

use this after deserializing an sbsp tag in tag tool to extract an sbsp's geometry resources to an .obj file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment