Blender V4.5
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)
Objectget_object_by_geom_uid (const COLLADAFW::UniqueId &geom_uid) override
Meshget_mesh_by_geom_uid (const COLLADAFW::UniqueId &geom_uid) override
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) override

Detailed Description

Definition at line 65 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 187 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 1002 of file MeshImporter.cpp.

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

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)
overridevirtual

Implements MeshImporterBase.

Definition at line 885 of file MeshImporter.cpp.

References this.

◆ get_mesh_by_geom_uid()

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

Implements MeshImporterBase.

Definition at line 877 of file MeshImporter.cpp.

◆ get_object_by_geom_uid()

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

Implements MeshImporterBase.

Definition at line 869 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 970 of file MeshImporter.cpp.

References bc_copy_materials_to_data(), bc_has_same_material_configuration(), bc_remove_mark(), bc_remove_materials_from_object(), Mesh::id, and ID_REAL_USERS.

◆ write_geometry()

bool MeshImporter::write_geometry ( const COLLADAFW::Geometry * geom)

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