Blender V4.3
blender::io::obj::OBJWriter Class Reference

#include <obj_export_file_writer.hh>

Inherits blender::NonMovable, and blender::NonCopyable.

Public Member Functions

 OBJWriter (const char *filepath, const OBJExportParams &export_params) noexcept(false)
 
 ~OBJWriter ()
 
FILE * get_outfile () const
 
void write_header () const
 
void write_object_name (FormatHandler &fh, const OBJMesh &obj_mesh_data) const
 
void write_mtllib_name (const StringRefNull mtl_filepath) const
 
void write_vertex_coords (FormatHandler &fh, const OBJMesh &obj_mesh_data, bool write_colors) const
 
void write_uv_coords (FormatHandler &fh, OBJMesh &obj_mesh_data) const
 
void write_normals (FormatHandler &fh, OBJMesh &obj_mesh_data)
 
void write_face_elements (FormatHandler &fh, const IndexOffsets &offsets, const OBJMesh &obj_mesh_data, FunctionRef< const char *(int)> matname_fn)
 
void write_edges_indices (FormatHandler &fh, const IndexOffsets &offsets, const OBJMesh &obj_mesh_data) const
 
void write_nurbs_curve (FormatHandler &fh, const OBJCurve &obj_nurbs_data) const
 

Detailed Description

Responsible for writing a .OBJ file.

Definition at line 38 of file obj_export_file_writer.hh.

Constructor & Destructor Documentation

◆ OBJWriter()

blender::io::obj::OBJWriter::OBJWriter ( const char * filepath,
const OBJExportParams & export_params )
inline

Definition at line 45 of file obj_export_file_writer.hh.

References BLI_fopen().

◆ ~OBJWriter()

blender::io::obj::OBJWriter::~OBJWriter ( )
inline

Definition at line 53 of file obj_export_file_writer.hh.

Member Function Documentation

◆ get_outfile()

FILE * blender::io::obj::OBJWriter::get_outfile ( ) const
inline

◆ write_edges_indices()

void blender::io::obj::OBJWriter::write_edges_indices ( FormatHandler & fh,
const IndexOffsets & offsets,
const OBJMesh & obj_mesh_data ) const

◆ write_face_elements()

void blender::io::obj::OBJWriter::write_face_elements ( FormatHandler & fh,
const IndexOffsets & offsets,
const OBJMesh & obj_mesh_data,
FunctionRef< const char *(int)> matname_fn )

Write face elements with at least vertex indices, and conditionally with UV vertex indices and face normal indices. Also write groups: smooth, vertex, material. The matname_fn turns a 0-indexed material slot number in an Object into the name used in the .obj file.

Note
UV indices were stored while writing UV vertices.

Definition at line 339 of file obj_export_file_writer.cc.

References Geometry::attributes, blender::io::obj::OBJMesh::calc_face_vert_indices(), blender::io::obj::DEFORM_GROUP_DISABLED, OBJExportParams::export_material_groups, OBJExportParams::export_materials, OBJExportParams::export_vertex_groups, blender::bke::Face, blender::io::obj::OBJMesh::get_face_deform_group_index(), blender::io::obj::OBJMesh::get_face_deform_group_name(), blender::io::obj::OBJMesh::get_face_normal_indices(), blender::io::obj::OBJMesh::get_face_uv_indices(), blender::io::obj::OBJMesh::get_mesh(), blender::io::obj::OBJMesh::get_object_name(), blender::io::obj::get_smooth_group(), blender::io::obj::OBJMesh::is_mirrored_transform(), blender::threading::EnumerableThreadSpecific< T >::local(), blender::io::obj::MATERIAL_GROUP_DISABLED, blender::io::obj::NEGATIVE_INIT, blender::io::obj::NOT_FOUND, blender::io::obj::obj_parallel_chunked_output(), blender::io::obj::OBJMesh::remap_face_index(), blender::Vector< T, InlineBufferCapacity, Allocator >::resize(), blender::io::obj::spaces_to_underscores(), blender::io::obj::OBJMesh::tot_deform_groups(), blender::io::obj::OBJMesh::tot_faces(), blender::io::obj::OBJMesh::tot_materials(), blender::io::obj::OBJMesh::tot_uv_vertices(), blender::io::obj::FormatHandler::write_obj_group(), blender::io::obj::FormatHandler::write_obj_smooth(), and blender::io::obj::FormatHandler::write_obj_usemtl().

