forked from bartvdbraak/blender
Collada: (Exporter) add 'mesh type selection(view|render)' for Apply modifiers option
This commit is contained in:
parent
b5b8306685
commit
0df30d1063
@ -345,7 +345,7 @@ void ArmatureExporter::export_controller(Object *ob, Object *ob_arm)
|
|||||||
Mesh *me;
|
Mesh *me;
|
||||||
|
|
||||||
if (this->export_settings->apply_modifiers) {
|
if (this->export_settings->apply_modifiers) {
|
||||||
me = bc_to_mesh_apply_modifiers(scene, ob);
|
me = bc_to_mesh_apply_modifiers(scene, ob, this->export_settings->export_mesh_type);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
me = (Mesh *)ob->data;
|
me = (Mesh *)ob->data;
|
||||||
|
@ -24,16 +24,15 @@
|
|||||||
* \ingroup collada
|
* \ingroup collada
|
||||||
*/
|
*/
|
||||||
|
|
||||||
extern "C" {
|
|
||||||
#include "BLI_linklist.h"
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifndef __EXPORTSETTINGS_H__
|
#ifndef __EXPORTSETTINGS_H__
|
||||||
#define __EXPORTSETTINGS_H__
|
#define __EXPORTSETTINGS_H__
|
||||||
|
|
||||||
|
#include "collada.h"
|
||||||
|
|
||||||
struct ExportSettings {
|
struct ExportSettings {
|
||||||
public:
|
public:
|
||||||
bool apply_modifiers;
|
bool apply_modifiers;
|
||||||
|
BC_export_mesh_type export_mesh_type;
|
||||||
bool selected;
|
bool selected;
|
||||||
bool include_children;
|
bool include_children;
|
||||||
bool include_armatures;
|
bool include_armatures;
|
||||||
|
@ -78,7 +78,7 @@ void GeometryExporter::operator()(Object *ob)
|
|||||||
bool use_instantiation = this->export_settings->use_object_instantiation;
|
bool use_instantiation = this->export_settings->use_object_instantiation;
|
||||||
Mesh *me;
|
Mesh *me;
|
||||||
if (this->export_settings->apply_modifiers) {
|
if (this->export_settings->apply_modifiers) {
|
||||||
me = bc_to_mesh_apply_modifiers(mScene, ob);
|
me = bc_to_mesh_apply_modifiers(mScene, ob, this->export_settings->export_mesh_type);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
me = (Mesh *)ob->data;
|
me = (Mesh *)ob->data;
|
||||||
|
@ -28,9 +28,9 @@
|
|||||||
/* COLLADABU_ASSERT, may be able to remove later */
|
/* COLLADABU_ASSERT, may be able to remove later */
|
||||||
#include "COLLADABUPlatform.h"
|
#include "COLLADABUPlatform.h"
|
||||||
|
|
||||||
#include "ExportSettings.h"
|
|
||||||
#include "DocumentExporter.h"
|
#include "DocumentExporter.h"
|
||||||
#include "DocumentImporter.h"
|
#include "DocumentImporter.h"
|
||||||
|
#include "ExportSettings.h"
|
||||||
|
|
||||||
extern "C"
|
extern "C"
|
||||||
{
|
{
|
||||||
@ -40,6 +40,7 @@ extern "C"
|
|||||||
/* make dummy file */
|
/* make dummy file */
|
||||||
#include "BLI_fileops.h"
|
#include "BLI_fileops.h"
|
||||||
#include "BLI_path_util.h"
|
#include "BLI_path_util.h"
|
||||||
|
#include "BLI_linklist.h"
|
||||||
|
|
||||||
int collada_import(bContext *C, const char *filepath)
|
int collada_import(bContext *C, const char *filepath)
|
||||||
{
|
{
|
||||||
@ -53,6 +54,7 @@ int collada_export(Scene *sce,
|
|||||||
const char *filepath,
|
const char *filepath,
|
||||||
|
|
||||||
int apply_modifiers,
|
int apply_modifiers,
|
||||||
|
BC_export_mesh_type export_mesh_type,
|
||||||
|
|
||||||
int selected,
|
int selected,
|
||||||
int include_children,
|
int include_children,
|
||||||
@ -77,7 +79,7 @@ int collada_export(Scene *sce,
|
|||||||
export_settings.filepath = (char *)filepath;
|
export_settings.filepath = (char *)filepath;
|
||||||
|
|
||||||
export_settings.apply_modifiers = apply_modifiers != 0;
|
export_settings.apply_modifiers = apply_modifiers != 0;
|
||||||
|
export_settings.export_mesh_type = export_mesh_type;
|
||||||
export_settings.selected = selected != 0;
|
export_settings.selected = selected != 0;
|
||||||
export_settings.include_children = include_children != 0;
|
export_settings.include_children = include_children != 0;
|
||||||
export_settings.include_armatures = include_armatures != 0;
|
export_settings.include_armatures = include_armatures != 0;
|
||||||
|
@ -27,12 +27,28 @@
|
|||||||
#ifndef __COLLADA_H__
|
#ifndef __COLLADA_H__
|
||||||
#define __COLLADA_H__
|
#define __COLLADA_H__
|
||||||
|
|
||||||
struct bContext;
|
#include <stdlib.h>
|
||||||
struct Scene;
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "BLI_linklist.h"
|
||||||
|
#include "RNA_types.h"
|
||||||
|
|
||||||
|
typedef enum BC_export_mesh_type {
|
||||||
|
BC_MESH_TYPE_VIEW,
|
||||||
|
BC_MESH_TYPE_RENDER,
|
||||||
|
} BC_export_mesh_type;
|
||||||
|
|
||||||
|
static EnumPropertyItem prop_bc_export_mesh_type[] = {
|
||||||
|
{BC_MESH_TYPE_VIEW, "view", 0, "View", "Apply modifier's view settings"},
|
||||||
|
{BC_MESH_TYPE_RENDER, "render", 0, "Render", "Apply modifier's render settings"},
|
||||||
|
{0, NULL, 0, NULL, NULL}
|
||||||
|
};
|
||||||
|
|
||||||
|
struct bContext;
|
||||||
|
struct Scene;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* both return 1 on success, 0 on error
|
* both return 1 on success, 0 on error
|
||||||
*/
|
*/
|
||||||
@ -40,6 +56,7 @@ int collada_import(bContext *C, const char *filepath);
|
|||||||
int collada_export(Scene *sce,
|
int collada_export(Scene *sce,
|
||||||
const char *filepath,
|
const char *filepath,
|
||||||
int apply_modifiers,
|
int apply_modifiers,
|
||||||
|
BC_export_mesh_type export_mesh_type,
|
||||||
|
|
||||||
int selected,
|
int selected,
|
||||||
int include_children,
|
int include_children,
|
||||||
|
@ -138,11 +138,22 @@ Object *bc_add_object(Scene *scene, int type, const char *name)
|
|||||||
return ob;
|
return ob;
|
||||||
}
|
}
|
||||||
|
|
||||||
Mesh *bc_to_mesh_apply_modifiers(Scene *scene, Object *ob)
|
Mesh *bc_to_mesh_apply_modifiers(Scene *scene, Object *ob, BC_export_mesh_type export_mesh_type)
|
||||||
{
|
{
|
||||||
Mesh *tmpmesh;
|
Mesh *tmpmesh;
|
||||||
CustomDataMask mask = CD_MASK_MESH;
|
CustomDataMask mask = CD_MASK_MESH;
|
||||||
DerivedMesh *dm = mesh_create_derived_view(scene, ob, mask);
|
DerivedMesh *dm;
|
||||||
|
switch (export_mesh_type) {
|
||||||
|
case BC_MESH_TYPE_VIEW: {
|
||||||
|
dm = mesh_create_derived_view(scene, ob, mask);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case BC_MESH_TYPE_RENDER: {
|
||||||
|
dm = mesh_create_derived_render(scene, ob, mask);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
tmpmesh = BKE_mesh_add("ColladaMesh"); // name is not important here
|
tmpmesh = BKE_mesh_add("ColladaMesh"); // name is not important here
|
||||||
DM_to_mesh(dm, tmpmesh, ob);
|
DM_to_mesh(dm, tmpmesh, ob);
|
||||||
dm->release(dm);
|
dm->release(dm);
|
||||||
|
@ -57,7 +57,7 @@ extern float bc_get_float_value(const COLLADAFW::FloatOrDoubleArray& array, unsi
|
|||||||
extern int bc_test_parent_loop(Object *par, Object *ob);
|
extern int bc_test_parent_loop(Object *par, Object *ob);
|
||||||
extern int bc_set_parent(Object *ob, Object *par, bContext *C, bool is_parent_space = true);
|
extern int bc_set_parent(Object *ob, Object *par, bContext *C, bool is_parent_space = true);
|
||||||
extern Object *bc_add_object(Scene *scene, int type, const char *name);
|
extern Object *bc_add_object(Scene *scene, int type, const char *name);
|
||||||
extern Mesh *bc_to_mesh_apply_modifiers(Scene *scene, Object *ob);
|
extern Mesh *bc_to_mesh_apply_modifiers(Scene *scene, Object *ob, BC_export_mesh_type export_mesh_type);
|
||||||
|
|
||||||
extern Object *bc_get_assigned_armature(Object *ob);
|
extern Object *bc_get_assigned_armature(Object *ob);
|
||||||
extern Object *bc_get_highest_selected_ancestor_or_self(LinkNode *export_set, Object *ob);
|
extern Object *bc_get_highest_selected_ancestor_or_self(LinkNode *export_set, Object *ob);
|
||||||
|
@ -39,6 +39,7 @@
|
|||||||
#include "DNA_scene_types.h"
|
#include "DNA_scene_types.h"
|
||||||
#include "BKE_utildefines.h"
|
#include "BKE_utildefines.h"
|
||||||
|
|
||||||
|
|
||||||
#ifdef RNA_RUNTIME
|
#ifdef RNA_RUNTIME
|
||||||
|
|
||||||
#include "BKE_animsys.h"
|
#include "BKE_animsys.h"
|
||||||
@ -89,6 +90,7 @@ static void rna_Scene_collada_export(
|
|||||||
Scene *scene,
|
Scene *scene,
|
||||||
const char *filepath,
|
const char *filepath,
|
||||||
int apply_modifiers,
|
int apply_modifiers,
|
||||||
|
int export_mesh_type,
|
||||||
int selected,
|
int selected,
|
||||||
int include_children,
|
int include_children,
|
||||||
int include_armatures,
|
int include_armatures,
|
||||||
@ -97,7 +99,7 @@ static void rna_Scene_collada_export(
|
|||||||
int sort_by_name,
|
int sort_by_name,
|
||||||
int second_life)
|
int second_life)
|
||||||
{
|
{
|
||||||
collada_export(scene, filepath, apply_modifiers, selected,
|
collada_export(scene, filepath, apply_modifiers, export_mesh_type, selected,
|
||||||
include_children, include_armatures, deform_bones_only,
|
include_children, include_armatures, deform_bones_only,
|
||||||
use_object_instantiation, sort_by_name, second_life);
|
use_object_instantiation, sort_by_name, second_life);
|
||||||
}
|
}
|
||||||
@ -127,7 +129,9 @@ void RNA_api_scene(StructRNA *srna)
|
|||||||
parm = RNA_def_string(func, "filepath", "", FILE_MAX, "File Path", "File path to write Collada file");
|
parm = RNA_def_string(func, "filepath", "", FILE_MAX, "File Path", "File path to write Collada file");
|
||||||
RNA_def_property_flag(parm, PROP_REQUIRED);
|
RNA_def_property_flag(parm, PROP_REQUIRED);
|
||||||
RNA_def_property_subtype(parm, PROP_FILEPATH); /* allow non utf8 */
|
RNA_def_property_subtype(parm, PROP_FILEPATH); /* allow non utf8 */
|
||||||
parm = RNA_def_boolean(func, "apply_modifiers", 0, "Apply Modifiers", "Apply modifiers (in Preview resolution)");
|
parm = RNA_def_boolean(func, "apply_modifiers", 0, "Apply Modifiers", "Apply modifiers");
|
||||||
|
parm = RNA_def_int(func, "export_mesh_type", 0, INT_MIN, INT_MAX,
|
||||||
|
"Resolution", "Modifier resolution for export", INT_MIN, INT_MAX);
|
||||||
parm = RNA_def_boolean(func, "selected", 0, "Selection Only", "Export only selected elements");
|
parm = RNA_def_boolean(func, "selected", 0, "Selection Only", "Export only selected elements");
|
||||||
parm = RNA_def_boolean(func, "include_children", 0, "Include Children", "Export all children of selected objects (even if not selected)");
|
parm = RNA_def_boolean(func, "include_children", 0, "Include Children", "Export all children of selected objects (even if not selected)");
|
||||||
parm = RNA_def_boolean(func, "include_armatures", 0, "Include Armatures", "Export related armatures (even if not selected)");
|
parm = RNA_def_boolean(func, "include_armatures", 0, "Include Armatures", "Export related armatures (even if not selected)");
|
||||||
|
@ -2163,6 +2163,7 @@ static int wm_collada_export_exec(bContext *C, wmOperator *op)
|
|||||||
{
|
{
|
||||||
char filepath[FILE_MAX];
|
char filepath[FILE_MAX];
|
||||||
int apply_modifiers;
|
int apply_modifiers;
|
||||||
|
int export_mesh_type;
|
||||||
int selected;
|
int selected;
|
||||||
int include_children;
|
int include_children;
|
||||||
int include_armatures;
|
int include_armatures;
|
||||||
@ -2181,6 +2182,7 @@ static int wm_collada_export_exec(bContext *C, wmOperator *op)
|
|||||||
|
|
||||||
/* Options panel */
|
/* Options panel */
|
||||||
apply_modifiers = RNA_boolean_get(op->ptr, "apply_modifiers");
|
apply_modifiers = RNA_boolean_get(op->ptr, "apply_modifiers");
|
||||||
|
export_mesh_type = RNA_enum_get(op->ptr, "export_mesh_type_selection");
|
||||||
selected = RNA_boolean_get(op->ptr, "selected");
|
selected = RNA_boolean_get(op->ptr, "selected");
|
||||||
include_children = RNA_boolean_get(op->ptr, "include_children");
|
include_children = RNA_boolean_get(op->ptr, "include_children");
|
||||||
include_armatures = RNA_boolean_get(op->ptr, "include_armatures");
|
include_armatures = RNA_boolean_get(op->ptr, "include_armatures");
|
||||||
@ -2196,6 +2198,7 @@ static int wm_collada_export_exec(bContext *C, wmOperator *op)
|
|||||||
CTX_data_scene(C),
|
CTX_data_scene(C),
|
||||||
filepath,
|
filepath,
|
||||||
apply_modifiers,
|
apply_modifiers,
|
||||||
|
export_mesh_type,
|
||||||
selected,
|
selected,
|
||||||
include_children,
|
include_children,
|
||||||
include_armatures,
|
include_armatures,
|
||||||
@ -2213,7 +2216,7 @@ static int wm_collada_export_exec(bContext *C, wmOperator *op)
|
|||||||
|
|
||||||
void uiCollada_exportSettings(uiLayout *layout, PointerRNA *imfptr)
|
void uiCollada_exportSettings(uiLayout *layout, PointerRNA *imfptr)
|
||||||
{
|
{
|
||||||
uiLayout *box, *row;
|
uiLayout *box, *row, *col, *sub, *split;
|
||||||
|
|
||||||
// Export Options:
|
// Export Options:
|
||||||
box = uiLayoutBox(layout);
|
box = uiLayoutBox(layout);
|
||||||
@ -2221,17 +2224,28 @@ void uiCollada_exportSettings(uiLayout *layout, PointerRNA *imfptr)
|
|||||||
uiItemL(row, IFACE_("Export Data Options:"), ICON_MESH_DATA);
|
uiItemL(row, IFACE_("Export Data Options:"), ICON_MESH_DATA);
|
||||||
|
|
||||||
row = uiLayoutRow(box, 0);
|
row = uiLayoutRow(box, 0);
|
||||||
uiItemR(row, imfptr, "apply_modifiers", 0, NULL, ICON_NONE);
|
col = uiLayoutColumn(row, 0);
|
||||||
|
split = uiLayoutSplit(col, 0.5f, 0);
|
||||||
|
uiItemR(split, imfptr, "apply_modifiers", 0, NULL, ICON_NONE);
|
||||||
|
sub = uiLayoutRow(split, 0);
|
||||||
|
uiItemR(sub, imfptr, "export_mesh_type_selection", UI_ITEM_R_EXPAND, IFACE_("Color"), ICON_NONE);
|
||||||
|
uiLayoutSetEnabled(sub, RNA_boolean_get(imfptr, "apply_modifiers"));
|
||||||
|
|
||||||
row = uiLayoutRow(box, 0);
|
row = uiLayoutRow(box, 0);
|
||||||
uiItemR(row, imfptr, "selected", 0, NULL, ICON_NONE);
|
uiItemR(row, imfptr, "selected", 0, NULL, ICON_NONE);
|
||||||
|
|
||||||
row = uiLayoutRow(box, 0);
|
row = uiLayoutRow(box, 0);
|
||||||
uiItemR(row, imfptr, "include_children", 0, NULL, ICON_NONE);
|
col = uiLayoutColumn(row, 0);
|
||||||
|
split = uiLayoutSplit(col, 0.1f, 0);
|
||||||
|
sub = uiLayoutRow(split, 0);
|
||||||
|
uiItemR(split, imfptr, "include_children", 0, NULL, ICON_NONE);
|
||||||
uiLayoutSetEnabled(row, RNA_boolean_get(imfptr, "selected"));
|
uiLayoutSetEnabled(row, RNA_boolean_get(imfptr, "selected"));
|
||||||
|
|
||||||
row = uiLayoutRow(box, 0);
|
row = uiLayoutRow(box, 0);
|
||||||
uiItemR(row, imfptr, "include_armatures", 0, NULL, ICON_NONE);
|
col = uiLayoutColumn(row, 0);
|
||||||
|
split = uiLayoutSplit(col, 0.1f, 0);
|
||||||
|
sub = uiLayoutRow(split, 0);
|
||||||
|
uiItemR(split, imfptr, "include_armatures", 0, NULL, ICON_NONE);
|
||||||
uiLayoutSetEnabled(row, RNA_boolean_get(imfptr, "selected"));
|
uiLayoutSetEnabled(row, RNA_boolean_get(imfptr, "selected"));
|
||||||
|
|
||||||
row = uiLayoutRow(box, 0);
|
row = uiLayoutRow(box, 0);
|
||||||
@ -2278,6 +2292,11 @@ static void WM_OT_collada_export(wmOperatorType *ot)
|
|||||||
RNA_def_boolean(ot->srna, "apply_modifiers", 0, "Apply Modifiers",
|
RNA_def_boolean(ot->srna, "apply_modifiers", 0, "Apply Modifiers",
|
||||||
"Apply modifiers (Preview Resolution)");
|
"Apply modifiers (Preview Resolution)");
|
||||||
|
|
||||||
|
RNA_def_int(ot->srna, "export_mesh_type", 0, INT_MIN, INT_MAX,
|
||||||
|
"Resolution", "Modifier resolution for export", INT_MIN, INT_MAX);
|
||||||
|
|
||||||
|
RNA_def_enum(ot->srna, "export_mesh_type_selection", prop_bc_export_mesh_type,
|
||||||
|
0, "Resolution", "Modifier resolution for export");
|
||||||
|
|
||||||
RNA_def_boolean(ot->srna, "selected", 0, "Selection Only",
|
RNA_def_boolean(ot->srna, "selected", 0, "Selection Only",
|
||||||
"Export only selected elements");
|
"Export only selected elements");
|
||||||
|
Loading…
Reference in New Issue
Block a user