Blender
V3.3
|
#include <MeshImporter.h>
Public Member Functions | |
MeshImporter (UnitConverter *unitconv, ArmatureImporter *arm, Main *bmain, Scene *sce, ViewLayer *view_layer) | |
virtual Object * | get_object_by_geom_uid (const COLLADAFW::UniqueId &geom_uid) |
virtual Mesh * | get_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) |
Object * | create_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) |
Definition at line 63 of file MeshImporter.h.
MeshImporter::MeshImporter | ( | UnitConverter * | unitconv, |
ArmatureImporter * | arm, | ||
Main * | bmain, | ||
Scene * | sce, | ||
ViewLayer * | view_layer | ||
) |
Definition at line 192 of file MeshImporter.cpp.
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 974 of file MeshImporter.cpp.
References Object::actcol, BKE_MAT_ASSIGN_OBJECT, BKE_object_material_assign(), and MPoly::mat_nr.
Referenced by create_mesh_object().
Object * MeshImporter::create_mesh_object | ( | COLLADAFW::Node * | node, |
COLLADAFW::InstanceGeometry * | geom, | ||
bool | isController, | ||
std::map< COLLADAFW::UniqueId, Material * > & | uid_material_map | ||
) |
Definition at line 1022 of file MeshImporter.cpp.
References assign_material_to_geom(), bc_add_object(), bc_set_mark(), BKE_id_free_us(), BKE_mesh_assign_object(), BKE_mesh_validate(), Object::data, ArmatureImporter::get_geometry_uid(), getName(), Mesh::id, id_us_plus(), node, and OB_MESH.
Referenced by DocumentImporter::write_node().
|
virtual |
Implements MeshImporterBase.
Definition at line 863 of file MeshImporter.cpp.
|
virtual |
Implements MeshImporterBase.
Definition at line 855 of file MeshImporter.cpp.
|
virtual |
Implements MeshImporterBase.
Definition at line 847 of file MeshImporter.cpp.
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 942 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, ID_REAL_USERS, and if().
Referenced by DocumentImporter::finish().
bool MeshImporter::write_geometry | ( | const COLLADAFW::Geometry * | geom | ) |
Create a mesh storing a pointer in a map so it can be retrieved later by geometry UID.
Definition at line 1095 of file MeshImporter.cpp.
References bc_geomTypeToStr(), bc_get_dae_name(), BKE_mesh_add(), BKE_mesh_calc_edges(), Mesh::id, id_us_min(), mesh, and ID::name.
Referenced by DocumentImporter::writeGeometry().