Referenced by blender::io::obj::write_mesh_objects().

◆ write_header()

void blender::io::obj::OBJWriter::write_header ( ) const

◆ write_mtllib_name()

void blender::io::obj::OBJWriter::write_mtllib_name ( const StringRefNull mtl_filepath) const

◆ write_normals()

void blender::io::obj::OBJWriter::write_normals ( FormatHandler & fh,
OBJMesh & obj_mesh_data )

Write corner normals for smooth-shaded faces, and face normals otherwise, as "vn x y z".

Note
Normal indices ares stored here, but written with faces later.

Definition at line 298 of file obj_export_file_writer.cc.

References blender::io::obj::OBJMesh::get_normal_coords(), blender::io::obj::obj_parallel_chunked_output(), and blender::Span< T >::size().

Referenced by blender::io::obj::write_mesh_objects().

◆ write_nurbs_curve()

void blender::io::obj::OBJWriter::write_nurbs_curve ( FormatHandler & fh,
const OBJCurve & obj_nurbs_data ) const

Write a NURBS curve to the .OBJ file in parameter form.

The numbers written here are indices into the vertex coordinates written earlier, relative to the line that is going to be written. [0.0 - 1.0] is the curve parameter range. 0.0 1.0 -1 -2 -3 -4 for a non-cyclic curve with 4 vertices. 0.0 1.0 -1 -2 -3 -4 -1 -2 -3 for a cyclic curve with 4 vertices.

In parm u 0 0.1 .. line:, (total control points + 2) equidistant numbers in the parameter range are inserted. However for curves with endpoint flag, first degree+1 numbers are zeroes, and last degree+1 numbers are ones

Definition at line 446 of file obj_export_file_writer.cc.

References CU_NURB_CYCLIC, CU_NURB_ENDPOINT, blender::io::obj::OBJCurve::get_curve_name(), blender::io::obj::OBJCurve::get_nurbs_degree(), blender::io::obj::OBJCurve::get_nurbs_flagu(), OBJExportParams::global_scale, blender::io::obj::OBJCurve::total_spline_control_points(), blender::io::obj::OBJCurve::total_spline_vertices(), blender::io::obj::OBJCurve::total_splines(), blender::io::obj::OBJCurve::vertex_coordinates(), blender::io::obj::FormatHandler::write_obj_cstype(), blender::io::obj::FormatHandler::write_obj_curve_begin(), blender::io::obj::FormatHandler::write_obj_curve_end(), blender::io::obj::FormatHandler::write_obj_face_v(), blender::io::obj::FormatHandler::write_obj_group(), blender::io::obj::FormatHandler::write_obj_nurbs_degree(), blender::io::obj::FormatHandler::write_obj_nurbs_group_end(), blender::io::obj::FormatHandler::write_obj_nurbs_parm(), blender::io::obj::FormatHandler::write_obj_nurbs_parm_begin(), blender::io::obj::FormatHandler::write_obj_nurbs_parm_end(), and blender::io::obj::FormatHandler::write_obj_vertex().

Referenced by blender::io::obj::write_nurbs_curve_objects().

◆ write_object_name()

◆ write_uv_coords()

void blender::io::obj::OBJWriter::write_uv_coords ( FormatHandler & fh,
OBJMesh & obj_mesh_data ) const

Write UV vertex coordinates for all vertices as vt u v.

Note
UV indices are stored here, but written with faces later.

Definition at line 289 of file obj_export_file_writer.cc.

References blender::io::obj::OBJMesh::get_uv_coords(), blender::io::obj::obj_parallel_chunked_output(), and blender::Span< T >::size().

Referenced by blender::io::obj::write_mesh_objects().

◆ write_vertex_coords()


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