diff --git a/source/blender/collada/EffectExporter.cpp b/source/blender/collada/EffectExporter.cpp index 76b5114..11ea02e 100644 --- a/source/blender/collada/EffectExporter.cpp +++ b/source/blender/collada/EffectExporter.cpp @@ -47,7 +47,9 @@ extern "C" { #include "BKE_customdata.h" #include "BKE_mesh.h" #include "BKE_material.h" + #include "BKE_idprop.h" } +#include // OB_MESH is assumed static std::string getActiveUVLayerName(Object *ob) @@ -170,6 +172,26 @@ void EffectsExporter::writeTextures(COLLADASW::EffectProfile &ep, texture.setChildElementName("bump"); ep.addExtraTechniqueColorOrTexture(COLLADASW::ColorOrTexture(texture)); } + // AnKi: Add some textures + if (t->mapto & MAP_HAR) { + COLLADASW::Texture texture(key); + texture.setTexcoord(uvname); + texture.setSampler(*sampler); + texture.setProfileName("blender"); + texture.setChildElementName("roughness"); + ep.addExtraTechniqueColorOrTexture(COLLADASW::ColorOrTexture(texture)); + } + if (t->mapto & MAP_DISPLACE) { + COLLADASW::Texture texture(key); + texture.setTexcoord(uvname); + texture.setSampler(*sampler); + texture.setProfileName("blender"); + texture.setChildElementName("height"); + ep.addExtraTechniqueColorOrTexture(COLLADASW::ColorOrTexture(texture)); + } + if ((t->mapto & MAP_COLMIR) || (t->mapto & MAP_RAYMIRR)) { + ep.setReflective(createTexture(ima, uvname, sampler)); + } } void EffectsExporter::operator()(Material *ma, Object *ob) @@ -398,6 +420,68 @@ void EffectsExporter::operator()(Material *ma, Object *ob) } } + // AnKi: Export extra properties + static const char *property_names[] = { + "diffuse_texture_detail", + "normal_texture_detail", + "material_override", + "metallic", + "roughness", + "subsurface", + NULL}; + IDProperty *rprop = ma->id.properties; + while (rprop) { + if (rprop->type == IDP_GROUP) { + // Search properties + const char **iter = property_names; + while (*iter != NULL) { + const char *prop_name = *iter; + IDProperty *prop = IDP_GetPropertyFromGroup(rprop, prop_name); + + if (prop) { + const char *value = NULL; + float valuef = 0.0; + bool ok = true; + + if(prop->type == IDP_STRING) { + value = IDP_String(prop); + } + else if (prop->type == IDP_FLOAT) { + valuef = IDP_Float(prop); + } + else if (prop->type == IDP_DOUBLE) { + valuef = IDP_Double(prop); + } + else if (prop->type == IDP_INT) { + valuef = IDP_Int(prop); + } + else { + printf("Property value type cannot be handled\n"); + ok = false; + } + + if (ok) + { + if (value) { + printf("Found %s property \"%s\"\n", prop_name, value); + ep.addExtraTechniqueParameter("blender", prop_name, COLLADASW::String(value)); + } + else { + printf("Found %s property %f\n", prop_name, valuef); + std::stringstream ss; + ss << valuef; + ep.addExtraTechniqueParameter("blender", prop_name, COLLADASW::String(ss.str())); + } + } + } // end found + + ++iter; + } // end iterate property_names + } // end group + + rprop = rprop->next; + } + // performs the actual writing ep.addProfileElements(); bool twoSided = false; diff --git a/source/blender/collada/GeometryExporter.cpp b/source/blender/collada/GeometryExporter.cpp index 7c7c57f..b02ba47 100644 --- a/source/blender/collada/GeometryExporter.cpp +++ b/source/blender/collada/GeometryExporter.cpp @@ -47,6 +47,7 @@ extern "C" { #include "BKE_customdata.h" #include "BKE_material.h" #include "BKE_mesh.h" + #include "BKE_idprop.h" } #include "collada_internal.h" @@ -143,13 +144,133 @@ void GeometryExporter::operator()(Object *ob) createPolylist(0, has_uvs, has_color, ob, me, geom_id, norind); } } - + + // AnKi: Export mesh properties + { + static const char *property_names[] = { + "particles", + "collision", + "sector", + "portal", + "lod1", + "skip", + "reflection_probe", + "reflection_proxy", + "occluder", + "collision_mesh", + "decal_diffuse_atlas", + "decal_diffuse_sub_texture", + "decal_diffuse_factor", + "decal_normal_roughness_atlas", + "decal_normal_roughness_sub_texture", + "decal_normal_roughness_factor", + NULL}; + + ID *mesh_id = (ID*)ob->data; + IDProperty *rprop = mesh_id->properties; + while (rprop) { + if (rprop->type == IDP_GROUP) { + const char **iter = property_names; + while (*iter != NULL) { + const char *prop_name = *iter; + IDProperty *prop = IDP_GetPropertyFromGroup(rprop, prop_name); + + if (prop) { + const char *value = NULL; + float valuef = 0.0; + bool ok = true; + + if(prop->type == IDP_STRING) { + value = IDP_String(prop); + } + else if (prop->type == IDP_FLOAT) { + valuef = IDP_Float(prop); + } + else if (prop->type == IDP_DOUBLE) { + valuef = IDP_Double(prop); + } + else if (prop->type == IDP_INT) { + valuef = IDP_Int(prop); + } + else { + printf("Property value type cannot be handled\n"); + ok = false; + } + + if (ok) { + if (value) { + printf("Found %s property \"%s\"\n", prop_name, value); + + std::string str = std::string("<") + prop_name + ">" + value + ""; + mSW->appendTextBlock(str.c_str()); + } + else { + printf("Found %s property \"%f\"\n", prop_name, valuef); + + std::stringstream ss; + ss << "<" << prop_name << ">" << valuef << ""; + mSW->appendTextBlock(ss.str().c_str()); + } + } + } // end found + + ++iter; + } // end iterate property_names + } // end group + + rprop = rprop->next; + } + } + closeMesh(); if (me->flag & ME_TWOSIDED) { mSW->appendTextBlock("1"); } + // AnKi: Export object properties + { + static const char *property_names[] = { + "add some", + NULL}; + IDProperty *rprop = ob->id.properties; + while (rprop) { + if (rprop->type == IDP_GROUP) { + // Search properties + const char **iter = property_names; + while (*iter != NULL) { + const char *prop_name = *iter; + IDProperty *prop = IDP_GetPropertyFromGroup(rprop, prop_name); + + if (prop) { + const char *value = NULL; + + if(prop->type == IDP_STRING) { + value = IDP_String(prop); + } + else { + printf("Property's value is not string\n"); + } + + if (value) { + printf("Found %s property \"%s\"\n", prop_name, value); + + std::string str = std::string("<") + prop_name + ">" + value + ""; + mSW->appendTextBlock(str.c_str()); + } + else { + printf("Value error in %s property\n", prop_name); + } + } // end found + + ++iter; + } // end iterate property_names + } // end group + + rprop = rprop->next; + } + } + closeGeometry(); if (this->export_settings->include_shapekeys) { diff --git a/source/blender/collada/LightExporter.cpp b/source/blender/collada/LightExporter.cpp index ff50abf..205f687 100644 --- a/source/blender/collada/LightExporter.cpp +++ b/source/blender/collada/LightExporter.cpp @@ -31,6 +31,9 @@ #include "COLLADASWLight.h" #include "BLI_math.h" +extern "C" { +#include "BKE_idprop.h" +} #include "LightExporter.h" #include "collada_internal.h" @@ -107,6 +110,7 @@ void LightsExporter::operator()(Object *ob) cla.setLinearAttenuation(linatt); cla.setQuadraticAttenuation(quadatt); exportBlenderProfile(cla, la); + cla.addExtraTechniqueParameter("FCOLLADA", "outer_cone", RAD2DEGF(la->spotsize)); // AnKi: Add cone angle addLight(cla); } // lamp @@ -190,6 +194,49 @@ bool LightsExporter::exportBlenderProfile(COLLADASW::Light &cla, Lamp *la) cla.addExtraTechniqueParameter("blender", "skyblendfac", la->skyblendfac); cla.addExtraTechniqueParameter("blender", "sky_exposure", la->sky_exposure); cla.addExtraTechniqueParameter("blender", "sky_colorspace", la->sky_colorspace); - + + // AnKi: Export properties + static const char *property_names[] = { + "lens_flare", + "lens_flare_first_sprite_size", + "lens_flare_color", + "specular_color", + "shadow", + "light_event_intensity", + "light_event_frequency", + NULL}; + IDProperty *rprop = la->id.properties; + while (rprop) { + if (rprop->type == IDP_GROUP) { + // Search properties + const char **iter = property_names; + while (*iter != NULL) { + const char *prop_name = *iter; + IDProperty *prop = IDP_GetPropertyFromGroup(rprop, prop_name); + + if (prop) { + const char *value = NULL; + + if(prop->type == IDP_STRING) { + value = IDP_String(prop); + } + + if (value) { + printf("Found %s property \"%s\"\n", prop_name, value); + + cla.addExtraTechniqueParameter("blender", prop_name, COLLADASW::String(value)); + } + else { + printf("Value error in %s property\n", prop_name); + } + } // end found + + ++iter; + } // end iterate property_names + } // end group + + rprop = rprop->next; + } + return true; } diff --git a/source/blender/collada/SceneExporter.cpp b/source/blender/collada/SceneExporter.cpp index 30cd6dd..17563dd 100644 --- a/source/blender/collada/SceneExporter.cpp +++ b/source/blender/collada/SceneExporter.cpp @@ -28,6 +28,7 @@ extern "C" { #include "BLI_utildefines.h" #include "BKE_object.h" #include "BLI_listbase.h" + #include "BKE_group.h" } #include "SceneExporter.h" @@ -234,6 +235,14 @@ void SceneExporter::writeNodes(Object *ob, Scene *sce) } } + // AnKi: Export group + Group *group = BKE_group_object_find(NULL, ob); + if (group) { + colladaNode.addExtraTechniqueParameter("blender", "group", COLLADASW::String(group->id.name)); + } else { + colladaNode.addExtraTechniqueParameter("blender", "group", COLLADASW::String("none")); + } + for (std::list::iterator i = child_objects.begin(); i != child_objects.end(); ++i) { if (bc_is_marked(*i)) { bc_remove_mark(*i);