|
Blender V4.3
|
#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 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 66 of file MeshImporter.h.
| 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.
| 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().
| Object * MeshImporter::create_mesh_object | ( | COLLADAFW::Node * | node, |
| COLLADAFW::InstanceGeometry * | geom, | ||
| bool | isController, | ||
| std::map< COLLADAFW::UniqueId, Material * > & | uid_material_map ) |
Definition at line 1058 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(), and OB_MESH.
Referenced by DocumentImporter::write_node().
|
virtual |
Implements MeshImporterBase.
Definition at line 894 of file MeshImporter.cpp.
|
virtual |
Implements MeshImporterBase.
Definition at line 886 of file MeshImporter.cpp.
|
virtual |
Implements MeshImporterBase.
Definition at line 878 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 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().
| 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 1131 of file MeshImporter.cpp.
References bc_geomTypeToStr(), bc_get_dae_name(), bc_has_out_of_bound_indices(), BKE_mesh_add(), BKE_mesh_set_custom_normals(), Mesh::corners_num, blender::Vector< T, InlineBufferCapacity, Allocator >::data(), Mesh::id, id_us_min(), blender::Vector< T, InlineBufferCapacity, Allocator >::is_empty(), blender::bke::mesh_calc_edges(), ID::name, and blender::Vector< T, InlineBufferCapacity, Allocator >::size().
Referenced by DocumentImporter::writeGeometry().