PDA

View Full Version : Export plugin configure dialog


monster
10th December 2003, 08:56 PM
Hi Folks,

I've managed to write a plugin that exports from Ac3d to the OGRE (http://www.ogre3d.org/) mesh and material format. Which is nice.

But I'd like the user to be able to configure the exporter in a couple of ways, for example; to scale the mesh on export, to collapse all the objects into a single OGRE sub-mesh.

I imagine this can be done in tcl/tk, but I'm afraid I wouldn't know where to start with this! So, a couple of questions;
1) Do I have to supply a tcl script or can I execute the commands to build up a configuration dialog 'on-the-fly' from the exporter?
2) Is there a mechanism within exporters for writing values to (so I can save the config preferences between exports), and reading them back from, the UI widgets I create?
3) Can anyone recommend a simple guide to tcl? Bearing in mind that the dialog will probably be very basic!

Thanks for your time.

monster
11th December 2003, 05:53 AM
I had thought I'd be able to use prefs_append_prefspec.

Would that add my settings to the standard Ac3d Settings dialog and have them managed (i.e. loaded and saved) by Ac3d?

But I get link errors using this function;

LNK2019: unresolved external symbol __imp__prefs_append_prefspec referenced in function _AC3DPluginInit

Andy
11th December 2003, 06:54 AM
Thanks - I'll investigate...

Andy
11th December 2003, 07:34 AM
Unfortunately, this symbol was not exported as C, but C++. I'll fix this for the next release.

You should be able to refine it with:

Prototype void prefs_append_prefspec(PrefSpec *n);

in your C++ plugin.



add a pref like this:

static double grid_size = 1.0;

PrefSpec pref =
{
"field_grid_size", PREF_DOUBLE, (void *)&grid_size,
};


AC3D_PLUGIN_FUNC int AC3DPluginInit()
{
double ver = ac_get_version_number();

prefs_append_prefspec(&pref);

...
This means that it will be saved and loaded from the AC3D settings file.
It won't appear in the settings dialog. If you want to access the pref from within tcl, you need to call.

Prototype void ac_tcl_link_pref(PrefSpec *p);
The var can now be accessed in tcl with pref_field_grid_size.

You can set a function to be called before the filename selection of you importer:

Prototype Boolean ac_exporter_set_settings_function(char *suffix, ac_file_settings_func func); // to be called before export

If 'func' returns TRUE, the exporter function will be called.
You'll need to make a tcl dialog which uses a tcl 'vwait' to block the eventhandler before returning.

Another way to do this would be:

ac_add_command( ogre_plugin", ogre_function );
ac_add_export_menu_item("Ogre...", "ac3d ogre_plugin");

Then in the ogre_function, you can popup a tcl dialog and do your own saving from there.

A good reference for tcl/tk is AC3D's own tcl/tk files in the tcl directory. Other than that - a google search should find some docs.

Andy

monster
11th December 2003, 11:23 AM
Yay! That worked a treat.
Cheers Andy!