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

Thread Tools Display Modes
Old 11th November 2003, 05:38 AM   #1
Professional user
Andy's Avatar
Join Date: Jun 2003
Posts: 4,490
Default Migrating plugins for AC3D 3.6 (and before) to AC3D 4.0

Summary guide for migrating plugins from AC3D 3.6 and earlier to AC3D 4.0

material type is now ACMaterial

use surface_get_twosided(s) rather than surface->twosided
use surface_get_type rather than surface->type

use surface_set_twosided(Surface *, Boolean) rather than acessing the surface structure

vertex normals are now per vertex reference - not in the vertex structure.
Use normal from SVertex in the surface's vertlist.


use this:
ac_register_file_exporter("LOD", ".lod", "LOD", do_lod_save, "level of detail plugin");

Boolean do_lod save(char *filename, ACObject *top); // return true on success

rather than this:
ac_add_command("lod_export_plugin", do_lod_save);
ac_add_export_menu_item("LOD...", "ac3d lod_export_plugin");


The way selections are retrived have been changed considerably. Most of the function prototypes in the ac_plugin.h header file should be self explainitory but the main rules are now this:

When you ask for a selection - you get a list returned. If this list is NULL (or list_count(list) returns 0), no elements are selected.
You must free the list when you have finished with it (list_free(&list)).

The functions ending in '_all' e,g, ac_selection_get_whole_surfaces_all and ac_selection_get_vertices_all will work in all selection modes. Others don't work in all selection modes (see header file).


Unlke previous versions of AC3D, you must now keep track of changes you make to the geometry and the selection so that any changes you make can be restored and redone using Edit->Uodo/redo. This doesn't affect importers and exporters but any function that modifies geometry needs to be able to do this. It's important that the geometry and selection are restored to the exact same state because of the undos and redos in the chain may rely on it.

Note that this means that whilst imports and exporters can be written in C (or C++), other functions must be in C++.

This is handled by the Undoable class. Essentially, you subclass this and provide an execute function, along with an undo function (that restores the changes you made)

The Undoable is added to AC3D with add_undoable(Undoable *u, char *name) - where name is the text that will appear on the Edit->Undo menu.

This can get complicated if you are changing a lot of things so there are some convienient undoables already provided e.g.
Prototype void add_undoable_vertex_positions(char *name, List *vertexlist);

This is called with a list of vertices. The Undoble that's added saves the position of the current vertices so they can be restored later. So - if you are writting a function that moves vertices, you just need to call this before you adjust any vertices and AC3D will handle everything else for you.

When developing a function or if you are going to make a lot of changes to the world geometry, to save coding time you can use:

Prototype void add_undoable_all(char *name);

This makes a copy of everything. so that whatever happens to the geometry, an Undo will restore everything to the original state. Whilst not very efficient, it means that your function will be undoable.
Andy is offline   Reply With Quote

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 02:44 AM.

AC3D Forum
(C) Inivis Limited 2020