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:
authorTamito Kajiyama <rd6t-kjym@asahi-net.or.jp>2012-03-25 12:20:19 +0400
committerTamito Kajiyama <rd6t-kjym@asahi-net.or.jp>2012-03-25 12:20:19 +0400
commit3b711a6ed009b35bb69cd0ca878eeb8d55fa0e77 (patch)
treeb3fdb366cb49bdea5b57dfa6ba4a82635c68d0ee /source/blender/collada/DocumentImporter.cpp
parenta2ebfc82dbe954acc432ae017ac62a30a11b6a16 (diff)
parente99a23fc6b33b5097eab44aac19c2a089ddebce6 (diff)
Merged changes in the trunk up to revision 45133.
Conflicts resolved: source/blender/blenloader/intern/readfile.c source/blender/blenloader/intern/writefile.c source/blender/bmesh/intern/bmesh_construct.c source/blender/bmesh/intern/bmesh_mesh_conv.c source/blender/bmesh/intern/bmesh_mesh_conv.h source/blender/editors/interface/interface_templates.c source/blender/editors/interface/resources.c source/blender/editors/mesh/bmesh_select.c source/blender/editors/mesh/bmesh_tools.c source/blender/editors/space_view3d/drawobject.c source/blender/render/intern/source/shadeoutput.c
Diffstat (limited to 'source/blender/collada/DocumentImporter.cpp')
-rw-r--r--source/blender/collada/DocumentImporter.cpp107
1 files changed, 60 insertions, 47 deletions
diff --git a/source/blender/collada/DocumentImporter.cpp b/source/blender/collada/DocumentImporter.cpp
index 90c74d8b226..9e604978f64 100644
--- a/source/blender/collada/DocumentImporter.cpp
+++ b/source/blender/collada/DocumentImporter.cpp
@@ -121,10 +121,12 @@ bool DocumentImporter::import()
loader.registerExtraDataCallbackHandler(ehandler);
- if (!root.loadDocument(mFilename))
+ if (!root.loadDocument(mFilename)) {
+ fprintf(stderr, "COLLADAFW::Root::loadDocument() returned false on 1st pass\n");
return false;
+ }
- if(errorHandler.hasError())
+ if (errorHandler.hasError())
return false;
/** TODO set up scene graph and such here */
@@ -134,8 +136,10 @@ bool DocumentImporter::import()
COLLADASaxFWL::Loader loader2;
COLLADAFW::Root root2(&loader2, this);
- if (!root2.loadDocument(mFilename))
+ if (!root2.loadDocument(mFilename)) {
+ fprintf(stderr, "COLLADAFW::Root::loadDocument() returned false on 2nd pass\n");
return false;
+ }
delete ehandler;
@@ -157,7 +161,7 @@ void DocumentImporter::start(){}
void DocumentImporter::finish()
{
- if(mImportStage!=General)
+ if (mImportStage!=General)
return;
/** TODO Break up and put into 2-pass parsing of DAE */
@@ -235,7 +239,15 @@ void DocumentImporter::finish()
void DocumentImporter::translate_anim_recursive(COLLADAFW::Node *node, COLLADAFW::Node *par = NULL, Object *parob = NULL)
{
- if (par && par->getType() == COLLADAFW::Node::JOINT) {
+
+ // The split in #29246, rootmap must point at actual root when
+ // calculating bones in apply_curves_as_matrix.
+ // This has to do with inverse bind poses being world space
+ // (the sources for skinned bones' restposes) and the way
+ // non-skinning nodes have their "restpose" recursively calculated.
+ // XXX TODO: design issue, how to support unrelated joints taking
+ // part in skinning.
+ if (par) { // && par->getType() == COLLADAFW::Node::JOINT) {
// par is root if there's no corresp. key in root_map
if (root_map.find(par->getUniqueId()) == root_map.end())
root_map[node->getUniqueId()] = par;
@@ -313,8 +325,10 @@ 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, Object *par_ob, bool is_library_node)
+Object* DocumentImporter::create_instance_node(Object *source_ob, COLLADAFW::Node *source_node, COLLADAFW::Node *instance_node, Scene *sce, bool is_library_node)
{
+ fprintf(stderr, "create <instance_node> under node id=%s from node id=%s\n", instance_node ? instance_node->getOriginalId().c_str() : NULL, source_node ? source_node->getOriginalId().c_str() : NULL);
+
Object *obn = copy_object(source_ob);
obn->recalc |= OB_RECALC_OB|OB_RECALC_DATA|OB_RECALC_TIME;
scene_add_base(sce, obn);
@@ -325,7 +339,7 @@ Object* DocumentImporter::create_instance_node(Object *source_ob, COLLADAFW::Nod
// transformation matrix and apply it to the newly instantiated
// object to account for node hierarchy transforms in
// .dae
- if(source_node) {
+ if (source_node) {
COLLADABU::Math::Matrix4 mat4 = source_node->getTransformationMatrix();
COLLADABU::Math::Matrix4 bmat4 = mat4.transpose(); // transpose to get blender row-major order
float mat[4][4];
@@ -357,10 +371,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, NULL, is_library_node);
+ new_child = create_instance_node(object_map[id], node_map[id], child_node, sce, is_library_node);
}
else {
- new_child = create_instance_node(object_map[child_id], child_node, NULL, sce, NULL, is_library_node);
+ new_child = create_instance_node(object_map[child_id], child_node, NULL, sce, is_library_node);
}
bc_set_parent(new_child, obn, mContext, true);
@@ -369,21 +383,14 @@ 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) {
- if (par_ob && obn)
- bc_set_parent(obn, par_ob, mContext);
- return NULL;
- }
-
- else return obn;
+ return obn;
}
void DocumentImporter::write_node (COLLADAFW::Node *node, COLLADAFW::Node *parent_node, Scene *sce, Object *par, bool is_library_node)
{
Object *ob = NULL;
bool is_joint = node->getType() == COLLADAFW::Node::JOINT;
+ bool read_transform = true;
if (is_joint) {
if ( par ) {
@@ -432,16 +439,18 @@ void DocumentImporter::write_node (COLLADAFW::Node *node, COLLADAFW::Node *paren
while (inst_done < inst_node.getCount()) {
const COLLADAFW::UniqueId& node_id = inst_node[inst_done]->getInstanciatedObjectId();
if (object_map.find(node_id) == object_map.end()) {
- fprintf(stderr, "Cannot find node to instanciate.\n");
+ fprintf(stderr, "Cannot find object for node referenced by <instance_node name=\"%s\">.\n", inst_node[inst_done]->getName().c_str());
ob = NULL;
}
else {
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, par, is_library_node);
+ ob = create_instance_node(source_ob, source_node, node, sce, is_library_node);
}
++inst_done;
+
+ read_transform = false;
}
// if node is empty - create empty object
// XXX empty node may not mean it is empty object, not sure about this
@@ -449,7 +458,8 @@ void DocumentImporter::write_node (COLLADAFW::Node *node, COLLADAFW::Node *paren
ob = add_object(sce, OB_EMPTY);
}
- // check if object is not NULL
+ // XXX: if there're multiple instances, only one is stored
+
if (!ob) return;
std::string nodename = node->getName().size() ? node->getName() : node->getOriginalId();
@@ -462,7 +472,8 @@ void DocumentImporter::write_node (COLLADAFW::Node *node, COLLADAFW::Node *paren
libnode_ob.push_back(ob);
}
- anim_importer.read_node_transform(node, ob); // overwrites location set earlier
+ if (read_transform)
+ anim_importer.read_node_transform(node, ob); // overwrites location set earlier
if (!is_joint) {
// if par was given make this object child of the previous
@@ -481,7 +492,7 @@ void DocumentImporter::write_node (COLLADAFW::Node *node, COLLADAFW::Node *paren
\return The writer should return true, if writing succeeded, false otherwise.*/
bool DocumentImporter::writeVisualScene ( const COLLADAFW::VisualScene* visualScene )
{
- if(mImportStage!=General)
+ if (mImportStage!=General)
return true;
// this method called on post process after writeGeometry, writeMaterial, etc.
@@ -504,7 +515,7 @@ bool DocumentImporter::writeVisualScene ( const COLLADAFW::VisualScene* visualSc
\return The writer should return true, if writing succeeded, false otherwise.*/
bool DocumentImporter::writeLibraryNodes ( const COLLADAFW::LibraryNodes* libraryNodes )
{
- if(mImportStage!=General)
+ if (mImportStage!=General)
return true;
Scene *sce = CTX_data_scene(mContext);
@@ -522,7 +533,7 @@ bool DocumentImporter::writeLibraryNodes ( const COLLADAFW::LibraryNodes* librar
\return The writer should return true, if writing succeeded, false otherwise.*/
bool DocumentImporter::writeGeometry ( const COLLADAFW::Geometry* geom )
{
- if(mImportStage!=General)
+ if (mImportStage!=General)
return true;
return mesh_importer.write_geometry(geom);
@@ -532,7 +543,7 @@ bool DocumentImporter::writeGeometry ( const COLLADAFW::Geometry* geom )
\return The writer should return true, if writing succeeded, false otherwise.*/
bool DocumentImporter::writeMaterial( const COLLADAFW::Material* cmat )
{
- if(mImportStage!=General)
+ if (mImportStage!=General)
return true;
const std::string& str_mat_id = cmat->getName().size() ? cmat->getName() : cmat->getOriginalId();
@@ -688,10 +699,10 @@ void DocumentImporter::write_profile_COMMON(COLLADAFW::EffectCommon *ef, Materia
}
}
- if(ef->getOpacity().isTexture()) {
+ if (ef->getOpacity().isTexture()) {
COLLADAFW::Texture ctex = ef->getOpacity().getTexture();
mtex = create_texture(ef, ctex, ma, i, texindex_texarray_map);
- if(mtex != NULL) {
+ if (mtex != NULL) {
mtex->mapto = MAP_ALPHA;
mtex->tex->imaflag |= TEX_USEALPHA;
i++;
@@ -721,7 +732,7 @@ void DocumentImporter::write_profile_COMMON(COLLADAFW::EffectCommon *ef, Materia
bool DocumentImporter::writeEffect( const COLLADAFW::Effect* effect )
{
- if(mImportStage!=General)
+ if (mImportStage!=General)
return true;
const COLLADAFW::UniqueId& uid = effect->getUniqueId();
@@ -733,7 +744,7 @@ bool DocumentImporter::writeEffect( const COLLADAFW::Effect* effect )
Material *ma = uid_effect_map[uid];
std::map<COLLADAFW::UniqueId, Material*>::iterator iter;
- for(iter = uid_material_map.begin(); iter != uid_material_map.end() ; iter++ )
+ for (iter = uid_material_map.begin(); iter != uid_material_map.end() ; iter++ )
{
if ( iter->second == ma ) {
this->FW_object_map[iter->first] = effect;
@@ -759,7 +770,7 @@ bool DocumentImporter::writeEffect( const COLLADAFW::Effect* effect )
\return The writer should return true, if writing succeeded, false otherwise.*/
bool DocumentImporter::writeCamera( const COLLADAFW::Camera* camera )
{
- if(mImportStage!=General)
+ if (mImportStage!=General)
return true;
Camera *cam = NULL;
@@ -875,7 +886,7 @@ bool DocumentImporter::writeCamera( const COLLADAFW::Camera* camera )
\return The writer should return true, if writing succeeded, false otherwise.*/
bool DocumentImporter::writeImage( const COLLADAFW::Image* image )
{
- if(mImportStage!=General)
+ if (mImportStage!=General)
return true;
// XXX maybe it is necessary to check if the path is absolute or relative
@@ -900,7 +911,7 @@ bool DocumentImporter::writeImage( const COLLADAFW::Image* image )
\return The writer should return true, if writing succeeded, false otherwise.*/
bool DocumentImporter::writeLight( const COLLADAFW::Light* light )
{
- if(mImportStage!=General)
+ if (mImportStage!=General)
return true;
Lamp *lamp = NULL;
@@ -909,7 +920,7 @@ bool DocumentImporter::writeLight( const COLLADAFW::Light* light )
TagsMap::iterator etit;
ExtraTags *et = 0;
etit = uid_tags_map.find(light->getUniqueId().toAscii());
- if(etit != uid_tags_map.end())
+ if (etit != uid_tags_map.end())
et = etit->second;
la_id = light->getOriginalId();
@@ -923,7 +934,7 @@ bool DocumentImporter::writeLight( const COLLADAFW::Light* light )
}
// if we find an ExtraTags for this, use that instead.
- if(et && et->isProfile("blender")) {
+ if (et && et->isProfile("blender")) {
et->setData("type", &(lamp->type));
et->setData("flag", &(lamp->flag));
et->setData("mode", &(lamp->mode));
@@ -996,17 +1007,19 @@ bool DocumentImporter::writeLight( const COLLADAFW::Light* light )
lamp->b = col.getBlue();
}
- if(IS_EQ(linatt, 0.0f) && quadatt > 0.0f) {
+ if (IS_EQ(linatt, 0.0f) && quadatt > 0.0f) {
att2 = quadatt;
d = sqrt(1.0f/quadatt);
}
// linear light
- else if(IS_EQ(quadatt, 0.0f) && linatt > 0.0f) {
+ else if (IS_EQ(quadatt, 0.0f) && linatt > 0.0f) {
att1 = linatt;
d = (1.0f/linatt);
- } else if (IS_EQ(constatt, 1.0f)) {
+ }
+ else if (IS_EQ(constatt, 1.0f)) {
att1 = 1.0f;
- } else {
+ }
+ else {
// assuming point light (const att = 1.0);
att1 = 1.0f;
}
@@ -1028,9 +1041,9 @@ bool DocumentImporter::writeLight( const COLLADAFW::Light* light )
lamp->type = LA_SPOT;
lamp->att1 = att1;
lamp->att2 = att2;
- if(IS_EQ(att1, 0.0f) && att2 > 0)
+ if (IS_EQ(att1, 0.0f) && att2 > 0)
lamp->falloff_type = LA_FALLOFF_INVSQUARE;
- if(IS_EQ(att2, 0.0f) && att1 > 0)
+ if (IS_EQ(att2, 0.0f) && att1 > 0)
lamp->falloff_type = LA_FALLOFF_INVLINEAR;
lamp->spotsize = light->getFallOffAngle().getValue();
lamp->spotblend = light->getFallOffExponent().getValue();
@@ -1048,9 +1061,9 @@ bool DocumentImporter::writeLight( const COLLADAFW::Light* light )
lamp->type = LA_LOCAL;
lamp->att1 = att1;
lamp->att2 = att2;
- if(IS_EQ(att1, 0.0f) && att2 > 0)
+ if (IS_EQ(att1, 0.0f) && att2 > 0)
lamp->falloff_type = LA_FALLOFF_INVSQUARE;
- if(IS_EQ(att2, 0.0f) && att1 > 0)
+ if (IS_EQ(att2, 0.0f) && att1 > 0)
lamp->falloff_type = LA_FALLOFF_INVLINEAR;
}
break;
@@ -1071,7 +1084,7 @@ bool DocumentImporter::writeLight( const COLLADAFW::Light* light )
// this function is called only for animations that pass COLLADAFW::validate
bool DocumentImporter::writeAnimation( const COLLADAFW::Animation* anim )
{
- if(mImportStage!=General)
+ if (mImportStage!=General)
return true;
// return true;
@@ -1081,7 +1094,7 @@ bool DocumentImporter::writeAnimation( const COLLADAFW::Animation* anim )
// called on post-process stage after writeVisualScenes
bool DocumentImporter::writeAnimationList( const COLLADAFW::AnimationList* animationList )
{
- if(mImportStage!=General)
+ if (mImportStage!=General)
return true;
// return true;
@@ -1098,7 +1111,7 @@ bool DocumentImporter::writeSkinControllerData( const COLLADAFW::SkinControllerD
// this is called on postprocess, before writeVisualScenes
bool DocumentImporter::writeController( const COLLADAFW::Controller* controller )
{
- if(mImportStage!=General)
+ if (mImportStage!=General)
return true;
return armature_importer.write_controller(controller);
@@ -1116,7 +1129,7 @@ bool DocumentImporter::writeKinematicsScene( const COLLADAFW::KinematicsScene* k
ExtraTags* DocumentImporter::getExtraTags(const COLLADAFW::UniqueId &uid)
{
- if(uid_tags_map.find(uid.toAscii())==uid_tags_map.end()) {
+ if (uid_tags_map.find(uid.toAscii())==uid_tags_map.end()) {
return NULL;
}
return uid_tags_map[uid.toAscii()];