DHART
Loading...
Searching...
No Matches
DHARTAPI.Geometry.OBJLoader Class Reference

Load mesh geometry from OBJ files on disk. More...

Static Public Member Functions

static MeshInfo LoadOBJ (string path, float xrot=0, float yrot=0, float zrot=0)
 Load an obj from the OBJ file at the given filepath. More...
 
static MeshInfo[] LoadOBJSubmeshes (string path, GROUP_METHOD gm, float xrot=0, float yrot=0, float zrot=0)
 Load an obj from the OBJ file at the given filepath. More...
 
static MeshInfo LoadOBJ (string path, Vector3D rotation)
 Load an obj from the OBJ file at the given filepath. More...
 

Detailed Description

Load mesh geometry from OBJ files on disk.

Remarks
Internally is doing the same work as calling MeshInfo's constructor, so loaders for other filetypes can be created.

Member Function Documentation

◆ LoadOBJ() [1/2]

static MeshInfo DHARTAPI.Geometry.OBJLoader.LoadOBJ ( string  path,
float  xrot = 0,
float  yrot = 0,
float  zrot = 0 
)
static

Load an obj from the OBJ file at the given filepath.

Parameters
pathPath to a valid OBJ file.
xrotDegrees to rotate the mesh on the x axis.
yrotDegrees to rotate the mesh on the y axis.
zrotDegrees to rotate the mesh on the z axis.
Returns
An instance of MeshInfo containing the mesh loaded from the OBJ at path.
Exceptions
System.IO.FileNotFoundExceptionNo file was found at path.
DHARTAPI.Exceptions.InvalidMeshExceptionThe file at the path was not a valid OBJ.
Remarks
Use the other overload if you want to use a CommonRotation on the mesh.
// Loading a mesh from plane.obj with no rotation.
MeshInfo MI = OBJLoader.LoadOBJ("plane.obj");
A collection of vertices and indices representing geometry.
Definition: MeshInfo.cs:50
Load mesh geometry from OBJ files on disk.
Definition: OBJLoader.cs:26
static MeshInfo LoadOBJ(string path, float xrot=0, float yrot=0, float zrot=0)
Load an obj from the OBJ file at the given filepath.
Definition: OBJLoader.cs:50

Referenced by StringToEdgeCost.Main().

◆ LoadOBJ() [2/2]

static MeshInfo DHARTAPI.Geometry.OBJLoader.LoadOBJ ( string  path,
Vector3D  rotation 
)
static

Load an obj from the OBJ file at the given filepath.

Parameters
pathPath to a valid OBJ file.
rotationDegrees to rotate the mesh in the x,y, and z direction after loading.
Returns
An instance of MeshInfo containing the mesh loaded from the OBJ at path.
Exceptions
System.IO.FileNotFoundExceptionNo file was found at path.
DHARTAPI.Exceptions.InvalidMeshExceptionThe file at the path did not represent a valid OBJ.
Remarks
The rotation parameter can be used with the rotations in CommonRotations to easily perform common rotations on meshes. This is useful if you're loading a mesh that is Y-up and you need to convert it to Z-up for use in the GraohGenerator.
// Loading a mesh from plane.obj with no rotation.
MeshInfo MI = OBJLoader.LoadOBJ("plane.obj");

◆ LoadOBJSubmeshes()

static MeshInfo[] DHARTAPI.Geometry.OBJLoader.LoadOBJSubmeshes ( string  path,
GROUP_METHOD  gm,
float  xrot = 0,
float  yrot = 0,
float  zrot = 0 
)
static

Load an obj from the OBJ file at the given filepath.

Parameters
pathPath to a valid OBJ file.
gmMethod of grouping the OBJ into submeshes
xrotDegrees to rotate the mesh on the x axis.
yrotDegrees to rotate the mesh on the y axis.
zrotDegrees to rotate the mesh on the z axis.
Returns
All submeshes in the obj file at path grouped by gm
Exceptions
System.IO.FileNotFoundExceptionNo file was found at path.
DHARTAPI.Exceptions.InvalidMeshExceptionThe file at the path was not a valid OBJ.
See also
GROUP_METHOD to see the different ways of grouping the different geometry in a .obj file
Example
// Load submeshes
MeshInfo[] submeshes = OBJLoader.LoadOBJSubmeshes("ExampleModels/sponza.obj", GROUP_METHOD.BY_GROUP);
// Print the first five
for(int i = 0; i < 5; i++)
Debug.WriteLine(submeshes[i]);
static MeshInfo[] LoadOBJSubmeshes(string path, GROUP_METHOD gm, float xrot=0, float yrot=0, float zrot=0)
Load an obj from the OBJ file at the given filepath.
Definition: OBJLoader.cs:86
GROUP_METHOD
Methods for seperating meshes when loading from OBJ.
Definition: OBJLoader.cs:12
Name: arcs_floor, ID: 0, Verts: 150, Triangles: 192
Name: arcs_03, ID: 1, Verts: 750, Triangles: 1344
Name: object32, ID: 2, Verts: 3190, Triangles: 4784
Name: object31, ID: 3, Verts: 3454, Triangles: 5264
Name: pillar_cor, ID: 4, Verts: 3478, Triangles: 5312

The documentation for this class was generated from the following file: