style cleanup

This commit is contained in:
Campbell Barton 2012-06-12 22:05:33 +00:00
parent 46c95d37c6
commit 2e8a2f7668
28 changed files with 1293 additions and 1254 deletions

@ -162,12 +162,12 @@ struct MovieClip *BKE_object_movieclip_get(struct Scene *scene, struct Object *o
typedef enum eObRelationTypes {
OB_REL_NONE = 0, /* just the selection as is */
OB_REL_PARENT = (1<<0), /* immediate parent */
OB_REL_PARENT_RECURSIVE = (1<<1), /* parents up to root of selection tree*/
OB_REL_CHILDREN = (1<<2), /* immediate children */
OB_REL_CHILDREN_RECURSIVE = (1<<3), /* All children */
OB_REL_MOD_ARMATURE = (1<<4), /* Armatures related to the selected objects */
OB_REL_SCENE_CAMERA = (1<<5), /* you might want the scene camera too even if unselected? */
OB_REL_PARENT = (1 << 0), /* immediate parent */
OB_REL_PARENT_RECURSIVE = (1 << 1), /* parents up to root of selection tree*/
OB_REL_CHILDREN = (1 << 2), /* immediate children */
OB_REL_CHILDREN_RECURSIVE = (1 << 3), /* All children */
OB_REL_MOD_ARMATURE = (1 << 4), /* Armatures related to the selected objects */
OB_REL_SCENE_CAMERA = (1 << 5), /* you might want the scene camera too even if unselected? */
} eObRelationTypes;
typedef enum eObjectSet {

@ -3090,13 +3090,11 @@ static Object *obrel_armature_find(Object *ob)
ob_arm = ob->parent;
}
else {
ModifierData *mod = (ModifierData*)ob->modifiers.first;
while (mod) {
ModifierData *mod;
for (mod = (ModifierData *)ob->modifiers.first; mod; mod = mod->next) {
if (mod->type == eModifierType_Armature) {
ob_arm = ((ArmatureModifierData*)mod)->object;
ob_arm = ((ArmatureModifierData *)mod)->object;
}
mod = mod->next;
}
}
@ -3104,11 +3102,11 @@ static Object *obrel_armature_find(Object *ob)
}
static int obrel_is_recursive_child(Object *ob, Object *child) {
Object *ancestor = child->parent;
while (ancestor)
{
if(ancestor == ob) return TRUE;
ancestor = ancestor->parent;
Object *par;
for (par = child->parent; par; par = par->parent) {
if (par == ob) {
return TRUE;
}
}
return FALSE;
}
@ -3151,16 +3149,16 @@ struct LinkNode *BKE_object_relational_superset(struct Scene *scene, eObjectSet
obrel_list_add(&links, ob);
}
else {
if ( (objectSet == OB_SET_SELECTED && TESTBASELIB_BGMODE(((View3D *)NULL), scene, base))
|| (objectSet == OB_SET_VISIBLE && BASE_EDITABLE_BGMODE(((View3D *)NULL), scene, base))
) {
if ((objectSet == OB_SET_SELECTED && TESTBASELIB_BGMODE(((View3D *)NULL), scene, base)) ||
(objectSet == OB_SET_VISIBLE && BASE_EDITABLE_BGMODE(((View3D *)NULL), scene, base)))
{
Object *ob = base->object;
if (obrel_list_test(ob))
obrel_list_add(&links, ob);
/* parent relationship */
if (includeFilter & ( OB_REL_PARENT | OB_REL_PARENT_RECURSIVE )) {
if (includeFilter & (OB_REL_PARENT | OB_REL_PARENT_RECURSIVE)) {
Object *parent = ob->parent;
if (obrel_list_test(parent)) {
@ -3169,7 +3167,7 @@ struct LinkNode *BKE_object_relational_superset(struct Scene *scene, eObjectSet
/* recursive parent relationship */
if (includeFilter & OB_REL_PARENT_RECURSIVE) {
parent = parent->parent;
while (obrel_list_test(parent)){
while (obrel_list_test(parent)) {
obrel_list_add(&links, parent);
parent = parent->parent;
@ -3179,15 +3177,16 @@ struct LinkNode *BKE_object_relational_superset(struct Scene *scene, eObjectSet
}
/* child relationship */
if (includeFilter & ( OB_REL_CHILDREN | OB_REL_CHILDREN_RECURSIVE )) {
if (includeFilter & (OB_REL_CHILDREN | OB_REL_CHILDREN_RECURSIVE)) {
Base *local_base;
for (local_base = scene->base.first; local_base; local_base = local_base->next) {
if (BASE_EDITABLE_BGMODE(((View3D *)NULL), scene, local_base)) {
Object *child = local_base->object;
if (obrel_list_test(child)) {
if ((includeFilter & OB_REL_CHILDREN_RECURSIVE && obrel_is_recursive_child(ob,child))
|| (includeFilter & OB_REL_CHILDREN && child->parent && child->parent == ob )) {
if ((includeFilter & OB_REL_CHILDREN_RECURSIVE && obrel_is_recursive_child(ob, child)) ||
(includeFilter & OB_REL_CHILDREN && child->parent && child->parent == ob))
{
obrel_list_add(&links, child);
}
}
@ -3206,7 +3205,7 @@ struct LinkNode *BKE_object_relational_superset(struct Scene *scene, eObjectSet
}
}
} // end for
}
return links;
}

@ -28,7 +28,7 @@ template<class Functor>
void forEachObjectInExportSet(Scene *sce, Functor &f, LinkNode *export_set)
{
LinkNode *node;
for(node=export_set; node; node=node->next) {
for (node = export_set; node; node = node->next) {
Object *ob = (Object *)node->link;
f(ob);
}
@ -48,7 +48,7 @@ void AnimationExporter::exportAnimations(Scene *sce)
}
// called for each exported object
void AnimationExporter::operator() (Object *ob)
void AnimationExporter::operator()(Object *ob)
{
FCurve *fcu;
char *transformName;
@ -56,24 +56,24 @@ void AnimationExporter::operator() (Object *ob)
//Export transform animations
if (ob->adt && ob->adt->action) {
fcu = (FCurve*)ob->adt->action->curves.first;
fcu = (FCurve *)ob->adt->action->curves.first;
//transform matrix export for bones are temporarily disabled here.
if ( ob->type == OB_ARMATURE ) {
bArmature *arm = (bArmature*)ob->data;
for (Bone *bone = (Bone*)arm->bonebase.first; bone; bone = bone->next)
if (ob->type == OB_ARMATURE) {
bArmature *arm = (bArmature *)ob->data;
for (Bone *bone = (Bone *)arm->bonebase.first; bone; bone = bone->next)
write_bone_animation_matrix(ob, bone);
}
while (fcu) {
//for armature animations as objects
if ( ob->type == OB_ARMATURE )
if (ob->type == OB_ARMATURE)
transformName = fcu->rna_path;
else
transformName = extract_transform_name( fcu->rna_path );
transformName = extract_transform_name(fcu->rna_path);
if ((!strcmp(transformName, "location") || !strcmp(transformName, "scale")) ||
(!strcmp(transformName, "rotation_euler") && ob->rotmode == ROT_MODE_EUL)||
(!strcmp(transformName, "rotation_euler") && ob->rotmode == ROT_MODE_EUL) ||
(!strcmp(transformName, "rotation_quaternion")))
{
dae_animation(ob, fcu, transformName, false);
@ -84,12 +84,12 @@ void AnimationExporter::operator() (Object *ob)
}
//Export Lamp parameter animations
if ( (ob->type == OB_LAMP ) && ((Lamp*)ob ->data)->adt && ((Lamp*)ob ->data)->adt->action ) {
fcu = (FCurve*)(((Lamp*)ob ->data)->adt->action->curves.first);
if ( (ob->type == OB_LAMP) && ((Lamp *)ob->data)->adt && ((Lamp *)ob->data)->adt->action) {
fcu = (FCurve *)(((Lamp *)ob->data)->adt->action->curves.first);
while (fcu) {
transformName = extract_transform_name( fcu->rna_path );
transformName = extract_transform_name(fcu->rna_path);
if ((!strcmp(transformName, "color")) || (!strcmp(transformName, "spot_size"))||
if ((!strcmp(transformName, "color")) || (!strcmp(transformName, "spot_size")) ||
(!strcmp(transformName, "spot_blend")) || (!strcmp(transformName, "distance")))
{
dae_animation(ob, fcu, transformName, true);
@ -99,14 +99,14 @@ void AnimationExporter::operator() (Object *ob)
}
//Export Camera parameter animations
if ( (ob->type == OB_CAMERA ) && ((Camera*)ob ->data)->adt && ((Camera*)ob ->data)->adt->action ) {
fcu = (FCurve*)(((Camera*)ob ->data)->adt->action->curves.first);
if ( (ob->type == OB_CAMERA) && ((Camera *)ob->data)->adt && ((Camera *)ob->data)->adt->action) {
fcu = (FCurve *)(((Camera *)ob->data)->adt->action->curves.first);
while (fcu) {
transformName = extract_transform_name( fcu->rna_path );
transformName = extract_transform_name(fcu->rna_path);
if ((!strcmp(transformName, "lens"))||
(!strcmp(transformName, "ortho_scale"))||
(!strcmp(transformName, "clip_end"))||(!strcmp(transformName, "clip_start")))
if ((!strcmp(transformName, "lens")) ||
(!strcmp(transformName, "ortho_scale")) ||
(!strcmp(transformName, "clip_end")) || (!strcmp(transformName, "clip_start")))
{
dae_animation(ob, fcu, transformName, true);
}
@ -116,19 +116,19 @@ void AnimationExporter::operator() (Object *ob)
//Export Material parameter animations.
for (int a = 0; a < ob->totcol; a++) {
Material *ma = give_current_material(ob, a+1);
Material *ma = give_current_material(ob, a + 1);
if (!ma) continue;
if (ma->adt && ma->adt->action) {
/* isMatAnim = true; */
fcu = (FCurve*)ma->adt->action->curves.first;
fcu = (FCurve *)ma->adt->action->curves.first;
while (fcu) {
transformName = extract_transform_name( fcu->rna_path );
transformName = extract_transform_name(fcu->rna_path);
if ((!strcmp(transformName, "specular_hardness"))||(!strcmp(transformName, "specular_color")) ||
(!strcmp(transformName, "diffuse_color"))||(!strcmp(transformName, "alpha")) ||
if ((!strcmp(transformName, "specular_hardness")) || (!strcmp(transformName, "specular_color")) ||
(!strcmp(transformName, "diffuse_color")) || (!strcmp(transformName, "alpha")) ||
(!strcmp(transformName, "ior")))
{
dae_animation(ob, fcu, transformName, true, ma );
dae_animation(ob, fcu, transformName, true, ma);
}
fcu = fcu->next;
}
@ -138,33 +138,33 @@ void AnimationExporter::operator() (Object *ob)
}
//euler sources from quternion sources
float * AnimationExporter::get_eul_source_for_quat(Object *ob )
float *AnimationExporter::get_eul_source_for_quat(Object *ob)
{
FCurve *fcu = (FCurve*)ob->adt->action->curves.first;
FCurve *fcu = (FCurve *)ob->adt->action->curves.first;
const int keys = fcu->totvert;
float *quat = (float*)MEM_callocN(sizeof(float) * fcu->totvert * 4, "quat output source values");
float *eul = (float*)MEM_callocN(sizeof(float) * fcu->totvert * 3, "quat output source values");
float *quat = (float *)MEM_callocN(sizeof(float) * fcu->totvert * 4, "quat output source values");
float *eul = (float *)MEM_callocN(sizeof(float) * fcu->totvert * 3, "quat output source values");
float temp_quat[4];
float temp_eul[3];
while (fcu) {
char * transformName = extract_transform_name( fcu->rna_path );
char *transformName = extract_transform_name(fcu->rna_path);
if ( !strcmp(transformName, "rotation_quaternion") ) {
for ( int i = 0 ; i < fcu->totvert ; i++) {
*(quat + ( i * 4 ) + fcu->array_index) = fcu->bezt[i].vec[1][1];
if (!strcmp(transformName, "rotation_quaternion") ) {
for (int i = 0; i < fcu->totvert; i++) {
*(quat + (i * 4) + fcu->array_index) = fcu->bezt[i].vec[1][1];
}
}
fcu = fcu->next;
}
for ( int i = 0 ; i < keys ; i++) {
for ( int j = 0;j<4;j++)
temp_quat[j] = quat[(i*4)+j];
for (int i = 0; i < keys; i++) {
for (int j = 0; j < 4; j++)
temp_quat[j] = quat[(i * 4) + j];
quat_to_eul(temp_eul, temp_quat);
for (int k = 0;k<3;k++)
eul[i*3 + k] = temp_eul[k];
for (int k = 0; k < 3; k++)
eul[i * 3 + k] = temp_eul[k];
}
MEM_freeN(quat);
@ -173,22 +173,22 @@ float * AnimationExporter::get_eul_source_for_quat(Object *ob )
}
//Get proper name for bones
std::string AnimationExporter::getObjectBoneName( Object* ob, const FCurve* fcu )
std::string AnimationExporter::getObjectBoneName(Object *ob, const FCurve *fcu)
{
//hard-way to derive the bone name from rna_path. Must find more compact method
std::string rna_path = std::string(fcu->rna_path);
char* boneName = strtok((char *)rna_path.c_str(), "\"");
char *boneName = strtok((char *)rna_path.c_str(), "\"");
boneName = strtok(NULL, "\"");
if ( boneName != NULL )
if (boneName != NULL)
return /*id_name(ob) + "_" +*/ std::string(boneName);
else
return id_name(ob);
}
//convert f-curves to animation curves and write
void AnimationExporter::dae_animation(Object* ob, FCurve *fcu, char* transformName, bool is_param, Material * ma )
void AnimationExporter::dae_animation(Object *ob, FCurve *fcu, char *transformName, bool is_param, Material *ma)
{
const char *axis_name = NULL;
char anim_id[200];
@ -196,14 +196,14 @@ void AnimationExporter::dae_animation(Object* ob, FCurve *fcu, char* transformNa
bool has_tangents = false;
bool quatRotation = false;
if ( !strcmp(transformName, "rotation_quaternion") ) {
if (!strcmp(transformName, "rotation_quaternion") ) {
fprintf(stderr, "quaternion rotation curves are not supported. rotation curve will not be exported\n");
quatRotation = true;
return;
}
//axis names for colors
else if ( !strcmp(transformName, "color")||!strcmp(transformName, "specular_color")||!strcmp(transformName, "diffuse_color")||
else if (!strcmp(transformName, "color") || !strcmp(transformName, "specular_color") || !strcmp(transformName, "diffuse_color") ||
(!strcmp(transformName, "alpha")))
{
const char *axis_names[] = {"R", "G", "B"};
@ -213,7 +213,7 @@ void AnimationExporter::dae_animation(Object* ob, FCurve *fcu, char* transformNa
//axis names for transforms
else if ((!strcmp(transformName, "location") || !strcmp(transformName, "scale")) ||
(!strcmp(transformName, "rotation_euler"))||(!strcmp(transformName, "rotation_quaternion")))
(!strcmp(transformName, "rotation_euler")) || (!strcmp(transformName, "rotation_quaternion")))
{
const char *axis_names[] = {"X", "Y", "Z"};
if (fcu->array_index < 3)
@ -229,7 +229,7 @@ void AnimationExporter::dae_animation(Object* ob, FCurve *fcu, char* transformNa
//Create anim Id
if (ob->type == OB_ARMATURE) {
ob_name = getObjectBoneName(ob, fcu);
BLI_snprintf(anim_id, sizeof(anim_id), "%s_%s.%s", (char*)translate_id(ob_name).c_str(),
BLI_snprintf(anim_id, sizeof(anim_id), "%s_%s.%s", (char *)translate_id(ob_name).c_str(),
transformName, axis_name);
}
else {
@ -237,7 +237,7 @@ void AnimationExporter::dae_animation(Object* ob, FCurve *fcu, char* transformNa
ob_name = id_name(ob) + "_material";
else
ob_name = id_name(ob);
BLI_snprintf(anim_id, sizeof(anim_id), "%s_%s_%s", (char*)translate_id(ob_name).c_str(),
BLI_snprintf(anim_id, sizeof(anim_id), "%s_%s_%s", (char *)translate_id(ob_name).c_str(),
fcu->rna_path, axis_name);
}
@ -252,16 +252,16 @@ void AnimationExporter::dae_animation(Object* ob, FCurve *fcu, char* transformNa
//quat rotations are skipped for now, because of complications with determining axis.
if (quatRotation) {
float *eul = get_eul_source_for_quat(ob);
float *eul_axis = (float*)MEM_callocN(sizeof(float) * fcu->totvert, "quat output source values");
for (int i = 0 ; i< fcu->totvert ; i++) {
eul_axis[i] = eul[i*3 + fcu->array_index];
float *eul_axis = (float *)MEM_callocN(sizeof(float) * fcu->totvert, "quat output source values");
for (int i = 0; i < fcu->totvert; i++) {
eul_axis[i] = eul[i * 3 + fcu->array_index];
}
output_id= create_source_from_array(COLLADASW::InputSemantic::OUTPUT, eul_axis, fcu->totvert, quatRotation, anim_id, axis_name);
output_id = create_source_from_array(COLLADASW::InputSemantic::OUTPUT, eul_axis, fcu->totvert, quatRotation, anim_id, axis_name);
MEM_freeN(eul);
MEM_freeN(eul_axis);
}
else {
output_id= create_source_from_fcurve(COLLADASW::InputSemantic::OUTPUT, fcu, anim_id, axis_name);
output_id = create_source_from_fcurve(COLLADASW::InputSemantic::OUTPUT, fcu, anim_id, axis_name);
}
// create interpolations source
std::string interpolation_id = create_interpolation_source(fcu, anim_id, axis_name, &has_tangents);
@ -296,19 +296,19 @@ void AnimationExporter::dae_animation(Object* ob, FCurve *fcu, char* transformNa
std::string target;
if ( !is_param )
if (!is_param)
target = translate_id(ob_name) +
"/" + get_transform_sid(fcu->rna_path, -1, axis_name, true);
else {
if ( ob->type == OB_LAMP )
if (ob->type == OB_LAMP)
target = get_light_id(ob) +
"/" + get_light_param_sid(fcu->rna_path, -1, axis_name, true);
if ( ob->type == OB_CAMERA )
if (ob->type == OB_CAMERA)
target = get_camera_id(ob) +
"/" + get_camera_param_sid(fcu->rna_path, -1, axis_name, true);
if ( ma )
if (ma)
target = translate_id(id_name(ma)) + "-effect" +
"/common/" /*profile common is only supported */ + get_transform_sid(fcu->rna_path, -1, axis_name, true);
}
@ -330,18 +330,18 @@ void AnimationExporter::write_bone_animation_matrix(Object *ob_arm, Bone *bone)
sample_and_write_bone_animation_matrix(ob_arm, bone);
for (Bone *child = (Bone*)bone->childbase.first; child; child = child->next)
for (Bone *child = (Bone *)bone->childbase.first; child; child = child->next)
write_bone_animation_matrix(ob_arm, child);
}
bool AnimationExporter::is_bone_deform_group(Bone * bone)
bool AnimationExporter::is_bone_deform_group(Bone *bone)
{
bool is_def;
//Check if current bone is deform
if ((bone->flag & BONE_NO_DEFORM) == 0 ) return true;
if ((bone->flag & BONE_NO_DEFORM) == 0) return true;
//Check child bones
else {
for (Bone *child = (Bone*)bone->childbase.first; child; child = child->next) {
for (Bone *child = (Bone *)bone->childbase.first; child; child = child->next) {
//loop through all the children until deform bone is found, and then return
is_def = is_bone_deform_group(child);
if (is_def) return true;
@ -353,16 +353,16 @@ bool AnimationExporter::is_bone_deform_group(Bone * bone)
void AnimationExporter::sample_and_write_bone_animation_matrix(Object *ob_arm, Bone *bone)
{
bArmature *arm = (bArmature*)ob_arm->data;
bArmature *arm = (bArmature *)ob_arm->data;
int flag = arm->flag;
std::vector<float> fra;
//char prefix[256];
FCurve* fcu = (FCurve*)ob_arm->adt->action->curves.first;
FCurve *fcu = (FCurve *)ob_arm->adt->action->curves.first;
while (fcu) {
std::string bone_name = getObjectBoneName(ob_arm, fcu);
int val = BLI_strcasecmp((char*)bone_name.c_str(), bone->name);
if (val==0) break;
int val = BLI_strcasecmp((char *)bone_name.c_str(), bone->name);
if (val == 0) break;
fcu = fcu->next;
}
@ -379,7 +379,7 @@ void AnimationExporter::sample_and_write_bone_animation_matrix(Object *ob_arm, B
}
if (fra.size()) {
dae_baked_animation(fra, ob_arm, bone );
dae_baked_animation(fra, ob_arm, bone);
}
if (flag & ARM_RESTPOS)
@ -396,8 +396,8 @@ void AnimationExporter::dae_baked_animation(std::vector<float> &fra, Object *ob_
if (!fra.size())
return;
BLI_snprintf(anim_id, sizeof(anim_id), "%s_%s_%s", (char*)translate_id(ob_name).c_str(),
(char*)translate_id(bone_name).c_str(), "pose_matrix");
BLI_snprintf(anim_id, sizeof(anim_id), "%s_%s_%s", (char *)translate_id(ob_name).c_str(),
(char *)translate_id(bone_name).c_str(), "pose_matrix");
openAnimation(anim_id, COLLADABU::Utils::EMPTY_STRING);
@ -406,7 +406,7 @@ void AnimationExporter::dae_baked_animation(std::vector<float> &fra, Object *ob_
// create output source
std::string output_id;
output_id = create_4x4_source( fra, ob_arm, bone, anim_id);
output_id = create_4x4_source(fra, ob_arm, bone, anim_id);
// create interpolations source
std::string interpolation_id = fake_interpolation_source(fra.size(), anim_id, "");
@ -451,8 +451,8 @@ void AnimationExporter::dae_bone_animation(std::vector<float> &fra, float *value
std::string transform_sid = get_transform_sid(NULL, tm_type, axis_name, false);
BLI_snprintf(anim_id, sizeof(anim_id), "%s_%s_%s", (char*)translate_id(ob_name).c_str(),
(char*)translate_id(bone_name).c_str(), (char*)transform_sid.c_str());
BLI_snprintf(anim_id, sizeof(anim_id), "%s_%s_%s", (char *)translate_id(ob_name).c_str(),
(char *)translate_id(bone_name).c_str(), (char *)transform_sid.c_str());
openAnimation(anim_id, COLLADABU::Utils::EMPTY_STRING);
@ -533,7 +533,7 @@ void AnimationExporter::add_source_parameters(COLLADASW::SourceBase::ParameterNa
param.push_back(axis);
}
else
if ( transform ) {
if (transform) {
param.push_back("TRANSFORM");
}
else { //assumes if axis isn't specified all axises are added
@ -715,7 +715,7 @@ std::string AnimationExporter::create_source_from_vector(COLLADASW::InputSemanti
return source_id;
}
std::string AnimationExporter::create_4x4_source(std::vector<float> &frames, Object * ob_arm, Bone *bone, const std::string& anim_id)
std::string AnimationExporter::create_4x4_source(std::vector<float> &frames, Object *ob_arm, Bone *bone, const std::string& anim_id)
{
COLLADASW::InputSemantic::Semantics semantic = COLLADASW::InputSemantic::OUTPUT;
std::string source_id = anim_id + get_semantic_suffix(semantic);
@ -843,11 +843,11 @@ std::string AnimationExporter::create_interpolation_source(FCurve *fcu, const st
*has_tangents = false;
for (unsigned int i = 0; i < fcu->totvert; i++) {
if (fcu->bezt[i].ipo==BEZT_IPO_BEZ) {
if (fcu->bezt[i].ipo == BEZT_IPO_BEZ) {
source.appendValues(BEZIER_NAME);
*has_tangents = true;
}
else if (fcu->bezt[i].ipo==BEZT_IPO_CONST) {
else if (fcu->bezt[i].ipo == BEZT_IPO_CONST) {
source.appendValues(STEP_NAME);
}
else { // BEZT_IPO_LIN
@ -987,7 +987,7 @@ std::string AnimationExporter::get_camera_param_sid(char *rna_path, int tm_type,
std::string AnimationExporter::get_transform_sid(char *rna_path, int tm_type, const char *axis_name, bool append_axis)
{
std::string tm_name;
bool is_rotation =false;
bool is_rotation = false;
// when given rna_path, determine tm_type from it
if (rna_path) {
char *name = extract_transform_name(rna_path);
@ -1061,7 +1061,7 @@ std::string AnimationExporter::get_transform_sid(char *rna_path, int tm_type, co
return std::string("");
}
char* AnimationExporter::extract_transform_name(char *rna_path)
char *AnimationExporter::extract_transform_name(char *rna_path)
{
char *dot = strrchr(rna_path, '.');
return dot ? (dot + 1) : rna_path;
@ -1070,7 +1070,7 @@ char* AnimationExporter::extract_transform_name(char *rna_path)
//find keyframes of all the objects animations
void AnimationExporter::find_frames(Object *ob, std::vector<float> &fra)
{
FCurve *fcu= (FCurve*)ob->adt->action->curves.first;
FCurve *fcu = (FCurve *)ob->adt->action->curves.first;
for (; fcu; fcu = fcu->next) {
@ -1097,7 +1097,7 @@ void AnimationExporter::enable_fcurves(bAction *act, char *bone_name)
if (bone_name)
BLI_snprintf(prefix, sizeof(prefix), "pose.bones[\"%s\"]", bone_name);
for (fcu = (FCurve*)act->curves.first; fcu; fcu = fcu->next) {
for (fcu = (FCurve *)act->curves.first; fcu; fcu = fcu->next) {
if (bone_name) {
if (!strncmp(fcu->rna_path, prefix, strlen(prefix)))
fcu->flag &= ~FCURVE_DISABLED;
@ -1110,9 +1110,10 @@ void AnimationExporter::enable_fcurves(bAction *act, char *bone_name)
}
}
/* TODO - only check NodeLink objects that are exported */
bool AnimationExporter::hasAnimations(Scene *sce)
{
Base *base= (Base*) sce->base.first;
Base *base = (Base *) sce->base.first;
while (base) {
Object *ob = base->object;
@ -1120,26 +1121,26 @@ bool AnimationExporter::hasAnimations(Scene *sce)
FCurve *fcu = 0;
//Check for object transform animations
if (ob->adt && ob->adt->action)
fcu = (FCurve*)ob->adt->action->curves.first;
fcu = (FCurve *)ob->adt->action->curves.first;
//Check for Lamp parameter animations
else if ( (ob->type == OB_LAMP ) && ((Lamp*)ob ->data)->adt && ((Lamp*)ob ->data)->adt->action )
fcu = (FCurve*)(((Lamp*)ob ->data)->adt->action->curves.first);
else if ( (ob->type == OB_LAMP) && ((Lamp *)ob->data)->adt && ((Lamp *)ob->data)->adt->action)
fcu = (FCurve *)(((Lamp *)ob->data)->adt->action->curves.first);
//Check for Camera parameter animations
else if ( (ob->type == OB_CAMERA ) && ((Camera*)ob ->data)->adt && ((Camera*)ob ->data)->adt->action )
fcu = (FCurve*)(((Camera*)ob ->data)->adt->action->curves.first);
else if ( (ob->type == OB_CAMERA) && ((Camera *)ob->data)->adt && ((Camera *)ob->data)->adt->action)
fcu = (FCurve *)(((Camera *)ob->data)->adt->action->curves.first);
//Check Material Effect parameter animations.
for (int a = 0; a < ob->totcol; a++) {
Material *ma = give_current_material(ob, a+1);
Material *ma = give_current_material(ob, a + 1);
if (!ma) continue;
if (ma->adt && ma->adt->action) {
fcu = (FCurve*)ma->adt->action->curves.first;
fcu = (FCurve *)ma->adt->action->curves.first;
}
}
if ( fcu)
if (fcu)
return true;
base= base->next;
base = base->next;
}
return false;
}
@ -1157,7 +1158,7 @@ void AnimationExporter::find_rotation_frames(Object *ob, std::vector<float> &fra
void AnimationExporter::find_frames(Object *ob, std::vector<float> &fra, const char *prefix, const char *tm_name)
{
FCurve *fcu= (FCurve*)ob->adt->action->curves.first;
FCurve *fcu = (FCurve *)ob->adt->action->curves.first;
for (; fcu; fcu = fcu->next) {
if (prefix && strncmp(prefix, fcu->rna_path, strlen(prefix)))
@ -1189,13 +1190,13 @@ void AnimationExporter::write_bone_animation(Object *ob_arm, Bone *bone)
for (int i = 0; i < 3; i++)
sample_and_write_bone_animation(ob_arm, bone, i);
for (Bone *child = (Bone*)bone->childbase.first; child; child = child->next)
for (Bone *child = (Bone *)bone->childbase.first; child; child = child->next)
write_bone_animation(ob_arm, child);
}
void AnimationExporter::sample_and_write_bone_animation(Object *ob_arm, Bone *bone, int transform_type)
{
bArmature *arm = (bArmature*)ob_arm->data;
bArmature *arm = (bArmature *)ob_arm->data;
int flag = arm->flag;
std::vector<float> fra;
char prefix[256];
@ -1227,12 +1228,12 @@ void AnimationExporter::sample_and_write_bone_animation(Object *ob_arm, Bone *bo
}
//v array will hold all values which will be exported.
if (fra.size()) {
float *values = (float*)MEM_callocN(sizeof(float) * 3 * fra.size(), "temp. anim frames");
float *values = (float *)MEM_callocN(sizeof(float) * 3 * fra.size(), "temp. anim frames");
sample_animation(values, fra, transform_type, bone, ob_arm, pchan);
if (transform_type == 0) {
// write x, y, z curves separately if it is rotation
float *axisValues = (float*)MEM_callocN(sizeof(float) * fra.size(), "temp. anim frames");
float *axisValues = (float *)MEM_callocN(sizeof(float) * fra.size(), "temp. anim frames");
for (int i = 0; i < 3; i++) {
for (unsigned int j = 0; j < fra.size(); j++)

@ -62,8 +62,8 @@ static const char *bc_get_joint_name(T *node)
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);
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;
@ -92,7 +92,7 @@ void AnimationImporter::animation_to_fcurves(COLLADAFW::AnimationCurve *curve)
size_t dim = curve->getOutDimension();
unsigned int i;
std::vector<FCurve*>& fcurves = curve_map[curve->getUniqueId()];
std::vector<FCurve *>& fcurves = curve_map[curve->getUniqueId()];
switch (dim) {
case 1: // X, Y, Z or angle
@ -100,10 +100,10 @@ void AnimationImporter::animation_to_fcurves(COLLADAFW::AnimationCurve *curve)
case 4:
case 16: // matrix
{
for (i = 0; i < dim; i++ ) {
FCurve *fcu = (FCurve*)MEM_callocN(sizeof(FCurve), "FCurve");
for (i = 0; i < dim; i++) {
FCurve *fcu = (FCurve *)MEM_callocN(sizeof(FCurve), "FCurve");
fcu->flag = (FCURVE_VISIBLE|FCURVE_AUTO_HANDLES|FCURVE_SELECTED);
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();
@ -119,19 +119,19 @@ void AnimationImporter::animation_to_fcurves(COLLADAFW::AnimationCurve *curve)
bez.vec[1][1] = bc_get_float_value(output, j * dim + i);
if ( curve->getInterpolationType() == COLLADAFW::AnimationCurve::INTERPOLATION_BEZIER ||
if (curve->getInterpolationType() == COLLADAFW::AnimationCurve::INTERPOLATION_BEZIER ||
curve->getInterpolationType() == COLLADAFW::AnimationCurve::INTERPOLATION_STEP)
{
COLLADAFW::FloatOrDoubleArray& intan = curve->getInTangentValues();
COLLADAFW::FloatOrDoubleArray& outtan = curve->getOutTangentValues();
// intangent
bez.vec[0][0] = bc_get_float_value(intan, (j * 2 * dim ) + (2 * i)) * fps;
bez.vec[0][1] = bc_get_float_value(intan, (j * 2 * dim )+ (2 * i) + 1);
bez.vec[0][0] = bc_get_float_value(intan, (j * 2 * dim) + (2 * i)) * fps;
bez.vec[0][1] = bc_get_float_value(intan, (j * 2 * dim) + (2 * i) + 1);
// outtangent
bez.vec[2][0] = bc_get_float_value(outtan, (j * 2 * dim ) + (2 * i)) * fps;
bez.vec[2][1] = bc_get_float_value(outtan, (j * 2 * dim )+ (2 * i) + 1);
bez.vec[2][0] = bc_get_float_value(outtan, (j * 2 * dim) + (2 * i)) * fps;
bez.vec[2][1] = bc_get_float_value(outtan, (j * 2 * dim) + (2 * i) + 1);
if (curve->getInterpolationType() == COLLADAFW::AnimationCurve::INTERPOLATION_BEZIER)
bez.ipo = BEZT_IPO_BEZ;
else
@ -158,7 +158,7 @@ void AnimationImporter::animation_to_fcurves(COLLADAFW::AnimationCurve *curve)
fprintf(stderr, "Output dimension of %d is not yet supported (animation id = %s)\n", (int)dim, curve->getOriginalId().c_str());
}
for (std::vector<FCurve*>::iterator it = fcurves.begin(); it != fcurves.end(); it++)
for (std::vector<FCurve *>::iterator it = fcurves.begin(); it != fcurves.end(); it++)
unused_curves.push_back(*it);
}
@ -174,14 +174,14 @@ void AnimationImporter::fcurve_deg_to_rad(FCurve *cu)
}
void AnimationImporter::add_fcurves_to_object(Object *ob, std::vector<FCurve*>& curves, char *rna_path, int array_index, Animation *animated)
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);
if (!ob->adt || !ob->adt->action) act = verify_adt_action((ID *)&ob->id, 1);
else act = ob->adt->action;
std::vector<FCurve*>::iterator it;
std::vector<FCurve *>::iterator it;
int i;
#if 0
@ -211,7 +211,7 @@ void AnimationImporter::add_fcurves_to_object(Object *ob, std::vector<FCurve*>&
/* 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 = (bActionGroup *)MEM_callocN(sizeof(bActionGroup), "bActionGroup");
grp->flag = AGRP_SELECTED;
BLI_strncpy(grp->name, bone_name, sizeof(grp->name));
@ -240,22 +240,23 @@ void AnimationImporter::add_fcurves_to_object(Object *ob, std::vector<FCurve*>&
}
AnimationImporter::AnimationImporter(UnitConverter *conv, ArmatureImporter *arm, Scene *scene) :
TransformReader(conv), armature_importer(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++)
for (std::vector<FCurve *>::iterator it = unused_curves.begin(); it != unused_curves.end(); it++)
free_fcurve(*it);
if (unused_curves.size())
fprintf(stderr, "removed %d unused curves\n", (int)unused_curves.size());
}
bool AnimationImporter::write_animation(const COLLADAFW::Animation* anim)
bool AnimationImporter::write_animation(const COLLADAFW::Animation *anim)
{
if (anim->getAnimationType() == COLLADAFW::Animation::ANIMATION_CURVE) {
COLLADAFW::AnimationCurve *curve = (COLLADAFW::AnimationCurve*)anim;
COLLADAFW::AnimationCurve *curve = (COLLADAFW::AnimationCurve *)anim;
// XXX Don't know if it's necessary
// Should we check outPhysicalDimension?
@ -294,7 +295,7 @@ bool AnimationImporter::write_animation(const COLLADAFW::Animation* anim)
}
// called on post-process stage after writeVisualScenes
bool AnimationImporter::write_animation_list(const COLLADAFW::AnimationList* animlist)
bool AnimationImporter::write_animation_list(const COLLADAFW::AnimationList *animlist)
{
const COLLADAFW::UniqueId& animlist_id = animlist->getUniqueId();
@ -334,14 +335,14 @@ virtual void AnimationImporter::change_eul_to_quat(Object *ob, bAction *act)
bActionGroup *grp;
int i;
for (grp = (bActionGroup*)act->groups.first; grp; grp = grp->next) {
for (grp = (bActionGroup *)act->groups.first; grp; grp = grp->next) {
FCurve *eulcu[3] = {NULL, NULL, NULL};
if (fcurves_actionGroup_map.find(grp) == fcurves_actionGroup_map.end())
continue;
std::vector<FCurve*> &rot_fcurves = fcurves_actionGroup_map[grp];
std::vector<FCurve *> &rot_fcurves = fcurves_actionGroup_map[grp];
if (rot_fcurves.size() > 3) continue;
@ -415,7 +416,7 @@ virtual void AnimationImporter::change_eul_to_quat(Object *ob, bAction *act)
}
bPoseChannel *pchan;
for (pchan = (bPoseChannel*)ob->pose->chanbase.first; pchan; pchan = pchan->next) {
for (pchan = (bPoseChannel *)ob->pose->chanbase.first; pchan; pchan = pchan->next) {
pchan->rotmode = ROT_MODE_QUAT;
}
}
@ -423,9 +424,9 @@ virtual void AnimationImporter::change_eul_to_quat(Object *ob, bAction *act)
//sets the rna_path and array index to curve
void AnimationImporter::modify_fcurve(std::vector<FCurve*>* curves, const char* rna_path, int array_index )
void AnimationImporter::modify_fcurve(std::vector<FCurve *> *curves, const char *rna_path, int array_index)
{
std::vector<FCurve*>::iterator it;
std::vector<FCurve *>::iterator it;
int i;
for (it = curves->begin(), i = 0; it != curves->end(); it++, i++) {
FCurve *fcu = *it;
@ -438,19 +439,19 @@ void AnimationImporter::modify_fcurve(std::vector<FCurve*>* curves, const char*
}
}
void AnimationImporter::unused_fcurve(std::vector<FCurve*>* curves)
void AnimationImporter::unused_fcurve(std::vector<FCurve *> *curves)
{
// when an error happens and we can't actually use curve remove it from unused_curves
std::vector<FCurve*>::iterator it;
std::vector<FCurve *>::iterator it;
for (it = curves->begin(); it != curves->end(); it++) {
FCurve *fcu = *it;
unused_curves.erase(std::remove(unused_curves.begin(), unused_curves.end(), fcu), unused_curves.end());
}
}
void AnimationImporter::find_frames( std::vector<float>* frames, std::vector<FCurve*>* curves)
void AnimationImporter::find_frames(std::vector<float> *frames, std::vector<FCurve *> *curves)
{
std::vector<FCurve*>::iterator iter;
std::vector<FCurve *>::iterator iter;
for (iter = curves->begin(); iter != curves->end(); iter++) {
FCurve *fcu = *iter;
@ -466,16 +467,16 @@ void AnimationImporter::find_frames( std::vector<float>* frames, std::vector<FCu
}
//creates the rna_paths and array indices of fcurves from animations using transformation and bound animation class of each animation.
void AnimationImporter:: Assign_transform_animations(COLLADAFW::Transformation * transform,
const COLLADAFW::AnimationList::AnimationBinding * binding,
std::vector<FCurve*>* curves, bool is_joint, char * joint_path)
void AnimationImporter:: Assign_transform_animations(COLLADAFW::Transformation *transform,
const COLLADAFW::AnimationList::AnimationBinding *binding,
std::vector<FCurve *> *curves, bool is_joint, char *joint_path)
{
COLLADAFW::Transformation::TransformationType tm_type = transform->getTransformationType();
bool is_matrix = tm_type == COLLADAFW::Transformation::MATRIX;
bool is_rotation = tm_type == COLLADAFW::Transformation::ROTATE;
//to check if the no of curves are valid
bool xyz = ((tm_type == COLLADAFW::Transformation::TRANSLATE ||tm_type == COLLADAFW::Transformation::SCALE) && binding->animationClass == COLLADAFW::AnimationList::POSITION_XYZ);
bool xyz = ((tm_type == COLLADAFW::Transformation::TRANSLATE || tm_type == COLLADAFW::Transformation::SCALE) && binding->animationClass == COLLADAFW::AnimationList::POSITION_XYZ);
if (!((!xyz && curves->size() == 1) || (xyz && curves->size() == 3) || is_matrix)) {
@ -497,16 +498,16 @@ void AnimationImporter:: Assign_transform_animations(COLLADAFW::Transformation *
switch (binding->animationClass) {
case COLLADAFW::AnimationList::POSITION_X:
modify_fcurve(curves, rna_path, 0 );
modify_fcurve(curves, rna_path, 0);
break;
case COLLADAFW::AnimationList::POSITION_Y:
modify_fcurve(curves, rna_path, 1 );
modify_fcurve(curves, rna_path, 1);
break;
case COLLADAFW::AnimationList::POSITION_Z:
modify_fcurve(curves, rna_path, 2 );
modify_fcurve(curves, rna_path, 2);
break;
case COLLADAFW::AnimationList::POSITION_XYZ:
modify_fcurve(curves, rna_path, -1 );
modify_fcurve(curves, rna_path, -1);
break;
default:
unused_fcurve(curves);
@ -523,27 +524,27 @@ void AnimationImporter:: Assign_transform_animations(COLLADAFW::Transformation *
BLI_snprintf(rna_path, sizeof(rna_path), "%s.rotation_euler", joint_path);
else
BLI_strncpy(rna_path, "rotation_euler", sizeof(rna_path));
std::vector<FCurve*>::iterator iter;
std::vector<FCurve *>::iterator iter;
for (iter = curves->begin(); iter != curves->end(); iter++) {
FCurve* fcu = *iter;
FCurve *fcu = *iter;
//if transform is rotation the fcurves values must be turned in to radian.
if (is_rotation)
fcurve_deg_to_rad(fcu);
}
COLLADAFW::Rotate* rot = (COLLADAFW::Rotate*)transform;
COLLADAFW::Rotate *rot = (COLLADAFW::Rotate *)transform;
COLLADABU::Math::Vector3& axis = rot->getRotationAxis();
switch (binding->animationClass) {
case COLLADAFW::AnimationList::ANGLE:
if (COLLADABU::Math::Vector3::UNIT_X == axis) {
modify_fcurve(curves, rna_path, 0 );
modify_fcurve(curves, rna_path, 0);
}
else if (COLLADABU::Math::Vector3::UNIT_Y == axis) {
modify_fcurve(curves, rna_path, 1 );
modify_fcurve(curves, rna_path, 1);
}
else if (COLLADABU::Math::Vector3::UNIT_Z == axis) {
modify_fcurve(curves, rna_path, 2 );
modify_fcurve(curves, rna_path, 2);
}
else
unused_fcurve(curves);
@ -579,7 +580,7 @@ void AnimationImporter:: Assign_transform_animations(COLLADAFW::Transformation *
}
//creates the rna_paths and array indices of fcurves from animations using color and bound animation class of each animation.
void AnimationImporter:: Assign_color_animations(const COLLADAFW::UniqueId& listid, ListBase *AnimCurves, const char * anim_type)
void AnimationImporter:: Assign_color_animations(const COLLADAFW::UniqueId& listid, ListBase *AnimCurves, const char *anim_type)
{
char rna_path[100];
BLI_strncpy(rna_path, anim_type, sizeof(rna_path));
@ -587,35 +588,35 @@ void AnimationImporter:: Assign_color_animations(const COLLADAFW::UniqueId& list
const COLLADAFW::AnimationList *animlist = animlist_map[listid];
const COLLADAFW::AnimationList::AnimationBindings& bindings = animlist->getAnimationBindings();
//all the curves belonging to the current binding
std::vector<FCurve*> animcurves;
std::vector<FCurve *> animcurves;
for (unsigned int j = 0; j < bindings.getCount(); j++) {
animcurves = curve_map[bindings[j].animation];
switch (bindings[j].animationClass) {
case COLLADAFW::AnimationList::COLOR_R:
modify_fcurve(&animcurves, rna_path, 0 );
modify_fcurve(&animcurves, rna_path, 0);
break;
case COLLADAFW::AnimationList::COLOR_G:
modify_fcurve(&animcurves, rna_path, 1 );
modify_fcurve(&animcurves, rna_path, 1);
break;
case COLLADAFW::AnimationList::COLOR_B:
modify_fcurve(&animcurves, rna_path, 2 );
modify_fcurve(&animcurves, rna_path, 2);
break;
case COLLADAFW::AnimationList::COLOR_RGB:
case COLLADAFW::AnimationList::COLOR_RGBA: // to do-> set intensity
modify_fcurve(&animcurves, rna_path, -1 );
modify_fcurve(&animcurves, rna_path, -1);
break;
default:
unused_fcurve(&animcurves);
fprintf(stderr, "AnimationClass %d is not supported for %s.\n",
bindings[j].animationClass, "COLOR" );
bindings[j].animationClass, "COLOR");
}
std::vector<FCurve*>::iterator iter;
std::vector<FCurve *>::iterator iter;
//Add the curves of the current animation to the object
for (iter = animcurves.begin(); iter != animcurves.end(); iter++) {
FCurve * fcu = *iter;
FCurve *fcu = *iter;
BLI_addtail(AnimCurves, fcu);
}
}
@ -623,7 +624,7 @@ void AnimationImporter:: Assign_color_animations(const COLLADAFW::UniqueId& list
}
void AnimationImporter:: Assign_float_animations(const COLLADAFW::UniqueId& listid, ListBase *AnimCurves, const char * anim_type)
void AnimationImporter:: Assign_float_animations(const COLLADAFW::UniqueId& listid, ListBase *AnimCurves, const char *anim_type)
{
char rna_path[100];
if (animlist_map.find(listid) == animlist_map.end()) {
@ -634,16 +635,16 @@ void AnimationImporter:: Assign_float_animations(const COLLADAFW::UniqueId& list
const COLLADAFW::AnimationList *animlist = animlist_map[listid];
const COLLADAFW::AnimationList::AnimationBindings& bindings = animlist->getAnimationBindings();
//all the curves belonging to the current binding
std::vector<FCurve*> animcurves;
std::vector<FCurve *> animcurves;
for (unsigned int j = 0; j < bindings.getCount(); j++) {
animcurves = curve_map[bindings[j].animation];
BLI_strncpy(rna_path, anim_type, sizeof(rna_path));
modify_fcurve(&animcurves, rna_path, 0 );
std::vector<FCurve*>::iterator iter;
modify_fcurve(&animcurves, rna_path, 0);
std::vector<FCurve *>::iterator iter;
//Add the curves of the current animation to the object
for (iter = animcurves.begin(); iter != animcurves.end(); iter++) {
FCurve * fcu = *iter;
FCurve *fcu = *iter;
BLI_addtail(AnimCurves, fcu);
}
}
@ -651,13 +652,13 @@ void AnimationImporter:: Assign_float_animations(const COLLADAFW::UniqueId& list
}
void AnimationImporter::apply_matrix_curves( Object * ob, std::vector<FCurve*>& animcurves, COLLADAFW::Node* root, COLLADAFW::Node* node,
COLLADAFW::Transformation * tm )
void AnimationImporter::apply_matrix_curves(Object *ob, std::vector<FCurve *>& animcurves, COLLADAFW::Node *root, COLLADAFW::Node *node,
COLLADAFW::Transformation *tm)
{
bool is_joint = node->getType() == COLLADAFW::Node::JOINT;
const char *bone_name = is_joint ? bc_get_joint_name(node) : NULL;
char joint_path[200];
if ( is_joint )
if (is_joint)
armature_importer->get_rna_path_for_joint(node, joint_path, sizeof(joint_path));
std::vector<float> frames;
@ -670,7 +671,7 @@ void AnimationImporter::apply_matrix_curves( Object * ob, std::vector<FCurve*>&
get_joint_rest_mat(irest_dae, root, node);
invert_m4(irest_dae);
Bone *bone = BKE_armature_find_bone_name((bArmature*)ob->data, bone_name);
Bone *bone = BKE_armature_find_bone_name((bArmature *)ob->data, bone_name);
if (!bone) {
fprintf(stderr, "cannot find bone \"%s\"\n", bone_name);
return;
@ -771,12 +772,12 @@ void AnimationImporter::apply_matrix_curves( Object * ob, std::vector<FCurve*>&
add_bezt(newcu[i], fra, scale[i - 7]);
}
}
verify_adt_action((ID*)&ob->id, 1);
verify_adt_action((ID *)&ob->id, 1);
ListBase *curves = &ob->adt->action->curves;
// add curves
for (int i= 0; i < totcu; i++) {
for (int i = 0; i < totcu; i++) {
if (is_joint)
add_bone_fcurve(ob, node, newcu[i]);
else
@ -795,12 +796,12 @@ void AnimationImporter::apply_matrix_curves( Object * ob, std::vector<FCurve*>&
}
void AnimationImporter::translate_Animations ( COLLADAFW::Node * node,
std::map<COLLADAFW::UniqueId, COLLADAFW::Node*>& root_map,
std::multimap<COLLADAFW::UniqueId, Object*>& object_map,
std::map<COLLADAFW::UniqueId, const COLLADAFW::Object*> FW_object_map)
void AnimationImporter::translate_Animations(COLLADAFW::Node *node,
std::map<COLLADAFW::UniqueId, COLLADAFW::Node *>& root_map,
std::multimap<COLLADAFW::UniqueId, Object *>& object_map,
std::map<COLLADAFW::UniqueId, const COLLADAFW::Object *> FW_object_map)
{
AnimationImporter::AnimMix* animType = get_animation_type(node, FW_object_map );
AnimationImporter::AnimMix *animType = get_animation_type(node, FW_object_map);
bool is_joint = node->getType() == COLLADAFW::Node::JOINT;
COLLADAFW::Node *root = root_map.find(node->getUniqueId()) == root_map.end() ? node : root_map[node->getUniqueId()];
@ -810,17 +811,17 @@ void AnimationImporter::translate_Animations ( COLLADAFW::Node * node,
return;
}
bAction * act;
bAction *act;
if ( (animType->transform) != 0 ) {
if ( (animType->transform) != 0) {
/* const char *bone_name = is_joint ? bc_get_joint_name(node) : NULL; */ /* UNUSED */
char joint_path[200];
if ( is_joint )
if (is_joint)
armature_importer->get_rna_path_for_joint(node, joint_path, sizeof(joint_path));
if (!ob->adt || !ob->adt->action) act = verify_adt_action((ID*)&ob->id, 1);
if (!ob->adt || !ob->adt->action) act = verify_adt_action((ID *)&ob->id, 1);
else act = ob->adt->action;
//Get the list of animation curves of the object
@ -847,11 +848,11 @@ void AnimationImporter::translate_Animations ( COLLADAFW::Node * node,
const COLLADAFW::AnimationList *animlist = animlist_map[listid];
const COLLADAFW::AnimationList::AnimationBindings& bindings = animlist->getAnimationBindings();
//all the curves belonging to the current binding
std::vector<FCurve*> animcurves;
std::vector<FCurve *> animcurves;
for (unsigned int j = 0; j < bindings.getCount(); j++) {
animcurves = curve_map[bindings[j].animation];
if ( is_matrix ) {
apply_matrix_curves(ob, animcurves, root, node, transform );
if (is_matrix) {
apply_matrix_curves(ob, animcurves, root, node, transform);
}
else {
@ -861,12 +862,12 @@ void AnimationImporter::translate_Animations ( COLLADAFW::Node * node,
}
else {
//calculate rnapaths and array index of fcurves according to transformation and animation class
Assign_transform_animations(transform, &bindings[j], &animcurves, is_joint, joint_path );
Assign_transform_animations(transform, &bindings[j], &animcurves, is_joint, joint_path);
std::vector<FCurve*>::iterator iter;
std::vector<FCurve *>::iterator iter;
//Add the curves of the current animation to the object
for (iter = animcurves.begin(); iter != animcurves.end(); iter++) {
FCurve * fcu = *iter;
FCurve *fcu = *iter;
BLI_addtail(AnimCurves, fcu);
}
@ -882,9 +883,9 @@ void AnimationImporter::translate_Animations ( COLLADAFW::Node * node,
}
if ((animType->light) != 0) {
Lamp * lamp = (Lamp*) ob->data;
Lamp *lamp = (Lamp *) ob->data;
if (!lamp->adt || !lamp->adt->action) act = verify_adt_action((ID*)&lamp->id, 1);
if (!lamp->adt || !lamp->adt->action) act = verify_adt_action((ID *)&lamp->id, 1);
else act = lamp->adt->action;
ListBase *AnimCurves = &(act->curves);
@ -899,63 +900,63 @@ void AnimationImporter::translate_Animations ( COLLADAFW::Node * node,
Assign_color_animations(listid, AnimCurves, "color");
}
if ((animType->light & LIGHT_FOA) != 0 ) {
if ((animType->light & LIGHT_FOA) != 0) {
const COLLADAFW::AnimatableFloat *foa = &(light->getFallOffAngle());
const COLLADAFW::UniqueId& listid = foa->getAnimationList();
Assign_float_animations( listid, AnimCurves, "spot_size");
Assign_float_animations(listid, AnimCurves, "spot_size");
}
if ( (animType->light & LIGHT_FOE) != 0 ) {
if ( (animType->light & LIGHT_FOE) != 0) {
const COLLADAFW::AnimatableFloat *foe = &(light->getFallOffExponent());
const COLLADAFW::UniqueId& listid = foe->getAnimationList();
Assign_float_animations( listid, AnimCurves, "spot_blend");
Assign_float_animations(listid, AnimCurves, "spot_blend");
}
}
}
if ( (animType->camera) != 0) {
Camera * camera = (Camera*) ob->data;
Camera *camera = (Camera *) ob->data;
if (!camera->adt || !camera->adt->action) act = verify_adt_action((ID*)&camera->id, 1);
if (!camera->adt || !camera->adt->action) act = verify_adt_action((ID *)&camera->id, 1);
else act = camera->adt->action;
ListBase *AnimCurves = &(act->curves);
const COLLADAFW::InstanceCameraPointerArray& nodeCameras= node->getInstanceCameras();
const COLLADAFW::InstanceCameraPointerArray& nodeCameras = node->getInstanceCameras();
for (unsigned int i = 0; i < nodeCameras.getCount(); i++) {
const COLLADAFW::Camera *camera = (COLLADAFW::Camera *) FW_object_map[nodeCameras[i]->getInstanciatedObjectId()];
if ((animType->camera & CAMERA_XFOV) != 0 ) {
if ((animType->camera & CAMERA_XFOV) != 0) {
const COLLADAFW::AnimatableFloat *xfov = &(camera->getXFov());
const COLLADAFW::UniqueId& listid = xfov->getAnimationList();
Assign_float_animations( listid, AnimCurves, "lens");
Assign_float_animations(listid, AnimCurves, "lens");
}
else if ((animType->camera & CAMERA_XMAG) != 0 ) {
else if ((animType->camera & CAMERA_XMAG) != 0) {
const COLLADAFW::AnimatableFloat *xmag = &(camera->getXMag());
const COLLADAFW::UniqueId& listid = xmag->getAnimationList();
Assign_float_animations( listid, AnimCurves, "ortho_scale");
Assign_float_animations(listid, AnimCurves, "ortho_scale");
}
if ((animType->camera & CAMERA_ZFAR) != 0 ) {
if ((animType->camera & CAMERA_ZFAR) != 0) {
const COLLADAFW::AnimatableFloat *zfar = &(camera->getFarClippingPlane());
const COLLADAFW::UniqueId& listid = zfar->getAnimationList();
Assign_float_animations( listid, AnimCurves, "clip_end");
Assign_float_animations(listid, AnimCurves, "clip_end");
}
if ((animType->camera & CAMERA_ZNEAR) != 0 ) {
if ((animType->camera & CAMERA_ZNEAR) != 0) {
const COLLADAFW::AnimatableFloat *znear = &(camera->getNearClippingPlane());
const COLLADAFW::UniqueId& listid = znear->getAnimationList();
Assign_float_animations( listid, AnimCurves, "clip_start");
Assign_float_animations(listid, AnimCurves, "clip_start");
}
}
}
if ( animType->material != 0) {
if (animType->material != 0) {
Material *ma = give_current_material(ob, 1);
if (!ma->adt || !ma->adt->action) act = verify_adt_action((ID*)&ma->id, 1);
if (!ma->adt || !ma->adt->action) act = verify_adt_action((ID *)&ma->id, 1);
else act = ma->adt->action;
ListBase *AnimCurves = &(act->curves);
@ -972,25 +973,25 @@ void AnimationImporter::translate_Animations ( COLLADAFW::Node * node,
if ((animType->material & MATERIAL_SHININESS) != 0) {
const COLLADAFW::FloatOrParam *shin = &(efc->getShininess());
const COLLADAFW::UniqueId& listid = shin->getAnimationList();
Assign_float_animations( listid, AnimCurves, "specular_hardness" );
Assign_float_animations(listid, AnimCurves, "specular_hardness");
}
if ((animType->material & MATERIAL_IOR) != 0) {
const COLLADAFW::FloatOrParam *ior = &(efc->getIndexOfRefraction());
const COLLADAFW::UniqueId& listid = ior->getAnimationList();
Assign_float_animations( listid, AnimCurves, "raytrace_transparency.ior" );
Assign_float_animations(listid, AnimCurves, "raytrace_transparency.ior");
}
if ((animType->material & MATERIAL_SPEC_COLOR) != 0) {
const COLLADAFW::ColorOrTexture *cot = &(efc->getSpecular());
const COLLADAFW::UniqueId& listid = cot->getColor().getAnimationList();
Assign_color_animations( listid, AnimCurves, "specular_color" );
Assign_color_animations(listid, AnimCurves, "specular_color");
}
if ((animType->material & MATERIAL_DIFF_COLOR) != 0) {
const COLLADAFW::ColorOrTexture *cot = &(efc->getDiffuse());
const COLLADAFW::UniqueId& listid = cot->getColor().getAnimationList();
Assign_color_animations( listid, AnimCurves, "diffuse_color" );
Assign_color_animations(listid, AnimCurves, "diffuse_color");
}
}
}
@ -998,7 +999,7 @@ void AnimationImporter::translate_Animations ( COLLADAFW::Node * node,
}
}
void AnimationImporter::add_bone_animation_sampled(Object * ob, std::vector<FCurve*>& animcurves, COLLADAFW::Node* root, COLLADAFW::Node* node, COLLADAFW::Transformation * tm)
void AnimationImporter::add_bone_animation_sampled(Object *ob, std::vector<FCurve *>& animcurves, COLLADAFW::Node *root, COLLADAFW::Node *node, COLLADAFW::Transformation *tm)
{
const char *bone_name = bc_get_joint_name(node);
char joint_path[200];
@ -1010,9 +1011,9 @@ void AnimationImporter::add_bone_animation_sampled(Object * ob, std::vector<FCur
// convert degrees to radians
if (tm->getTransformationType() == COLLADAFW::Transformation::ROTATE) {
std::vector<FCurve*>::iterator iter;
std::vector<FCurve *>::iterator iter;
for (iter = animcurves.begin(); iter != animcurves.end(); iter++) {
FCurve* fcu = *iter;
FCurve *fcu = *iter;
fcurve_deg_to_rad(fcu);
}
@ -1025,7 +1026,7 @@ void AnimationImporter::add_bone_animation_sampled(Object * ob, std::vector<FCur
get_joint_rest_mat(irest_dae, root, node);
invert_m4(irest_dae);
Bone *bone = BKE_armature_find_bone_name((bArmature*)ob->data, bone_name);
Bone *bone = BKE_armature_find_bone_name((bArmature *)ob->data, bone_name);
if (!bone) {
fprintf(stderr, "cannot find bone \"%s\"\n", bone_name);
return;
@ -1116,10 +1117,10 @@ void AnimationImporter::add_bone_animation_sampled(Object * ob, std::vector<FCur
add_bezt(newcu[i], fra, scale[i - 7]);
}
}
verify_adt_action((ID*)&ob->id, 1);
verify_adt_action((ID *)&ob->id, 1);
// add curves
for (int i= 0; i < totcu; i++) {
for (int i = 0; i < totcu; i++) {
add_bone_fcurve(ob, node, newcu[i]);
}
@ -1130,8 +1131,8 @@ void AnimationImporter::add_bone_animation_sampled(Object * ob, std::vector<FCur
//Check if object is animated by checking if animlist_map holds the animlist_id of node transforms
AnimationImporter::AnimMix* AnimationImporter::get_animation_type ( const COLLADAFW::Node * node,
std::map<COLLADAFW::UniqueId, const COLLADAFW::Object*> FW_object_map)
AnimationImporter::AnimMix *AnimationImporter::get_animation_type(const COLLADAFW::Node *node,
std::map<COLLADAFW::UniqueId, const COLLADAFW::Object *> FW_object_map)
{
AnimMix *types = new AnimMix();
@ -1147,7 +1148,7 @@ AnimationImporter::AnimMix* AnimationImporter::get_animation_type ( const COLLAD
continue;
}
else {
types->transform = types->transform|NODE_TRANSFORM;
types->transform = types->transform | NODE_TRANSFORM;
break;
}
}
@ -1159,7 +1160,7 @@ AnimationImporter::AnimMix* AnimationImporter::get_animation_type ( const COLLAD
types->light = setAnimType(&(light->getFallOffAngle()), (types->light), LIGHT_FOA);
types->light = setAnimType(&(light->getFallOffExponent()), (types->light), LIGHT_FOE);
if ( types->light != 0) break;
if (types->light != 0) break;
}
@ -1167,7 +1168,7 @@ AnimationImporter::AnimMix* AnimationImporter::get_animation_type ( const COLLAD
for (unsigned int i = 0; i < nodeCameras.getCount(); i++) {
const COLLADAFW::Camera *camera = (COLLADAFW::Camera *) FW_object_map[nodeCameras[i]->getInstanciatedObjectId()];
if ( camera->getCameraType() == COLLADAFW::Camera::PERSPECTIVE ) {
if (camera->getCameraType() == COLLADAFW::Camera::PERSPECTIVE) {
types->camera = setAnimType(&(camera->getXMag()), (types->camera), CAMERA_XFOV);
}
else {
@ -1176,7 +1177,7 @@ AnimationImporter::AnimMix* AnimationImporter::get_animation_type ( const COLLAD
types->camera = setAnimType(&(camera->getFarClippingPlane()), (types->camera), CAMERA_ZFAR);
types->camera = setAnimType(&(camera->getNearClippingPlane()), (types->camera), CAMERA_ZNEAR);
if ( types->camera != 0) break;
if (types->camera != 0) break;
}
@ -1202,16 +1203,16 @@ AnimationImporter::AnimMix* AnimationImporter::get_animation_type ( const COLLAD
return types;
}
int AnimationImporter::setAnimType ( const COLLADAFW::Animatable * prop, int types, int addition)
int AnimationImporter::setAnimType(const COLLADAFW::Animatable *prop, int types, int addition)
{
const COLLADAFW::UniqueId& listid = prop->getAnimationList();
if (animlist_map.find(listid) != animlist_map.end())
return types|addition;
return types | addition;
else return types;
}
// Is not used anymore.
void AnimationImporter::find_frames_old(std::vector<float> * frames, COLLADAFW::Node * node, COLLADAFW::Transformation::TransformationType tm_type)
void AnimationImporter::find_frames_old(std::vector<float> *frames, COLLADAFW::Node *node, COLLADAFW::Transformation::TransformationType tm_type)
{
bool is_matrix = tm_type == COLLADAFW::Transformation::MATRIX;
bool is_rotation = tm_type == COLLADAFW::Transformation::ROTATE;
@ -1237,11 +1238,11 @@ void AnimationImporter::find_frames_old(std::vector<float> * frames, COLLADAFW::
if (bindings.getCount()) {
//for each AnimationBinding get the fcurves which animate the transform
for (unsigned int j = 0; j < bindings.getCount(); j++) {
std::vector<FCurve*>& curves = curve_map[bindings[j].animation];
std::vector<FCurve *>& curves = curve_map[bindings[j].animation];
bool xyz = ((nodeTmType == COLLADAFW::Transformation::TRANSLATE || nodeTmType == COLLADAFW::Transformation::SCALE) && bindings[j].animationClass == COLLADAFW::AnimationList::POSITION_XYZ);
if ((!xyz && curves.size() == 1) || (xyz && curves.size() == 3) || is_matrix) {
std::vector<FCurve*>::iterator iter;
std::vector<FCurve *>::iterator iter;
for (iter = curves.begin(); iter != curves.end(); iter++) {
FCurve *fcu = *iter;
@ -1275,8 +1276,8 @@ void AnimationImporter::find_frames_old(std::vector<float> * frames, COLLADAFW::
// animlist_map - map animlist id -> animlist
// curve_map - map anim id -> curve(s)
Object *AnimationImporter::translate_animation_OLD(COLLADAFW::Node *node,
std::map<COLLADAFW::UniqueId, Object*>& object_map,
std::map<COLLADAFW::UniqueId, COLLADAFW::Node*>& root_map,
std::map<COLLADAFW::UniqueId, Object *>& object_map,
std::map<COLLADAFW::UniqueId, COLLADAFW::Node *>& root_map,
COLLADAFW::Transformation::TransformationType tm_type,
Object *par_job)
{
@ -1307,7 +1308,7 @@ Object *AnimationImporter::translate_animation_OLD(COLLADAFW::Node *node,
get_joint_rest_mat(irest_dae, root, node);
invert_m4(irest_dae);
Bone *bone = BKE_armature_find_bone_name((bArmature*)ob->data, bone_name);
Bone *bone = BKE_armature_find_bone_name((bArmature *)ob->data, bone_name);
if (!bone) {
fprintf(stderr, "cannot find bone \"%s\"\n", bone_name);
return NULL;
@ -1496,7 +1497,7 @@ Object *AnimationImporter::translate_animation_OLD(COLLADAFW::Node *node,
#endif
}
verify_adt_action((ID*)&ob->id, 1);
verify_adt_action((ID *)&ob->id, 1);
ListBase *curves = &ob->adt->action->curves;
@ -1604,7 +1605,7 @@ bool AnimationImporter::evaluate_animation(COLLADAFW::Transformation *tm, float
for (unsigned int j = 0; j < bindings.getCount(); j++) {
const COLLADAFW::AnimationList::AnimationBinding& binding = bindings[j];
std::vector<FCurve*>& curves = curve_map[binding.animation];
std::vector<FCurve *>& curves = curve_map[binding.animation];
COLLADAFW::AnimationList::AnimationClass animclass = binding.animationClass;
char path[100];
@ -1642,7 +1643,7 @@ bool AnimationImporter::evaluate_animation(COLLADAFW::Transformation *tm, float
return false;
}
COLLADABU::Math::Vector3& axis = ((COLLADAFW::Rotate*)tm)->getRotationAxis();
COLLADABU::Math::Vector3& axis = ((COLLADAFW::Rotate *)tm)->getRotationAxis();
float ax[3] = {(float)axis[0], (float)axis[1], (float)axis[2]};
float angle = evaluate_fcurve(curves[0], fra);
@ -1691,7 +1692,7 @@ bool AnimationImporter::evaluate_animation(COLLADAFW::Transformation *tm, float
COLLADABU::Math::Matrix4 matrix;
int i = 0, j = 0;
for (std::vector<FCurve*>::iterator it = curves.begin(); it != curves.end(); it++) {
for (std::vector<FCurve *>::iterator it = curves.begin(); it != curves.end(); it++) {
matrix.setElement(i, j, evaluate_fcurve(*it, fra));
j++;
if (j == 4) {
@ -1704,7 +1705,7 @@ bool AnimationImporter::evaluate_animation(COLLADAFW::Transformation *tm, float
COLLADAFW::Matrix tm(matrix);
dae_matrix_to_mat4(&tm, mat);
std::vector<FCurve*>::iterator it;
std::vector<FCurve *>::iterator it;
return true;
}
@ -1770,14 +1771,14 @@ bool AnimationImporter::calc_joint_parent_mat_rest(float mat[4][4], float par[4]
Object *AnimationImporter::get_joint_object(COLLADAFW::Node *root, COLLADAFW::Node *node, Object *par_job)
{
if (joint_objects.find(node->getUniqueId()) == joint_objects.end()) {
Object *job = bc_add_object(scene, OB_EMPTY, (char*)get_joint_name(node));
Object *job = bc_add_object(scene, OB_EMPTY, (char *)get_joint_name(node));
job->lay = BKE_scene_base_find(scene, job)->lay = 2;
mul_v3_fl(job->size, 0.5f);
job->recalc |= OB_RECALC_OB;
verify_adt_action((ID*)&job->id, 1);
verify_adt_action((ID *)&job->id, 1);
job->rotmode = ROT_MODE_QUAT;
@ -1854,7 +1855,7 @@ void AnimationImporter::add_bone_fcurve(Object *ob, COLLADAFW::Node *node, FCurv
/* 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 = (bActionGroup *)MEM_callocN(sizeof(bActionGroup), "bActionGroup");
grp->flag = AGRP_SELECTED;
BLI_strncpy(grp->name, bone_name, sizeof(grp->name));
@ -1874,7 +1875,7 @@ void AnimationImporter::add_bezt(FCurve *fcu, float fra, float value)
memset(&bez, 0, sizeof(BezTriple));
bez.vec[1][0] = fra;
bez.vec[1][1] = value;
bez.ipo = BEZT_IPO_LIN ;/* use default interpolation mode here... */
bez.ipo = BEZT_IPO_LIN; /* use default interpolation mode here... */
bez.f1 = bez.f2 = bez.f3 = SELECT;
bez.h1 = bez.h2 = HD_AUTO;
insert_bezt_fcurve(fcu, &bez, 0);

@ -58,16 +58,17 @@ extern "C" {
// XXX exporter writes wrong data for shared armatures. A separate
// controller should be written for each armature-mesh binding how do
// we make controller ids then?
ArmatureExporter::ArmatureExporter(COLLADASW::StreamWriter *sw, const ExportSettings *export_settings) : COLLADASW::LibraryControllers(sw), export_settings(export_settings) {}
ArmatureExporter::ArmatureExporter(COLLADASW::StreamWriter *sw, const ExportSettings *export_settings) : COLLADASW::LibraryControllers(sw), export_settings(export_settings) {
}
// write bone nodes
void ArmatureExporter::add_armature_bones(Object *ob_arm, Scene* sce,
SceneExporter* se,
std::list<Object*>& child_objects)
void ArmatureExporter::add_armature_bones(Object *ob_arm, Scene *sce,
SceneExporter *se,
std::list<Object *>& child_objects)
{
// write bone nodes
bArmature *arm = (bArmature*)ob_arm->data;
for (Bone *bone = (Bone*)arm->bonebase.first; bone; bone = bone->next) {
bArmature *arm = (bArmature *)ob_arm->data;
for (Bone *bone = (Bone *)arm->bonebase.first; bone; bone = bone->next) {
// start from root bones
if (!bone->parent)
add_bone_node(bone, ob_arm, sce, se, child_objects);
@ -82,7 +83,7 @@ bool ArmatureExporter::is_skinned_mesh(Object *ob)
bool ArmatureExporter::add_instance_controller(Object *ob)
{
Object *ob_arm = bc_get_assigned_armature(ob);
bArmature *arm = (bArmature*)ob_arm->data;
bArmature *arm = (bArmature *)ob_arm->data;
const std::string& controller_id = get_controller_id(ob_arm, ob);
@ -94,7 +95,7 @@ bool ArmatureExporter::add_instance_controller(Object *ob)
// write root bone URLs
Bone *bone;
for (bone = (Bone*)arm->bonebase.first; bone; bone = bone->next) {
for (bone = (Bone *)arm->bonebase.first; bone; bone = bone->next) {
if (!bone->parent)
ins.addSkeleton(COLLADABU::URI(COLLADABU::Utils::EMPTY_STRING, get_joint_id(bone, ob_arm)));
}
@ -140,7 +141,7 @@ void ArmatureExporter::find_objects_using_armature(Object *ob_arm, std::vector<O
{
objects.clear();
Base *base= (Base*) sce->base.first;
Base *base = (Base *) sce->base.first;
while (base) {
Object *ob = base->object;
@ -148,7 +149,7 @@ void ArmatureExporter::find_objects_using_armature(Object *ob_arm, std::vector<O
objects.push_back(ob);
}
base= base->next;
base = base->next;
}
}
#endif
@ -159,9 +160,9 @@ std::string ArmatureExporter::get_joint_sid(Bone *bone, Object *ob_arm)
}
// parent_mat is armature-space
void ArmatureExporter::add_bone_node(Bone *bone, Object *ob_arm, Scene* sce,
SceneExporter* se,
std::list<Object*>& child_objects)
void ArmatureExporter::add_bone_node(Bone *bone, Object *ob_arm, Scene *sce,
SceneExporter *se,
std::list<Object *>& child_objects)
{
std::string node_id = get_joint_id(bone, ob_arm);
std::string node_name = std::string(bone->name);
@ -182,7 +183,7 @@ void ArmatureExporter::add_bone_node(Bone *bone, Object *ob_arm, Scene* sce,
add_bone_transform(ob_arm, bone, node);
// Write nodes of childobjects, remove written objects from list
std::list<Object*>::iterator i = child_objects.begin();
std::list<Object *>::iterator i = child_objects.begin();
while (i != child_objects.end()) {
if ((*i)->partype == PARBONE && (0 == strcmp((*i)->parsubstr, bone->name))) {
@ -219,29 +220,32 @@ void ArmatureExporter::add_bone_node(Bone *bone, Object *ob_arm, Scene* sce,
else i++;
}
for (Bone *child = (Bone*)bone->childbase.first; child; child = child->next) {
for (Bone *child = (Bone *)bone->childbase.first; child; child = child->next) {
add_bone_node(child, ob_arm, sce, se, child_objects);
}
node.end();
//}
}
/*void ArmatureExporter::add_blender_leaf_bone(Bone *bone, Object *ob_arm, COLLADASW::Node& node)
#if 0
void ArmatureExporter::add_blender_leaf_bone(Bone *bone, Object *ob_arm, COLLADASW::Node& node)
{
node.start();
add_bone_transform(ob_arm, bone, node);
node.addExtraTechniqueParameter("blender", "tip_x", bone->tail[0] );
node.addExtraTechniqueParameter("blender", "tip_y", bone->tail[1] );
node.addExtraTechniqueParameter("blender", "tip_z", bone->tail[2] );
node.addExtraTechniqueParameter("blender", "tip_x", bone->tail[0]);
node.addExtraTechniqueParameter("blender", "tip_y", bone->tail[1]);
node.addExtraTechniqueParameter("blender", "tip_z", bone->tail[2]);
for (Bone *child = (Bone*)bone->childbase.first; child; child = child->next) {
for (Bone *child = (Bone *)bone->childbase.first; child; child = child->next) {
add_bone_node(child, ob_arm, sce, se, child_objects);
}
node.end();
}*/
}
#endif
void ArmatureExporter::add_bone_transform(Object *ob_arm, Bone *bone, COLLADASW::Node& node)
{
bPoseChannel *pchan = BKE_pose_channel_find_name(ob_arm->pose, bone->name);
@ -292,7 +296,7 @@ std::string ArmatureExporter::get_controller_id(Object *ob_arm, Object *ob)
// ob should be of type OB_MESH
// both args are required
void ArmatureExporter::export_controller(Object* ob, Object *ob_arm)
void ArmatureExporter::export_controller(Object *ob, Object *ob_arm)
{
// joint names
// joint inverse bind matrices
@ -302,8 +306,8 @@ void ArmatureExporter::export_controller(Object* ob, Object *ob_arm)
// joint names: ob -> vertex group names
// vertex group weights: me->dvert -> groups -> index, weight
/*
me->dvert:
#if 0
me->dvert :
typedef struct MDeformVert {
struct MDeformWeight *dw;
@ -315,16 +319,16 @@ void ArmatureExporter::export_controller(Object* ob, Object *ob_arm)
int def_nr;
float weight;
} MDeformWeight;
*/
#endif
bool use_instantiation = this->export_settings->use_object_instantiation;
Mesh *me;
if ( this->export_settings->apply_modifiers ) {
if (this->export_settings->apply_modifiers) {
me = bc_to_mesh_apply_modifiers(scene, ob);
}
else {
me = (Mesh*)ob->data;
me = (Mesh *)ob->data;
}
BKE_mesh_tessface_ensure(me);
@ -352,7 +356,7 @@ void ArmatureExporter::export_controller(Object* ob, Object *ob_arm)
std::vector<int> joint_index_by_def_index;
bDeformGroup *def;
for (def = (bDeformGroup*)ob->defbase.first, i = 0, j = 0; def; def = def->next, i++) {
for (def = (bDeformGroup *)ob->defbase.first, i = 0, j = 0; def; def = def->next, i++) {
if (is_bone_defgroup(ob_arm, def))
joint_index_by_def_index.push_back(j++);
else
@ -375,18 +379,20 @@ void ArmatureExporter::export_controller(Object* ob, Object *ob_arm)
}
if (sumw > 0.0f) {
float invsumw = 1.0f/sumw;
float invsumw = 1.0f / sumw;
vcounts.push_back(jw.size());
for (std::map<int, float>::iterator m = jw.begin(); m != jw.end(); ++m) {
joints.push_back((*m).first);
weights.push_back(invsumw*(*m).second);
weights.push_back(invsumw * (*m).second);
}
}
else {
vcounts.push_back(0);
/*vcounts.push_back(1);
#if 0
vcounts.push_back(1);
joints.push_back(-1);
weights.push_back(1.0f);*/
weights.push_back(1.0f);
#endif
}
}
}
@ -431,7 +437,7 @@ std::string ArmatureExporter::add_joints_source(Object *ob_arm, ListBase *defbas
int totjoint = 0;
bDeformGroup *def;
for (def = (bDeformGroup*)defbase->first; def; def = def->next) {
for (def = (bDeformGroup *)defbase->first; def; def = def->next) {
if (is_bone_defgroup(ob_arm, def))
totjoint++;
}
@ -447,7 +453,7 @@ std::string ArmatureExporter::add_joints_source(Object *ob_arm, ListBase *defbas
source.prepareToAppendValues();
for (def = (bDeformGroup*)defbase->first; def; def = def->next) {
for (def = (bDeformGroup *)defbase->first; def; def = def->next) {
Bone *bone = get_bone_from_defgroup(ob_arm, def);
if (bone)
source.appendValues(get_joint_sid(bone, ob_arm));
@ -463,7 +469,7 @@ std::string ArmatureExporter::add_inv_bind_mats_source(Object *ob_arm, ListBase
std::string source_id = controller_id + BIND_POSES_SOURCE_ID_SUFFIX;
int totjoint = 0;
for (bDeformGroup *def = (bDeformGroup*)defbase->first; def; def = def->next) {
for (bDeformGroup *def = (bDeformGroup *)defbase->first; def; def = def->next) {
if (is_bone_defgroup(ob_arm, def))
totjoint++;
}
@ -481,7 +487,7 @@ std::string ArmatureExporter::add_inv_bind_mats_source(Object *ob_arm, ListBase
source.prepareToAppendValues();
bPose *pose = ob_arm->pose;
bArmature *arm = (bArmature*)ob_arm->data;
bArmature *arm = (bArmature *)ob_arm->data;
int flag = arm->flag;
@ -491,7 +497,7 @@ std::string ArmatureExporter::add_inv_bind_mats_source(Object *ob_arm, ListBase
BKE_pose_where_is(scene, ob_arm);
}
for (bDeformGroup *def = (bDeformGroup*)defbase->first; def; def = def->next) {
for (bDeformGroup *def = (bDeformGroup *)defbase->first; def; def = def->next) {
if (is_bone_defgroup(ob_arm, def)) {
bPoseChannel *pchan = BKE_pose_channel_find_name(pose, def->name);
@ -530,13 +536,13 @@ std::string ArmatureExporter::add_inv_bind_mats_source(Object *ob_arm, ListBase
return source_id;
}
Bone *ArmatureExporter::get_bone_from_defgroup(Object *ob_arm, bDeformGroup* def)
Bone *ArmatureExporter::get_bone_from_defgroup(Object *ob_arm, bDeformGroup *def)
{
bPoseChannel *pchan = BKE_pose_channel_find_name(ob_arm->pose, def->name);
return pchan ? pchan->bone : NULL;
}
bool ArmatureExporter::is_bone_defgroup(Object *ob_arm, bDeformGroup* def)
bool ArmatureExporter::is_bone_defgroup(Object *ob_arm, bDeformGroup *def)
{
return get_bone_from_defgroup(ob_arm, def) != NULL;
}

@ -50,7 +50,8 @@ static const char *bc_get_joint_name(T *node)
}
ArmatureImporter::ArmatureImporter(UnitConverter *conv, MeshImporterBase *mesh, AnimationImporterBase *anim, Scene *sce) :
TransformReader(conv), scene(sce), empty(NULL), mesh_importer(mesh), anim_importer(anim) {}
TransformReader(conv), scene(sce), empty(NULL), mesh_importer(mesh), anim_importer(anim) {
}
ArmatureImporter::~ArmatureImporter()
{
@ -77,12 +78,12 @@ JointData *ArmatureImporter::get_joint_data(COLLADAFW::Node *node);
return &joint_index_to_joint_info_map[joint_index];
}
#endif
void ArmatureImporter::create_unskinned_bone( COLLADAFW::Node *node, EditBone *parent, int totchild,
float parent_mat[][4], Object * ob_arm)
void ArmatureImporter::create_unskinned_bone(COLLADAFW::Node *node, EditBone *parent, int totchild,
float parent_mat[][4], Object *ob_arm)
{
std::vector<COLLADAFW::Node*>::iterator it;
std::vector<COLLADAFW::Node *>::iterator it;
it = std::find(finished_joints.begin(), finished_joints.end(), node);
if ( it != finished_joints.end()) return;
if (it != finished_joints.end()) return;
float mat[4][4];
float obmat[4][4];
@ -90,7 +91,7 @@ void ArmatureImporter::create_unskinned_bone( COLLADAFW::Node *node, EditBone *p
// object-space
get_node_mat(obmat, node, NULL, NULL);
EditBone *bone = ED_armature_edit_bone_add((bArmature*)ob_arm->data, (char*)bc_get_joint_name(node));
EditBone *bone = ED_armature_edit_bone_add((bArmature *)ob_arm->data, (char *)bc_get_joint_name(node));
totbone++;
if (parent) bone->parent = parent;
@ -107,9 +108,9 @@ void ArmatureImporter::create_unskinned_bone( COLLADAFW::Node *node, EditBone *p
}
float loc[3], size[3], rot[3][3];
mat4_to_loc_rot_size( loc, rot, size, obmat);
mat3_to_vec_roll(rot, NULL, &angle );
bone->roll=angle;
mat4_to_loc_rot_size(loc, rot, size, obmat);
mat3_to_vec_roll(rot, NULL, &angle);
bone->roll = angle;
// set head
copy_v3_v3(bone->head, mat[3]);
@ -142,7 +143,7 @@ void ArmatureImporter::create_unskinned_bone( COLLADAFW::Node *node, EditBone *p
COLLADAFW::NodePointerArray& children = node->getChildNodes();
for (unsigned int i = 0; i < children.getCount(); i++) {
create_unskinned_bone( children[i], bone, children.getCount(), mat, ob_arm);
create_unskinned_bone(children[i], bone, children.getCount(), mat, ob_arm);
}
// in second case it's not a leaf bone, but we handle it the same way
@ -158,9 +159,9 @@ void ArmatureImporter::create_bone(SkinInfo& skin, COLLADAFW::Node *node, EditBo
float parent_mat[][4], bArmature *arm)
{
//Checking if bone is already made.
std::vector<COLLADAFW::Node*>::iterator it;
std::vector<COLLADAFW::Node *>::iterator it;
it = std::find(finished_joints.begin(), finished_joints.end(), node);
if ( it != finished_joints.end()) return;
if (it != finished_joints.end()) return;
float joint_inv_bind_mat[4][4];
@ -169,7 +170,7 @@ void ArmatureImporter::create_bone(SkinInfo& skin, COLLADAFW::Node *node, EditBo
float mat[4][4];
// TODO rename from Node "name" attrs later
EditBone *bone = ED_armature_edit_bone_add(arm, (char*)bc_get_joint_name(node));
EditBone *bone = ED_armature_edit_bone_add(arm, (char *)bc_get_joint_name(node));
totbone++;
if (skin.get_joint_inv_bind_matrix(joint_inv_bind_mat, node)) {
@ -190,9 +191,9 @@ void ArmatureImporter::create_bone(SkinInfo& skin, COLLADAFW::Node *node, EditBo
copy_m4_m4(mat, obmat);
float loc[3], size[3], rot[3][3], angle;
mat4_to_loc_rot_size( loc, rot, size, obmat);
mat3_to_vec_roll(rot, NULL, &angle );
bone->roll=angle;
mat4_to_loc_rot_size(loc, rot, size, obmat);
mat3_to_vec_roll(rot, NULL, &angle);
bone->roll = angle;
}
@ -267,7 +268,7 @@ void ArmatureImporter::create_bone(SkinInfo& skin, COLLADAFW::Node *node, EditBo
finished_joints.push_back(node);
}
void ArmatureImporter::add_leaf_bone(float mat[][4], EditBone *bone, COLLADAFW::Node * node)
void ArmatureImporter::add_leaf_bone(float mat[][4], EditBone *bone, COLLADAFW::Node *node)
{
LeafBone leaf;
@ -337,7 +338,7 @@ void ArmatureImporter::set_euler_rotmode()
{
// just set rotmode = ROT_MODE_EUL on pose channel for each joint
std::map<COLLADAFW::UniqueId, COLLADAFW::Node*>::iterator it;
std::map<COLLADAFW::UniqueId, COLLADAFW::Node *>::iterator it;
for (it = joint_by_uid.begin(); it != joint_by_uid.end(); it++) {
@ -378,7 +379,7 @@ Object *ArmatureImporter::get_empty_for_leaves()
#if 0
Object *ArmatureImporter::find_armature(COLLADAFW::Node *node)
{
JointData* jd = get_joint_data(node);
JointData *jd = get_joint_data(node);
if (jd) return jd->ob_arm;
COLLADAFW::NodePointerArray& children = node->getChildNodes();
@ -408,10 +409,10 @@ ArmatureJoints& ArmatureImporter::get_armature_joints(Object *ob_arm)
#endif
void ArmatureImporter::create_armature_bones( )
{
std::vector<COLLADAFW::Node*>::iterator ri;
std::vector<COLLADAFW::Node *>::iterator ri;
//if there is an armature created for root_joint next root_joint
for (ri = root_joints.begin(); ri != root_joints.end(); ri++) {
if ( get_armature_for_joint(*ri) != NULL ) continue;
if (get_armature_for_joint(*ri) != NULL) continue;
//add armature object for current joint
//Object *ob_arm = bc_add_object(scene, OB_ARMATURE, NULL);
@ -428,8 +429,8 @@ void ArmatureImporter::create_armature_bones( )
// create unskinned bones
/*
TODO:
check if bones have already been created for a given joint
* TODO:
* check if bones have already been created for a given joint
*/
leaf_bone_length = FLT_MAX;
create_unskinned_bone(*ri, NULL, (*ri)->getChildNodes().getCount(), NULL, ob_arm);
@ -442,10 +443,10 @@ void ArmatureImporter::create_armature_bones( )
ED_armature_from_edit(ob_arm);
set_pose(ob_arm, *ri, NULL, NULL );
set_pose(ob_arm, *ri, NULL, NULL);
ED_armature_edit_free(ob_arm);
DAG_id_tag_update(&ob_arm->id, OB_RECALC_OB|OB_RECALC_DATA);
DAG_id_tag_update(&ob_arm->id, OB_RECALC_OB | OB_RECALC_DATA);
}
@ -496,7 +497,7 @@ void ArmatureImporter::create_armature_bones(SkinInfo& skin)
SkinInfo *a = &skin;
Object *shared = NULL;
std::vector<COLLADAFW::Node*> skin_root_joints;
std::vector<COLLADAFW::Node *> skin_root_joints;
std::map<COLLADAFW::UniqueId, SkinInfo>::iterator it;
for (it = skin_by_data_uid.begin(); it != skin_by_data_uid.end(); it++) {
@ -508,7 +509,7 @@ void ArmatureImporter::create_armature_bones(SkinInfo& skin)
b->find_root_joints(root_joints, joint_by_uid, skin_root_joints);
std::vector<COLLADAFW::Node*>::iterator ri;
std::vector<COLLADAFW::Node *>::iterator ri;
for (ri = skin_root_joints.begin(); ri != skin_root_joints.end(); ri++) {
if (a->uses_joint_or_descendant(*ri)) {
shared = b->BKE_armature_from_object();
@ -540,7 +541,7 @@ void ArmatureImporter::create_armature_bones(SkinInfo& skin)
check if bones have already been created for a given joint
*/
std::vector<COLLADAFW::Node*>::iterator ri;
std::vector<COLLADAFW::Node *>::iterator ri;
for (ri = root_joints.begin(); ri != root_joints.end(); ri++) {
// for shared armature check if bone tree is already created
if (shared && std::find(skin_root_joints.begin(), skin_root_joints.end(), *ri) != skin_root_joints.end())
@ -548,7 +549,7 @@ void ArmatureImporter::create_armature_bones(SkinInfo& skin)
// since root_joints may contain joints for multiple controllers, we need to filter
if (skin.uses_joint_or_descendant(*ri)) {
create_bone(skin, *ri, NULL, (*ri)->getChildNodes().getCount(), NULL, (bArmature*)ob_arm->data);
create_bone(skin, *ri, NULL, (*ri)->getChildNodes().getCount(), NULL, (bArmature *)ob_arm->data);
if (joint_parent_map.find((*ri)->getUniqueId()) != joint_parent_map.end() && !skin.get_parent())
skin.set_parent(joint_parent_map[(*ri)->getUniqueId()]);
@ -560,7 +561,7 @@ void ArmatureImporter::create_armature_bones(SkinInfo& skin)
// exit armature edit mode
ED_armature_from_edit(ob_arm);
ED_armature_edit_free(ob_arm);
DAG_id_tag_update(&ob_arm->id, OB_RECALC_OB|OB_RECALC_DATA);
DAG_id_tag_update(&ob_arm->id, OB_RECALC_OB | OB_RECALC_DATA);
// set_leaf_bone_shapes(ob_arm);
// set_euler_rotmode();
@ -571,9 +572,9 @@ void ArmatureImporter::create_armature_bones(SkinInfo& skin)
// is a child of a node (not joint), root should be true since
// this is where we build armature bones from
void ArmatureImporter::set_pose(Object * ob_arm, COLLADAFW::Node * root_node, const char *parentname, float parent_mat[][4])
void ArmatureImporter::set_pose(Object *ob_arm, COLLADAFW::Node *root_node, const char *parentname, float parent_mat[][4])
{
char * bone_name = (char *) bc_get_joint_name ( root_node);
char *bone_name = (char *) bc_get_joint_name(root_node);
float mat[4][4];
float obmat[4][4];
@ -584,7 +585,7 @@ void ArmatureImporter::set_pose(Object * ob_arm, COLLADAFW::Node * root_node, c
get_node_mat(obmat, root_node, NULL, NULL);
//if (*edbone)
bPoseChannel * pchan = BKE_pose_channel_find_name(ob_arm -> pose, bone_name);
bPoseChannel *pchan = BKE_pose_channel_find_name(ob_arm->pose, bone_name);
//else fprintf ( "",
// get world-space
@ -592,7 +593,7 @@ void ArmatureImporter::set_pose(Object * ob_arm, COLLADAFW::Node * root_node, c
mult_m4_m4m4(mat, parent_mat, obmat);
bPoseChannel *parchan = BKE_pose_channel_find_name(ob_arm->pose, parentname);
mult_m4_m4m4(pchan->pose_mat, parchan->pose_mat, mat );
mult_m4_m4m4(pchan->pose_mat, parchan->pose_mat, mat);
}
else {
@ -694,7 +695,7 @@ void ArmatureImporter::link_armature(Object *ob_arm, const COLLADAFW::UniqueId&
}
#endif
bool ArmatureImporter::write_skin_controller_data(const COLLADAFW::SkinControllerData* data)
bool ArmatureImporter::write_skin_controller_data(const COLLADAFW::SkinControllerData *data)
{
// at this stage we get vertex influence info that should go into me->verts and ob->defbase
// there's no info to which object this should be long so we associate it with skin controller data UID
@ -719,14 +720,14 @@ bool ArmatureImporter::write_skin_controller_data(const COLLADAFW::SkinControlle
return true;
}
bool ArmatureImporter::write_controller(const COLLADAFW::Controller* controller)
bool ArmatureImporter::write_controller(const COLLADAFW::Controller *controller)
{
// - create and store armature object
const COLLADAFW::UniqueId& skin_id = controller->getUniqueId();
if (controller->getControllerType() == COLLADAFW::Controller::CONTROLLER_TYPE_SKIN) {
COLLADAFW::SkinController *co = (COLLADAFW::SkinController*)controller;
COLLADAFW::SkinController *co = (COLLADAFW::SkinController *)controller;
// to be able to find geom id by controller id
geom_uid_by_controller_uid[skin_id] = co->getSource();
@ -766,7 +767,7 @@ Object *ArmatureImporter::get_armature_for_joint(COLLADAFW::Node *node)
return skin.BKE_armature_from_object();
}
std::map<COLLADAFW::UniqueId, Object*>::iterator arm;
std::map<COLLADAFW::UniqueId, Object *>::iterator arm;
for (arm = unskinned_armature_map.begin(); arm != unskinned_armature_map.end(); arm++) {
if (arm->first == node->getUniqueId() )
return arm->second;
@ -799,6 +800,3 @@ bool ArmatureImporter::get_joint_bind_mat(float m[][4], COLLADAFW::Node *joint)
return found;
}

@ -37,13 +37,14 @@ extern "C" {
#include "collada_internal.h"
CamerasExporter::CamerasExporter(COLLADASW::StreamWriter *sw, const ExportSettings *export_settings): COLLADASW::LibraryCameras(sw), export_settings(export_settings) {}
CamerasExporter::CamerasExporter(COLLADASW::StreamWriter *sw, const ExportSettings *export_settings) : COLLADASW::LibraryCameras(sw), export_settings(export_settings) {
}
template<class Functor>
void forEachCameraObjectInExportSet(Scene *sce, Functor &f, LinkNode *export_set)
{
LinkNode *node;
for(node=export_set; node; node = node->next) {
for (node = export_set; node; node = node->next) {
Object *ob = (Object *)node->link;
if (ob->type == OB_CAMERA && ob->data) {
@ -63,7 +64,7 @@ void CamerasExporter::exportCameras(Scene *sce)
void CamerasExporter::operator()(Object *ob, Scene *sce)
{
// TODO: shiftx, shifty, YF_dofdist
Camera *cam = (Camera*)ob->data;
Camera *cam = (Camera *)ob->data;
std::string cam_id(get_camera_id(ob));
std::string cam_name(id_name(cam));
@ -72,7 +73,7 @@ void CamerasExporter::operator()(Object *ob, Scene *sce)
case CAM_PERSP: {
COLLADASW::PerspectiveOptic persp(mSW);
persp.setXFov(RAD2DEGF(focallength_to_fov(cam->lens, cam->sensor_x)), "xfov");
persp.setAspectRatio((float)(sce->r.xsch)/(float)(sce->r.ysch), false, "aspect_ratio");
persp.setAspectRatio((float)(sce->r.xsch) / (float)(sce->r.ysch), false, "aspect_ratio");
persp.setZFar(cam->clipend, false, "zfar");
persp.setZNear(cam->clipsta, false, "znear");
COLLADASW::Camera ccam(mSW, &persp, cam_id, cam_name);
@ -84,11 +85,12 @@ void CamerasExporter::operator()(Object *ob, Scene *sce)
{
COLLADASW::OrthographicOptic ortho(mSW);
ortho.setXMag(cam->ortho_scale, "xmag");
ortho.setAspectRatio((float)(sce->r.xsch)/(float)(sce->r.ysch), false, "aspect_ratio");
ortho.setAspectRatio((float)(sce->r.xsch) / (float)(sce->r.ysch), false, "aspect_ratio");
ortho.setZFar(cam->clipend, false, "zfar");
ortho.setZNear(cam->clipsta, false, "znear");
COLLADASW::Camera ccam(mSW, &ortho, cam_id, cam_name);
addCamera(ccam);
break;
}}
}
}
}

@ -134,7 +134,7 @@ char *bc_CustomData_get_layer_name(const struct CustomData *data, int type, int
int layer_index = CustomData_get_layer_index(data, type);
if (layer_index < 0) return NULL;
return data->layers[layer_index+n].name;
return data->layers[layer_index + n].name;
}
char *bc_CustomData_get_active_layer_name(const CustomData *data, int type)
@ -146,7 +146,8 @@ char *bc_CustomData_get_active_layer_name(const CustomData *data, int type)
return data->layers[layer_index].name;
}
DocumentExporter::DocumentExporter(const ExportSettings *export_settings) : export_settings(export_settings) {}
DocumentExporter::DocumentExporter(const ExportSettings *export_settings) : export_settings(export_settings) {
}
// TODO: it would be better to instantiate animations rather than create a new one per object
// COLLADA allows this through multiple <channel>s in <animation>.
@ -221,9 +222,9 @@ void DocumentExporter::exportCurrentScene(Scene *sce)
}
char version_buf[128];
#ifdef WITH_BUILDINFO
sprintf(version_buf, "Blender %d.%02d.%d r%s", BLENDER_VERSION/100, BLENDER_VERSION%100, BLENDER_SUBVERSION, build_rev);
sprintf(version_buf, "Blender %d.%02d.%d r%s", BLENDER_VERSION / 100, BLENDER_VERSION % 100, BLENDER_SUBVERSION, build_rev);
#else
sprintf(version_buf, "Blender %d.%02d.%d", BLENDER_VERSION/100, BLENDER_VERSION%100, BLENDER_SUBVERSION);
sprintf(version_buf, "Blender %d.%02d.%d", BLENDER_VERSION / 100, BLENDER_VERSION % 100, BLENDER_SUBVERSION);
#endif
asset.getContributor().mAuthoringTool = version_buf;
asset.add();
@ -284,14 +285,13 @@ void DocumentExporter::exportCurrentScene(Scene *sce)
}
void DocumentExporter::exportScenes(const char* filename)
void DocumentExporter::exportScenes(const char *filename)
{
}
/*
NOTES:
* AnimationExporter::sample_animation enables all curves on armature, this is undesirable for a user
* NOTES:
*
* AnimationExporter::sample_animation enables all curves on armature, this is undesirable for a user
*
*/

@ -103,13 +103,14 @@ DocumentImporter::DocumentImporter(bContext *C, const char *filename) :
armature_importer(&unit_converter, &mesh_importer, &anim_importer, CTX_data_scene(C)),
mesh_importer(&unit_converter, &armature_importer, CTX_data_scene(C)),
anim_importer(&unit_converter, &armature_importer, CTX_data_scene(C))
{}
{
}
DocumentImporter::~DocumentImporter()
{
TagsMap::iterator etit;
etit = uid_tags_map.begin();
while (etit!=uid_tags_map.end()) {
while (etit != uid_tags_map.end()) {
delete etit->second;
etit++;
}
@ -171,11 +172,11 @@ void DocumentImporter::start()
void DocumentImporter::finish()
{
if (mImportStage!=General)
if (mImportStage != General)
return;
/** TODO Break up and put into 2-pass parsing of DAE */
std::vector<const COLLADAFW::VisualScene*>::iterator it;
std::vector<const COLLADAFW::VisualScene *>::iterator it;
for (it = vscenes.begin(); it != vscenes.end(); it++) {
PointerRNA sceneptr, unit_settings;
PropertyRNA *system, *scale;
@ -214,7 +215,7 @@ void DocumentImporter::finish()
armature_importer.fix_animation();
#endif
for (std::vector<const COLLADAFW::VisualScene*>::iterator it = vscenes.begin(); it != vscenes.end(); it++) {
for (std::vector<const COLLADAFW::VisualScene *>::iterator it = vscenes.begin(); it != vscenes.end(); it++) {
const COLLADAFW::NodePointerArray& roots = (*it)->getRootNodes();
for (unsigned int i = 0; i < roots.getCount(); i++)
@ -226,7 +227,7 @@ void DocumentImporter::finish()
fprintf(stderr, "got %d library nodes to free\n", (int)libnode_ob.size());
// free all library_nodes
std::vector<Object*>::iterator it;
std::vector<Object *>::iterator it;
for (it = libnode_ob.begin(); it != libnode_ob.end(); it++) {
Object *ob = *it;
@ -234,8 +235,8 @@ void DocumentImporter::finish()
if (base) {
BLI_remlink(&sce->base, base);
BKE_libblock_free_us(&G.main->object, base->object);
if (sce->basact==base)
sce->basact= NULL;
if (sce->basact == base)
sce->basact = NULL;
MEM_freeN(base);
}
}
@ -265,18 +266,20 @@ void DocumentImporter::translate_anim_recursive(COLLADAFW::Node *node, COLLADAFW
root_map[node->getUniqueId()] = root_map[par->getUniqueId()];
}
/*COLLADAFW::Transformation::TransformationType types[] = {
#if 0
COLLADAFW::Transformation::TransformationType types[] = {
COLLADAFW::Transformation::ROTATE,
COLLADAFW::Transformation::SCALE,
COLLADAFW::Transformation::TRANSLATE,
COLLADAFW::Transformation::MATRIX
};
Object *ob;*/
Object *ob;
#endif
unsigned int i;
//for (i = 0; i < 4; i++)
//ob =
// ob =
anim_importer.translate_Animations(node, root_map, object_map, FW_object_map);
COLLADAFW::NodePointerArray &children = node->getChildNodes();
@ -286,8 +289,8 @@ void DocumentImporter::translate_anim_recursive(COLLADAFW::Node *node, COLLADAFW
}
/** When this method is called, the writer must write the global document asset.
\return The writer should return true, if writing succeeded, false otherwise.*/
bool DocumentImporter::writeGlobalAsset ( const COLLADAFW::FileInfo* asset )
* \return The writer should return true, if writing succeeded, false otherwise.*/
bool DocumentImporter::writeGlobalAsset(const COLLADAFW::FileInfo *asset)
{
unit_converter.read_asset(asset);
@ -295,13 +298,13 @@ bool DocumentImporter::writeGlobalAsset ( const COLLADAFW::FileInfo* asset )
}
/** When this method is called, the writer must write the scene.
\return The writer should return true, if writing succeeded, false otherwise.*/
bool DocumentImporter::writeScene ( const COLLADAFW::Scene* scene )
* \return The writer should return true, if writing succeeded, false otherwise.*/
bool DocumentImporter::writeScene(const COLLADAFW::Scene *scene)
{
// XXX could store the scene id, but do nothing for now
return true;
}
Object* DocumentImporter::create_camera_object(COLLADAFW::InstanceCamera *camera, Scene *sce)
Object *DocumentImporter::create_camera_object(COLLADAFW::InstanceCamera *camera, Scene *sce)
{
const COLLADAFW::UniqueId& cam_uid = camera->getInstanciatedObjectId();
if (uid_camera_map.find(cam_uid) == uid_camera_map.end()) {
@ -311,7 +314,7 @@ Object* DocumentImporter::create_camera_object(COLLADAFW::InstanceCamera *camera
Object *ob = bc_add_object(sce, OB_CAMERA, NULL);
Camera *cam = uid_camera_map[cam_uid];
Camera *old_cam = (Camera*)ob->data;
Camera *old_cam = (Camera *)ob->data;
ob->data = cam;
old_cam->id.us--;
if (old_cam->id.us == 0)
@ -319,7 +322,7 @@ Object* DocumentImporter::create_camera_object(COLLADAFW::InstanceCamera *camera
return ob;
}
Object* DocumentImporter::create_lamp_object(COLLADAFW::InstanceLight *lamp, Scene *sce)
Object *DocumentImporter::create_lamp_object(COLLADAFW::InstanceLight *lamp, Scene *sce)
{
const COLLADAFW::UniqueId& lamp_uid = lamp->getInstanciatedObjectId();
if (uid_lamp_map.find(lamp_uid) == uid_lamp_map.end()) {
@ -329,7 +332,7 @@ Object* DocumentImporter::create_lamp_object(COLLADAFW::InstanceLight *lamp, Sce
Object *ob = bc_add_object(sce, OB_LAMP, NULL);
Lamp *la = uid_lamp_map[lamp_uid];
Lamp *old_lamp = (Lamp*)ob->data;
Lamp *old_lamp = (Lamp *)ob->data;
ob->data = la;
old_lamp->id.us--;
if (old_lamp->id.us == 0)
@ -337,12 +340,12 @@ 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, 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 = BKE_object_copy(source_ob);
obn->recalc |= OB_RECALC_OB|OB_RECALC_DATA|OB_RECALC_TIME;
obn->recalc |= OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME;
BKE_scene_base_add(sce, obn);
if (instance_node) {
@ -399,17 +402,17 @@ Object* DocumentImporter::create_instance_node(Object *source_ob, COLLADAFW::Nod
return obn;
}
void DocumentImporter::write_node (COLLADAFW::Node *node, COLLADAFW::Node *parent_node, Scene *sce, Object *par, bool is_library_node)
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;
std::vector<Object*> * objects_done = new std::vector<Object *>();
std::vector<Object *> *objects_done = new std::vector<Object *>();
if (is_joint) {
if ( par ) {
Object * empty = par;
if (par) {
Object *empty = par;
par = bc_add_object(sce, OB_ARMATURE, NULL);
bc_set_parent(par, empty->parent, mContext);
//remove empty : todo
@ -449,7 +452,7 @@ void DocumentImporter::write_node (COLLADAFW::Node *node, COLLADAFW::Node *paren
++lamp_done;
}
while (controller_done < controller.getCount()) {
COLLADAFW::InstanceGeometry *geom = (COLLADAFW::InstanceGeometry*)controller[controller_done];
COLLADAFW::InstanceGeometry *geom = (COLLADAFW::InstanceGeometry *)controller[controller_done];
ob = mesh_importer.create_mesh_object(node, geom, true, uid_material_map, material_texture_mapping_map);
objects_done->push_back(ob);
++controller_done;
@ -487,7 +490,7 @@ void DocumentImporter::write_node (COLLADAFW::Node *node, COLLADAFW::Node *paren
for (std::vector<Object *>::iterator it = objects_done->begin(); it != objects_done->end(); ++it) {
ob = *it;
std::string nodename = node->getName().size() ? node->getName() : node->getOriginalId();
rename_id(&ob->id, (char*)nodename.c_str());
rename_id(&ob->id, (char *)nodename.c_str());
object_map.insert(std::make_pair<COLLADAFW::UniqueId, Object *>(node->getUniqueId(), ob));
node_map[node->getUniqueId()] = node;
@ -498,7 +501,7 @@ void DocumentImporter::write_node (COLLADAFW::Node *node, COLLADAFW::Node *paren
}
for (std::vector<Object *>::iterator it = objects_done->begin(); it != objects_done->end(); ++it) {
ob =*it;
ob = *it;
if (read_transform)
anim_importer.read_node_transform(node, ob); // overwrites location set earlier
@ -517,10 +520,10 @@ void DocumentImporter::write_node (COLLADAFW::Node *node, COLLADAFW::Node *paren
}
/** When this method is called, the writer must write the entire visual scene.
\return The writer should return true, if writing succeeded, false otherwise.*/
bool DocumentImporter::writeVisualScene ( const COLLADAFW::VisualScene* visualScene )
* \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.
@ -539,11 +542,11 @@ bool DocumentImporter::writeVisualScene ( const COLLADAFW::VisualScene* visualSc
}
/** When this method is called, the writer must handle all nodes contained in the
library nodes.
\return The writer should return true, if writing succeeded, false otherwise.*/
bool DocumentImporter::writeLibraryNodes ( const COLLADAFW::LibraryNodes* libraryNodes )
* library nodes.
* \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);
@ -558,24 +561,24 @@ bool DocumentImporter::writeLibraryNodes ( const COLLADAFW::LibraryNodes* librar
}
/** When this method is called, the writer must write the geometry.
\return The writer should return true, if writing succeeded, false otherwise.*/
bool DocumentImporter::writeGeometry ( const COLLADAFW::Geometry* geom )
* \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);
}
/** When this method is called, the writer must write the material.
\return The writer should return true, if writing succeeded, false otherwise.*/
bool DocumentImporter::writeMaterial( const COLLADAFW::Material* cmat )
* \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();
Material *ma = BKE_material_add((char*)str_mat_id.c_str());
Material *ma = BKE_material_add((char *)str_mat_id.c_str());
this->uid_effect_map[cmat->getInstantiatedEffect()] = ma;
this->uid_material_map[cmat->getUniqueId()] = ma;
@ -584,7 +587,7 @@ bool DocumentImporter::writeMaterial( const COLLADAFW::Material* cmat )
}
// create mtex, create texture, set texture image
MTex* DocumentImporter::create_texture(COLLADAFW::EffectCommon *ef, COLLADAFW::Texture &ctex, Material *ma,
MTex *DocumentImporter::create_texture(COLLADAFW::EffectCommon *ef, COLLADAFW::Texture &ctex, Material *ma,
int i, TexIndexTextureArrayMap &texindex_texarray_map)
{
COLLADAFW::SamplerPointerArray& samp_array = ef->getSamplerPointerArray();
@ -735,32 +738,34 @@ void DocumentImporter::write_profile_COMMON(COLLADAFW::EffectCommon *ef, Materia
mtex->tex->imaflag |= TEX_USEALPHA;
i++;
ma->spectra = ma->alpha = 0;
ma->mode |= MA_ZTRANSP|MA_TRANSP;
ma->mode |= MA_ZTRANSP | MA_TRANSP;
}
}
// TRANSPARENT
// color
// if (ef->getOpacity().isColor()) {
// // XXX don't know what to do here
// }
// // texture
// else if (ef->getOpacity().isTexture()) {
// ctex = ef->getOpacity().getTexture();
// if (mtex != NULL) mtex->mapto &= MAP_ALPHA;
// else {
// mtex = create_texture(ef, ctex, ma, i, texindex_texarray_map);
// if (mtex != NULL) mtex->mapto = MAP_ALPHA;
// }
// }
#if 0
if (ef->getOpacity().isColor()) {
// XXX don't know what to do here
}
// texture
else if (ef->getOpacity().isTexture()) {
ctex = ef->getOpacity().getTexture();
if (mtex != NULL) mtex->mapto &= MAP_ALPHA;
else {
mtex = create_texture(ef, ctex, ma, i, texindex_texarray_map);
if (mtex != NULL) mtex->mapto = MAP_ALPHA;
}
}
#endif
material_texture_mapping_map[ma] = texindex_texarray_map;
}
/** When this method is called, the writer must write the effect.
\return The writer should return true, if writing succeeded, false otherwise.*/
* \return The writer should return true, if writing succeeded, false otherwise.*/
bool DocumentImporter::writeEffect( const COLLADAFW::Effect* effect )
bool DocumentImporter::writeEffect(const COLLADAFW::Effect *effect)
{
if (mImportStage!=General)
if (mImportStage != General)
return true;
const COLLADAFW::UniqueId& uid = effect->getUniqueId();
@ -771,9 +776,9 @@ 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++ ) {
if ( iter->second == ma ) {
std::map<COLLADAFW::UniqueId, Material *>::iterator iter;
for (iter = uid_material_map.begin(); iter != uid_material_map.end(); iter++) {
if (iter->second == ma) {
this->FW_object_map[iter->first] = effect;
break;
}
@ -794,10 +799,10 @@ bool DocumentImporter::writeEffect( const COLLADAFW::Effect* effect )
/** When this method is called, the writer must write the camera.
\return The writer should return true, if writing succeeded, false otherwise.*/
bool DocumentImporter::writeCamera( const COLLADAFW::Camera* camera )
* \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;
@ -805,8 +810,8 @@ bool DocumentImporter::writeCamera( const COLLADAFW::Camera* camera )
cam_id = camera->getOriginalId();
cam_name = camera->getName();
if (cam_name.size()) cam = (Camera *)BKE_camera_add((char*)cam_name.c_str());
else cam = (Camera *)BKE_camera_add((char*)cam_id.c_str());
if (cam_name.size()) cam = (Camera *)BKE_camera_add((char *)cam_name.c_str());
else cam = (Camera *)BKE_camera_add((char *)cam_id.c_str());
if (!cam) {
fprintf(stderr, "Cannot create camera.\n");
@ -843,7 +848,7 @@ bool DocumentImporter::writeCamera( const COLLADAFW::Camera* camera )
{
double ymag = camera->getYMag().getValue();
double aspect = camera->getAspectRatio().getValue();
double xmag = aspect*ymag;
double xmag = aspect * ymag;
cam->ortho_scale = (float)xmag;
}
break;
@ -852,7 +857,7 @@ bool DocumentImporter::writeCamera( const COLLADAFW::Camera* camera )
{
double yfov = camera->getYFov().getValue();
double aspect = camera->getAspectRatio().getValue();
double xfov = aspect*yfov;
double xfov = aspect * yfov;
// xfov is in degrees, cam->lens is in millimiters
cam->lens = fov_to_focallength(DEG2RADF(xfov), cam->sensor_x);
}
@ -910,15 +915,15 @@ bool DocumentImporter::writeCamera( const COLLADAFW::Camera* camera )
}
/** When this method is called, the writer must write the image.
\return The writer should return true, if writing succeeded, false otherwise.*/
bool DocumentImporter::writeImage( const COLLADAFW::Image* image )
* \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
const std::string& filepath = image->getImageURI().toNativePath();
const char *filename = (const char*)mFilename.c_str();
const char *filename = (const char *)mFilename.c_str();
char dir[FILE_MAX];
char full_path[FILE_MAX];
@ -935,10 +940,10 @@ bool DocumentImporter::writeImage( const COLLADAFW::Image* image )
}
/** When this method is called, the writer must write the light.
\return The writer should return true, if writing succeeded, false otherwise.*/
bool DocumentImporter::writeLight( const COLLADAFW::Light* light )
* \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;
@ -952,8 +957,8 @@ bool DocumentImporter::writeLight( const COLLADAFW::Light* light )
la_id = light->getOriginalId();
la_name = light->getName();
if (la_name.size()) lamp = (Lamp*)BKE_lamp_add((char*)la_name.c_str());
else lamp = (Lamp*)BKE_lamp_add((char*)la_id.c_str());
if (la_name.size()) lamp = (Lamp *)BKE_lamp_add((char *)la_name.c_str());
else lamp = (Lamp *)BKE_lamp_add((char *)la_id.c_str());
if (!lamp) {
fprintf(stderr, "Cannot create lamp.\n");
@ -1036,12 +1041,12 @@ bool DocumentImporter::writeLight( const COLLADAFW::Light* light )
if (IS_EQ(linatt, 0.0f) && quadatt > 0.0f) {
att2 = quadatt;
d = sqrt(1.0f/quadatt);
d = sqrt(1.0f / quadatt);
}
// linear light
else if (IS_EQ(quadatt, 0.0f) && linatt > 0.0f) {
att1 = linatt;
d = (1.0f/linatt);
d = (1.0f / linatt);
}
else if (IS_EQ(constatt, 1.0f)) {
att1 = 1.0f;
@ -1051,7 +1056,7 @@ bool DocumentImporter::writeLight( const COLLADAFW::Light* light )
att1 = 1.0f;
}
d *= ( 1.0f / unit_converter.getLinearMeter());
d *= (1.0f / unit_converter.getLinearMeter());
lamp->energy = e;
lamp->dist = d;
@ -1109,9 +1114,9 @@ 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 )
bool DocumentImporter::writeAnimation(const COLLADAFW::Animation *anim)
{
if (mImportStage!=General)
if (mImportStage != General)
return true;
// return true;
@ -1119,9 +1124,9 @@ bool DocumentImporter::writeAnimation( const COLLADAFW::Animation* anim )
}
// called on post-process stage after writeVisualScenes
bool DocumentImporter::writeAnimationList( const COLLADAFW::AnimationList* animationList )
bool DocumentImporter::writeAnimationList(const COLLADAFW::AnimationList *animationList)
{
if (mImportStage!=General)
if (mImportStage != General)
return true;
// return true;
@ -1129,40 +1134,40 @@ bool DocumentImporter::writeAnimationList( const COLLADAFW::AnimationList* anima
}
/** When this method is called, the writer must write the skin controller data.
\return The writer should return true, if writing succeeded, false otherwise.*/
bool DocumentImporter::writeSkinControllerData( const COLLADAFW::SkinControllerData* skin )
* \return The writer should return true, if writing succeeded, false otherwise.*/
bool DocumentImporter::writeSkinControllerData(const COLLADAFW::SkinControllerData *skin)
{
return armature_importer.write_skin_controller_data(skin);
}
// this is called on postprocess, before writeVisualScenes
bool DocumentImporter::writeController( const COLLADAFW::Controller* controller )
bool DocumentImporter::writeController(const COLLADAFW::Controller *controller)
{
if (mImportStage!=General)
if (mImportStage != General)
return true;
return armature_importer.write_controller(controller);
}
bool DocumentImporter::writeFormulas( const COLLADAFW::Formulas* formulas )
bool DocumentImporter::writeFormulas(const COLLADAFW::Formulas *formulas)
{
return true;
}
bool DocumentImporter::writeKinematicsScene( const COLLADAFW::KinematicsScene* kinematicsScene )
bool DocumentImporter::writeKinematicsScene(const COLLADAFW::KinematicsScene *kinematicsScene)
{
return true;
}
ExtraTags* DocumentImporter::getExtraTags(const COLLADAFW::UniqueId &uid)
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()];
}
bool DocumentImporter::addExtraTags( const COLLADAFW::UniqueId &uid, ExtraTags *extra_tags)
bool DocumentImporter::addExtraTags(const COLLADAFW::UniqueId &uid, ExtraTags *extra_tags)
{
uid_tags_map[uid.toAscii()] = extra_tags;
return true;

@ -46,7 +46,7 @@
// OB_MESH is assumed
static std::string getActiveUVLayerName(Object *ob)
{
Mesh *me = (Mesh*)ob->data;
Mesh *me = (Mesh *)ob->data;
int num_layers = CustomData_number_of_layers(&me->fdata, CD_MTFACE);
if (num_layers)
@ -55,24 +55,25 @@ static std::string getActiveUVLayerName(Object *ob)
return "";
}
EffectsExporter::EffectsExporter(COLLADASW::StreamWriter *sw, const ExportSettings *export_settings) : COLLADASW::LibraryEffects(sw), export_settings(export_settings) {}
EffectsExporter::EffectsExporter(COLLADASW::StreamWriter *sw, const ExportSettings *export_settings) : COLLADASW::LibraryEffects(sw), export_settings(export_settings) {
}
bool EffectsExporter::hasEffects(Scene *sce)
{
Base *base = (Base *)sce->base.first;
while (base) {
Object *ob= base->object;
Object *ob = base->object;
int a;
for (a = 0; a < ob->totcol; a++) {
Material *ma = give_current_material(ob, a+1);
Material *ma = give_current_material(ob, a + 1);
// no material, but check all of the slots
if (!ma) continue;
return true;
}
base= base->next;
base = base->next;
}
return false;
}
@ -97,7 +98,7 @@ void EffectsExporter::writeBlinn(COLLADASW::EffectProfile &ep, Material *ma)
ep.setShininess(ma->har, false, "shininess");
// specular
cot = getcol(ma->specr, ma->specg, ma->specb, 1.0f);
ep.setSpecular(cot, false, "specular" );
ep.setSpecular(cot, false, "specular");
}
void EffectsExporter::writeLambert(COLLADASW::EffectProfile &ep, Material *ma)
@ -111,10 +112,10 @@ void EffectsExporter::writePhong(COLLADASW::EffectProfile &ep, Material *ma)
COLLADASW::ColorOrTexture cot;
ep.setShaderType(COLLADASW::EffectProfile::PHONG);
// shininess
ep.setShininess(ma->har, false, "shininess" );
ep.setShininess(ma->har, false, "shininess");
// specular
cot = getcol(ma->specr, ma->specg, ma->specb, 1.0f);
ep.setSpecular(cot, false, "specular" );
ep.setSpecular(cot, false, "specular");
}
void EffectsExporter::operator()(Material *ma, Object *ob)
@ -129,7 +130,7 @@ void EffectsExporter::operator()(Material *ma, Object *ob)
ep.setProfileType(COLLADASW::EffectProfile::COMMON);
ep.openProfile();
// set shader type - one of three blinn, phong or lambert
if (ma->spec>0.0f) {
if (ma->spec > 0.0f) {
if (ma->spec_shader == MA_SPEC_BLINN) {
writeBlinn(ep, ma);
}
@ -168,7 +169,7 @@ void EffectsExporter::operator()(Material *ma, Object *ob)
}
// emission
cot=getcol(ma->emit, ma->emit, ma->emit, 1.0f);
cot = getcol(ma->emit, ma->emit, ma->emit, 1.0f);
ep.setEmission(cot, false, "emission");
// diffuse multiplied by diffuse intensity
@ -178,7 +179,7 @@ void EffectsExporter::operator()(Material *ma, Object *ob)
// ambient
/* ma->ambX is calculated only on render, so lets do it here manually and not rely on ma->ambX. */
if (this->scene->world)
cot = getcol(this->scene->world->ambr*ma->amb, this->scene->world->ambg*ma->amb, this->scene->world->ambb*ma->amb, 1.0f);
cot = getcol(this->scene->world->ambr * ma->amb, this->scene->world->ambg * ma->amb, this->scene->world->ambb * ma->amb, 1.0f);
else
cot = getcol(ma->amb, ma->amb, ma->amb, 1.0f);
@ -273,7 +274,7 @@ void EffectsExporter::operator()(Material *ma, Object *ob)
std::string key(id_name(ima));
key = translate_id(key);
int i = im_samp_map[key];
COLLADASW::Sampler *sampler = (COLLADASW::Sampler*)samp_surf[i][0];
COLLADASW::Sampler *sampler = (COLLADASW::Sampler *)samp_surf[i][0];
//COLLADASW::Surface *surface = (COLLADASW::Surface*)samp_surf[i][1];
std::string uvname = strlen(t->uvname) ? t->uvname : active_uv;
@ -320,7 +321,7 @@ void EffectsExporter::operator()(Material *ma, Object *ob)
ep.addProfileElements();
bool twoSided = false;
if (ob->type == OB_MESH && ob->data) {
Mesh *me = (Mesh*)ob->data;
Mesh *me = (Mesh *)ob->data;
if (me->flag & ME_TWOSIDED)
twoSided = true;
}

@ -45,36 +45,36 @@ ErrorHandler::~ErrorHandler()
}
//--------------------------------------------------------------------
bool ErrorHandler::handleError( const COLLADASaxFWL::IError* error )
bool ErrorHandler::handleError(const COLLADASaxFWL::IError *error)
{
mError = true;
if ( error->getErrorClass() == COLLADASaxFWL::IError::ERROR_SAXPARSER ) {
COLLADASaxFWL::SaxParserError* saxParserError = (COLLADASaxFWL::SaxParserError*) error;
if (error->getErrorClass() == COLLADASaxFWL::IError::ERROR_SAXPARSER) {
COLLADASaxFWL::SaxParserError *saxParserError = (COLLADASaxFWL::SaxParserError *) error;
const GeneratedSaxParser::ParserError& parserError = saxParserError->getError();
// Workaround to avoid wrong error
if ( parserError.getErrorType() == GeneratedSaxParser::ParserError::ERROR_VALIDATION_MIN_OCCURS_UNMATCHED) {
if ( strcmp(parserError.getElement(), "effect") == 0 ) {
if (parserError.getErrorType() == GeneratedSaxParser::ParserError::ERROR_VALIDATION_MIN_OCCURS_UNMATCHED) {
if (strcmp(parserError.getElement(), "effect") == 0) {
mError = false;
}
}
if ( parserError.getErrorType() == GeneratedSaxParser::ParserError::ERROR_VALIDATION_SEQUENCE_PREVIOUS_SIBLING_NOT_PRESENT) {
if ( !((strcmp(parserError.getElement(), "extra") == 0) &&
if (parserError.getErrorType() == GeneratedSaxParser::ParserError::ERROR_VALIDATION_SEQUENCE_PREVIOUS_SIBLING_NOT_PRESENT) {
if (!((strcmp(parserError.getElement(), "extra") == 0) &&
(strcmp(parserError.getAdditionalText().c_str(), "sibling: fx_profile_abstract") == 0)))
{
mError = false;
}
}
if ( parserError.getErrorType() == GeneratedSaxParser::ParserError::ERROR_COULD_NOT_OPEN_FILE) {
if (parserError.getErrorType() == GeneratedSaxParser::ParserError::ERROR_COULD_NOT_OPEN_FILE) {
std::cout << "Couldn't open file" << std::endl;
}
std::cout << "Schema validation error: " << parserError.getErrorMessage() << std::endl;
}
else if ( error->getErrorClass() == COLLADASaxFWL::IError::ERROR_SAXFWL ) {
COLLADASaxFWL::SaxFWLError* saxFWLError = (COLLADASaxFWL::SaxFWLError*) error;
else if (error->getErrorClass() == COLLADASaxFWL::IError::ERROR_SAXFWL) {
COLLADASaxFWL::SaxFWLError *saxFWLError = (COLLADASaxFWL::SaxFWLError *) error;
std::cout << "Sax FWL Error: " << saxFWLError->getErrorMessage() << std::endl;
}
else {

@ -35,9 +35,10 @@ ExtraHandler::ExtraHandler(DocumentImporter *dimp, AnimationImporter *aimp) : cu
this->aimp = aimp;
}
ExtraHandler::~ExtraHandler() {}
ExtraHandler::~ExtraHandler() {
}
bool ExtraHandler::elementBegin( const char* elementName, const char** attributes)
bool ExtraHandler::elementBegin(const char *elementName, const char **attributes)
{
// \todo attribute handling for profile tags
currentElement = std::string(elementName);
@ -45,26 +46,27 @@ bool ExtraHandler::elementBegin( const char* elementName, const char** attribute
return true;
}
bool ExtraHandler::elementEnd(const char* elementName )
bool ExtraHandler::elementEnd(const char *elementName)
{
return true;
}
bool ExtraHandler::textData(const char* text, size_t textLength)
bool ExtraHandler::textData(const char *text, size_t textLength)
{
char buf[1024];
if (currentElement.length() == 0 || currentExtraTags == 0) return false;
BLI_snprintf(buf, textLength+1, "%s", text);
BLI_snprintf(buf, textLength + 1, "%s", text);
currentExtraTags->addTag(currentElement, std::string(buf));
return true;
}
bool ExtraHandler::parseElement (
const char* profileName,
bool ExtraHandler::parseElement(
const char *profileName,
const unsigned long& elementHash,
const COLLADAFW::UniqueId& uniqueId ) {
const COLLADAFW::UniqueId& uniqueId)
{
if (BLI_strcaseeq(profileName, "blender")) {
//printf("In parseElement for supported profile %s for id %s\n", profileName, uniqueId.toAscii().c_str());
currentUid = uniqueId;

@ -32,7 +32,7 @@
#include "ExtraTags.h"
ExtraTags::ExtraTags( std::string profile)
ExtraTags::ExtraTags(std::string profile)
{
this->profile = profile;
this->tags = std::map<std::string, std::string>();
@ -42,19 +42,19 @@ ExtraTags::~ExtraTags()
{
}
bool ExtraTags::isProfile( std::string profile)
bool ExtraTags::isProfile(std::string profile)
{
return this->profile == profile;
}
bool ExtraTags::addTag( std::string tag, std::string data)
bool ExtraTags::addTag(std::string tag, std::string data)
{
tags[tag] = data;
return true;
}
int ExtraTags::asInt( std::string tag, bool *ok)
int ExtraTags::asInt(std::string tag, bool *ok)
{
if (tags.find(tag) == tags.end()) {
*ok = false;
@ -64,7 +64,7 @@ int ExtraTags::asInt( std::string tag, bool *ok)
return atoi(tags[tag].c_str());
}
float ExtraTags::asFloat( std::string tag, bool *ok)
float ExtraTags::asFloat(std::string tag, bool *ok)
{
if (tags.find(tag) == tags.end()) {
*ok = false;
@ -74,7 +74,7 @@ float ExtraTags::asFloat( std::string tag, bool *ok)
return (float)atof(tags[tag].c_str());
}
std::string ExtraTags::asString( std::string tag, bool *ok)
std::string ExtraTags::asString(std::string tag, bool *ok)
{
if (tags.find(tag) == tags.end()) {
*ok = false;

@ -52,7 +52,8 @@ extern "C" {
#include "collada_utils.h"
// TODO: optimize UV sets by making indexed list with duplicates removed
GeometryExporter::GeometryExporter(COLLADASW::StreamWriter *sw, const ExportSettings *export_settings) : COLLADASW::LibraryGeometries(sw), export_settings(export_settings) {}
GeometryExporter::GeometryExporter(COLLADASW::StreamWriter *sw, const ExportSettings *export_settings) : COLLADASW::LibraryGeometries(sw), export_settings(export_settings) {
}
void GeometryExporter::exportGeom(Scene *sce)
@ -76,11 +77,11 @@ void GeometryExporter::operator()(Object *ob)
bool use_instantiation = this->export_settings->use_object_instantiation;
Mesh *me;
if ( this->export_settings->apply_modifiers ) {
if (this->export_settings->apply_modifiers) {
me = bc_to_mesh_apply_modifiers(mScene, ob);
}
else {
me = (Mesh*)ob->data;
me = (Mesh *)ob->data;
}
BKE_mesh_tessface_ensure(me);
@ -91,7 +92,9 @@ void GeometryExporter::operator()(Object *ob)
// Skip if linked geometry was already exported from another reference
if (use_instantiation &&
exportedGeometry.find(geom_id) != exportedGeometry.end())
{
return;
}
std::string geom_name = (use_instantiation) ? id_name(ob->data) : id_name(ob);
@ -204,8 +207,8 @@ void GeometryExporter::createLooseEdgeList(Object *ob,
for (index = 0; index < edges_in_linelist; index++)
{
lines.appendValues(edge_list[2*index+1]);
lines.appendValues(edge_list[2*index]);
lines.appendValues(edge_list[2 * index + 1]);
lines.appendValues(edge_list[2 * index]);
}
lines.finish();
}
@ -388,7 +391,7 @@ void GeometryExporter::createVertexColorSource(std::string geom_id, Mesh *me)
int index = CustomData_get_active_layer_index(&me->fdata, CD_MCOL);
MCol *mcol = (MCol*)me->fdata.layers[index].data;
MCol *mcol = (MCol *)me->fdata.layers[index].data;
MCol *c = mcol;
for (i = 0, f = me->mface; i < me->totface; i++, c += 4, f++)
@ -422,10 +425,10 @@ void GeometryExporter::createTexcoordsSource(std::string geom_id, Mesh *me)
for (i = 0; i < totfaces; i++) {
MFace *f = &mfaces[i];
if (f->v4 == 0) {
totuv+=3;
totuv += 3;
}
else {
totuv+=4;
totuv += 4;
}
}
@ -434,7 +437,7 @@ void GeometryExporter::createTexcoordsSource(std::string geom_id, Mesh *me)
// write <source> for each layer
// each <source> will get id like meshName + "map-channel-1"
for (int a = 0; a < num_layers; a++) {
MTFace *tface = (MTFace*)CustomData_get_layer_n(&me->fdata, CD_MTFACE, a);
MTFace *tface = (MTFace *)CustomData_get_layer_n(&me->fdata, CD_MTFACE, a);
// char *name = CustomData_get_layer_name(&me->fdata, CD_MTFACE, a);
COLLADASW::FloatSourceF source(mSW);
@ -563,8 +566,9 @@ COLLADASW::URI GeometryExporter::makeUrl(std::string id)
return COLLADASW::URI(COLLADABU::Utils::EMPTY_STRING, id);
}
/* int GeometryExporter::getTriCount(MFace *faces, int totface) {
#if 0
int GeometryExporter::getTriCount(MFace *faces, int totface)
{
int i;
int tris = 0;
for (i = 0; i < totface; i++) {
@ -576,4 +580,5 @@ COLLADASW::URI GeometryExporter::makeUrl(std::string id)
}
return tris;
}*/
}
#endif

@ -42,17 +42,19 @@
#include "BLI_string.h"
ImagesExporter::ImagesExporter(COLLADASW::StreamWriter *sw, const ExportSettings *export_settings) : COLLADASW::LibraryImages(sw), export_settings(export_settings)
{}
{
}
/* TODO - shouldn't this use the objects LinkNode's ? */
bool ImagesExporter::hasImages(Scene *sce)
{
Base *base = (Base *)sce->base.first;
while (base) {
Object *ob= base->object;
Object *ob = base->object;
int a;
for (a = 0; a < ob->totcol; a++) {
Material *ma = give_current_material(ob, a+1);
Material *ma = give_current_material(ob, a + 1);
// no material, but check all of the slots
if (!ma) continue;
@ -63,7 +65,7 @@ bool ImagesExporter::hasImages(Scene *sce)
}
}
base= base->next;
base = base->next;
}
return false;
}

@ -44,7 +44,7 @@
void InstanceWriter::add_material_bindings(COLLADASW::BindMaterial& bind_material, Object *ob)
{
for (int a = 0; a < ob->totcol; a++) {
Material *ma = give_current_material(ob, a+1);
Material *ma = give_current_material(ob, a + 1);
COLLADASW::InstanceMaterialList& iml = bind_material.getInstanceMaterialList();
@ -56,7 +56,7 @@ void InstanceWriter::add_material_bindings(COLLADASW::BindMaterial& bind_materia
COLLADASW::InstanceMaterial im(ostr.str(), COLLADASW::URI(COLLADABU::Utils::EMPTY_STRING, matid));
// create <bind_vertex_input> for each uv map
Mesh *me = (Mesh*)ob->data;
Mesh *me = (Mesh *)ob->data;
int totlayer = CustomData_number_of_layers(&me->fdata, CD_MTFACE);
for (int b = 0; b < totlayer; b++) {

@ -39,7 +39,7 @@ template<class Functor>
void forEachLampObjectInExportSet(Scene *sce, Functor &f, LinkNode *export_set)
{
LinkNode *node;
for (node=export_set; node; node = node->next) {
for (node = export_set; node; node = node->next) {
Object *ob = (Object *)node->link;
if (ob->type == OB_LAMP && ob->data) {
@ -48,7 +48,8 @@ void forEachLampObjectInExportSet(Scene *sce, Functor &f, LinkNode *export_set)
}
}
LightsExporter::LightsExporter(COLLADASW::StreamWriter *sw, const ExportSettings *export_settings): COLLADASW::LibraryLights(sw), export_settings(export_settings) {}
LightsExporter::LightsExporter(COLLADASW::StreamWriter *sw, const ExportSettings *export_settings) : COLLADASW::LibraryLights(sw), export_settings(export_settings) {
}
void LightsExporter::exportLights(Scene *sce)
{
@ -61,7 +62,7 @@ void LightsExporter::exportLights(Scene *sce)
void LightsExporter::operator()(Object *ob)
{
Lamp *la = (Lamp*)ob->data;
Lamp *la = (Lamp *)ob->data;
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);
@ -71,7 +72,7 @@ void LightsExporter::operator()(Object *ob)
constatt = 1.0f;
if (la->falloff_type==LA_FALLOFF_INVLINEAR) {
if (la->falloff_type == LA_FALLOFF_INVLINEAR) {
linatt = 1.0f / d;
quadatt = 0.0f;
}

@ -31,7 +31,8 @@
#include "COLLADABUUtils.h"
#include "collada_internal.h"
MaterialsExporter::MaterialsExporter(COLLADASW::StreamWriter *sw, const ExportSettings *export_settings): COLLADASW::LibraryMaterials(sw), export_settings(export_settings) {}
MaterialsExporter::MaterialsExporter(COLLADASW::StreamWriter *sw, const ExportSettings *export_settings) : COLLADASW::LibraryMaterials(sw), export_settings(export_settings) {
}
void MaterialsExporter::exportMaterials(Scene *sce)
{
@ -45,23 +46,23 @@ void MaterialsExporter::exportMaterials(Scene *sce)
}
}
/* TODO - shouldn't this use the scenes object LinkNode's ? */
bool MaterialsExporter::hasMaterials(Scene *sce)
{
Base *base = (Base *)sce->base.first;
while (base) {
Object *ob= base->object;
Object *ob = base->object;
int a;
for (a = 0; a < ob->totcol; a++) {
Material *ma = give_current_material(ob, a+1);
Material *ma = give_current_material(ob, a + 1);
// no material, but check all of the slots
if (!ma) continue;
return true;
}
base= base->next;
base = base->next;
}
return false;
}

@ -111,7 +111,8 @@ static const char *bc_geomTypeToStr(COLLADAFW::Geometry::GeometryType type)
UVDataWrapper::UVDataWrapper(COLLADAFW::MeshVertexData& vdata) : mVData(&vdata)
{}
{
}
#ifdef COLLADA_DEBUG
void WVDataWrapper::print()
@ -120,20 +121,20 @@ void WVDataWrapper::print()
switch (mVData->getType()) {
case COLLADAFW::MeshVertexData::DATA_TYPE_FLOAT:
{
COLLADAFW::ArrayPrimitiveType<float>* values = mVData->getFloatValues();
COLLADAFW::ArrayPrimitiveType<float> *values = mVData->getFloatValues();
if (values->getCount()) {
for (int i = 0; i < values->getCount(); i += 2) {
fprintf(stderr, "%.1f, %.1f\n", (*values)[i], (*values)[i+1]);
fprintf(stderr, "%.1f, %.1f\n", (*values)[i], (*values)[i + 1]);
}
}
}
break;
case COLLADAFW::MeshVertexData::DATA_TYPE_DOUBLE:
{
COLLADAFW::ArrayPrimitiveType<double>* values = mVData->getDoubleValues();
COLLADAFW::ArrayPrimitiveType<double> *values = mVData->getDoubleValues();
if (values->getCount()) {
for (int i = 0; i < values->getCount(); i += 2) {
fprintf(stderr, "%.1f, %.1f\n", (float)(*values)[i], (float)(*values)[i+1]);
fprintf(stderr, "%.1f, %.1f\n", (float)(*values)[i], (float)(*values)[i + 1]);
}
}
}
@ -146,24 +147,24 @@ void WVDataWrapper::print()
void UVDataWrapper::getUV(int uv_index, float *uv)
{
int stride = mVData->getStride(0);
if (stride==0) stride = 2;
if (stride == 0) stride = 2;
switch (mVData->getType()) {
case COLLADAFW::MeshVertexData::DATA_TYPE_FLOAT:
{
COLLADAFW::ArrayPrimitiveType<float>* values = mVData->getFloatValues();
COLLADAFW::ArrayPrimitiveType<float> *values = mVData->getFloatValues();
if (values->empty()) return;
uv[0] = (*values)[uv_index*stride];
uv[1] = (*values)[uv_index*stride + 1];
uv[0] = (*values)[uv_index * stride];
uv[1] = (*values)[uv_index * stride + 1];
}
break;
case COLLADAFW::MeshVertexData::DATA_TYPE_DOUBLE:
{
COLLADAFW::ArrayPrimitiveType<double>* values = mVData->getDoubleValues();
COLLADAFW::ArrayPrimitiveType<double> *values = mVData->getDoubleValues();
if (values->empty()) return;
uv[0] = (float)(*values)[uv_index*stride];
uv[1] = (float)(*values)[uv_index*stride + 1];
uv[0] = (float)(*values)[uv_index * stride];
uv[1] = (float)(*values)[uv_index * stride + 1];
}
break;
@ -279,7 +280,7 @@ bool MeshImporter::is_nice_mesh(COLLADAFW::Mesh *mesh) // checks if mesh has sup
// OpenCollada passes POLYGONS type for <polylist>
if (type == COLLADAFW::MeshPrimitive::POLYLIST || type == COLLADAFW::MeshPrimitive::POLYGONS) {
COLLADAFW::Polygons *mpvc = (COLLADAFW::Polygons*)mp;
COLLADAFW::Polygons *mpvc = (COLLADAFW::Polygons *)mp;
COLLADAFW::Polygons::VertexCountArray& vca = mpvc->getGroupedVerticesVertexCountArray();
for (unsigned int j = 0; j < vca.getCount(); j++) {
@ -293,12 +294,12 @@ bool MeshImporter::is_nice_mesh(COLLADAFW::Mesh *mesh) // checks if mesh has sup
}
else if ( type == COLLADAFW::MeshPrimitive::LINES )
else if (type == COLLADAFW::MeshPrimitive::LINES)
{
// TODO: Add Checker for line syntax here
}
else if (type != COLLADAFW::MeshPrimitive::TRIANGLES && type!= COLLADAFW::MeshPrimitive::TRIANGLE_FANS) {
else if (type != COLLADAFW::MeshPrimitive::TRIANGLES && type != COLLADAFW::MeshPrimitive::TRIANGLE_FANS) {
fprintf(stderr, "Primitive type %s is not supported.\n", type_str);
return false;
}
@ -317,10 +318,10 @@ void MeshImporter::read_vertices(COLLADAFW::Mesh *mesh, Mesh *me)
// vertices
COLLADAFW::MeshVertexData& pos = mesh->getPositions();
int stride = pos.getStride(0);
if (stride==0) stride = 3;
if (stride == 0) stride = 3;
me->totvert = mesh->getPositions().getFloatValues()->getCount() / stride;
me->mvert = (MVert*)CustomData_add_layer(&me->vdata, CD_MVERT, CD_CALLOC, NULL, me->totvert);
me->mvert = (MVert *)CustomData_add_layer(&me->vdata, CD_MVERT, CD_CALLOC, NULL, me->totvert);
MVert *mvert;
int i;
@ -339,12 +340,12 @@ int MeshImporter::triangulate_poly(unsigned int *indices, int totvert, MVert *ve
dispbase.first = dispbase.last = NULL;
dl = (DispList*)MEM_callocN(sizeof(DispList), "poly disp");
dl = (DispList *)MEM_callocN(sizeof(DispList), "poly disp");
dl->nr = totvert;
dl->type = DL_POLY;
dl->parts = 1;
dl->verts = vert = (float*)MEM_callocN(totvert * 3 * sizeof(float), "poly verts");
dl->index = (int*)MEM_callocN(sizeof(int) * 3 * totvert, "dl index");
dl->verts = vert = (float *)MEM_callocN(totvert * 3 * sizeof(float), "poly verts");
dl->index = (int *)MEM_callocN(sizeof(int) * 3 * totvert, "dl index");
BLI_addtail(&dispbase, dl);
@ -356,14 +357,14 @@ int MeshImporter::triangulate_poly(unsigned int *indices, int totvert, MVert *ve
BKE_displist_fill(&dispbase, &dispbase, 0);
int tottri = 0;
dl= (DispList*)dispbase.first;
dl = (DispList *)dispbase.first;
if (dl->type == DL_INDEX3) {
tottri = dl->parts;
int *index = dl->index;
for (i= 0; i < tottri; i++) {
int t[3]= {*index, *(index + 1), *(index + 2)};
for (i = 0; i < tottri; i++) {
int t[3] = {*index, *(index + 1), *(index + 2)};
std::sort(t, t + 3);
@ -394,9 +395,9 @@ int MeshImporter::count_new_tris(COLLADAFW::Mesh *mesh, Mesh *me)
unsigned int *indices = mp->getPositionIndices().getData();
if (type == COLLADAFW::MeshPrimitive::POLYLIST ||
type == COLLADAFW::MeshPrimitive::POLYGONS) {
COLLADAFW::Polygons *mpvc = (COLLADAFW::Polygons*)mp;
type == COLLADAFW::MeshPrimitive::POLYGONS)
{
COLLADAFW::Polygons *mpvc = (COLLADAFW::Polygons *)mp;
COLLADAFW::Polygons::VertexCountArray& vcounta = mpvc->getGroupedVerticesVertexCountArray();
for (unsigned int j = 0; j < prim_totface; j++) {
@ -434,7 +435,7 @@ bool MeshImporter::primitive_has_useable_normals(COLLADAFW::MeshPrimitive *mp) {
else {
fprintf(stderr,
"Warning: Number of normals %d is different from the number of vertices %d, skipping normals\n",
normals_count, index_count );
normals_count, index_count);
}
}
@ -496,7 +497,7 @@ void MeshImporter::allocate_face_data(COLLADAFW::Mesh *mesh, Mesh *me, int new_t
// allocate space for faces
if (total_facecount > 0) {
me->totface = total_facecount + new_tris;
me->mface = (MFace*)CustomData_add_layer(&me->fdata, CD_MFACE, CD_CALLOC, NULL, me->totface);
me->mface = (MFace *)CustomData_add_layer(&me->fdata, CD_MFACE, CD_CALLOC, NULL, me->totface);
}
}
@ -566,7 +567,7 @@ void MeshImporter::mesh_add_edges(Mesh *mesh, int len)
void MeshImporter::read_lines(COLLADAFW::Mesh *mesh, Mesh *me)
{
unsigned int loose_edge_count = get_loose_edge_count(mesh);
if(loose_edge_count > 0) {
if (loose_edge_count > 0) {
unsigned int face_edge_count = me->totedge;
unsigned int total_edge_count = loose_edge_count + face_edge_count;
@ -587,11 +588,11 @@ void MeshImporter::read_lines(COLLADAFW::Mesh *mesh, Mesh *me)
unsigned int *indices = mp->getPositionIndices().getData();
for (int i = 0; i < edge_count; i++, med++) {
med->bweight= 0;
med->bweight = 0;
med->crease = 0;
med->flag = 0;
med->v1 = indices[ 2*i ];
med->v2 = indices[ 2*i + 1];
med->v1 = indices[2 * i];
med->v2 = indices[2 * i + 1];
}
}
}
@ -630,7 +631,7 @@ void MeshImporter::read_faces(COLLADAFW::Mesh *mesh, Mesh *me, int new_tris) //T
}
// activate the first uv map
if (totuvset) me->mtface = (MTFace*)CustomData_get_layer_n(&me->fdata, CD_MTFACE, 0);
if (totuvset) me->mtface = (MTFace *)CustomData_get_layer_n(&me->fdata, CD_MTFACE, 0);
UVDataWrapper uvs(mesh->getUVCoords());
@ -686,14 +687,14 @@ void MeshImporter::read_faces(COLLADAFW::Mesh *mesh, Mesh *me, int new_tris) //T
for (unsigned int k = 0; k < totuvset; k++) {
if (!index_list_array.empty() && index_list_array[k]) {
// get mtface by face index and uv set index
MTFace *mtface = (MTFace*)CustomData_get_layer_n(&me->fdata, CD_MTFACE, k);
MTFace *mtface = (MTFace *)CustomData_get_layer_n(&me->fdata, CD_MTFACE, k);
set_face_uv(&mtface[face_index], uvs, k, *index_list_array[k], index, false);
}
}
#else
for (unsigned int k = 0; k < index_list_array.getCount(); k++) {
// get mtface by face index and uv set index
MTFace *mtface = (MTFace*)CustomData_get_layer_n(&me->fdata, CD_MTFACE, k);
MTFace *mtface = (MTFace *)CustomData_get_layer_n(&me->fdata, CD_MTFACE, k);
set_face_uv(&mtface[face_index], uvs, *index_list_array[k], index, false);
}
#endif
@ -725,13 +726,13 @@ void MeshImporter::read_faces(COLLADAFW::Mesh *mesh, Mesh *me, int new_tris) //T
for (unsigned int vertex_index = 0; vertex_index < vertex_count - 2; vertex_index++) {
// For each triangle store indeces of its 3 vertices
unsigned int triangle_vertex_indices[3]={first_vertex, indices[1], indices[2]};
unsigned int triangle_vertex_indices[3] = {first_vertex, indices[1], indices[2]};
set_face_indices(mface, triangle_vertex_indices, false);
test_index_face(mface, &me->fdata, face_index, 3);
if (mp_has_normals) { // vertex normals, same inplementation as for the triangles
// the same for vertces normals
unsigned int vertex_normal_indices[3]={first_normal, nind[1], nind[2]};
unsigned int vertex_normal_indices[3] = {first_normal, nind[1], nind[2]};
if (!flat_face(vertex_normal_indices, nor, 3))
mface->flag |= ME_SMOOTH;
nind++;
@ -751,7 +752,7 @@ void MeshImporter::read_faces(COLLADAFW::Mesh *mesh, Mesh *me, int new_tris) //T
}
}
else if (type == COLLADAFW::MeshPrimitive::POLYLIST || type == COLLADAFW::MeshPrimitive::POLYGONS) {
COLLADAFW::Polygons *mpvc = (COLLADAFW::Polygons*)mp;
COLLADAFW::Polygons *mpvc = (COLLADAFW::Polygons *)mp;
COLLADAFW::Polygons::VertexCountArray& vcounta = mpvc->getGroupedVerticesVertexCountArray();
for (unsigned int j = 0; j < prim_totface; j++) {
@ -769,14 +770,14 @@ void MeshImporter::read_faces(COLLADAFW::Mesh *mesh, Mesh *me, int new_tris) //T
for (unsigned int k = 0; k < totuvset; k++) {
if (!index_list_array.empty() && index_list_array[k]) {
// get mtface by face index and uv set index
MTFace *mtface = (MTFace*)CustomData_get_layer_n(&me->fdata, CD_MTFACE, k);
MTFace *mtface = (MTFace *)CustomData_get_layer_n(&me->fdata, CD_MTFACE, k);
set_face_uv(&mtface[face_index], uvs, k, *index_list_array[k], index, mface->v4 != 0);
}
}
#else
for (unsigned int k = 0; k < index_list_array.getCount(); k++) {
// get mtface by face index and uv set index
MTFace *mtface = (MTFace*)CustomData_get_layer_n(&me->fdata, CD_MTFACE, k);
MTFace *mtface = (MTFace *)CustomData_get_layer_n(&me->fdata, CD_MTFACE, k);
set_face_uv(&mtface[face_index], uvs, *index_list_array[k], index, vcount == 4);
}
#endif
@ -819,7 +820,7 @@ void MeshImporter::read_faces(COLLADAFW::Mesh *mesh, Mesh *me, int new_tris) //T
for (unsigned int l = 0; l < totuvset; l++) {
if (!index_list_array.empty() && index_list_array[l]) {
// get mtface by face index and uv set index
MTFace *mtface = (MTFace*)CustomData_get_layer_n(&me->fdata, CD_MTFACE, l);
MTFace *mtface = (MTFace *)CustomData_get_layer_n(&me->fdata, CD_MTFACE, l);
set_face_uv(&mtface[face_index], uvs, l, *index_list_array[l], uv_indices);
}
}
@ -828,7 +829,7 @@ void MeshImporter::read_faces(COLLADAFW::Mesh *mesh, Mesh *me, int new_tris) //T
int uvset_index = index_list_array[l]->getSetIndex();
// get mtface by face index and uv set index
MTFace *mtface = (MTFace*)CustomData_get_layer_n(&me->fdata, CD_MTFACE, uvset_index);
MTFace *mtface = (MTFace *)CustomData_get_layer_n(&me->fdata, CD_MTFACE, uvset_index);
set_face_uv(&mtface[face_index], uvs, *index_list_array[l], uv_indices);
}
#endif
@ -875,7 +876,7 @@ void MeshImporter::get_vector(float v[3], COLLADAFW::MeshVertexData& arr, int i,
switch (arr.getType()) {
case COLLADAFW::MeshVertexData::DATA_TYPE_FLOAT:
{
COLLADAFW::ArrayPrimitiveType<float>* values = arr.getFloatValues();
COLLADAFW::ArrayPrimitiveType<float> *values = arr.getFloatValues();
if (values->empty()) return;
v[0] = (*values)[i++];
@ -886,7 +887,7 @@ void MeshImporter::get_vector(float v[3], COLLADAFW::MeshVertexData& arr, int i,
break;
case COLLADAFW::MeshVertexData::DATA_TYPE_DOUBLE:
{
COLLADAFW::ArrayPrimitiveType<double>* values = arr.getDoubleValues();
COLLADAFW::ArrayPrimitiveType<double> *values = arr.getDoubleValues();
if (values->empty()) return;
v[0] = (float)(*values)[i++];
@ -921,11 +922,12 @@ bool MeshImporter::flat_face(unsigned int *nind, COLLADAFW::MeshVertexData& nor,
return true;
}
MeshImporter::MeshImporter(UnitConverter *unitconv, ArmatureImporter *arm, Scene *sce) : unitconverter(unitconv), scene(sce), armature_importer(arm) {}
MeshImporter::MeshImporter(UnitConverter *unitconv, ArmatureImporter *arm, Scene *sce) : unitconverter(unitconv), scene(sce), armature_importer(arm) {
}
void MeshImporter::bmeshConversion()
{
for (std::map<COLLADAFW::UniqueId, Mesh*>::iterator m = uid_mesh_map.begin();
for (std::map<COLLADAFW::UniqueId, Mesh *>::iterator m = uid_mesh_map.begin();
m != uid_mesh_map.end(); ++m)
{
if ((*m).second) {
@ -954,14 +956,14 @@ MTex *MeshImporter::assign_textures_to_uvlayer(COLLADAFW::TextureCoordinateBindi
size_t setindex = ctexture.getSetIndex();
std::string uvname = ctexture.getSemantic();
if (setindex==-1) return NULL;
if (setindex == -1) return NULL;
const CustomData *data = &me->fdata;
int layer_index = CustomData_get_layer_index(data, CD_MTFACE);
if (layer_index == -1) return NULL;
CustomDataLayer *cdl = &data->layers[layer_index+setindex];
CustomDataLayer *cdl = &data->layers[layer_index + setindex];
/* set uvname to bind_vertex_input semantic */
BLI_strncpy(cdl->name, uvname.c_str(), sizeof(cdl->name));
@ -972,9 +974,9 @@ MTex *MeshImporter::assign_textures_to_uvlayer(COLLADAFW::TextureCoordinateBindi
return color_texture;
}
std::vector<MTex*> textures = texindex_texarray_map[texture_index];
std::vector<MTex *> textures = texindex_texarray_map[texture_index];
std::vector<MTex*>::iterator it;
std::vector<MTex *>::iterator it;
for (it = textures.begin(); it != textures.end(); it++) {
@ -989,12 +991,12 @@ MTex *MeshImporter::assign_textures_to_uvlayer(COLLADAFW::TextureCoordinateBindi
}
MTFace *MeshImporter::assign_material_to_geom(COLLADAFW::MaterialBinding cmaterial,
std::map<COLLADAFW::UniqueId, Material*>& uid_material_map,
std::map<COLLADAFW::UniqueId, Material *>& uid_material_map,
Object *ob, const COLLADAFW::UniqueId *geom_uid,
MTex **color_texture, char *layername, MTFace *texture_face,
std::map<Material*, TexIndexTextureArrayMap>& material_texture_mapping_map, short mat_index)
std::map<Material *, TexIndexTextureArrayMap>& material_texture_mapping_map, short mat_index)
{
Mesh *me = (Mesh*)ob->data;
Mesh *me = (Mesh *)ob->data;
const COLLADAFW::UniqueId& ma_uid = cmaterial.getReferencedMaterial();
// do we know this material?
@ -1008,8 +1010,8 @@ MTFace *MeshImporter::assign_material_to_geom(COLLADAFW::MaterialBinding cmateri
// again. Make sure we don't overwrite them on the next occurrences, so keep list of
// what we already have handled.
std::multimap<COLLADAFW::UniqueId, COLLADAFW::UniqueId>::iterator it;
it=materials_mapped_to_geom.find(*geom_uid);
while (it!=materials_mapped_to_geom.end()) {
it = materials_mapped_to_geom.find(*geom_uid);
while (it != materials_mapped_to_geom.end()) {
if (it->second == ma_uid && it->first == *geom_uid) return NULL; // do nothing if already found
it++;
}
@ -1034,7 +1036,7 @@ 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,
texture_face = (MTFace *)CustomData_get_layer_named(&me->fdata, CD_MTFACE,
(*color_texture)->uvname);
strcpy(layername, (*color_texture)->uvname);
}
@ -1057,7 +1059,7 @@ MTFace *MeshImporter::assign_material_to_geom(COLLADAFW::MaterialBinding cmateri
mface->mat_nr = mat_index;
// bind texture images to faces
if (texture_face && (*color_texture)) {
texture_face->tpage = (Image*)(*color_texture)->tex->ima;
texture_face->tpage = (Image *)(*color_texture)->tex->ima;
texture_face++;
}
}
@ -1069,8 +1071,8 @@ MTFace *MeshImporter::assign_material_to_geom(COLLADAFW::MaterialBinding cmateri
Object *MeshImporter::create_mesh_object(COLLADAFW::Node *node, COLLADAFW::InstanceGeometry *geom,
bool isController,
std::map<COLLADAFW::UniqueId, Material*>& uid_material_map,
std::map<Material*, TexIndexTextureArrayMap>& material_texture_mapping_map)
std::map<COLLADAFW::UniqueId, Material *>& uid_material_map,
std::map<Material *, TexIndexTextureArrayMap>& material_texture_mapping_map)
{
const COLLADAFW::UniqueId *geom_uid = &geom->getInstanciatedObjectId();
@ -1097,7 +1099,7 @@ Object *MeshImporter::create_mesh_object(COLLADAFW::Node *node, COLLADAFW::Insta
// name Object
const std::string& id = node->getName().size() ? node->getName() : node->getOriginalId();
const char *name = (id.length())? id.c_str(): NULL;
const char *name = (id.length()) ? id.c_str() : NULL;
// add object
Object *ob = bc_add_object(scene, OB_MESH, name);
@ -1106,7 +1108,7 @@ Object *MeshImporter::create_mesh_object(COLLADAFW::Node *node, COLLADAFW::Insta
uid_object_map[*geom_uid] = ob;
// replace ob->data freeing the old one
Mesh *old_mesh = (Mesh*)ob->data;
Mesh *old_mesh = (Mesh *)ob->data;
set_mesh(ob, uid_mesh_map[*geom_uid]);
@ -1137,7 +1139,7 @@ Object *MeshImporter::create_mesh_object(COLLADAFW::Node *node, COLLADAFW::Insta
}
// create a mesh storing a pointer in a map so it can be retrieved later by geometry UID
bool MeshImporter::write_geometry(const COLLADAFW::Geometry* geom)
bool MeshImporter::write_geometry(const COLLADAFW::Geometry *geom)
{
// TODO: import also uvs, normals
// XXX what to do with normal indices?
@ -1150,7 +1152,7 @@ bool MeshImporter::write_geometry(const COLLADAFW::Geometry* geom)
return true;
}
COLLADAFW::Mesh *mesh = (COLLADAFW::Mesh*)geom;
COLLADAFW::Mesh *mesh = (COLLADAFW::Mesh *)geom;
if (!is_nice_mesh(mesh)) {
fprintf(stderr, "Ignoring mesh %s\n", bc_get_dae_name(mesh));
@ -1158,7 +1160,7 @@ bool MeshImporter::write_geometry(const COLLADAFW::Geometry* geom)
}
const std::string& str_geom_id = mesh->getName().size() ? mesh->getName() : mesh->getOriginalId();
Mesh *me = BKE_mesh_add((char*)str_geom_id.c_str());
Mesh *me = BKE_mesh_add((char *)str_geom_id.c_str());
me->id.us--; // is already 1 here, but will be set later in set_mesh
// store the Mesh pointer to link it later with an Object

@ -30,7 +30,8 @@
SceneExporter::SceneExporter(COLLADASW::StreamWriter *sw, ArmatureExporter *arm, const ExportSettings *export_settings)
: COLLADASW::LibraryVisualScenes(sw), arm_exporter(arm), export_settings(export_settings)
{}
{
}
void SceneExporter::exportScene(Scene *sce)
{
@ -48,14 +49,14 @@ void SceneExporter::exportHierarchy(Scene *sce)
std::vector<Object *> base_objects;
// Ensure all objects in the export_set are marked
for(node = this->export_settings->export_set; node; node = node->next) {
Object *ob = (Object*) node->link;
for (node = this->export_settings->export_set; node; node = node->next) {
Object *ob = (Object *) node->link;
ob->id.flag |= LIB_DOIT;
}
// Now find all exportable base ojects (highest in export hierarchy)
for(node = this->export_settings->export_set; node; node = node->next) {
Object *ob = (Object*) node->link;
for (node = this->export_settings->export_set; node; node = node->next) {
Object *ob = (Object *) node->link;
if (bc_is_base_node(this->export_settings->export_set, ob))
{
switch (ob->type) {
@ -71,7 +72,7 @@ void SceneExporter::exportHierarchy(Scene *sce)
}
// And now export the base objects:
for(int index=0; index < base_objects.size(); index++) {
for (int index = 0; index < base_objects.size(); index++) {
Object *ob = base_objects[index];
if (bc_is_marked(ob)) {
bc_remove_mark(ob);
@ -84,7 +85,7 @@ void SceneExporter::writeNodes(Object *ob, Scene *sce)
{
// Add associated armature first if available
Object *ob_arm = bc_get_assigned_armature(ob);
if(ob_arm != NULL && bc_is_marked(ob_arm)) {
if (ob_arm != NULL && bc_is_marked(ob_arm)) {
bc_remove_mark(ob_arm);
writeNodes(ob_arm, sce);
}
@ -97,10 +98,10 @@ void SceneExporter::writeNodes(Object *ob, Scene *sce)
colladaNode.start();
bool is_skinned_mesh = arm_exporter->is_skinned_mesh(ob);
std::list<Object*> child_objects;
std::list<Object *> child_objects;
// list child objects
LinkNode *node = this->export_settings->export_set ;
LinkNode *node = this->export_settings->export_set;
while (node) {
// cob - child object
Object *cob = (Object *)node->link;
@ -132,7 +133,7 @@ void SceneExporter::writeNodes(Object *ob, Scene *sce)
if (this->export_settings->include_armatures && is_skinned_mesh) {
instance_controller_created = arm_exporter->add_instance_controller(ob);
}
if (!instance_controller_created){
if (!instance_controller_created) {
COLLADASW::InstanceGeometry instGeom(mSW);
instGeom.setUrl(COLLADASW::URI(COLLADABU::Utils::EMPTY_STRING, get_geometry_id(ob, this->export_settings->use_object_instantiation)));
@ -165,7 +166,7 @@ void SceneExporter::writeNodes(Object *ob, Scene *sce)
GroupObject *go = NULL;
Group *gr = ob->dup_group;
/* printf("group detected '%s'\n", gr->id.name+2); */
for (go = (GroupObject*)(gr->gobject.first); go; go=go->next) {
for (go = (GroupObject *)(gr->gobject.first); go; go = go->next) {
printf("\t%s\n", go->ob->id.name);
}
}
@ -175,8 +176,8 @@ void SceneExporter::writeNodes(Object *ob, Scene *sce)
colladaNode.end();
}
for (std::list<Object*>::iterator i= child_objects.begin(); i != child_objects.end(); ++i) {
if(bc_is_marked(*i)) {
for (std::list<Object *>::iterator i = child_objects.begin(); i != child_objects.end(); ++i) {
if (bc_is_marked(*i)) {
bc_remove_mark(*i);
writeNodes(*i, sce);
}

@ -57,7 +57,8 @@ static const char *bc_get_joint_name(T *node)
// This is used to store data passed in write_controller_data.
// Arrays from COLLADAFW::SkinControllerData lose ownership, so do this class members
// so that arrays don't get freed until we free them explicitly.
SkinInfo::SkinInfo() {}
SkinInfo::SkinInfo() {
}
SkinInfo::SkinInfo(const SkinInfo& skin) : weights(skin.weights),
joint_data(skin.joint_data),
@ -73,7 +74,8 @@ SkinInfo::SkinInfo(const SkinInfo& skin) : weights(skin.weights),
transfer_int_array_data_const(skin.joint_indices, joint_indices);
}
SkinInfo::SkinInfo(UnitConverter *conv) : unit_converter(conv), ob_arm(NULL), parent(NULL) {}
SkinInfo::SkinInfo(UnitConverter *conv) : unit_converter(conv), ob_arm(NULL), parent(NULL) {
}
// nobody owns the data after this, so it should be freed manually with releaseMemory
template <class T>
@ -87,21 +89,21 @@ void SkinInfo::transfer_array_data(T& src, T& dest)
// when src is const we cannot src.yieldOwnerShip, this is used by copy constructor
void SkinInfo::transfer_int_array_data_const(const COLLADAFW::IntValuesArray& src, COLLADAFW::IntValuesArray& dest)
{
dest.setData((int*)src.getData(), src.getCount());
dest.setData((int *)src.getData(), src.getCount());
dest.yieldOwnerShip();
}
void SkinInfo::transfer_uint_array_data_const(const COLLADAFW::UIntValuesArray& src, COLLADAFW::UIntValuesArray& dest)
{
dest.setData((unsigned int*)src.getData(), src.getCount());
dest.setData((unsigned int *)src.getData(), src.getCount());
dest.yieldOwnerShip();
}
void SkinInfo::borrow_skin_controller_data(const COLLADAFW::SkinControllerData* skin)
void SkinInfo::borrow_skin_controller_data(const COLLADAFW::SkinControllerData *skin)
{
transfer_array_data((COLLADAFW::UIntValuesArray&)skin->getJointsPerVertex(), joints_per_vertex);
transfer_array_data((COLLADAFW::UIntValuesArray&)skin->getWeightIndices(), weight_indices);
transfer_array_data((COLLADAFW::IntValuesArray&)skin->getJointIndices(), joint_indices);
transfer_array_data((COLLADAFW::UIntValuesArray &)skin->getJointsPerVertex(), joints_per_vertex);
transfer_array_data((COLLADAFW::UIntValuesArray &)skin->getWeightIndices(), weight_indices);
transfer_array_data((COLLADAFW::IntValuesArray &)skin->getJointIndices(), joint_indices);
// transfer_array_data(skin->getWeights(), weights);
// cannot transfer data for FloatOrDoubleArray, copy values manually
@ -130,7 +132,7 @@ void SkinInfo::add_joint(const COLLADABU::Math::Matrix4& matrix)
joint_data.push_back(jd);
}
void SkinInfo::set_controller(const COLLADAFW::SkinController* co)
void SkinInfo::set_controller(const COLLADAFW::SkinController *co)
{
controller_uid = co->getUniqueId();
@ -155,7 +157,7 @@ Object *SkinInfo::create_armature(Scene *scene)
return ob_arm;
}
Object* SkinInfo::set_armature(Object *ob_arm)
Object *SkinInfo::set_armature(Object *ob_arm)
{
if (this->ob_arm)
return this->ob_arm;
@ -211,7 +213,7 @@ bool SkinInfo::uses_joint_or_descendant(COLLADAFW::Node *node)
return false;
}
void SkinInfo::link_armature(bContext *C, Object *ob, std::map<COLLADAFW::UniqueId, COLLADAFW::Node*>& joint_by_uid,
void SkinInfo::link_armature(bContext *C, Object *ob, std::map<COLLADAFW::UniqueId, COLLADAFW::Node *>& joint_by_uid,
TransformReader *tm)
{
Main *bmain = CTX_data_main(C);
@ -233,11 +235,11 @@ void SkinInfo::link_armature(bContext *C, Object *ob, std::map<COLLADAFW::Unique
BKE_object_workob_calc_parent(scene, ob, &workob);
invert_m4_m4(ob->parentinv, workob.obmat);
ob->recalc |= OB_RECALC_OB|OB_RECALC_DATA;
ob->recalc |= OB_RECALC_OB | OB_RECALC_DATA;
DAG_scene_sort(bmain, scene);
DAG_ids_flush_update(bmain, 0);
WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, NULL);
WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL);
#endif
amd->deformflag = ARM_DEF_VGROUP;
@ -257,7 +259,7 @@ void SkinInfo::link_armature(bContext *C, Object *ob, std::map<COLLADAFW::Unique
name = bc_get_joint_name(joint_by_uid[(*it).joint_uid]);
}
ED_vgroup_add_name(ob, (char*)name);
ED_vgroup_add_name(ob, (char *)name);
}
// <vcount> - number of joints per vertex - joints_per_vertex
@ -274,12 +276,12 @@ void SkinInfo::link_armature(bContext *C, Object *ob, std::map<COLLADAFW::Unique
for (unsigned int vertex = 0, weight = 0; vertex < joints_per_vertex.getCount(); vertex++) {
unsigned int limit = weight + joints_per_vertex[vertex];
for ( ; weight < limit; weight++) {
for (; weight < limit; weight++) {
int joint = joint_indices[weight], joint_weight = weight_indices[weight];
// -1 means "weight towards the bind shape", we just don't assign it to any group
if (joint != -1) {
bDeformGroup *def = (bDeformGroup*)BLI_findlink(&ob->defbase, joint);
bDeformGroup *def = (bDeformGroup *)BLI_findlink(&ob->defbase, joint);
ED_vgroup_vert_add(ob, def, vertex, weights[joint_weight], WEIGHT_REPLACE);
}
@ -297,16 +299,16 @@ void SkinInfo::set_parent(Object *_parent)
parent = _parent;
}
Object* SkinInfo::get_parent()
Object *SkinInfo::get_parent()
{
return parent;
}
void SkinInfo::find_root_joints(const std::vector<COLLADAFW::Node*> &root_joints,
std::map<COLLADAFW::UniqueId, COLLADAFW::Node*>& joint_by_uid,
std::vector<COLLADAFW::Node*>& result)
void SkinInfo::find_root_joints(const std::vector<COLLADAFW::Node *> &root_joints,
std::map<COLLADAFW::UniqueId, COLLADAFW::Node *>& joint_by_uid,
std::vector<COLLADAFW::Node *>& result)
{
std::vector<COLLADAFW::Node*>::const_iterator it;
std::vector<COLLADAFW::Node *>::const_iterator it;
// for each root_joint
for (it = root_joints.begin(); it != root_joints.end(); it++) {
COLLADAFW::Node *root = *it;

@ -29,7 +29,8 @@
#include "TransformReader.h"
TransformReader::TransformReader(UnitConverter* conv) : unit_converter(conv) {}
TransformReader::TransformReader(UnitConverter *conv) : unit_converter(conv) {
}
void TransformReader::get_node_mat(float mat[][4], COLLADAFW::Node *node, std::map<COLLADAFW::UniqueId, Animation> *animation_map, Object *ob)
{
@ -78,7 +79,7 @@ void TransformReader::get_node_mat(float mat[][4], COLLADAFW::Node *node, std::m
void TransformReader::dae_rotate_to_mat4(COLLADAFW::Transformation *tm, float m[][4])
{
COLLADAFW::Rotate *ro = (COLLADAFW::Rotate*)tm;
COLLADAFW::Rotate *ro = (COLLADAFW::Rotate *)tm;
COLLADABU::Math::Vector3& axis = ro->getRotationAxis();
const float angle = (float)DEG2RAD(ro->getRotationAngle());
const float ax[] = {axis[0], axis[1], axis[2]};
@ -90,7 +91,7 @@ void TransformReader::dae_rotate_to_mat4(COLLADAFW::Transformation *tm, float m[
void TransformReader::dae_translate_to_mat4(COLLADAFW::Transformation *tm, float m[][4])
{
COLLADAFW::Translate *tra = (COLLADAFW::Translate*)tm;
COLLADAFW::Translate *tra = (COLLADAFW::Translate *)tm;
COLLADABU::Math::Vector3& t = tra->getTranslation();
unit_m4(m);
@ -102,24 +103,24 @@ void TransformReader::dae_translate_to_mat4(COLLADAFW::Transformation *tm, float
void TransformReader::dae_scale_to_mat4(COLLADAFW::Transformation *tm, float m[][4])
{
COLLADABU::Math::Vector3& s = ((COLLADAFW::Scale*)tm)->getScale();
COLLADABU::Math::Vector3& s = ((COLLADAFW::Scale *)tm)->getScale();
float size[3] = {(float)s[0], (float)s[1], (float)s[2]};
size_to_mat4(m, size);
}
void TransformReader::dae_matrix_to_mat4(COLLADAFW::Transformation *tm, float m[][4])
{
unit_converter->dae_matrix_to_mat4_(m, ((COLLADAFW::Matrix*)tm)->getMatrix());
unit_converter->dae_matrix_to_mat4_(m, ((COLLADAFW::Matrix *)tm)->getMatrix());
}
void TransformReader::dae_translate_to_v3(COLLADAFW::Transformation *tm, float v[3])
{
dae_vector3_to_v3(((COLLADAFW::Translate*)tm)->getTranslation(), v);
dae_vector3_to_v3(((COLLADAFW::Translate *)tm)->getTranslation(), v);
}
void TransformReader::dae_scale_to_v3(COLLADAFW::Transformation *tm, float v[3])
{
dae_vector3_to_v3(((COLLADAFW::Scale*)tm)->getScale(), v);
dae_vector3_to_v3(((COLLADAFW::Scale *)tm)->getScale(), v);
}
void TransformReader::dae_vector3_to_v3(const COLLADABU::Math::Vector3 &v3, float v[3])

@ -47,11 +47,11 @@ void TransformWriter::add_node_transform(COLLADASW::Node& node, float mat[][4],
}
double dmat[4][4];
UnitConverter* converter = new UnitConverter();
UnitConverter *converter = new UnitConverter();
converter->mat4_to_dae_double(dmat, local);
TransformBase::decompose(local, loc, rot, NULL, scale);
if ( node.getType() == COLLADASW::Node::JOINT)
if (node.getType() == COLLADASW::Node::JOINT)
node.addMatrix("transform", dmat);
else
add_transform(node, loc, rot, scale);
@ -59,7 +59,7 @@ void TransformWriter::add_node_transform(COLLADASW::Node& node, float mat[][4],
void TransformWriter::add_node_transform_ob(COLLADASW::Node& node, Object *ob)
{
/*
#if 0
float rot[3], loc[3], scale[3];
if (ob->parent) {
@ -92,7 +92,7 @@ void TransformWriter::add_node_transform_ob(COLLADASW::Node& node, Object *ob)
}
add_transform(node, loc, rot, scale);
*/
#endif
/* Using parentinv should allow use of existing curves */
if (ob->parent) {
@ -124,9 +124,11 @@ void TransformWriter::add_node_transform_identity(COLLADASW::Node& node)
void TransformWriter::add_transform(COLLADASW::Node& node, float loc[3], float rot[3], float scale[3])
{
node.addTranslate("location", loc[0], loc[1], loc[2]);
/*node.addRotateZ("rotationZ", COLLADABU::Math::Utils::radToDegF(rot[2]));
#if 0
node.addRotateZ("rotationZ", COLLADABU::Math::Utils::radToDegF(rot[2]));
node.addRotateY("rotationY", COLLADABU::Math::Utils::radToDegF(rot[1]));
node.addRotateX("rotationX", COLLADABU::Math::Utils::radToDegF(rot[0]));*/
node.addRotateX("rotationX", COLLADABU::Math::Utils::radToDegF(rot[0]));
#endif
node.addRotateZ("rotationZ", RAD2DEGF(rot[2]));
node.addRotateY("rotationY", RAD2DEGF(rot[1]));
node.addRotateX("rotationX", RAD2DEGF(rot[0]));

@ -41,15 +41,15 @@ extern "C"
#include "BLI_fileops.h"
#include "BLI_path_util.h"
int collada_import(bContext *C, const char *filepath)
{
DocumentImporter imp (C, filepath);
int collada_import(bContext *C, const char *filepath)
{
DocumentImporter imp(C, filepath);
if (imp.import()) return 1;
return 0;
}
}
int collada_export(
int collada_export(
Scene *sce,
const char *filepath,
int selected,
@ -59,8 +59,8 @@ extern "C"
int include_children,
int use_object_instantiation,
int second_life )
{
int second_life)
{
ExportSettings export_settings;
/* annoying, collada crashes if file cant be created! [#27162] */
@ -94,5 +94,7 @@ extern "C"
BLI_linklist_free(export_settings.export_set, NULL);
return 1;
}
}
/* end extern C */
}

@ -31,9 +31,10 @@
#include "BLI_linklist.h"
UnitConverter::UnitConverter() : unit(), up_axis(COLLADAFW::FileInfo::Z_UP) {}
UnitConverter::UnitConverter() : unit(), up_axis(COLLADAFW::FileInfo::Z_UP) {
}
void UnitConverter::read_asset(const COLLADAFW::FileInfo* asset)
void UnitConverter::read_asset(const COLLADAFW::FileInfo *asset)
{
unit = asset->getUnit();
up_axis = asset->getUpAxisType();
@ -121,72 +122,74 @@ void TransformBase::decompose(float mat[][4], float *loc, float eul[3], float qu
* must obviously be removed too, otherwise they would be heavily misinterpreted.
*/
const unsigned char translate_start_name_map[256] = {
95, 95, 95, 95, 95, 95, 95, 95, 95,
95, 95, 95, 95, 95, 95, 95, 95,
95, 95, 95, 95, 95, 95, 95, 95,
95, 95, 95, 95, 95, 95, 95, 95,
95, 95, 95, 95, 95, 95, 95, 95,
95, 95, 95, 95, 95, 95, 95, 95,
95, 95, 95, 95, 95, 95, 95, 95,
95, 95, 95, 95, 95, 95, 95, 95,
65, 66, 67, 68, 69, 70, 71, 72,
73, 74, 75, 76, 77, 78, 79, 80,
81, 82, 83, 84, 85, 86, 87, 88,
89, 90, 95, 95, 95, 95, 95, 95,
97, 98, 99, 100, 101, 102, 103, 104,
105, 106, 107, 108, 109, 110, 111, 112,
113, 114, 115, 116, 117, 118, 119, 120,
121, 122, 95, 95, 95, 95, 95, 95,
95, 95, 95, 95, 95, 95, 95, 95,
95, 95, 95, 95, 95, 95, 95, 95,
95, 95, 95, 95, 95, 95, 95, 95,
95, 95, 95, 95, 95, 95, 95, 95,
95, 95, 95, 95, 95, 95, 95, 95,
95, 95, 95, 95, 95, 95, 95, 95,
95, 95, 95, 95, 95, 95, 95, 95,
95, 95, 95, 95, 95, 95, 95, 192,
193, 194, 195, 196, 197, 198, 199, 200,
201, 202, 203, 204, 205, 206, 207, 208,
209, 210, 211, 212, 213, 214, 95, 216,
217, 218, 219, 220, 221, 222, 223, 224,
225, 226, 227, 228, 229, 230, 231, 232,
233, 234, 235, 236, 237, 238, 239, 240,
241, 242, 243, 244, 245, 246, 95, 248,
249, 250, 251, 252, 253, 254, 255};
95, 95, 95, 95, 95, 95, 95, 95, 95,
95, 95, 95, 95, 95, 95, 95, 95,
95, 95, 95, 95, 95, 95, 95, 95,
95, 95, 95, 95, 95, 95, 95, 95,
95, 95, 95, 95, 95, 95, 95, 95,
95, 95, 95, 95, 95, 95, 95, 95,
95, 95, 95, 95, 95, 95, 95, 95,
95, 95, 95, 95, 95, 95, 95, 95,
65, 66, 67, 68, 69, 70, 71, 72,
73, 74, 75, 76, 77, 78, 79, 80,
81, 82, 83, 84, 85, 86, 87, 88,
89, 90, 95, 95, 95, 95, 95, 95,
97, 98, 99, 100, 101, 102, 103, 104,
105, 106, 107, 108, 109, 110, 111, 112,
113, 114, 115, 116, 117, 118, 119, 120,
121, 122, 95, 95, 95, 95, 95, 95,
95, 95, 95, 95, 95, 95, 95, 95,
95, 95, 95, 95, 95, 95, 95, 95,
95, 95, 95, 95, 95, 95, 95, 95,
95, 95, 95, 95, 95, 95, 95, 95,
95, 95, 95, 95, 95, 95, 95, 95,
95, 95, 95, 95, 95, 95, 95, 95,
95, 95, 95, 95, 95, 95, 95, 95,
95, 95, 95, 95, 95, 95, 95, 192,
193, 194, 195, 196, 197, 198, 199, 200,
201, 202, 203, 204, 205, 206, 207, 208,
209, 210, 211, 212, 213, 214, 95, 216,
217, 218, 219, 220, 221, 222, 223, 224,
225, 226, 227, 228, 229, 230, 231, 232,
233, 234, 235, 236, 237, 238, 239, 240,
241, 242, 243, 244, 245, 246, 95, 248,
249, 250, 251, 252, 253, 254, 255
};
const unsigned char translate_name_map[256] = {
95, 95, 95, 95, 95, 95, 95, 95, 95,
95, 95, 95, 95, 95, 95, 95, 95,
95, 95, 95, 95, 95, 95, 95, 95,
95, 95, 95, 95, 95, 95, 95, 95,
95, 95, 95, 95, 95, 95, 95, 95,
95, 95, 95, 95, 45, 95, 95, 48,
49, 50, 51, 52, 53, 54, 55, 56,
57, 95, 95, 95, 95, 95, 95, 95,
65, 66, 67, 68, 69, 70, 71, 72,
73, 74, 75, 76, 77, 78, 79, 80,
81, 82, 83, 84, 85, 86, 87, 88,
89, 90, 95, 95, 95, 95, 95, 95,
97, 98, 99, 100, 101, 102, 103, 104,
105, 106, 107, 108, 109, 110, 111, 112,
113, 114, 115, 116, 117, 118, 119, 120,
121, 122, 95, 95, 95, 95, 95, 95,
95, 95, 95, 95, 95, 95, 95, 95,
95, 95, 95, 95, 95, 95, 95, 95,
95, 95, 95, 95, 95, 95, 95, 95,
95, 95, 95, 95, 95, 95, 95, 95,
95, 95, 95, 95, 95, 95, 95, 95,
95, 95, 95, 95, 95, 95, 95, 95,
95, 95, 95, 95, 95, 95, 183, 95,
95, 95, 95, 95, 95, 95, 95, 192,
193, 194, 195, 196, 197, 198, 199, 200,
201, 202, 203, 204, 205, 206, 207, 208,
209, 210, 211, 212, 213, 214, 95, 216,
217, 218, 219, 220, 221, 222, 223, 224,
225, 226, 227, 228, 229, 230, 231, 232,
233, 234, 235, 236, 237, 238, 239, 240,
241, 242, 243, 244, 245, 246, 95, 248,
249, 250, 251, 252, 253, 254, 255};
95, 95, 95, 95, 95, 95, 95, 95, 95,
95, 95, 95, 95, 95, 95, 95, 95,
95, 95, 95, 95, 95, 95, 95, 95,
95, 95, 95, 95, 95, 95, 95, 95,
95, 95, 95, 95, 95, 95, 95, 95,
95, 95, 95, 95, 45, 95, 95, 48,
49, 50, 51, 52, 53, 54, 55, 56,
57, 95, 95, 95, 95, 95, 95, 95,
65, 66, 67, 68, 69, 70, 71, 72,
73, 74, 75, 76, 77, 78, 79, 80,
81, 82, 83, 84, 85, 86, 87, 88,
89, 90, 95, 95, 95, 95, 95, 95,
97, 98, 99, 100, 101, 102, 103, 104,
105, 106, 107, 108, 109, 110, 111, 112,
113, 114, 115, 116, 117, 118, 119, 120,
121, 122, 95, 95, 95, 95, 95, 95,
95, 95, 95, 95, 95, 95, 95, 95,
95, 95, 95, 95, 95, 95, 95, 95,
95, 95, 95, 95, 95, 95, 95, 95,
95, 95, 95, 95, 95, 95, 95, 95,
95, 95, 95, 95, 95, 95, 95, 95,
95, 95, 95, 95, 95, 95, 95, 95,
95, 95, 95, 95, 95, 95, 183, 95,
95, 95, 95, 95, 95, 95, 95, 192,
193, 194, 195, 196, 197, 198, 199, 200,
201, 202, 203, 204, 205, 206, 207, 208,
209, 210, 211, 212, 213, 214, 95, 216,
217, 218, 219, 220, 221, 222, 223, 224,
225, 226, 227, 228, 229, 230, 231, 232,
233, 234, 235, 236, 237, 238, 239, 240,
241, 242, 243, 244, 245, 246, 95, 248,
249, 250, 251, 252, 253, 254, 255
};
typedef std::map< std::string, std::vector<std::string> > map_string_list;
map_string_list global_id_map;
@ -205,7 +208,7 @@ std::string translate_id(const std::string &id)
std::string id_translated = id;
id_translated[0] = translate_start_name_map[(unsigned int)id_translated[0]];
for (unsigned int i=1; i < id_translated.size(); i++) {
for (unsigned int i = 1; i < id_translated.size(); i++) {
id_translated[i] = translate_name_map[(unsigned int)id_translated[i]];
}
// It's so much workload now, the if () should speed up things.
@ -215,7 +218,7 @@ std::string translate_id(const std::string &id)
if (iter != global_id_map.end()) {
unsigned int i = 0;
bool found = false;
for (i=0; i < iter->second.size(); i++) {
for (i = 0; i < iter->second.size(); i++) {
if (id == iter->second[i]) {
found = true;
break;
@ -244,7 +247,7 @@ std::string translate_id(const std::string &id)
std::string id_name(void *id)
{
return ((ID*)id)->name + 2;
return ((ID *)id)->name + 2;
}
std::string get_geometry_id(Object *ob)

@ -117,7 +117,7 @@ int bc_set_parent(Object *ob, Object *par, bContext *C, bool is_parent_space)
DAG_scene_sort(bmain, sce);
DAG_ids_flush_update(bmain, 0);
WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, NULL);
WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL);
return true;
}
@ -126,9 +126,9 @@ Object *bc_add_object(Scene *scene, int type, const char *name)
{
Object *ob = BKE_object_add_only_object(type, name);
ob->data= BKE_object_obdata_add_from_type(type);
ob->lay= scene->lay;
ob->recalc |= OB_RECALC_OB|OB_RECALC_DATA|OB_RECALC_TIME;
ob->data = BKE_object_obdata_add_from_type(type);
ob->lay = scene->lay;
ob->recalc |= OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME;
BKE_scene_base_select(scene, BKE_scene_base_add(scene, ob));
@ -154,13 +154,11 @@ Object *bc_get_assigned_armature(Object *ob)
ob_arm = ob->parent;
}
else {
ModifierData *mod = (ModifierData*)ob->modifiers.first;
while (mod) {
ModifierData *mod;
for (mod = (ModifierData *)ob->modifiers.first; mod; mod = mod->next) {
if (mod->type == eModifierType_Armature) {
ob_arm = ((ArmatureModifierData*)mod)->object;
ob_arm = ((ArmatureModifierData *)mod)->object;
}
mod = mod->next;
}
}

@ -591,7 +591,7 @@ void WM_operator_properties_alloc(PointerRNA **ptr, IDProperty **properties, con
void WM_operator_properties_sanitize(PointerRNA *ptr, const short no_context)
{
RNA_STRUCT_BEGIN (ptr, prop)
RNA_STRUCT_BEGIN(ptr, prop)
{
switch (RNA_property_type(prop)) {
case PROP_ENUM:
@ -625,7 +625,7 @@ void WM_operator_properties_reset(wmOperator *op)
PropertyRNA *iterprop;
iterprop = RNA_struct_iterator_property(op->type->srna);
RNA_PROP_BEGIN (op->ptr, itemptr, iterprop)
RNA_PROP_BEGIN(op->ptr, itemptr, iterprop)
{
PropertyRNA *prop = itemptr.data;
@ -1809,7 +1809,7 @@ static int wm_link_append_exec(bContext *C, wmOperator *op)
BLO_library_append_named_part_ex(C, mainl, &bh, name, idcode, flag);
}
else {
RNA_BEGIN (op->ptr, itemptr, "files")
RNA_BEGIN(op->ptr, itemptr, "files")
{
RNA_string_get(&itemptr, "name", name);
BLO_library_append_named_part_ex(C, mainl, &bh, name, idcode, flag);
@ -2163,10 +2163,10 @@ static int wm_collada_export_exec(bContext *C, wmOperator *op)
{
char filename[FILE_MAX];
int selected, second_life,
include_armatures,
apply_modifiers,
include_children,
use_object_instantiation;
int include_armatures,
int apply_modifiers,
int include_children,
int use_object_instantiation;
if (!RNA_struct_property_is_set(op->ptr, "filepath")) {
BKE_report(op->reports, RPT_ERROR, "No filename given");
@ -2315,7 +2315,7 @@ static void WM_OT_console_toggle(wmOperatorType *ot)
{
/* XXX Have to mark these for xgettext, as under linux they do not exists...
* And even worth, have to give the context as text, as xgettext doesn't expand macros. :( */
ot->name = CTX_N_("Operator"/* BLF_I18NCONTEXT_OPERATOR_DEFAULT */, "Toggle System Console");
ot->name = CTX_N_("Operator" /* BLF_I18NCONTEXT_OPERATOR_DEFAULT */, "Toggle System Console");
ot->idname = "WM_OT_console_toggle";
ot->description = N_("Toggle System Console");
@ -2869,7 +2869,7 @@ int (*WM_gesture_lasso_path_to_array(bContext *UNUSED(C), wmOperator *op, int *m
static int gesture_lasso_exec(bContext *C, wmOperator *op)
{
RNA_BEGIN (op->ptr, itemptr, "path")
RNA_BEGIN(op->ptr, itemptr, "path")
{
float loc[2];
@ -3825,7 +3825,8 @@ static void gesture_circle_modal_keymap(wmKeyConfig *keyconf)
{GESTURE_MODAL_DESELECT, "DESELECT", 0, "DeSelect", ""},
{GESTURE_MODAL_NOP, "NOP", 0, "No Operation", ""},
{0, NULL, 0, NULL, NULL}};
{0, NULL, 0, NULL, NULL}
};
wmKeyMap *keymap = WM_modalkeymap_get(keyconf, "View3D Gesture Circle");
@ -3873,7 +3874,8 @@ static void gesture_straightline_modal_keymap(wmKeyConfig *keyconf)
{GESTURE_MODAL_CANCEL, "CANCEL", 0, "Cancel", ""},
{GESTURE_MODAL_SELECT, "SELECT", 0, "Select", ""},
{GESTURE_MODAL_BEGIN, "BEGIN", 0, "Begin", ""},
{0, NULL, 0, NULL, NULL}};
{0, NULL, 0, NULL, NULL}
};
wmKeyMap *keymap = WM_modalkeymap_get(keyconf, "Gesture Straight Line");
@ -3902,7 +3904,8 @@ static void gesture_border_modal_keymap(wmKeyConfig *keyconf)
{GESTURE_MODAL_SELECT, "SELECT", 0, "Select", ""},
{GESTURE_MODAL_DESELECT, "DESELECT", 0, "DeSelect", ""},
{GESTURE_MODAL_BEGIN, "BEGIN", 0, "Begin", ""},
{0, NULL, 0, NULL, NULL}};
{0, NULL, 0, NULL, NULL}
};
wmKeyMap *keymap = WM_modalkeymap_get(keyconf, "Gesture Border");
@ -3962,7 +3965,8 @@ static void gesture_zoom_border_modal_keymap(wmKeyConfig *keyconf)
{GESTURE_MODAL_IN, "IN", 0, "In", ""},
{GESTURE_MODAL_OUT, "OUT", 0, "Out", ""},
{GESTURE_MODAL_BEGIN, "BEGIN", 0, "Begin", ""},
{0, NULL, 0, NULL, NULL}};
{0, NULL, 0, NULL, NULL}
};
wmKeyMap *keymap = WM_modalkeymap_get(keyconf, "Gesture Zoom Border");