Skip to content
Ploaj edited this page Jan 18, 2019 · 1 revision

SSBHLib Wiki

Here you will find examples on how to use the SSBHLib

Reading any supported SSBHFile

To read in any supported SSBHFile, you can use the TryParse from SSBH; "ISSBH_File" is inherited by all supported file types.

ISSBH_File File;
if(SSBH.TryParseSSBHFile("C:/meshfile.numshb", out File))
    Console.WriteLine(File.GetType().ToString()); // returns typeof(MESH)

Tools

These are the main way to interact with the Lib.

using SSBHLib.Tools

Reading a MESH file

Reading the vertex and triangle data out of a MESH file is simple with the Vertex Accessor.

using SSBHLib.Tools
...
MESH meshFile;
...
var accessor = SSBHMeshAccessor(meshFile);

// access vertex and triangle index information for each mesh object
foreach (MeshObject obj in meshFile.Objects)
{
    uint[] trianglelist = accessor.ReadIndices(obj);
    Tuple<string, SSBHVertexAttribute[]>[] attributes = accessor.ReadAttribute(obj);
}

The tuple contains the attribute names and the vertex information. For example, the name "Position0" represent the position of the vertices.

The SSBHVertexAttribute contains values X, Y, Z, and W. These may not always be used, so be conscious the type. "map1" for example, only uses X and Y.

If you know what attribute you want, you can get only that attribute as well.

SSBHVertexAttribute[] positions = accessor.ReadAttribute("Position0", obj);

If it doesn't exist, a null value is returned;

Clone this wiki locally