diff options
author | Joerg Mueller <nexyon@gmail.com> | 2011-06-21 02:55:18 +0400 |
---|---|---|
committer | Joerg Mueller <nexyon@gmail.com> | 2011-06-21 02:55:18 +0400 |
commit | 207911bdb3e5ba3e110cc7107186af988d2d10e8 (patch) | |
tree | 88684071e2813d52f8dc700b593d7644b2be88c8 /source/blender/collada/DocumentImporter.cpp | |
parent | adb81a0351c0854ee8529ae7a66ef9c907790ee5 (diff) | |
parent | 768184753abb5a69e278bfe6207fe070b2e0ffc7 (diff) |
Merge with trunk r37677
Diffstat (limited to 'source/blender/collada/DocumentImporter.cpp')
-rw-r--r-- | source/blender/collada/DocumentImporter.cpp | 42 |
1 files changed, 30 insertions, 12 deletions
diff --git a/source/blender/collada/DocumentImporter.cpp b/source/blender/collada/DocumentImporter.cpp index 117479b2022..14ce9a9b417 100644 --- a/source/blender/collada/DocumentImporter.cpp +++ b/source/blender/collada/DocumentImporter.cpp @@ -310,7 +310,7 @@ Object* DocumentImporter::create_lamp_object(COLLADAFW::InstanceLight *lamp, Sce return ob; } -Object* DocumentImporter::create_instance_node(Object *source_ob, COLLADAFW::Node *source_node, COLLADAFW::Node *instance_node, Scene *sce, bool is_library_node) +Object* DocumentImporter::create_instance_node(Object *source_ob, COLLADAFW::Node *source_node, COLLADAFW::Node *instance_node, Scene *sce, Object *par_ob, bool is_library_node) { Object *obn = copy_object(source_ob); obn->recalc |= OB_RECALC_OB|OB_RECALC_DATA|OB_RECALC_TIME; @@ -354,10 +354,10 @@ Object* DocumentImporter::create_instance_node(Object *source_ob, COLLADAFW::Nod Object *new_child = NULL; if (inodes.getCount()) { // \todo loop through instance nodes const COLLADAFW::UniqueId& id = inodes[0]->getInstanciatedObjectId(); - new_child = create_instance_node(object_map[id], node_map[id], child_node, sce, is_library_node); + new_child = create_instance_node(object_map[id], node_map[id], child_node, sce, NULL, is_library_node); } else { - new_child = create_instance_node(object_map[child_id], child_node, NULL, sce, is_library_node); + new_child = create_instance_node(object_map[child_id], child_node, NULL, sce, NULL, is_library_node); } bc_set_parent(new_child, obn, mContext, true); @@ -368,7 +368,12 @@ Object* DocumentImporter::create_instance_node(Object *source_ob, COLLADAFW::Nod // when we have an instance_node, don't return the object, because otherwise // its correct location gets overwritten in write_node(). Fixes bug #26012. - if(instance_node) return NULL; + if(instance_node) { + if (par_ob && obn) + bc_set_parent(obn, par_ob, mContext); + return NULL; + } + else return obn; } @@ -393,11 +398,11 @@ void DocumentImporter::write_node (COLLADAFW::Node *node, COLLADAFW::Node *paren COLLADAFW::InstanceLightPointerArray &lamp = node->getInstanceLights(); COLLADAFW::InstanceControllerPointerArray &controller = node->getInstanceControllers(); COLLADAFW::InstanceNodePointerArray &inst_node = node->getInstanceNodes(); - int geom_done = 0; - int camera_done = 0; - int lamp_done = 0; - int controller_done = 0; - int inst_done = 0; + size_t geom_done = 0; + size_t camera_done = 0; + size_t lamp_done = 0; + size_t controller_done = 0; + size_t inst_done = 0; // XXX linking object with the first <instance_geometry>, though a node may have more of them... // maybe join multiple <instance_...> meshes into 1, and link object with it? not sure... @@ -431,7 +436,7 @@ void DocumentImporter::write_node (COLLADAFW::Node *node, COLLADAFW::Node *paren Object *source_ob = object_map[node_id]; COLLADAFW::Node *source_node = node_map[node_id]; - ob = create_instance_node(source_ob, source_node, node, sce, is_library_node); + ob = create_instance_node(source_ob, source_node, node, sce, par, is_library_node); } ++inst_done; } @@ -444,7 +449,8 @@ void DocumentImporter::write_node (COLLADAFW::Node *node, COLLADAFW::Node *paren // check if object is not NULL if (!ob) return; - rename_id(&ob->id, (char*)node->getOriginalId().c_str()); + std::string nodename = node->getName().size() ? node->getName() : node->getOriginalId(); + rename_id(&ob->id, (char*)nodename.c_str()); object_map[node->getUniqueId()] = ob; node_map[node->getUniqueId()] = node; @@ -526,7 +532,7 @@ bool DocumentImporter::writeMaterial( const COLLADAFW::Material* cmat ) if(mImportStage!=General) return true; - const std::string& str_mat_id = cmat->getOriginalId(); + const std::string& str_mat_id = cmat->getName().size() ? cmat->getName() : cmat->getOriginalId(); Material *ma = add_material((char*)str_mat_id.c_str()); this->uid_effect_map[cmat->getInstantiatedEffect()] = ma; @@ -678,6 +684,18 @@ void DocumentImporter::write_profile_COMMON(COLLADAFW::EffectCommon *ef, Materia i++; } } + + if(ef->getOpacity().isTexture()) { + COLLADAFW::Texture ctex = ef->getOpacity().getTexture(); + mtex = create_texture(ef, ctex, ma, i, texindex_texarray_map); + if(mtex != NULL) { + mtex->mapto = MAP_ALPHA; + mtex->tex->imaflag |= TEX_USEALPHA; + i++; + ma->spectra = ma->alpha = 0; + ma->mode |= MA_ZTRANSP|MA_TRANSP; + } + } // TRANSPARENT // color // if (ef->getOpacity().isColor()) { |