From 51b796ff1528c52cc8b4079fab1003671652a4d9 Mon Sep 17 00:00:00 2001 From: Ton Roosendaal Date: Thu, 19 Apr 2018 17:34:44 +0200 Subject: Remove Blender Internal and legacy viewport from Blender 2.8. Brecht authored this commit, but he gave me the honours to actually do it. Here it goes; Blender Internal. Bye bye, you did great! * Point density, voxel data, ocean, environment map textures were removed, as these only worked within BI rendering. Note that the ocean modifier and the Cycles point density shader node continue to work. * Dynamic paint using material shading was removed, as this only worked with BI. If we ever wanted to support this again probably it should go through the baking API. * GPU shader export through the Python API was removed. This only worked for the old BI GLSL shaders, which no longer exists. Doing something similar for Eevee would be significantly more complicated because it uses a lot of multiplass rendering and logic outside the shader, it's probably impractical. * Collada material import / export code is mostly gone, as it only worked for BI materials. We need to add Cycles / Eevee material support at some point. * The mesh noise operator was removed since it only worked with BI material texture slots. A displacement modifier can be used instead. * The delete texture paint slot operator was removed since it only worked for BI material texture slots. Could be added back with node support. * Not all legacy viewport features are supported in the new viewport, but their code was removed. If we need to bring anything back we can look at older git revisions. * There is some legacy viewport code that I could not remove yet, and some that I probably missed. * Shader node execution code was left mostly intact, even though it is not used anywhere now. We may eventually use this to replace the texture nodes with Cycles / Eevee shader nodes. * The Cycles Bake panel now includes settings for baking multires normal and displacement maps. The underlying code needs to be merged properly, and we plan to add back support for multires AO baking and add support to Cycles baking for features like vertex color, displacement, and other missing baking features. * This commit removes DNA and the Python API for BI material, lamp, world and scene settings. This breaks a lot of addons. * There is more DNA that can be removed or renamed, where Cycles or Eevee are reusing some old BI properties but the names are not really correct anymore. * Texture slots for materials, lamps and world were removed. They remain for brushes, particles and freestyle linestyles. * 'BLENDER_RENDER' remains in the COMPAT_ENGINES of UI panels. Cycles and other renderers use this to find all panels to show, minus a few panels that they have their own replacement for. --- source/blender/collada/DocumentExporter.cpp | 1 - source/blender/collada/DocumentImporter.cpp | 146 +++++++------------------- source/blender/collada/DocumentImporter.h | 1 - source/blender/collada/EffectExporter.cpp | 157 ++-------------------------- source/blender/collada/EffectExporter.h | 5 - source/blender/collada/ImageExporter.cpp | 18 +--- source/blender/collada/LightExporter.cpp | 26 ----- source/blender/collada/MeshImporter.cpp | 64 +----------- source/blender/collada/MeshImporter.h | 10 +- source/blender/collada/collada_utils.cpp | 124 ---------------------- 10 files changed, 56 insertions(+), 496 deletions(-) (limited to 'source/blender/collada') diff --git a/source/blender/collada/DocumentExporter.cpp b/source/blender/collada/DocumentExporter.cpp index 0b70b73887f..a66c4db7b4d 100644 --- a/source/blender/collada/DocumentExporter.cpp +++ b/source/blender/collada/DocumentExporter.cpp @@ -71,7 +71,6 @@ extern "C" #include "DNA_mesh_types.h" #include "DNA_image_types.h" #include "DNA_material_types.h" -#include "DNA_texture_types.h" #include "DNA_anim_types.h" #include "DNA_action_types.h" #include "DNA_curve_types.h" diff --git a/source/blender/collada/DocumentImporter.cpp b/source/blender/collada/DocumentImporter.cpp index 97b11f72509..d50c4bb23c4 100644 --- a/source/blender/collada/DocumentImporter.cpp +++ b/source/blender/collada/DocumentImporter.cpp @@ -62,7 +62,6 @@ extern "C" { #include "BKE_layer.h" #include "BKE_lamp.h" #include "BKE_library.h" -#include "BKE_texture.h" #include "BKE_fcurve.h" #include "BKE_scene.h" #include "BKE_global.h" @@ -544,8 +543,7 @@ std::vector *DocumentImporter::write_node(COLLADAFW::Node *node, COLLA // maybe join multiple meshes into 1, and link object with it? not sure... // while (geom_done < geom.getCount()) { - ob = mesh_importer.create_mesh_object(node, geom[geom_done], false, uid_material_map, - material_texture_mapping_map); + ob = mesh_importer.create_mesh_object(node, geom[geom_done], false, uid_material_map); if (ob == NULL) { report_unknown_reference(*node, "instance_mesh"); } @@ -585,7 +583,7 @@ std::vector *DocumentImporter::write_node(COLLADAFW::Node *node, COLLA } while (controller_done < controller.getCount()) { COLLADAFW::InstanceGeometry *geometry = (COLLADAFW::InstanceGeometry *)controller[controller_done]; - ob = mesh_importer.create_mesh_object(node, geometry, true, uid_material_map, material_texture_mapping_map); + ob = mesh_importer.create_mesh_object(node, geometry, true, uid_material_map); if (ob == NULL) { report_unknown_reference(*node, "instance_controller"); } @@ -765,102 +763,74 @@ bool DocumentImporter::writeMaterial(const COLLADAFW::Material *cmat) return true; } -// create mtex, create texture, set texture image -MTex *DocumentImporter::create_texture(COLLADAFW::EffectCommon *ef, COLLADAFW::Texture &ctex, Material *ma, - int i, TexIndexTextureArrayMap &texindex_texarray_map) -{ - COLLADAFW::SamplerPointerArray& samp_array = ef->getSamplerPointerArray(); - COLLADAFW::Sampler *sampler = samp_array[ctex.getSamplerId()]; - - const COLLADAFW::UniqueId& ima_uid = sampler->getSourceImage(); - - if (uid_image_map.find(ima_uid) == uid_image_map.end()) { - fprintf(stderr, "Couldn't find an image by UID.\n"); - return NULL; - } - - ma->mtex[i] = BKE_texture_mtex_add(); - ma->mtex[i]->texco = TEXCO_UV; - ma->mtex[i]->tex = BKE_texture_add(G.main, "Texture"); - ma->mtex[i]->tex->type = TEX_IMAGE; - ma->mtex[i]->tex->ima = uid_image_map[ima_uid]; - - texindex_texarray_map[ctex.getTextureMapId()].push_back(ma->mtex[i]); - - return ma->mtex[i]; -} - void DocumentImporter::write_profile_COMMON(COLLADAFW::EffectCommon *ef, Material *ma) { COLLADAFW::EffectCommon::ShaderType shader = ef->getShaderType(); + + // TODO: add back texture and extended material parameter support // blinn if (shader == COLLADAFW::EffectCommon::SHADER_BLINN) { +#if 0 ma->spec_shader = MA_SPEC_BLINN; ma->spec = ef->getShininess().getFloatValue(); +#endif } // phong else if (shader == COLLADAFW::EffectCommon::SHADER_PHONG) { +#if 0 ma->spec_shader = MA_SPEC_PHONG; ma->har = ef->getShininess().getFloatValue(); +#endif } // lambert else if (shader == COLLADAFW::EffectCommon::SHADER_LAMBERT) { +#if 0 ma->diff_shader = MA_DIFF_LAMBERT; +#endif } // default - lambert else { +#if 0 ma->diff_shader = MA_DIFF_LAMBERT; fprintf(stderr, "Current shader type is not supported, default to lambert.\n"); +#endif } // reflectivity ma->ray_mirror = ef->getReflectivity().getFloatValue(); // index of refraction +#if 0 ma->ang = ef->getIndexOfRefraction().getFloatValue(); +#endif - int i = 0; COLLADAFW::Color col; - MTex *mtex = NULL; - TexIndexTextureArrayMap texindex_texarray_map; // DIFFUSE // color if (ef->getDiffuse().isColor()) { - /* too high intensity can create artefacts (fireflies) - So here we take care that intensity is set to 0.8 wherever possible - */ col = ef->getDiffuse().getColor(); - ma->ref = max_ffff(col.getRed(), col.getGreen(), col.getBlue(), 0.8); - ma->r = col.getRed() / ma->ref; - ma->g = col.getGreen() / ma->ref; - ma->b = col.getBlue() / ma->ref; + ma->r = col.getRed(); + ma->g = col.getGreen(); + ma->b = col.getBlue(); } // texture else if (ef->getDiffuse().isTexture()) { +#if 0 COLLADAFW::Texture ctex = ef->getDiffuse().getTexture(); - mtex = create_texture(ef, ctex, ma, i, texindex_texarray_map); - if (mtex != NULL) { - mtex->mapto = MAP_COL; - ma->texact = (int)i; - i++; - } +#endif } // AMBIENT // color if (ef->getAmbient().isColor()) { +#if 0 col = ef->getAmbient().getColor(); - ma->ambr = col.getRed(); - ma->ambg = col.getGreen(); - ma->ambb = col.getBlue(); +#endif } // texture else if (ef->getAmbient().isTexture()) { +#if 0 COLLADAFW::Texture ctex = ef->getAmbient().getTexture(); - mtex = create_texture(ef, ctex, ma, i, texindex_texarray_map); - if (mtex != NULL) { - mtex->mapto = MAP_AMB; - i++; - } +#endif } // SPECULAR // color @@ -872,29 +842,22 @@ void DocumentImporter::write_profile_COMMON(COLLADAFW::EffectCommon *ef, Materia } // texture else if (ef->getSpecular().isTexture()) { +#if 0 COLLADAFW::Texture ctex = ef->getSpecular().getTexture(); - mtex = create_texture(ef, ctex, ma, i, texindex_texarray_map); - if (mtex != NULL) { - mtex->mapto = MAP_SPEC; - i++; - } +#endif } // REFLECTIVE // color if (ef->getReflective().isColor()) { +#if 0 col = ef->getReflective().getColor(); - ma->mirr = col.getRed(); - ma->mirg = col.getGreen(); - ma->mirb = col.getBlue(); +#endif } // texture else if (ef->getReflective().isTexture()) { +#if 0 COLLADAFW::Texture ctex = ef->getReflective().getTexture(); - mtex = create_texture(ef, ctex, ma, i, texindex_texarray_map); - if (mtex != NULL) { - mtex->mapto = MAP_REF; - i++; - } +#endif } // EMISSION @@ -905,40 +868,31 @@ void DocumentImporter::write_profile_COMMON(COLLADAFW::EffectCommon *ef, Materia } // texture else if (ef->getEmission().isTexture()) { +#if 0 COLLADAFW::Texture ctex = ef->getEmission().getTexture(); - mtex = create_texture(ef, ctex, ma, i, texindex_texarray_map); - if (mtex != NULL) { - mtex->mapto = MAP_EMIT; - i++; - } +#endif } // TRANSPARENT // color if (ef->getOpacity().isColor()) { +#if 0 col = ef->getTransparent().getColor(); float alpha = ef->getTransparency().getFloatValue(); if (col.isValid()) { alpha *= col.getAlpha(); // Assuming A_ONE opaque mode } if (col.isValid() || alpha < 1.0) { - ma->alpha = alpha; - ma->mode |= MA_ZTRANSP | MA_TRANSP; + ... } +#endif } // texture else if (ef->getOpacity().isTexture()) { +#if 0 COLLADAFW::Texture ctex = ef->getOpacity().getTexture(); - mtex = create_texture(ef, ctex, ma, i, texindex_texarray_map); - if (mtex != NULL) { - mtex->mapto = MAP_ALPHA; - i++; - ma->spectra = ma->alpha = 0; - ma->mode |= MA_ZTRANSP | MA_TRANSP; - } +#endif } - - material_texture_mapping_map[ma] = texindex_texarray_map; } /** When this method is called, the writer must write the effect. @@ -1185,7 +1139,6 @@ bool DocumentImporter::writeLight(const COLLADAFW::Light *light) et->setData("spotsize", &(lamp->spotsize)); lamp->spotsize = DEG2RADF(lamp->spotsize); et->setData("spotblend", &(lamp->spotblend)); - et->setData("halo_intensity", &(lamp->haint)); et->setData("att1", &(lamp->att1)); et->setData("att2", &(lamp->att2)); et->setData("falloff_type", &(lamp->falloff_type)); @@ -1193,38 +1146,12 @@ bool DocumentImporter::writeLight(const COLLADAFW::Light *light) et->setData("clipend", &(lamp->clipend)); et->setData("bias", &(lamp->bias)); et->setData("soft", &(lamp->soft)); - et->setData("compressthresh", &(lamp->compressthresh)); et->setData("bufsize", &(lamp->bufsize)); - et->setData("samp", &(lamp->samp)); et->setData("buffers", &(lamp->buffers)); - et->setData("filtertype", &(lamp->filtertype)); - et->setData("bufflag", &(lamp->bufflag)); - et->setData("buftype", &(lamp->buftype)); - et->setData("ray_samp", &(lamp->ray_samp)); - et->setData("ray_sampy", &(lamp->ray_sampy)); - et->setData("ray_sampz", &(lamp->ray_sampz)); - et->setData("ray_samp_type", &(lamp->ray_samp_type)); et->setData("area_shape", &(lamp->area_shape)); et->setData("area_size", &(lamp->area_size)); et->setData("area_sizey", &(lamp->area_sizey)); et->setData("area_sizez", &(lamp->area_sizez)); - et->setData("adapt_thresh", &(lamp->adapt_thresh)); - et->setData("ray_samp_method", &(lamp->ray_samp_method)); - et->setData("shadhalostep", &(lamp->shadhalostep)); - et->setData("sun_effect_type", &(lamp->shadhalostep)); - et->setData("skyblendtype", &(lamp->skyblendtype)); - et->setData("horizon_brightness", &(lamp->horizon_brightness)); - et->setData("spread", &(lamp->spread)); - et->setData("sun_brightness", &(lamp->sun_brightness)); - et->setData("sun_size", &(lamp->sun_size)); - et->setData("backscattered_light", &(lamp->backscattered_light)); - et->setData("sun_intensity", &(lamp->sun_intensity)); - et->setData("atm_turbidity", &(lamp->atm_turbidity)); - et->setData("atm_extinction_factor", &(lamp->atm_extinction_factor)); - et->setData("atm_distance_factor", &(lamp->atm_distance_factor)); - et->setData("skyblendfac", &(lamp->skyblendfac)); - et->setData("sky_exposure", &(lamp->sky_exposure)); - et->setData("sky_colorspace", &(lamp->sky_colorspace)); } else { float constatt = light->getConstantAttenuation().getValue(); @@ -1288,7 +1215,6 @@ bool DocumentImporter::writeLight(const COLLADAFW::Light *light) { /* our sun is very strong, so pick a smaller energy level */ lamp->type = LA_SUN; - lamp->mode |= LA_NO_SPEC; } break; case COLLADAFW::Light::POINT_LIGHT: diff --git a/source/blender/collada/DocumentImporter.h b/source/blender/collada/DocumentImporter.h index fd61f3a68da..758caef7e60 100644 --- a/source/blender/collada/DocumentImporter.h +++ b/source/blender/collada/DocumentImporter.h @@ -77,7 +77,6 @@ public: Object* create_instance_node(Object*, COLLADAFW::Node*, COLLADAFW::Node*, Scene*, bool); void create_constraints(ExtraTags *et, Object *ob); std::vector *write_node(COLLADAFW::Node*, COLLADAFW::Node*, Scene*, Object*, bool); - MTex* create_texture(COLLADAFW::EffectCommon*, COLLADAFW::Texture&, Material*, int, TexIndexTextureArrayMap&); void write_profile_COMMON(COLLADAFW::EffectCommon*, Material*); void translate_anim_recursive(COLLADAFW::Node*, COLLADAFW::Node*, Object*); diff --git a/source/blender/collada/EffectExporter.cpp b/source/blender/collada/EffectExporter.cpp index 66f3f81f71f..dbcdfd01a9c 100644 --- a/source/blender/collada/EffectExporter.cpp +++ b/source/blender/collada/EffectExporter.cpp @@ -41,7 +41,6 @@ extern "C" { #include "DNA_mesh_types.h" - #include "DNA_texture_types.h" #include "DNA_world_types.h" #include "BKE_collection.h" @@ -95,128 +94,27 @@ void EffectsExporter::exportEffects(Scene *sce) } } -void EffectsExporter::writeBlinn(COLLADASW::EffectProfile &ep, Material *ma) -{ - COLLADASW::ColorOrTexture cot; - ep.setShaderType(COLLADASW::EffectProfile::BLINN); - // shininess - ep.setShininess(ma->har, false, "shininess"); - // specular - cot = getcol(ma->specr, ma->specg, ma->specb, 1.0f); - ep.setSpecular(cot, false, "specular"); -} - void EffectsExporter::writeLambert(COLLADASW::EffectProfile &ep, Material *ma) { COLLADASW::ColorOrTexture cot; ep.setShaderType(COLLADASW::EffectProfile::LAMBERT); } -void EffectsExporter::writePhong(COLLADASW::EffectProfile &ep, Material *ma) -{ - COLLADASW::ColorOrTexture cot; - ep.setShaderType(COLLADASW::EffectProfile::PHONG); - // shininess - ep.setShininess(ma->har, false, "shininess"); - // specular - cot = getcol(ma->specr, ma->specg, ma->specb, 1.0f); - ep.setSpecular(cot, false, "specular"); -} - -void EffectsExporter::writeTextures( - COLLADASW::EffectProfile &ep, - std::string &key, - COLLADASW::Sampler *sampler, - MTex *t, Image *ima, - std::string &uvname ) -{ - // Image not set for texture - if (!ima) return; - - // color - if (t->mapto & MAP_COL) { - ep.setDiffuse(createTexture(ima, uvname, sampler), false, "diffuse"); - } - // ambient - if (t->mapto & MAP_AMB) { - ep.setAmbient(createTexture(ima, uvname, sampler), false, "ambient"); - } - // specular - if (t->mapto & (MAP_SPEC | MAP_COLSPEC)) { - ep.setSpecular(createTexture(ima, uvname, sampler), false, "specular"); - } - // emission - if (t->mapto & MAP_EMIT) { - ep.setEmission(createTexture(ima, uvname, sampler), false, "emission"); - } - // reflective - if (t->mapto & MAP_REF) { - ep.setReflective(createTexture(ima, uvname, sampler)); - } - // alpha - if (t->mapto & MAP_ALPHA) { - ep.setTransparent(createTexture(ima, uvname, sampler)); - } - // extension: - // Normal map --> Must be stored with tag as different technique, - // since COLLADA doesn't support normal maps, even in current COLLADA 1.5. - if (t->mapto & MAP_NORM) { - COLLADASW::Texture texture(key); - texture.setTexcoord(uvname); - texture.setSampler(*sampler); - // technique FCOLLADA, with the tag, is most likely the best understood, - // most widespread de-facto standard. - texture.setProfileName("FCOLLADA"); - texture.setChildElementName("bump"); - ep.addExtraTechniqueColorOrTexture(COLLADASW::ColorOrTexture(texture)); - } -} - void EffectsExporter::operator()(Material *ma, Object *ob) { - // create a list of indices to textures of type TEX_IMAGE - std::vector tex_indices; - if (this->export_settings->include_material_textures) - createTextureIndices(ma, tex_indices); + // TODO: add back texture and extended material parameter support openEffect(translate_id(id_name(ma)) + "-effect"); COLLADASW::EffectProfile ep(mSW); 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_shader == MA_SPEC_BLINN) { - writeBlinn(ep, ma); - } - else { - // \todo figure out handling of all spec+diff shader combos blender has, for now write phong - // for now set phong in case spec shader is not blinn - writePhong(ep, ma); - } - } - else { - if (ma->diff_shader == MA_DIFF_LAMBERT) { - writeLambert(ep, ma); - } - else { - // \todo figure out handling of all spec+diff shader combos blender has, for now write phong - writePhong(ep, ma); - } - } + writeLambert(ep, ma); - // index of refraction - if (ma->mode & MA_RAYTRANSP) { - ep.setIndexOfRefraction(ma->ang, false, "index_of_refraction"); - } - else { - ep.setIndexOfRefraction(1.0f, false, "index_of_refraction"); - } - COLLADASW::ColorOrTexture cot; // transparency - if (ma->mode & MA_TRANSP) { + if (ma->alpha != 1.0f) { // Tod: because we are in A_ONE mode transparency is calculated like this: cot = getcol(1.0f, 1.0f, 1.0f, ma->alpha); ep.setTransparent(cot); @@ -224,34 +122,14 @@ void EffectsExporter::operator()(Material *ma, Object *ob) } // emission +#if 0 cot = getcol(ma->emit, ma->emit, ma->emit, 1.0f); - ep.setEmission(cot, false, "emission"); +#endif - // diffuse multiplied by diffuse intensity - cot = getcol(ma->r * ma->ref, ma->g * ma->ref, ma->b * ma->ref, 1.0f); + // diffuse + cot = getcol(ma->r, ma->g, ma->b, 1.0f); ep.setDiffuse(cot, false, "diffuse"); - // 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); - else - cot = getcol(ma->amb, ma->amb, ma->amb, 1.0f); - - ep.setAmbient(cot, false, "ambient"); - - // reflective, reflectivity - if (ma->mode & MA_RAYMIRROR) { - cot = getcol(ma->mirr, ma->mirg, ma->mirb, 1.0f); - ep.setReflective(cot); - ep.setReflectivity(ma->ray_mirror); - } - // else { - // cot = getcol(ma->specr, ma->specg, ma->specb, 1.0f); - // ep.setReflective(cot); - // ep.setReflectivity(ma->spec); - // } - // specular if (ep.getShaderType() != COLLADASW::EffectProfile::LAMBERT) { cot = getcol(ma->specr * ma->spec, ma->specg * ma->spec, ma->specb * ma->spec, 1.0f); @@ -260,6 +138,7 @@ void EffectsExporter::operator()(Material *ma, Object *ob) // XXX make this more readable if possible +#if 0 // create and for each image COLLADASW::Sampler samplers[MAX_MTEX]; //COLLADASW::Surface surfaces[MAX_MTEX]; @@ -310,6 +189,7 @@ void EffectsExporter::operator()(Material *ma, Object *ob) b++; } } +#endif // used as fallback when MTex->uvname is "" (this is pretty common) // it is indeed the correct value to use in that case @@ -317,6 +197,7 @@ void EffectsExporter::operator()(Material *ma, Object *ob) // write textures // XXX very slow +#if 0 for (a = 0; a < tex_indices.size(); a++) { MTex *t = ma->mtex[tex_indices[a]]; Image *ima = t->tex->ima; @@ -332,6 +213,7 @@ void EffectsExporter::operator()(Material *ma, Object *ob) COLLADASW::Sampler *sampler = (COLLADASW::Sampler *)samp_surf[i]; writeTextures(ep, key, sampler, t, ima, uvname); } +#endif // performs the actual writing ep.addProfileElements(); @@ -372,20 +254,3 @@ COLLADASW::ColorOrTexture EffectsExporter::getcol(float r, float g, float b, flo COLLADASW::ColorOrTexture cot(color); return cot; } - -//returns the array of mtex indices which have image -//need this for exporting textures -void EffectsExporter::createTextureIndices(Material *ma, std::vector &indices) -{ - indices.clear(); - - for (int a = 0; a < MAX_MTEX; a++) { - if (ma->mtex[a] && - ma->mtex[a]->tex && - ma->mtex[a]->tex->type == TEX_IMAGE && - ma->mtex[a]->texco == TEXCO_UV) - { - indices.push_back(a); - } - } -} diff --git a/source/blender/collada/EffectExporter.h b/source/blender/collada/EffectExporter.h index d20cbfdfe0b..eac428ae330 100644 --- a/source/blender/collada/EffectExporter.h +++ b/source/blender/collada/EffectExporter.h @@ -58,12 +58,7 @@ public: COLLADASW::ColorOrTexture getcol(float r, float g, float b, float a); private: - /** Fills the array of mtex indices which have image. Used for exporting images. */ - void createTextureIndices(Material *ma, std::vector &indices); - - void writeBlinn(COLLADASW::EffectProfile &ep, Material *ma); void writeLambert(COLLADASW::EffectProfile &ep, Material *ma); - void writePhong(COLLADASW::EffectProfile &ep, Material *ma); void writeTextures(COLLADASW::EffectProfile &ep, std::string &key, COLLADASW::Sampler *sampler, diff --git a/source/blender/collada/ImageExporter.cpp b/source/blender/collada/ImageExporter.cpp index 3cdc013c137..657037a869a 100644 --- a/source/blender/collada/ImageExporter.cpp +++ b/source/blender/collada/ImageExporter.cpp @@ -164,12 +164,7 @@ bool ImagesExporter::hasImages(Scene *sce) // no material, but check all of the slots if (!ma) continue; - int b; - for (b = 0; b < MAX_MTEX; b++) { - MTex *mtex = ma->mtex[b]; - if (mtex && mtex->tex && mtex->tex->ima) return true; - } - + // TODO: find image textures in shader nodes } } return false; @@ -191,13 +186,6 @@ void ImagesExporter::exportImages(Scene *sce) void ImagesExporter::operator()(Material *ma, Object *ob) { - int a; - bool use_texture_copies = this->export_settings->use_texture_copies; - for (a = 0; a < MAX_MTEX; a++) { - MTex *mtex = ma->mtex[a]; - if (mtex && mtex->tex && mtex->tex->ima) { - Image *image = mtex->tex->ima; - export_UV_Image(image, use_texture_copies); - } - } + // bool use_texture_copies = this->export_settings->use_texture_copies; + // TODO call export_UV_Image for every image in shader nodes } diff --git a/source/blender/collada/LightExporter.cpp b/source/blender/collada/LightExporter.cpp index ff50abfedae..d17941574d7 100644 --- a/source/blender/collada/LightExporter.cpp +++ b/source/blender/collada/LightExporter.cpp @@ -149,7 +149,6 @@ bool LightsExporter::exportBlenderProfile(COLLADASW::Light &cla, Lamp *la) cla.addExtraTechniqueParameter("blender", "dist", la->dist, "blender_dist"); cla.addExtraTechniqueParameter("blender", "spotsize", RAD2DEGF(la->spotsize)); cla.addExtraTechniqueParameter("blender", "spotblend", la->spotblend); - cla.addExtraTechniqueParameter("blender", "halo_intensity", la->haint, "blnder_halo_intensity"); cla.addExtraTechniqueParameter("blender", "att1", la->att1); cla.addExtraTechniqueParameter("blender", "att2", la->att2); // \todo figure out how we can have falloff curve supported here @@ -158,38 +157,13 @@ bool LightsExporter::exportBlenderProfile(COLLADASW::Light &cla, Lamp *la) cla.addExtraTechniqueParameter("blender", "clipend", la->clipend); cla.addExtraTechniqueParameter("blender", "bias", la->bias); cla.addExtraTechniqueParameter("blender", "soft", la->soft); - cla.addExtraTechniqueParameter("blender", "compressthresh", la->compressthresh); cla.addExtraTechniqueParameter("blender", "bufsize", la->bufsize); cla.addExtraTechniqueParameter("blender", "samp", la->samp); cla.addExtraTechniqueParameter("blender", "buffers", la->buffers); - cla.addExtraTechniqueParameter("blender", "filtertype", la->filtertype); - cla.addExtraTechniqueParameter("blender", "bufflag", la->bufflag); - cla.addExtraTechniqueParameter("blender", "buftype", la->buftype); - cla.addExtraTechniqueParameter("blender", "ray_samp", la->ray_samp); - cla.addExtraTechniqueParameter("blender", "ray_sampy", la->ray_sampy); - cla.addExtraTechniqueParameter("blender", "ray_sampz", la->ray_sampz); - cla.addExtraTechniqueParameter("blender", "ray_samp_type", la->ray_samp_type); cla.addExtraTechniqueParameter("blender", "area_shape", la->area_shape); cla.addExtraTechniqueParameter("blender", "area_size", la->area_size); cla.addExtraTechniqueParameter("blender", "area_sizey", la->area_sizey); cla.addExtraTechniqueParameter("blender", "area_sizez", la->area_sizez); - cla.addExtraTechniqueParameter("blender", "adapt_thresh", la->adapt_thresh); - cla.addExtraTechniqueParameter("blender", "ray_samp_method", la->ray_samp_method); - cla.addExtraTechniqueParameter("blender", "shadhalostep", la->shadhalostep); - cla.addExtraTechniqueParameter("blender", "sun_effect_type", la->shadhalostep); - cla.addExtraTechniqueParameter("blender", "skyblendtype", la->skyblendtype); - cla.addExtraTechniqueParameter("blender", "horizon_brightness", la->horizon_brightness); - cla.addExtraTechniqueParameter("blender", "spread", la->spread); - cla.addExtraTechniqueParameter("blender", "sun_brightness", la->sun_brightness); - cla.addExtraTechniqueParameter("blender", "sun_size", la->sun_size); - cla.addExtraTechniqueParameter("blender", "backscattered_light", la->backscattered_light); - cla.addExtraTechniqueParameter("blender", "sun_intensity", la->sun_intensity); - cla.addExtraTechniqueParameter("blender", "atm_turbidity", la->atm_turbidity); - cla.addExtraTechniqueParameter("blender", "atm_extinction_factor", la->atm_extinction_factor); - cla.addExtraTechniqueParameter("blender", "atm_distance_factor", la->atm_distance_factor); - cla.addExtraTechniqueParameter("blender", "skyblendfac", la->skyblendfac); - cla.addExtraTechniqueParameter("blender", "sky_exposure", la->sky_exposure); - cla.addExtraTechniqueParameter("blender", "sky_colorspace", la->sky_colorspace); return true; } diff --git a/source/blender/collada/MeshImporter.cpp b/source/blender/collada/MeshImporter.cpp index 339c8cec191..10b9745a6b9 100644 --- a/source/blender/collada/MeshImporter.cpp +++ b/source/blender/collada/MeshImporter.cpp @@ -879,48 +879,6 @@ std::string *MeshImporter::get_geometry_name(const std::string &mesh_name) return NULL; } -MTex *MeshImporter::assign_textures_to_uvlayer(COLLADAFW::TextureCoordinateBinding &ctexture, - Mesh *me, TexIndexTextureArrayMap& texindex_texarray_map, - MTex *color_texture) -{ - const COLLADAFW::TextureMapId texture_index = ctexture.getTextureMapId(); - size_t setindex = ctexture.getSetIndex(); - std::string uvname = ctexture.getSemantic(); - - if (setindex == -1) return NULL; - - const CustomData *data = &me->fdata; - int layer_index = CustomData_get_layer_index(data, CD_MTFACE); - - if (layer_index == -1) return NULL; - - CustomDataLayer *cdl = &data->layers[layer_index + setindex]; - - /* set uvname to bind_vertex_input semantic */ - BLI_strncpy(cdl->name, uvname.c_str(), sizeof(cdl->name)); - - if (texindex_texarray_map.find(texture_index) == texindex_texarray_map.end()) { - - fprintf(stderr, "Cannot find texture array by texture index.\n"); - return color_texture; - } - - std::vector textures = texindex_texarray_map[texture_index]; - - std::vector::iterator it; - - for (it = textures.begin(); it != textures.end(); it++) { - - MTex *texture = *it; - - if (texture) { - BLI_strncpy(texture->uvname, uvname.c_str(), sizeof(texture->uvname)); - if (texture->mapto == MAP_COL) color_texture = texture; - } - } - return color_texture; -} - /** * this function checks if both objects have the same * materials assigned to Object (in the same order) @@ -1058,10 +1016,8 @@ void MeshImporter::assign_material_to_geom( COLLADAFW::MaterialBinding cmaterial, std::map& uid_material_map, Object *ob, const COLLADAFW::UniqueId *geom_uid, - std::map& material_texture_mapping_map, short mat_index) + short mat_index) { - MTex *color_texture = NULL; - Mesh *me = (Mesh *)ob->data; const COLLADAFW::UniqueId& ma_uid = cmaterial.getReferencedMaterial(); // do we know this material? @@ -1081,17 +1037,6 @@ void MeshImporter::assign_material_to_geom( ob->actcol=0; assign_material(ob, ma, mat_index + 1, BKE_MAT_ASSIGN_OBJECT); - COLLADAFW::TextureCoordinateBindingArray& tex_array = - cmaterial.getTextureCoordinateBindingArray(); - TexIndexTextureArrayMap texindex_texarray_map = material_texture_mapping_map[ma]; - unsigned int i; - // loop through - for (i = 0; i < tex_array.getCount(); i++) { - - color_texture = assign_textures_to_uvlayer(tex_array[i], me, texindex_texarray_map, - color_texture); - } - MaterialIdPrimitiveArrayMap& mat_prim_map = geom_uid_mat_mapping_map[*geom_uid]; COLLADAFW::MaterialId mat_id = cmaterial.getMaterialId(); @@ -1106,7 +1051,7 @@ void MeshImporter::assign_material_to_geom( Primitive& prim = *it; MPoly *mpoly = prim.mpoly; - for (i = 0; i < prim.totpoly; i++, mpoly++) { + for (int i = 0; i < prim.totpoly; i++, mpoly++) { mpoly->mat_nr = mat_index; } } @@ -1115,8 +1060,7 @@ void MeshImporter::assign_material_to_geom( Object *MeshImporter::create_mesh_object(COLLADAFW::Node *node, COLLADAFW::InstanceGeometry *geom, bool isController, - std::map& uid_material_map, - std::map& material_texture_mapping_map) + std::map& uid_material_map) { const COLLADAFW::UniqueId *geom_uid = &geom->getInstanciatedObjectId(); @@ -1173,7 +1117,7 @@ Object *MeshImporter::create_mesh_object(COLLADAFW::Node *node, COLLADAFW::Insta if (mat_array[i].getReferencedMaterial().isValid()) { assign_material_to_geom( mat_array[i], uid_material_map, ob, geom_uid, - material_texture_mapping_map, i); + i); } else { fprintf(stderr, "invalid referenced material for %s\n", mat_array[i].getName().c_str()); diff --git a/source/blender/collada/MeshImporter.h b/source/blender/collada/MeshImporter.h index f57f57e07a7..09b3005d795 100644 --- a/source/blender/collada/MeshImporter.h +++ b/source/blender/collada/MeshImporter.h @@ -51,7 +51,6 @@ extern "C" { #include "DNA_meshdata_types.h" #include "DNA_object_types.h" #include "DNA_scene_types.h" -#include "DNA_texture_types.h" } @@ -167,23 +166,18 @@ public: virtual Mesh *get_mesh_by_geom_uid(const COLLADAFW::UniqueId& geom_uid); - MTex *assign_textures_to_uvlayer(COLLADAFW::TextureCoordinateBinding &ctexture, - Mesh *me, TexIndexTextureArrayMap& texindex_texarray_map, - MTex *color_texture); - void optimize_material_assignements(); void assign_material_to_geom( COLLADAFW::MaterialBinding cmaterial, std::map& uid_material_map, Object *ob, const COLLADAFW::UniqueId *geom_uid, - std::map& material_texture_mapping_map, short mat_index); + short mat_index); Object *create_mesh_object(COLLADAFW::Node *node, COLLADAFW::InstanceGeometry *geom, bool isController, - std::map& uid_material_map, - std::map& material_texture_mapping_map); + std::map& uid_material_map); // create a mesh storing a pointer in a map so it can be retrieved later by geometry UID bool write_geometry(const COLLADAFW::Geometry* geom); diff --git a/source/blender/collada/collada_utils.cpp b/source/blender/collada/collada_utils.cpp index 670dcba0a24..778ead55c8d 100644 --- a/source/blender/collada/collada_utils.cpp +++ b/source/blender/collada/collada_utils.cpp @@ -952,127 +952,3 @@ std::string bc_get_uvlayer_name(Mesh *me, int layer) } return ""; } - -#if 0 -/********************************************************************** -* -* Return the list of Mesh objects with assigned UVtextures and Images -* Note: We need to create artificaial materials for each of them -* -***********************************************************************/ -std::set bc_getUVTexturedObjects(Scene *sce, bool all_uv_layers) -{ - std::set UVObjects; - Base *base = (Base *)sce->base.first; - - while (base) { - Object *ob = base->object; - bool has_uvimage = false; - if (ob->type == OB_MESH) { - Mesh *me = (Mesh *)ob->data; - int active_uv_layer = CustomData_get_active_layer_index(&me->pdata, CD_MTEXPOLY); - - for (int i = 0; i < me->pdata.totlayer && !has_uvimage; i++) { - if (all_uv_layers || active_uv_layer == i) - { - if (me->pdata.layers[i].type == CD_MTEXPOLY) { - MTexPoly *txface = (MTexPoly *)me->pdata.layers[i].data; - MPoly *mpoly = me->mpoly; - for (int j = 0; j < me->totpoly; j++, mpoly++, txface++) { - - Image *ima = txface->tpage; - if (ima != NULL) { - has_uvimage = true; - break; - } - } - } - } - } - - if (has_uvimage) { - UVObjects.insert(ob); - } - } - base = base->next; - } - return UVObjects; -} - -/********************************************************************** -* -* Return the list of UV Texture images from all exported Mesh Items -* Note: We need to create one artificial material for each Image. -* -***********************************************************************/ -std::set bc_getUVImages(Scene *sce, bool all_uv_layers) -{ - std::set UVImages; - Base *base = (Base *)sce->base.first; - - while (base) { - Object *ob = base->object; - bool has_uvimage = false; - if (ob->type == OB_MESH) { - Mesh *me = (Mesh *)ob->data; - int active_uv_layer = CustomData_get_active_layer_index(&me->pdata, CD_MTEXPOLY); - - for (int i = 0; i < me->pdata.totlayer && !has_uvimage; i++) { - if (all_uv_layers || active_uv_layer == i) - { - if (me->pdata.layers[i].type == CD_MTEXPOLY) { - MTexPoly *txface = (MTexPoly *)me->pdata.layers[i].data; - MPoly *mpoly = me->mpoly; - for (int j = 0; j < me->totpoly; j++, mpoly++, txface++) { - - Image *ima = txface->tpage; - if (ima != NULL) { - if (UVImages.find(ima) == UVImages.end()) - UVImages.insert(ima); - } - } - } - } - } - } - base = base->next; - } - return UVImages; -} - -/********************************************************************** -* -* Return the list of UV Texture images for the given Object -* Note: We need to create one artificial material for each Image. -* -***********************************************************************/ -std::set bc_getUVImages(Object *ob, bool all_uv_layers) -{ - std::set UVImages; - - bool has_uvimage = false; - if (ob->type == OB_MESH) { - Mesh *me = (Mesh *)ob->data; - int active_uv_layer = CustomData_get_active_layer_index(&me->pdata, CD_MTEXPOLY); - - for (int i = 0; i < me->pdata.totlayer && !has_uvimage; i++) { - if (all_uv_layers || active_uv_layer == i) - { - if (me->pdata.layers[i].type == CD_MTEXPOLY) { - MTexPoly *txface = (MTexPoly *)me->pdata.layers[i].data; - MPoly *mpoly = me->mpoly; - for (int j = 0; j < me->totpoly; j++, mpoly++, txface++) { - - Image *ima = txface->tpage; - if (ima != NULL) { - if (UVImages.find(ima) == UVImages.end()) - UVImages.insert(ima); - } - } - } - } - } - } - return UVImages; -} -#endif -- cgit v1.2.3