[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [32310] trunk/blender/source/blender/ collada: SVN maintenance.

gsr b3d gsr.b3d at infernal-iceberg.com
Tue Oct 5 02:49:39 CEST 2010


Revision: 32310
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=32310
Author:   gsrb3d
Date:     2010-10-05 02:49:39 +0200 (Tue, 05 Oct 2010)

Log Message:
-----------
SVN maintenance.

Modified Paths:
--------------
    trunk/blender/source/blender/collada/AnimationImporter.cpp
    trunk/blender/source/blender/collada/AnimationImporter.h
    trunk/blender/source/blender/collada/ArmatureImporter.cpp
    trunk/blender/source/blender/collada/ArmatureImporter.h
    trunk/blender/source/blender/collada/MeshImporter.cpp
    trunk/blender/source/blender/collada/MeshImporter.h
    trunk/blender/source/blender/collada/SkinInfo.cpp
    trunk/blender/source/blender/collada/SkinInfo.h
    trunk/blender/source/blender/collada/TransformReader.cpp
    trunk/blender/source/blender/collada/TransformReader.h
    trunk/blender/source/blender/collada/collada_utils.cpp
    trunk/blender/source/blender/collada/collada_utils.h

Property Changed:
----------------
    trunk/blender/source/blender/collada/AnimationImporter.cpp
    trunk/blender/source/blender/collada/AnimationImporter.h
    trunk/blender/source/blender/collada/ArmatureImporter.cpp
    trunk/blender/source/blender/collada/ArmatureImporter.h
    trunk/blender/source/blender/collada/MeshImporter.cpp
    trunk/blender/source/blender/collada/MeshImporter.h
    trunk/blender/source/blender/collada/SkinInfo.cpp
    trunk/blender/source/blender/collada/SkinInfo.h
    trunk/blender/source/blender/collada/TransformReader.cpp
    trunk/blender/source/blender/collada/TransformReader.h
    trunk/blender/source/blender/collada/collada_utils.cpp
    trunk/blender/source/blender/collada/collada_utils.h

Modified: trunk/blender/source/blender/collada/AnimationImporter.cpp
===================================================================
--- trunk/blender/source/blender/collada/AnimationImporter.cpp	2010-10-05 00:05:14 UTC (rev 32309)
+++ trunk/blender/source/blender/collada/AnimationImporter.cpp	2010-10-05 00:49:39 UTC (rev 32310)
@@ -1,1149 +1,1149 @@
-/**
- * $Id: DocumentImporter.cpp 32235 2010-10-01 19:46:42Z jesterking $
- *
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * Contributor(s): Chingiz Dyussenov, Arystanbek Dyussenov, Nathan Letwory.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-#include "DNA_armature_types.h"
-
-#include "ED_keyframing.h"
-
-#include "BLI_listbase.h"
-#include "BLI_math.h"
-#include "BLI_path_util.h"
-#include "BLI_string.h"
-
-#include "BKE_action.h"
-#include "BKE_armature.h"
-#include "BKE_fcurve.h"
-#include "BKE_object.h"
-
-#include "MEM_guardedalloc.h"
-
-#include "collada_utils.h"
-#include "AnimationImporter.h"
-#include "ArmatureImporter.h"
-
-#include <algorithm>
-
-// use this for retrieving bone names, since these must be unique
-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();
-}
-
-FCurve *AnimationImporter::create_fcurve(int array_index, const char *rna_path)
-{
-	FCurve *fcu = (FCurve*)MEM_callocN(sizeof(FCurve), "FCurve");
-	
-	fcu->flag = (FCURVE_VISIBLE|FCURVE_AUTO_HANDLES|FCURVE_SELECTED);
-	fcu->rna_path = BLI_strdupn(rna_path, strlen(rna_path));
-	fcu->array_index = array_index;
-	return fcu;
-}
-	
-void AnimationImporter::create_bezt(FCurve *fcu, float frame, float output)
-{
-	BezTriple bez;
-	memset(&bez, 0, sizeof(BezTriple));
-	bez.vec[1][0] = frame;
-	bez.vec[1][1] = output;
-	bez.ipo = U.ipo_new; /* use default interpolation mode here... */
-	bez.f1 = bez.f2 = bez.f3 = SELECT;
-	bez.h1 = bez.h2 = HD_AUTO;
-	insert_bezt_fcurve(fcu, &bez, 0);
-	calchandles_fcurve(fcu);
-}
-
-// create one or several fcurves depending on the number of parameters being animated
-void AnimationImporter::animation_to_fcurves(COLLADAFW::AnimationCurve *curve)
-{
-	COLLADAFW::FloatOrDoubleArray& input = curve->getInputValues();
-	COLLADAFW::FloatOrDoubleArray& output = curve->getOutputValues();
-	// COLLADAFW::FloatOrDoubleArray& intan = curve->getInTangentValues();
-	// COLLADAFW::FloatOrDoubleArray& outtan = curve->getOutTangentValues();
-	float fps = (float)FPS;
-	size_t dim = curve->getOutDimension();
-	unsigned int i;
-
-	std::vector<FCurve*>& fcurves = curve_map[curve->getUniqueId()];
-
-	switch (dim) {
-	case 1: // X, Y, Z or angle
-	case 3: // XYZ
-	case 16: // matrix
-		{
-			for (i = 0; i < dim; i++ ) {
-				FCurve *fcu = (FCurve*)MEM_callocN(sizeof(FCurve), "FCurve");
-			
-				fcu->flag = (FCURVE_VISIBLE|FCURVE_AUTO_HANDLES|FCURVE_SELECTED);
-				// fcu->rna_path = BLI_strdupn(path, strlen(path));
-				fcu->array_index = 0;
-				//fcu->totvert = curve->getKeyCount();
-			
-				// create beztriple for each key
-				for (unsigned int j = 0; j < curve->getKeyCount(); j++) {
-					BezTriple bez;
-					memset(&bez, 0, sizeof(BezTriple));
-
-					// intangent
-					// bez.vec[0][0] = get_float_value(intan, j * 6 + i + i) * fps;
-					// bez.vec[0][1] = get_float_value(intan, j * 6 + i + i + 1);
-
-					// input, output
-					bez.vec[1][0] = bc_get_float_value(input, j) * fps; 
-					bez.vec[1][1] = bc_get_float_value(output, j * dim + i);
-
-					// outtangent
-					// bez.vec[2][0] = get_float_value(outtan, j * 6 + i + i) * fps;
-					// bez.vec[2][1] = get_float_value(outtan, j * 6 + i + i + 1);
-
-					bez.ipo = U.ipo_new; /* use default interpolation mode here... */
-					bez.f1 = bez.f2 = bez.f3 = SELECT;
-					bez.h1 = bez.h2 = HD_AUTO;
-					insert_bezt_fcurve(fcu, &bez, 0);
-				}
-
-				calchandles_fcurve(fcu);
-
-				fcurves.push_back(fcu);
-			}
-		}
-		break;
-	default:
-		fprintf(stderr, "Output dimension of %d is not yet supported (animation id = %s)\n", dim, curve->getOriginalId().c_str());
-	}
-
-	for (std::vector<FCurve*>::iterator it = fcurves.begin(); it != fcurves.end(); it++)
-		unused_curves.push_back(*it);
-}
-
-void AnimationImporter::fcurve_deg_to_rad(FCurve *cu)
-{
-	for (unsigned int i = 0; i < cu->totvert; i++) {
-		// TODO convert handles too
-		cu->bezt[i].vec[1][1] *= M_PI / 180.0f;
-	}
-}
-
-void AnimationImporter::add_fcurves_to_object(Object *ob, std::vector<FCurve*>& curves, char *rna_path, int array_index, Animation *animated)
-{
-	bAction *act;
-	
-	if (!ob->adt || !ob->adt->action) act = verify_adt_action((ID*)&ob->id, 1);
-	else act = ob->adt->action;
-	
-	std::vector<FCurve*>::iterator it;
-	int i;
-
-#if 0
-	char *p = strstr(rna_path, "rotation_euler");
-	bool is_rotation = p && *(p + strlen("rotation_euler")) == '\0';
-
-	// convert degrees to radians for rotation
-	if (is_rotation)
-		fcurve_deg_to_rad(fcu);
-#endif
-	
-	for (it = curves.begin(), i = 0; it != curves.end(); it++, i++) {
-		FCurve *fcu = *it;
-		fcu->rna_path = BLI_strdupn(rna_path, strlen(rna_path));
-		
-		if (array_index == -1) fcu->array_index = i;
-		else fcu->array_index = array_index;
-	
-		if (ob->type == OB_ARMATURE) {
-			bActionGroup *grp = NULL;
-			const char *bone_name = bc_get_joint_name(animated->node);
-			
-			if (bone_name) {
-				/* try to find group */
-				grp = action_groups_find_named(act, bone_name);
-				
-				/* no matching groups, so add one */
-				if (grp == NULL) {
-					/* Add a new group, and make it active */
-					grp = (bActionGroup*)MEM_callocN(sizeof(bActionGroup), "bActionGroup");
-					
-					grp->flag = AGRP_SELECTED;
-					BLI_strncpy(grp->name, bone_name, sizeof(grp->name));
-					
-					BLI_addtail(&act->groups, grp);
-					BLI_uniquename(&act->groups, grp, "Group", '.', offsetof(bActionGroup, name), 64);
-				}
-				
-				/* add F-Curve to group */
-				action_groups_add_channel(act, grp, fcu);
-				
-			}
-#if 0
-			if (is_rotation) {
-				fcurves_actionGroup_map[grp].push_back(fcu);
-			}
-#endif
-		}
-		else {
-			BLI_addtail(&act->curves, fcu);
-		}
-
-		// curve is used, so remove it from unused_curves
-		unused_curves.erase(std::remove(unused_curves.begin(), unused_curves.end(), fcu), unused_curves.end());
-	}
-}
-
-AnimationImporter::AnimationImporter(UnitConverter *conv, ArmatureImporter *arm, Scene *scene) :
-		TransformReader(conv), armature_importer(arm), scene(scene) { }
-
-AnimationImporter::~AnimationImporter()
-{
-	// free unused FCurves
-	for (std::vector<FCurve*>::iterator it = unused_curves.begin(); it != unused_curves.end(); it++)
-		free_fcurve(*it);
-
-	if (unused_curves.size())
-		fprintf(stderr, "removed %u unused curves\n", unused_curves.size());
-}
-
-bool AnimationImporter::write_animation(const COLLADAFW::Animation* anim) 
-{
-	if (anim->getAnimationType() == COLLADAFW::Animation::ANIMATION_CURVE) {
-		COLLADAFW::AnimationCurve *curve = (COLLADAFW::AnimationCurve*)anim;
-		
-		// XXX Don't know if it's necessary
-		// Should we check outPhysicalDimension?
-		if (curve->getInPhysicalDimension() != COLLADAFW::PHYSICAL_DIMENSION_TIME) {
-			fprintf(stderr, "Inputs physical dimension is not time. \n");
-			return true;
-		}
-
-		// a curve can have mixed interpolation type,
-		// in this case curve->getInterpolationTypes returns a list of interpolation types per key
-		COLLADAFW::AnimationCurve::InterpolationType interp = curve->getInterpolationType();
-
-		if (interp != COLLADAFW::AnimationCurve::INTERPOLATION_MIXED) {
-			switch (interp) {
-			case COLLADAFW::AnimationCurve::INTERPOLATION_LINEAR:
-			case COLLADAFW::AnimationCurve::INTERPOLATION_BEZIER:
-				animation_to_fcurves(curve);
-				break;
-			default:
-				// TODO there're also CARDINAL, HERMITE, BSPLINE and STEP types
-				fprintf(stderr, "CARDINAL, HERMITE, BSPLINE and STEP anim interpolation types not supported yet.\n");
-				break;
-			}
-		}
-		else {
-			// not supported yet
-			fprintf(stderr, "MIXED anim interpolation type is not supported yet.\n");
-		}
-	}
-	else {
-		fprintf(stderr, "FORMULA animation type is not supported yet.\n");
-	}
-	
-	return true;
-}
-	
-// called on post-process stage after writeVisualScenes
-bool AnimationImporter::write_animation_list(const COLLADAFW::AnimationList* animlist) 
-{
-	const COLLADAFW::UniqueId& animlist_id = animlist->getUniqueId();
-
-	animlist_map[animlist_id] = animlist;
-
-#if 0
-	// should not happen
-	if (uid_animated_map.find(animlist_id) == uid_animated_map.end()) {
-		return true;
-	}
-
-	// for bones rna_path is like: pose.bones["bone-name"].rotation
-	
-	// what does this AnimationList animate?
-	Animation& animated = uid_animated_map[animlist_id];
-	Object *ob = animated.ob;
-
-	char rna_path[100];
-	char joint_path[100];
-	bool is_joint = false;
-
-	// if ob is NULL, it should be a JOINT
-	if (!ob) {
-		ob = armature_importer->get_armature_for_joint(animated.node);
-
-		if (!ob) {
-			fprintf(stderr, "Cannot find armature for node %s\n", get_joint_name(animated.node));
-			return true;
-		}
-
-		armature_importer->get_rna_path_for_joint(animated.node, joint_path, sizeof(joint_path));
-
-		is_joint = true;
-	}
-	
-	const COLLADAFW::AnimationList::AnimationBindings& bindings = animlist->getAnimationBindings();
-
-	switch (animated.tm->getTransformationType()) {
-	case COLLADAFW::Transformation::TRANSLATE:
-	case COLLADAFW::Transformation::SCALE:
-		{
-			bool loc = animated.tm->getTransformationType() == COLLADAFW::Transformation::TRANSLATE;
-			if (is_joint)
-				BLI_snprintf(rna_path, sizeof(rna_path), "%s.%s", joint_path, loc ? "location" : "scale");
-			else
-				BLI_strncpy(rna_path, loc ? "location" : "scale", sizeof(rna_path));
-
-			for (int i = 0; i < bindings.getCount(); i++) {
-				const COLLADAFW::AnimationList::AnimationBinding& binding = bindings[i];

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list