rigObj 0.1.1
RigKit pack API - rigObj
Loading...
Searching...
No Matches
ObjIO.h File Reference
#include <string>
#include "ecs/MEcs.h"
#include "CDrawStyle.h"
#include "CMesh.h"
Include dependency graph for ObjIO.h:

Functions

IoResult rig::obj::load (const std::string &path, rigkit::ecs::CMesh &outMesh)
 Load a Wavefront OBJ into a CMesh (tinyobjloader).
IoResult rig::obj::save (const std::string &path, const rigkit::ecs::CMesh &mesh)
 Write CMesh to a simple Wavefront OBJ.
entt::entity rig::obj::makeMeshFromFile (rigkit::MEcs &ecs, const std::string &path, const rigkit::ecs::CDrawStyle &style={}, const std::string &name={}, IoResult *outResult=nullptr)
 Load OBJ and spawn a mesh entity (CTransform + CMesh + CDrawStyle).

Function Documentation

◆ load()

IoResult rig::obj::load ( const std::string & path,
rigkit::ecs::CMesh & outMesh )

Load a Wavefront OBJ into a CMesh (tinyobjloader).

Keeps the file's vertices and faces. Authored n-gons go in loops (a box stays 6 faces). Tessellates those loops to triangle indices for present. Does not weld coincident verts or merge coplanar islands. Fills texcoords when present (splits a vertex only when one OBJ vertex is used with two UVs). When materials exist, fills faceColors from diffuse. Never fills facePalette (RigKit-only; not part of Wavefront).

Parameters
pathFile path (.obj). MTL is resolved relative to the OBJ.

◆ makeMeshFromFile()

entt::entity rig::obj::makeMeshFromFile ( rigkit::MEcs & ecs,
const std::string & path,
const rigkit::ecs::CDrawStyle & style = {},
const std::string & name = {},
IoResult * outResult = nullptr )

Load OBJ and spawn a mesh entity (CTransform + CMesh + CDrawStyle).

Returns
Entity id, or entt::null on failure (see outResult).

◆ save()

IoResult rig::obj::save ( const std::string & path,
const rigkit::ecs::CMesh & mesh )

Write CMesh to a simple Wavefront OBJ.

Prefers authored n-gon loops; otherwise triangle indices. Geometry (+ UVs) only - does not write materials, faceColors, or facePalette. Palette indices are RigKit-only; use .rig / document codecs to keep them.