hxmesh
Module¶
Source code: hxmesh.py
The hxmesh
module provides an HxMesh
class which derives
from ReadWriteFile
and is used to read and write Devil Daggers
mesh data.
HxMesh
Class¶
- class vgio.devildaggers.hxmesh.HxMesh¶
Class for working with HxMesh files.
Example
Load a file named “boid” and access mesh object attributes:
from vgio.devildaggers.hxmesh import HxMesh with HxMesh.open('boid') as boid: indices = boid.indices vertices = boid.vertices
- indices¶
An unstructured sequence of triangle indices.
- vertices¶
A sequence of Vertex objects.
- HxMesh.__init__()¶
Constructs an HxMesh object.
- classmethod HxMesh.open(file, mode='r')¶
Open a ReadWriteFile object where file can be a path to a file (a string), or a file-like object.
The mode parameter should be ‘r’ to read an existing file, ‘w’ to truncate and write a new file, or ‘a’ to append to an existing file.
open() is also a context manager and supports the with statement:
with ReadWriteFile.open('file.ext') as file: file.save('file2.ext')
- Parameters
file – Either the path to the file, a file-like object, or bytes.
mode – An optional string that indicates which mode to open the file
- Returns
An ReadWriteFile object constructed from the information read from the file-like object.
- Raises
ValueError – If an invalid file mode is given.
TypeError – If attempting to write to a bytes object.
OSError – If the file argument is not a file-like object.
- HxMesh.close()¶
Closes the file pointer if possible. If mode is ‘w’ or ‘a’, the file will be written to.
- HxMesh.save(file)¶
Writes data to file.
- Parameters
file – Either the path to the file, or a file-like object.
- Raises
OSError – If file argument is not a file-like object.
Vertex
Class¶
- class vgio.devildaggers.hxmesh.Vertex¶
Class for representing an HxMesh vertex.
Example
Create a vertex object:
from vgio.devildaggers.hxmesh import Vertex position = 0, 0, 0 normal = 0, 0, 1 uv = 0, 1 vertex = Vertex(*position, *normal, *uv)
- position¶
Vertex position.
- normal¶
Vertex normal.
- uv¶
Vertex UV coordinates.
- Vertex.__init__(position_x, position_y, position_z, normal_x, normal_y, normal_z, u, v)¶
Constructs an HxMesh Vertex object.
- Parameters
position_x – The position x-coordinate
position_y – The position y-coordinate
position_z – The position z-coordinate
normal_x – The normal x-coordinate
normal_y – The normal y-coordinate
normal_z – The normal z-coordinate
u – The UV u-coordinate
v – The UV v-coordinate