Blender  V3.3
Public Member Functions | List of all members
blender::io::obj::OBJMesh Class Reference

#include <obj_export_mesh.hh>

Inheritance diagram for blender::io::obj::OBJMesh:
blender::NonCopyable

Public Member Functions

 OBJMesh (Depsgraph *depsgraph, const OBJExportParams &export_params, Object *mesh_object)
 
 ~OBJMesh ()
 
void clear ()
 
int tot_vertices () const
 
int tot_polygons () const
 
int tot_uv_vertices () const
 
int tot_normal_indices () const
 
int tot_edges () const
 
int tot_deform_groups () const
 
bool is_mirrored_transform () const
 
int16_t tot_materials () const
 
const Materialget_object_material (int16_t mat_nr) const
 
int16_t ith_poly_matnr (int poly_index) const
 
void ensure_mesh_normals () const
 
void ensure_mesh_edges () const
 
void calc_smooth_groups (bool use_bitflags)
 
int ith_smooth_group (int poly_index) const
 
bool is_ith_poly_smooth (int poly_index) const
 
const char * get_object_name () const
 
const char * get_object_mesh_name () const
 
const char * get_object_material_name (int16_t mat_nr) const
 
float3 calc_vertex_coords (int vert_index, float scaling_factor) const
 
Vector< int > calc_poly_vertex_indices (int poly_index) const
 
void store_uv_coords_and_indices ()
 
const Vector< float2 > & get_uv_coords () const
 
Span< int > calc_poly_uv_indices (int poly_index) const
 
float3 calc_poly_normal (int poly_index) const
 
void store_normal_coords_and_indices ()
 
const Vector< float3 > & get_normal_coords () const
 
Vector< int > calc_poly_normal_indices (int poly_index) const
 
int16_t get_poly_deform_group_index (int poly_index, MutableSpan< float > group_weights) const
 
const char * get_poly_deform_group_name (int16_t def_group_index) const
 
std::optional< std::array< int, 2 > > calc_loose_edge_vert_indices (int edge_index) const
 
void calc_poly_order ()
 
int remap_poly_index (int i) const
 
Meshget_mesh () const
 

Detailed Description

Definition at line 45 of file obj_export_mesh.hh.

Constructor & Destructor Documentation

◆ OBJMesh()

blender::io::obj::OBJMesh::OBJMesh ( Depsgraph depsgraph,
const OBJExportParams export_params,
Object mesh_object 
)

◆ ~OBJMesh()

blender::io::obj::OBJMesh::~OBJMesh ( )

Free new meshes allocated for triangulated meshes, or Curve converted to Mesh.

Definition at line 59 of file obj_export_mesh.cc.

References clear().

Member Function Documentation

◆ calc_loose_edge_vert_indices()

std::optional< std::array< int, 2 > > blender::io::obj::OBJMesh::calc_loose_edge_vert_indices ( int  edge_index) const

Calculate vertex indices of an edge's corners if it is a loose edge.

Definition at line 490 of file obj_export_mesh.cc.

References blender::io::obj::edge, and ME_LOOSEEDGE.

Referenced by blender::io::obj::OBJWriter::write_edges_indices().

◆ calc_poly_normal()

float3 blender::io::obj::OBJMesh::calc_poly_normal ( int  poly_index) const

Calculate polygon normal of a polygon at given index.

Should be used for flat-shaded polygons.

Definition at line 340 of file obj_export_mesh.cc.

References BKE_mesh_calc_poly_normal(), MPoly::loopstart, mul_m3_v3(), and normalize_v3().

◆ calc_poly_normal_indices()

Vector< int > blender::io::obj::OBJMesh::calc_poly_normal_indices ( int  poly_index) const

Calculate a polygon's polygon/loop normal indices.

Parameters
poly_indexIndex of the polygon to calculate indices for.
Returns
Vector of normal indices, aligned with vertices of polygon.

Definition at line 424 of file obj_export_mesh.cc.

References MPoly::loopstart, and MPoly::totloop.

Referenced by blender::io::obj::OBJWriter::write_poly_elements().

◆ calc_poly_order()

void blender::io::obj::OBJMesh::calc_poly_order ( )

◆ calc_poly_uv_indices()

