Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/collada')
-rw-r--r--source/blender/collada/AnimationImporter.cpp9
-rw-r--r--source/blender/collada/ArmatureImporter.cpp6
-rw-r--r--source/blender/collada/CMakeLists.txt20
-rw-r--r--source/blender/collada/DocumentImporter.cpp42
-rw-r--r--source/blender/collada/DocumentImporter.h2
-rw-r--r--source/blender/collada/LightExporter.cpp12
-rw-r--r--source/blender/collada/MeshImporter.cpp12
-rw-r--r--source/blender/collada/SkinInfo.cpp6
-rw-r--r--source/blender/collada/collada_internal.cpp2
9 files changed, 66 insertions, 45 deletions
diff --git a/source/blender/collada/AnimationImporter.cpp b/source/blender/collada/AnimationImporter.cpp
index a166324bde7..336f127b11f 100644
--- a/source/blender/collada/AnimationImporter.cpp
+++ b/source/blender/collada/AnimationImporter.cpp
@@ -53,12 +53,12 @@
#include <algorithm>
-// use this for retrieving bone names, since these must be unique
+// first try node name, if not available (since is optional), fall back to original id
template<class T>
static const char *bc_get_joint_name(T *node)
{
- const std::string& id = node->getOriginalId();
- return id.size() ? id.c_str() : node->getName().c_str();
+ const std::string& id = node->getName();
+ return id.size() ? id.c_str() : node->getOriginalId().c_str();
}
FCurve *AnimationImporter::create_fcurve(int array_index, const char *rna_path)
@@ -827,7 +827,8 @@ void AnimationImporter::evaluate_transform_at_frame(float mat[4][4], COLLADAFW::
unit_m4(m);
- if (!evaluate_animation(tm, m, fra, node->getOriginalId().c_str())) {
+ std::string nodename = node->getName().size() ? node->getName() : node->getOriginalId();
+ if (!evaluate_animation(tm, m, fra, nodename.c_str())) {
switch (type) {
case COLLADAFW::Transformation::ROTATE:
dae_rotate_to_mat4(tm, m);
diff --git a/source/blender/collada/ArmatureImporter.cpp b/source/blender/collada/ArmatureImporter.cpp
index 8987e4ffaf7..8b8e89fd4f5 100644
--- a/source/blender/collada/ArmatureImporter.cpp
+++ b/source/blender/collada/ArmatureImporter.cpp
@@ -42,12 +42,12 @@
#include "ArmatureImporter.h"
-// use this for retrieving bone names, since these must be unique
+// use node name, or fall back to original id if not present (name is optional)
template<class T>
static const char *bc_get_joint_name(T *node)
{
- const std::string& id = node->getOriginalId();
- return id.size() ? id.c_str() : node->getName().c_str();
+ const std::string& id = node->getName();
+ return id.size() ? id.c_str() : node->getOriginalId().c_str();
}
ArmatureImporter::ArmatureImporter(UnitConverter *conv, MeshImporterBase *mesh, AnimationImporterBase *anim, Scene *sce) :
diff --git a/source/blender/collada/CMakeLists.txt b/source/blender/collada/CMakeLists.txt
index a7e7c973f36..07da532146f 100644
--- a/source/blender/collada/CMakeLists.txt
+++ b/source/blender/collada/CMakeLists.txt
@@ -44,19 +44,19 @@ set(INC_SYS
if(APPLE)
list(APPEND INC_SYS
- ${OPENCOLLADA_INC}/COLLADAStreamWriter
- ${OPENCOLLADA_INC}/COLLADABaseUtils
- ${OPENCOLLADA_INC}/COLLADAFramework
- ${OPENCOLLADA_INC}/COLLADASaxFrameworkLoader
- ${OPENCOLLADA_INC}/GeneratedSaxParser
+ ${OPENCOLLADA_INCLUDE_DIR}/COLLADAStreamWriter
+ ${OPENCOLLADA_INCLUDE_DIR}/COLLADABaseUtils
+ ${OPENCOLLADA_INCLUDE_DIR}/COLLADAFramework
+ ${OPENCOLLADA_INCLUDE_DIR}/COLLADASaxFrameworkLoader
+ ${OPENCOLLADA_INCLUDE_DIR}/GeneratedSaxParser
)
else()
list(APPEND INC_SYS
- ${OPENCOLLADA_INC}/COLLADAStreamWriter/include
- ${OPENCOLLADA_INC}/COLLADABaseUtils/include
- ${OPENCOLLADA_INC}/COLLADAFramework/include
- ${OPENCOLLADA_INC}/COLLADASaxFrameworkLoader/include
- ${OPENCOLLADA_INC}/GeneratedSaxParser/include
+ ${OPENCOLLADA_INCLUDE_DIR}/COLLADAStreamWriter/include
+ ${OPENCOLLADA_INCLUDE_DIR}/COLLADABaseUtils/include
+ ${OPENCOLLADA_INCLUDE_DIR}/COLLADAFramework/include
+ ${OPENCOLLADA_INCLUDE_DIR}/COLLADASaxFrameworkLoader/include
+ ${OPENCOLLADA_INCLUDE_DIR}/GeneratedSaxParser/include
)
endif()
diff --git a/source/blender/collada/DocumentImporter.cpp b/source/blender/collada/DocumentImporter.cpp
index 10e6d611cc5..78ee444bb4e 100644
--- a/source/blender/collada/DocumentImporter.cpp
+++ b/source/blender/collada/DocumentImporter.cpp
@@ -309,7 +309,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;
@@ -353,10 +353,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);
@@ -367,7 +367,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;
}
@@ -385,11 +390,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...
@@ -423,7 +428,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;
}
@@ -436,7 +441,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;
@@ -518,7 +524,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;
@@ -670,6 +676,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()) {
diff --git a/source/blender/collada/DocumentImporter.h b/source/blender/collada/DocumentImporter.h
index e57d621eeef..5ccec534680 100644
--- a/source/blender/collada/DocumentImporter.h
+++ b/source/blender/collada/DocumentImporter.h
@@ -72,7 +72,7 @@ public:
/** these should not be here */
Object* create_camera_object(COLLADAFW::InstanceCamera*, Scene*);
Object* create_lamp_object(COLLADAFW::InstanceLight*, Scene*);
- Object* create_instance_node(Object*, COLLADAFW::Node*, COLLADAFW::Node*, Scene*, bool);
+ Object* create_instance_node(Object*, COLLADAFW::Node*, COLLADAFW::Node*, Scene*, Object*, bool);
void write_node(COLLADAFW::Node*, COLLADAFW::Node*, Scene*, Object*, bool);
MTex* create_texture(COLLADAFW::EffectCommon*, COLLADAFW::Texture&, Material*, int, TexIndexTextureArrayMap&);
void write_profile_COMMON(COLLADAFW::EffectCommon*, Material*);
diff --git a/source/blender/collada/LightExporter.cpp b/source/blender/collada/LightExporter.cpp
index 12ccf77f6ad..13eb62ca969 100644
--- a/source/blender/collada/LightExporter.cpp
+++ b/source/blender/collada/LightExporter.cpp
@@ -67,7 +67,7 @@ void LightsExporter::operator()(Object *ob)
std::string la_id(get_light_id(ob));
std::string la_name(id_name(la));
COLLADASW::Color col(la->r * la->energy, la->g * la->energy, la->b * la->energy);
- float e, d, constatt, linatt, quadatt;
+ float d, constatt, linatt, quadatt;
d = la->dist;
@@ -84,7 +84,7 @@ void LightsExporter::operator()(Object *ob)
// sun
if (la->type == LA_SUN) {
- COLLADASW::DirectionalLight cla(mSW, la_id, la_name, e);
+ COLLADASW::DirectionalLight cla(mSW, la_id, la_name);
cla.setColor(col);
cla.setConstantAttenuation(constatt);
exportBlenderProfile(cla, la);
@@ -92,7 +92,7 @@ void LightsExporter::operator()(Object *ob)
}
// hemi
else if (la->type == LA_HEMI) {
- COLLADASW::AmbientLight cla(mSW, la_id, la_name, e);
+ COLLADASW::AmbientLight cla(mSW, la_id, la_name);
cla.setColor(col);
cla.setConstantAttenuation(constatt);
exportBlenderProfile(cla, la);
@@ -100,7 +100,7 @@ void LightsExporter::operator()(Object *ob)
}
// spot
else if (la->type == LA_SPOT) {
- COLLADASW::SpotLight cla(mSW, la_id, la_name, e);
+ COLLADASW::SpotLight cla(mSW, la_id, la_name);
cla.setColor(col);
cla.setFallOffAngle(la->spotsize);
cla.setFallOffExponent(la->spotblend);
@@ -112,7 +112,7 @@ void LightsExporter::operator()(Object *ob)
}
// lamp
else if (la->type == LA_LOCAL) {
- COLLADASW::PointLight cla(mSW, la_id, la_name, e);
+ COLLADASW::PointLight cla(mSW, la_id, la_name);
cla.setColor(col);
cla.setConstantAttenuation(constatt);
cla.setLinearAttenuation(linatt);
@@ -123,7 +123,7 @@ void LightsExporter::operator()(Object *ob)
// area lamp is not supported
// it will be exported as a local lamp
else {
- COLLADASW::PointLight cla(mSW, la_id, la_name, e);
+ COLLADASW::PointLight cla(mSW, la_id, la_name);
cla.setColor(col);
cla.setConstantAttenuation(constatt);
cla.setLinearAttenuation(linatt);
diff --git a/source/blender/collada/MeshImporter.cpp b/source/blender/collada/MeshImporter.cpp
index b6576858c51..d1977d15fb2 100644
--- a/source/blender/collada/MeshImporter.cpp
+++ b/source/blender/collada/MeshImporter.cpp
@@ -62,7 +62,7 @@ extern "C" {
#include "MeshImporter.h"
#include "collada_utils.h"
-// works for COLLADAFW::Node, COLLADAFW::Geometry
+// get node name, or fall back to original id if not present (name is optional)
template<class T>
static const char *bc_get_dae_name(T *node)
{
@@ -755,9 +755,11 @@ MTex *MeshImporter::assign_textures_to_uvlayer(COLLADAFW::TextureCoordinateBindi
MTex *color_texture)
{
const COLLADAFW::TextureMapId texture_index = ctexture.getTextureMapId();
- const size_t setindex = ctexture.getSetIndex();
+ size_t setindex = ctexture.getSetIndex();
std::string uvname = ctexture.getSemantic();
+ if(setindex==-1) return NULL;
+
const CustomData *data = &me->fdata;
int layer_index = CustomData_get_layer_index(data, CD_MTFACE);
CustomDataLayer *cdl = &data->layers[layer_index+setindex];
@@ -833,7 +835,6 @@ MTFace *MeshImporter::assign_material_to_geom(COLLADAFW::MaterialBinding cmateri
if (*color_texture &&
strlen((*color_texture)->uvname) &&
strcmp(layername, (*color_texture)->uvname) != 0) {
-
texture_face = (MTFace*)CustomData_get_layer_named(&me->fdata, CD_MTFACE,
(*color_texture)->uvname);
strcpy(layername, (*color_texture)->uvname);
@@ -903,7 +904,7 @@ Object *MeshImporter::create_mesh_object(COLLADAFW::Node *node, COLLADAFW::Insta
uid_object_map[*geom_uid] = ob;
// name Object
- const std::string& id = node->getOriginalId();
+ const std::string& id = node->getName().size() ? node->getName() : node->getOriginalId();
if (id.length())
rename_id(&ob->id, (char*)id.c_str());
@@ -915,6 +916,7 @@ Object *MeshImporter::create_mesh_object(COLLADAFW::Node *node, COLLADAFW::Insta
if (old_mesh->id.us == 0) free_libblock(&G.main->mesh, old_mesh);
char layername[100];
+ layername[0] = '\0';
MTFace *texture_face = NULL;
MTex *color_texture = NULL;
@@ -957,7 +959,7 @@ bool MeshImporter::write_geometry(const COLLADAFW::Geometry* geom)
return true;
}
- const std::string& str_geom_id = mesh->getOriginalId();
+ const std::string& str_geom_id = mesh->getName().size() ? mesh->getName() : mesh->getOriginalId();
Mesh *me = add_mesh((char*)str_geom_id.c_str());
// store the Mesh pointer to link it later with an Object
diff --git a/source/blender/collada/SkinInfo.cpp b/source/blender/collada/SkinInfo.cpp
index 10780de2e70..83b9449c8f2 100644
--- a/source/blender/collada/SkinInfo.cpp
+++ b/source/blender/collada/SkinInfo.cpp
@@ -48,12 +48,12 @@
#include "SkinInfo.h"
#include "collada_utils.h"
-// use this for retrieving bone names, since these must be unique
+// use name, or fall back to original id if name not present (name is optional)
template<class T>
static const char *bc_get_joint_name(T *node)
{
- const std::string& id = node->getOriginalId();
- return id.size() ? id.c_str() : node->getName().c_str();
+ const std::string& id = node->getName();
+ return id.size() ? id.c_str() : node->getOriginalId().c_str();
}
// This is used to store data passed in write_controller_data.
diff --git a/source/blender/collada/collada_internal.cpp b/source/blender/collada/collada_internal.cpp
index 4f4d16d3b0d..9cb6a227fc9 100644
--- a/source/blender/collada/collada_internal.cpp
+++ b/source/blender/collada/collada_internal.cpp
@@ -265,7 +265,7 @@ std::string get_light_id(Object *ob)
std::string get_joint_id(Bone *bone, Object *ob_arm)
{
- return translate_id(id_name(ob_arm) + "_" + bone->name);
+ return translate_id(bone->name);
}
std::string get_camera_id(Object *ob)