Blender
V3.3
|
#include <obj_export_file_writer.hh>
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< eFileType::OBJ > &fh, const OBJMesh &obj_mesh_data) const |
void | write_mtllib_name (const StringRefNull mtl_filepath) const |
void | write_vertex_coords (FormatHandler< eFileType::OBJ > &fh, const OBJMesh &obj_mesh_data, bool write_colors) const |
void | write_uv_coords (FormatHandler< eFileType::OBJ > &fh, OBJMesh &obj_mesh_data) const |
void | write_poly_normals (FormatHandler< eFileType::OBJ > &fh, OBJMesh &obj_mesh_data) |
void | write_poly_elements (FormatHandler< eFileType::OBJ > &fh, const IndexOffsets &offsets, const OBJMesh &obj_mesh_data, std::function< const char *(int)> matname_fn) |
void | write_edges_indices (FormatHandler< eFileType::OBJ > &fh, const IndexOffsets &offsets, const OBJMesh &obj_mesh_data) const |
void | write_nurbs_curve (FormatHandler< eFileType::OBJ > &fh, const OBJCurve &obj_nurbs_data) const |
Responsible for writing a .OBJ file.
Definition at line 36 of file obj_export_file_writer.hh.
|
inlinenoexcept |
Definition at line 43 of file obj_export_file_writer.hh.
References BLI_fopen().
|
inline |
Definition at line 51 of file obj_export_file_writer.hh.
|
inline |
Definition at line 59 of file obj_export_file_writer.hh.
Referenced by blender::io::obj::write_nurbs_curve_objects().
void blender::io::obj::OBJWriter::write_edges_indices | ( | FormatHandler< eFileType::OBJ > & | fh, |
const IndexOffsets & | offsets, | ||
const OBJMesh & | obj_mesh_data | ||
) | const |
Write loose edges of a mesh as "l v1 v2".
Definition at line 417 of file obj_export_file_writer.cc.
References blender::io::obj::OBJMesh::calc_loose_edge_vert_indices(), blender::io::obj::edge, blender::io::obj::OBJMesh::tot_edges(), blender::io::obj::vertex_indices, blender::io::obj::IndexOffsets::vertex_offset, and blender::io::obj::FormatHandler< filetype, buffer_chunk_size >::write().
Referenced by blender::io::obj::write_mesh_objects().
void blender::io::obj::OBJWriter::write_header | ( | ) | const |
void blender::io::obj::OBJWriter::write_mtllib_name | ( | const StringRefNull | mtl_filepath | ) | const |
Write file name of Material Library in .OBJ file.
Definition at line 171 of file obj_export_file_writer.cc.
References BLI_split_dirfile(), blender::StringRefBase::data(), FILE_MAXDIR, FILE_MAXFILE, blender::io::obj::mtllib, blender::io::obj::FormatHandler< filetype, buffer_chunk_size >::write(), and blender::io::obj::FormatHandler< filetype, buffer_chunk_size >::write_to_file().
Referenced by blender::io::obj::write_mesh_objects().
void blender::io::obj::OBJWriter::write_nurbs_curve | ( | FormatHandler< eFileType::OBJ > & | 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 434 of file obj_export_file_writer.cc.
References blender::io::obj::cstype, CU_NURB_CYCLIC, CU_NURB_ENDPOINT, blender::io::obj::curve_element_begin, blender::io::obj::curve_element_end, blender::io::obj::OBJCurve::get_curve_name(), blender::io::obj::OBJCurve::get_nurbs_degree(), blender::io::obj::OBJCurve::get_nurbs_flagu(), blender::io::obj::nurbs_degree, blender::io::obj::nurbs_group_end, blender::io::obj::nurbs_parameter_begin, blender::io::obj::nurbs_parameter_end, blender::io::obj::nurbs_parameters, blender::io::obj::object_group, OBJExportParams::scaling_factor, 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::vertex_coords, blender::io::obj::vertex_indices, and blender::io::obj::FormatHandler< filetype, buffer_chunk_size >::write().
Referenced by blender::io::obj::write_nurbs_curve_objects().
void blender::io::obj::OBJWriter::write_object_name | ( | FormatHandler< eFileType::OBJ > & | fh, |
const OBJMesh & | obj_mesh_data | ||
) | const |
Write object's name or group.
Definition at line 187 of file obj_export_file_writer.cc.
References OBJExportParams::export_object_groups, blender::io::obj::OBJMesh::get_object_mesh_name(), blender::io::obj::OBJMesh::get_object_name(), blender::io::obj::object_group, blender::io::obj::object_name, blender::io::obj::spaces_to_underscores(), and blender::io::obj::FormatHandler< filetype, buffer_chunk_size >::write().
Referenced by blender::io::obj::write_mesh_objects().
void blender::io::obj::OBJWriter::write_poly_elements | ( | FormatHandler< eFileType::OBJ > & | fh, |
const IndexOffsets & | offsets, | ||
const OBJMesh & | obj_mesh_data, | ||
std::function< const char *(int)> | matname_fn | ||
) |
Write polygon elements with at least vertex indices, and conditionally with UV vertex indices and polygon 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.
Definition at line 337 of file obj_export_file_writer.cc.
References blender::io::obj::OBJMesh::calc_poly_normal_indices(), blender::io::obj::OBJMesh::calc_poly_uv_indices(), blender::io::obj::OBJMesh::calc_poly_vertex_indices(), blender::io::obj::DEFORM_GROUP_DISABLED, OBJExportParams::export_material_groups, OBJExportParams::export_materials, OBJExportParams::export_vertex_groups, blender::io::obj::OBJMesh::get_object_name(), blender::io::obj::OBJMesh::get_poly_deform_group_index(), blender::io::obj::OBJMesh::get_poly_deform_group_name(), blender::io::obj::get_smooth_group(), blender::io::obj::OBJMesh::is_mirrored_transform(), blender::io::obj::OBJMesh::ith_poly_matnr(), 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::object_group, blender::io::obj::object_name, blender::io::obj::poly_usemtl, blender::io::obj::OBJMesh::remap_poly_index(), blender::Vector< T, InlineBufferCapacity, Allocator >::resize(), blender::io::obj::smooth_group, blender::io::obj::spaces_to_underscores(), blender::io::obj::OBJMesh::tot_deform_groups(), blender::io::obj::OBJMesh::tot_materials(), blender::io::obj::OBJMesh::tot_polygons(), blender::io::obj::OBJMesh::tot_uv_vertices(), and blender::io::obj::FormatHandler< filetype, buffer_chunk_size >::write().
Referenced by blender::io::obj::write_mesh_objects().
void blender::io::obj::OBJWriter::write_poly_normals | ( | FormatHandler< eFileType::OBJ > & | fh, |
OBJMesh & | obj_mesh_data | ||
) |
Write loop normals for smooth-shaded polygons, and polygon normals otherwise, as "vn x y z".
Definition at line 295 of file obj_export_file_writer.cc.
References blender::io::obj::OBJMesh::get_normal_coords(), normal, blender::io::obj::normal, blender::io::obj::obj_parallel_chunked_output(), blender::Vector< T, InlineBufferCapacity, Allocator >::size(), and blender::io::obj::FormatHandler< filetype, buffer_chunk_size >::write().
void blender::io::obj::OBJWriter::write_uv_coords | ( | FormatHandler< eFileType::OBJ > & | fh, |
OBJMesh & | obj_mesh_data | ||
) | const |
Write UV vertex coordinates for all vertices as vt u v
.
Definition at line 285 of file obj_export_file_writer.cc.
References blender::io::obj::OBJMesh::get_uv_coords(), blender::io::obj::obj_parallel_chunked_output(), blender::Vector< T, InlineBufferCapacity, Allocator >::size(), blender::io::obj::uv_vertex_coords, and blender::io::obj::FormatHandler< filetype, buffer_chunk_size >::write().
void blender::io::obj::OBJWriter::write_vertex_coords | ( | FormatHandler< eFileType::OBJ > & | fh, |
const OBJMesh & | obj_mesh_data, | ||
bool | write_colors | ||
) | const |
Write vertex coordinates for all vertices as "v x y z" or "v x y z r g b".
Definition at line 251 of file obj_export_file_writer.cc.
References ATTR_DOMAIN_POINT, attribute, BKE_id_attributes_active_color_get(), BLI_assert, blender::io::obj::OBJMesh::calc_vertex_coords(), blender::io::obj::OBJMesh::get_mesh(), Mesh::id, linearrgb_to_srgb_v3_v3(), blender::bke::AttributeAccessor::lookup_or_default(), mesh, blender::bke::mesh_attributes(), CustomDataLayer::name, blender::io::obj::obj_parallel_chunked_output(), OBJExportParams::scaling_factor, Particle::size, blender::io::obj::OBJMesh::tot_vertices(), blender::io::obj::vertex_coords, blender::io::obj::vertex_coords_color, and blender::io::obj::FormatHandler< filetype, buffer_chunk_size >::write().
Referenced by blender::io::obj::write_mesh_objects().