Blender V4.3
MeshImporter Class Reference

#include <MeshImporter.h>

Inherits MeshImporterBase.

Public Member Functions

 MeshImporter (UnitConverter *unitconv, bool use_custom_normals, ArmatureImporter *arm, Main *bmain, Scene *sce, ViewLayer *view_layer)
 
virtual Objectget_object_by_geom_uid (const COLLADAFW::UniqueId &geom_uid)
 
virtual Meshget_mesh_by_geom_uid (const COLLADAFW::UniqueId &geom_uid)
 
void optimize_material_assignements ()
 
void assign_material_to_geom (COLLADAFW::MaterialBinding cmaterial, std::map< COLLADAFW::UniqueId, Material * > &uid_material_map, Object *ob, const COLLADAFW::UniqueId *geom_uid, short mat_index)
 
Objectcreate_mesh_object (COLLADAFW::Node *node, COLLADAFW::InstanceGeometry *geom, bool isController, std::map< COLLADAFW::UniqueId, Material * > &uid_material_map)
 
bool write_geometry (const COLLADAFW::Geometry *geom)
 
std::string * get_geometry_name (const std::string &mesh_name)
 

Detailed Description

Definition at line 66 of file MeshImporter.h.

Constructor & Destructor Documentation

◆ MeshImporter()

MeshImporter::MeshImporter ( UnitConverter * unitconv,
bool use_custom_normals,
ArmatureImporter * arm,
Main * bmain,
Scene * sce,
ViewLayer * view_layer )

Definition at line 197 of file MeshImporter.cpp.

Member Function Documentation

◆ assign_material_to_geom()

void MeshImporter::assign_material_to_geom ( COLLADAFW::MaterialBinding cmaterial,
std::map< COLLADAFW::UniqueId, Material * > & uid_material_map,
Object * ob,
const COLLADAFW::UniqueId * geom_uid,
short mat_index )

We do not know in advance which objects will share geometries. And we do not know either if the objects which share geometries come along with different materials. So we first create the objects and assign the materials to Object, then in a later cleanup we decide which materials shall be moved to the created geometries. Also see optimize_material_assignements() above.

Definition at line 1011 of file MeshImporter.cpp.

References Object::actcol, BKE_MAT_ASSIGN_OBJECT, and BKE_object_material_assign().

Referenced by create_mesh_object().

◆ create_mesh_object()

Object * MeshImporter::create_mesh_object ( COLLADAFW::Node * node,
COLLADAFW::InstanceGeometry * geom,
bool isController,
std::map< COLLADAFW::UniqueId, Material * > & uid_material_map )

◆ get_geometry_name()

std::string * MeshImporter::get_geometry_name ( const std::string & mesh_name)
virtual

Implements MeshImporterBase.

Definition at line 894 of file MeshImporter.cpp.

◆ get_mesh_by_geom_uid()

Mesh * MeshImporter::get_mesh_by_geom_uid ( const COLLADAFW::UniqueId & geom_uid)
virtual

Implements MeshImporterBase.

Definition at line 886 of file MeshImporter.cpp.

◆ get_object_by_geom_uid()

Object * MeshImporter::get_object_by_geom_uid ( const COLLADAFW::UniqueId & geom_uid)
virtual

Implements MeshImporterBase.

Definition at line 878 of file MeshImporter.cpp.

◆ optimize_material_assignements()

void MeshImporter::optimize_material_assignements ( )

During import all materials have been assigned to Object. Now we iterate over the imported objects and optimize the assignments as follows:

for each imported geometry: if number of users is 1: get the user (object) move the materials from Object to Data else: determine which materials are assigned to the first user check if all other users have the same materials in the same order if the check is positive: Add the materials of the first user to the geometry adjust all other users accordingly.

Definition at line 979 of file MeshImporter.cpp.

References bc_copy_materials_to_data(), bc_has_same_material_configuration(), bc_remove_mark(), bc_remove_materials_from_object(), and ID_REAL_USERS.

Referenced by DocumentImporter::finish().

◆ write_geometry()


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