Span< int > blender::io::obj::OBJMesh::calc_poly_uv_indices ( int  poly_index) const

Definition at line 330 of file obj_export_mesh.cc.

References BLI_assert.

Referenced by blender::io::obj::OBJWriter::write_poly_elements().

◆ calc_poly_vertex_indices()

Vector< int > blender::io::obj::OBJMesh::calc_poly_vertex_indices ( int  poly_index) const

Calculate vertex indices of all vertices of the polygon at the given index.

Definition at line 272 of file obj_export_mesh.cc.

References MPoly::loopstart, MPoly::totloop, and MLoop::v.

Referenced by blender::io::obj::OBJWriter::write_poly_elements().

◆ calc_smooth_groups()

void blender::io::obj::OBJMesh::calc_smooth_groups ( bool  use_bitflags)

Calculate smooth groups of a smooth-shaded object.

Returns
A polygon aligned array of smooth group numbers.

Definition at line 188 of file obj_export_mesh.cc.

References BKE_mesh_calc_smoothgroups(), Mesh::medge, Mesh::mloop, Mesh::mpoly, Mesh::totedge, Mesh::totloop, and Mesh::totpoly.

◆ calc_vertex_coords()

float3 blender::io::obj::OBJMesh::calc_vertex_coords ( int  vert_index,
float  scaling_factor 
) const

Calculate coordinates of the vertex at the given index.

Definition at line 263 of file obj_export_mesh.cc.

References copy_v3_v3(), mul_m4_v3(), and mul_v3_fl().

Referenced by blender::io::obj::OBJWriter::write_vertex_coords().

◆ clear()

void blender::io::obj::OBJMesh::clear ( )

◆ ensure_mesh_edges()

void blender::io::obj::OBJMesh::ensure_mesh_edges ( ) const

◆ ensure_mesh_normals()

void blender::io::obj::OBJMesh::ensure_mesh_normals ( ) const

Definition at line 177 of file obj_export_mesh.cc.

References BKE_mesh_calc_normals_split().

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

◆ get_mesh()

Mesh* blender::io::obj::OBJMesh::get_mesh ( ) const
inline

◆ get_normal_coords()

const Vector<float3>& blender::io::obj::OBJMesh::get_normal_coords ( ) const
inline

Definition at line 197 of file obj_export_mesh.hh.

Referenced by blender::io::obj::OBJWriter::write_poly_normals().

◆ get_object_material()

const Material * blender::io::obj::OBJMesh::get_object_material ( int16_t  mat_nr) const

Return mat_nr-th material of the object. The given index should be zero-based.

The const_cast is safe here because BKE_object_material_get_eval won't change the object but it is a big can of worms to fix the declaration of that function right now.

The call uses "+ 1" as material getter needs one-based indices.

Definition at line 219 of file obj_export_mesh.cc.

References BKE_object_material_get_eval().

Referenced by blender::io::obj::MTLWriter::add_materials().

◆ get_object_material_name()

const char * blender::io::obj::OBJMesh::get_object_material_name ( int16_t  mat_nr) const

Get object's material (at the given index) name. The given index should be zero-based.

Definition at line 254 of file obj_export_mesh.cc.

References Material::id, and ID::name.

◆ get_object_mesh_name()

const char * blender::io::obj::OBJMesh::get_object_mesh_name ( ) const

Get Object's Mesh's name.

Definition at line 249 of file obj_export_mesh.cc.

Referenced by blender::io::obj::OBJWriter::write_object_name().

◆ get_object_name()

const char * blender::io::obj::OBJMesh::get_object_name ( ) const

Get object name as it appears in the outliner.

Definition at line 244 of file obj_export_mesh.cc.

Referenced by blender::io::obj::OBJWriter::write_object_name(), and blender::io::obj::OBJWriter::write_poly_elements().

◆ get_poly_deform_group_index()

int16_t blender::io::obj::OBJMesh::get_poly_deform_group_index ( int  poly_index,
MutableSpan< float group_weights 
) const

Find the most representative vertex group of a polygon.

This adds up vertex group weights, and the group with the largest weight sum across the polygon is the one returned.

group_weights is temporary storage to avoid reallocations, it must be the size of amount of vertex groups in the object.

Definition at line 447 of file obj_export_mesh.cc.

