forked from bartvdbraak/blender
Added option for exporting material based textures. Cleaned up header files due to a bug in osx
This commit is contained in:
parent
870dba7657
commit
8ef4c4762b
@ -173,7 +173,8 @@ void EffectsExporter::operator()(Material *ma, Object *ob)
|
||||
{
|
||||
// create a list of indices to textures of type TEX_IMAGE
|
||||
std::vector<int> tex_indices;
|
||||
createTextureIndices(ma, tex_indices);
|
||||
if(this->export_settings->include_material_textures)
|
||||
createTextureIndices(ma, tex_indices);
|
||||
|
||||
openEffect(translate_id(id_name(ma)) + "-effect");
|
||||
|
||||
@ -309,7 +310,7 @@ void EffectsExporter::operator()(Material *ma, Object *ob)
|
||||
|
||||
|
||||
std::set<Image *> uv_textures;
|
||||
if (ob->type == OB_MESH && ob->totcol) {
|
||||
if (ob->type == OB_MESH && ob->totcol && this->export_settings->include_uv_textures) {
|
||||
Mesh *me = (Mesh *) ob->data;
|
||||
BKE_mesh_tessface_ensure(me);
|
||||
for (int i = 0; i < me->pdata.totlayer; i++) {
|
||||
|
@ -64,7 +64,7 @@ private:
|
||||
void writeBlinn(COLLADASW::EffectProfile &ep, Material *ma);
|
||||
void writeLambert(COLLADASW::EffectProfile &ep, Material *ma);
|
||||
void writePhong(COLLADASW::EffectProfile &ep, Material *ma);
|
||||
void EffectsExporter::writeTextures(COLLADASW::EffectProfile &ep,
|
||||
void writeTextures(COLLADASW::EffectProfile &ep,
|
||||
std::string &key,
|
||||
COLLADASW::Sampler *sampler,
|
||||
MTex *t, Image *ima,
|
||||
|
@ -41,6 +41,7 @@ public:
|
||||
|
||||
bool active_uv_only;
|
||||
bool include_uv_textures;
|
||||
bool include_material_textures;
|
||||
bool use_texture_copies;
|
||||
|
||||
bool use_object_instantiation;
|
||||
|
@ -98,7 +98,7 @@ void ImagesExporter::export_UV_Image(Image *image, bool use_copies)
|
||||
// So we have to export it. The export will keep the image state intact,
|
||||
// so the exported file will not be associated with the image.
|
||||
|
||||
if (BKE_imbuf_write_as(imbuf, export_path, &imageFormat, true) != 0) {
|
||||
if (BKE_imbuf_write_as(imbuf, export_path, &imageFormat, true) == 0) {
|
||||
fprintf(stderr, "Collada export: Cannot export image to:\n%s\n", export_path);
|
||||
}
|
||||
BLI_strncpy(export_path, export_file, sizeof(export_path));
|
||||
@ -215,7 +215,9 @@ void ImagesExporter::exportImages(Scene *sce)
|
||||
openLibrary();
|
||||
|
||||
MaterialFunctor mf;
|
||||
mf.forEachMaterialInExportSet<ImagesExporter>(sce, *this, this->export_settings->export_set);
|
||||
if (this->export_settings->include_material_textures) {
|
||||
mf.forEachMaterialInExportSet<ImagesExporter>(sce, *this, this->export_settings->export_set);
|
||||
}
|
||||
|
||||
if (this->export_settings->include_uv_textures) {
|
||||
export_UV_Images();
|
||||
|
@ -51,8 +51,8 @@ public:
|
||||
private:
|
||||
std::vector<std::string> mImages; // contains list of written images, to avoid duplicates
|
||||
|
||||
void ImagesExporter::export_UV_Images();
|
||||
void ImagesExporter::export_UV_Image(Image *image, bool use_texture_copies);
|
||||
void export_UV_Images();
|
||||
void export_UV_Image(Image *image, bool use_texture_copies);
|
||||
bool hasImages(Scene *sce);
|
||||
const ExportSettings *export_settings;
|
||||
};
|
||||
|
@ -63,6 +63,7 @@ int collada_export(Scene *sce,
|
||||
|
||||
int active_uv_only,
|
||||
int include_uv_textures,
|
||||
int include_material_textures,
|
||||
int use_texture_copies,
|
||||
|
||||
int use_object_instantiation,
|
||||
@ -90,8 +91,9 @@ int collada_export(Scene *sce,
|
||||
export_settings.deform_bones_only = deform_bones_only != 0;
|
||||
|
||||
export_settings.active_uv_only = active_uv_only != 0;
|
||||
export_settings.include_uv_textures = include_uv_textures;
|
||||
export_settings.use_texture_copies = use_texture_copies;
|
||||
export_settings.include_uv_textures = include_uv_textures != 0;
|
||||
export_settings.include_material_textures= include_material_textures != 0;
|
||||
export_settings.use_texture_copies = use_texture_copies != 0;
|
||||
|
||||
export_settings.use_object_instantiation = use_object_instantiation != 0;
|
||||
export_settings.sort_by_name = sort_by_name != 0;
|
||||
|
@ -57,8 +57,9 @@ int collada_export(Scene *sce,
|
||||
int include_armatures,
|
||||
int deform_bones_only,
|
||||
|
||||
int active_uv,
|
||||
int include_textures,
|
||||
int active_uv_only,
|
||||
int include_uv_textures,
|
||||
int include_material_textures,
|
||||
int use_texture_copies,
|
||||
|
||||
int use_object_instantiation,
|
||||
|
@ -85,6 +85,7 @@ static int wm_collada_export_exec(bContext *C, wmOperator *op)
|
||||
int deform_bones_only;
|
||||
|
||||
int include_uv_textures;
|
||||
int include_material_textures;
|
||||
int use_texture_copies;
|
||||
int active_uv_only;
|
||||
|
||||
@ -109,6 +110,7 @@ static int wm_collada_export_exec(bContext *C, wmOperator *op)
|
||||
deform_bones_only = RNA_boolean_get(op->ptr, "deform_bones_only");
|
||||
|
||||
include_uv_textures = RNA_boolean_get(op->ptr, "include_uv_textures");
|
||||
include_material_textures= RNA_boolean_get(op->ptr, "include_material_textures");
|
||||
use_texture_copies = RNA_boolean_get(op->ptr, "use_texture_copies");
|
||||
active_uv_only = RNA_boolean_get(op->ptr, "active_uv_only");
|
||||
|
||||
@ -129,8 +131,9 @@ static int wm_collada_export_exec(bContext *C, wmOperator *op)
|
||||
include_armatures,
|
||||
deform_bones_only,
|
||||
|
||||
include_uv_textures,
|
||||
active_uv_only,
|
||||
include_uv_textures,
|
||||
include_material_textures,
|
||||
use_texture_copies,
|
||||
|
||||
use_object_instantiation,
|
||||
@ -182,6 +185,9 @@ void uiCollada_exportSettings(uiLayout *layout, PointerRNA *imfptr)
|
||||
row = uiLayoutRow(box, 0);
|
||||
uiItemR(row, imfptr, "include_uv_textures", 0, NULL, ICON_NONE);
|
||||
|
||||
row = uiLayoutRow(box, 0);
|
||||
uiItemR(row, imfptr, "include_material_textures", 0, NULL, ICON_NONE);
|
||||
|
||||
row = uiLayoutRow(box, 0);
|
||||
uiItemR(row, imfptr, "use_texture_copies", 1, NULL, ICON_NONE);
|
||||
|
||||
@ -267,6 +273,9 @@ void WM_OT_collada_export(wmOperatorType *ot)
|
||||
RNA_def_boolean(ot->srna, "include_uv_textures", 0, "Include UV Textures",
|
||||
"Export textures assigned to the object UV maps");
|
||||
|
||||
RNA_def_boolean(ot->srna, "include_material_textures", 0, "Include Material Textures",
|
||||
"Export textures assigned to the object Materials");
|
||||
|
||||
RNA_def_boolean(ot->srna, "use_texture_copies", 1, "copy",
|
||||
"Copy textures to same folder where the .dae file is exported");
|
||||
|
||||
|
@ -98,7 +98,8 @@ static void rna_Scene_collada_export(
|
||||
int deform_bones_only,
|
||||
|
||||
int active_uv_only,
|
||||
int include_textures,
|
||||
int include_uv_textures,
|
||||
int include_material_textures,
|
||||
int use_texture_copies,
|
||||
|
||||
int use_object_instantiation,
|
||||
@ -107,8 +108,8 @@ static void rna_Scene_collada_export(
|
||||
{
|
||||
collada_export(scene, filepath, apply_modifiers, export_mesh_type, selected,
|
||||
include_children, include_armatures, deform_bones_only,
|
||||
active_uv_only, include_textures, use_texture_copies,
|
||||
use_object_instantiation, sort_by_name, second_life);
|
||||
active_uv_only, include_uv_textures, include_material_textures,
|
||||
use_texture_copies, use_object_instantiation, sort_by_name, second_life);
|
||||
}
|
||||
|
||||
#endif
|
||||
@ -145,7 +146,8 @@ void RNA_api_scene(StructRNA *srna)
|
||||
parm = RNA_def_boolean(func, "deform_bones_only", 0, "Deform Bones only", "Only export deforming bones with armatures");
|
||||
|
||||
parm = RNA_def_boolean(func, "active_uv_only", 0, "Active UV Layer only", "Export only the active UV Layer");
|
||||
parm = RNA_def_boolean(func, "include_textures", 0, "Include Textures", "Export related textures");
|
||||
parm = RNA_def_boolean(func, "include_uv_textures", 0, "Include UV Textures", "Export textures assigned to the object UV maps");
|
||||
parm = RNA_def_boolean(func, "include_material_textures", 0, "Include Material Textures", "Export textures assigned to the object Materials");
|
||||
parm = RNA_def_boolean(func, "use_texture_copies", 0, "copy", "Copy textures to same folder where the .dae file is exported");
|
||||
|
||||
parm = RNA_def_boolean(func, "use_object_instantiation", 1, "Use Object Instances", "Instantiate multiple Objects from same Data");
|
||||
|
Loading…
Reference in New Issue
Block a user