Go Back   AC3D Forums > Technical > AC3D Developers
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Display Modes
Old 28th September 2004, 03:25 PM   #1
fractile
Junior Member
Member
 
Join Date: Sep 2004
Location: Tampere, Finland
Posts: 14
Default plugin gui problem (and question on selections)

I have started making a planar/cubic texture mapper plugin. It's my first ac3d plugin. and I can't get my gui working..

I have tcl script for the gui that works fine when executed manually in console. I does not work in ac3d. I finally tested with an empty script and that causes SEG_FAULT as well.

This is the simplest script I could imagine:

-- ac3d_texturemapper.tcl --
proc tm_map_planar_gui {} {
}

This is how I try to use it (mostly copy-paste from examples):

-- ac3d_texturemapper.c --
AC3D_PLUGIN_FUNC int AC3DPluginInit(AC3DPluginInitData *d)

{
char *path = (char *)strdup(d->plugin_dir_path);
#ifdef WINDOWS

ac_unbackslash_string(path);

#endif
tcl_command("source \"%s/ac3d_texturemapper.tcl\"", path);
free(path)


ac_add_surface_menu_item("Map texture..", "ac3d tm_map_planar_gui", "Texture mapper plugin (planar)");

return(0);

}

Wheneven I choose the menu item, AC3D crashes. What am I missing here?

This can't be a compiler problem, since the plugin works fine without the tcl part (menu item pointing directly to a c -function).

I have also a question on selections: I read a previous post on hidden status and selections. Based on that I tried using ac_selection_get_whole_surfaces_all() to access selected surfaces. If I have understood correctly this list is read-only, right? How am I supposed to skip unselected surfaces when processing object tree/surfaces recursively?

- Mikko
fractile is offline   Reply With Quote
Old 30th September 2004, 02:14 AM   #2
Andy
Administrator
Professional user
 
Andy's Avatar
 
Join Date: Jun 2003
Posts: 4,563
Default

Did you mean the command to be "ac3d tm_map_planar_gui"?

This will only work if you have added your own command to AC3D.

More likely, you need tm_map_planar_gui as the command - that will call the tcl procedure rather than send the command to the AC3D command handler.

check that the tcl file is really being run - put some 'puts "hello" in your tcl file.

Also - check the console for any errors.

Let us know how you get on.


The selection functions such as ac_selection_get_whole_surfaces_all() will never return surfaces from hidden objects.

If you are traversing the whole world hierarchy, use these to check:

Code:
Prototype Boolean ac_object_is_visible(ACObject *ob); // returns TRUE if object is not hidden or locked
Prototype Boolean ac_object_is_locked(ACObject *ob);
Prototype Boolean ac_object_is_hidden(ACObject *ob);
Note that hiding/locking is object based. It's not possible to hide individual surfaces.

Andy
Andy is offline   Reply With Quote
Old 30th September 2004, 05:19 AM   #3
fractile
Junior Member
Member
 
Join Date: Sep 2004
Location: Tampere, Finland
Posts: 14
Default

This is what the debug output says, when I try to run the plugin (tcl function name is now fgtm_gui):

1096535466.304319 : found a plugin? ('ac3d_texturemapper.p') - will try loading...1096535466.304322 : attempting to load plugin '/home/mikko/ac3dlx/plugins/ac3d_texturemapper.p'1096535466.304459 : sending command to TCL: source "/home/mikko/ac3dlx/plugins/ac3d_texturemapper.tcl"
1096535466.304578 : sending command to TCL: add_surface_menu_item "Map texture.." "ac3d fgtm_gui" "Texture mapper plugin"
1096535466.304681 : sending command to TCL: add_surface_menu_item "Map texture (hack).." "ac3d fgtm_texturemap_cubic " "Texture mapper plugin"
Texturemapper plugin - Mikko Rytkönen / FRACTiLE Games
1096535466.304722 : plugin /home/mikko/ac3dlx/plugins/ac3d_texturemapper.p OK!
...
1096535473.642997 : received command : 'fgtm_gui'
Segmentation fault

There is a puts command at the begining of fgtm_gui, which obviously doesn't get run.

I'm trying to do things as in centre.c/centre.tcl example. It also does "source centre.tcl" and then adds menu item that directly calls a function defined in the tcl script (in my case, the fgtm_gui). The function in centre.tcl script then calls a function defined in c file (selection_recentre), when apply button is clicked in the tcl dialog. Thats what I'm eventually trying to do..

And BTW, I was more interested on how to test the selected state than hidden state. I want to only process surfaces that are selected.
fractile is offline   Reply With Quote
Old 30th September 2004, 07:05 AM   #4
Andy
Administrator
Professional user
 
Andy's Avatar
 
Join Date: Jun 2003
Posts: 4,563
Default

1096535473.642997 : received command : 'fgtm_gui'

This indicates that you are still calling AC3D's command interpreter.

You need to change the command that runs when the menu is selected so that it calls the tcl code directly e.g. remove the 'ac3d' from 'ac3d fgtm_gui'

ac_add_surface_menu_item("Map texture..", "ac3d fgtm_gui", "Texture mapper plugin (planar)");

to

ac_add_surface_menu_item("Map texture..", "fgtm_gui", "Texture mapper plugin (planar)");

Andy
Andy is offline   Reply With Quote
Old 2nd October 2004, 07:55 AM   #5
fractile
Junior Member
Member
 
Join Date: Sep 2004
Location: Tampere, Finland
Posts: 14
Default

Yes, that was it. Thanks a lot!
fractile is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



All times are GMT -4. The time now is 12:08 PM.


AC3D Forum
(C) Inivis Limited 2020