References blender::MutableSpan< T >::begin(), BKE_object_defgroup_count(), BLI_assert, CD_MDEFORMVERT, CustomData_get_layer(), MDeformWeight::def_nr, MDeformVert::dw, blender::MutableSpan< T >::end(), blender::MutableSpan< T >::fill(), MPoly::loopstart, NOT_FOUND, blender::MutableSpan< T >::size(), MPoly::totloop, MDeformVert::totweight, MLoop::v, and MDeformWeight::weight.

Referenced by blender::io::obj::OBJWriter::write_poly_elements().

◆ get_poly_deform_group_name()

const char * blender::io::obj::OBJMesh::get_poly_deform_group_name ( int16_t  def_group_index) const

Find the name of the vertex deform group at the given index. The index indices into the #Object.defbase.

Definition at line 483 of file obj_export_mesh.cc.

References BKE_object_defgroup_list(), BLI_findlink(), and bDeformGroup::name.

Referenced by blender::io::obj::OBJWriter::write_poly_elements().

◆ get_uv_coords()

const Vector<float2>& blender::io::obj::OBJMesh::get_uv_coords ( ) const
inline

Definition at line 180 of file obj_export_mesh.hh.

Referenced by blender::io::obj::OBJWriter::write_uv_coords().

◆ is_ith_poly_smooth()

bool blender::io::obj::OBJMesh::is_ith_poly_smooth ( int  poly_index) const

Definition at line 232 of file obj_export_mesh.cc.

References Material::flag, and ME_SMOOTH.

◆ is_mirrored_transform()

bool blender::io::obj::OBJMesh::is_mirrored_transform ( ) const
inline

◆ ith_poly_matnr()

int16_t blender::io::obj::OBJMesh::ith_poly_matnr ( int  poly_index) const

Returns a zero-based index of a polygon's material indexing into the Object's material slots.

Definition at line 237 of file obj_export_mesh.cc.

References BLI_assert, and NOT_FOUND.

Referenced by blender::io::obj::OBJWriter::write_poly_elements().

◆ ith_smooth_group()

int blender::io::obj::OBJMesh::ith_smooth_group ( int  poly_index) const
Returns
Smooth group of the polygon at the given index.

Definition at line 169 of file obj_export_mesh.cc.

References BLI_assert, and blender::io::obj::NEGATIVE_INIT.

◆ remap_poly_index()

int blender::io::obj::OBJMesh::remap_poly_index ( int  i) const
inline

Remap polygon index according to polygon writing order. When materials are not being written, the polygon order array might be empty, in which case remap is a no-op.

Definition at line 239 of file obj_export_mesh.hh.

References blender::Vector< T, InlineBufferCapacity, Allocator >::size().

Referenced by blender::io::obj::OBJWriter::write_poly_elements().

◆ store_normal_coords_and_indices()

void blender::io::obj::OBJMesh::store_normal_coords_and_indices ( )

◆ store_uv_coords_and_indices()

void blender::io::obj::OBJMesh::store_uv_coords_and_indices ( )

◆ tot_deform_groups()

int blender::io::obj::OBJMesh::tot_deform_groups ( ) const

◆ tot_edges()

int blender::io::obj::OBJMesh::tot_edges ( ) const

Definition at line 154 of file obj_export_mesh.cc.

References Mesh::totedge.

Referenced by blender::io::obj::OBJWriter::write_edges_indices().

◆ tot_materials()

int16_t blender::io::obj::OBJMesh::tot_materials ( ) const
Returns
Total materials in the object.

Definition at line 159 of file obj_export_mesh.cc.

References Mesh::totcol.

Referenced by blender::io::obj::MTLWriter::add_materials(), and blender::io::obj::OBJWriter::write_poly_elements().

◆ tot_normal_indices()

int blender::io::obj::OBJMesh::tot_normal_indices ( ) const

Definition at line 164 of file obj_export_mesh.cc.

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

◆ tot_polygons()

int blender::io::obj::OBJMesh::tot_polygons ( ) const

◆ tot_uv_vertices()

int blender::io::obj::OBJMesh::tot_uv_vertices ( ) const

◆ tot_vertices()

int blender::io::obj::OBJMesh::tot_vertices ( ) const

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