Clarisse 5.0 SP8 SDK
5.0.5.8.0
|
This topic covers how to use the Clarisse module system and how to declare new modules.
Modules are dynamic libraries written in C++ that are loaded by Clarisse during starup in order to extend Clarisse's core features. A module in Clarisse defines both OfClass and its implementation. It can virtually define anything, from new type of geometries, to custom materials and textures or custom renderering engines. Before writing your first module you should familiarize yourself with the CID syntax as well as cmagen.
Your module will have to link on several Clarisse libraries depending on your needs, but there are few that are required:
ix_module, ix_of, ix_dso, ix_core, ix_gui
Module entry point is a C function called on_register_module within the main file, which will declare and register callbacks depending on the module needs. Lets say you module main file is called main.cpp, here is a minimal example:
IX_MODULE_CLBK is a typedef to an internal class declared by the macro IX_BEGIN_DECLARE_MODULE_CALLBACKS. Its the name of the class containing the callbacks for this module.
Depending on the module you are creating, you may want to implement various callbacks. Please refer to the documentation of OfClassCallbacks and its subclasses to see which callbacks are available for your module to be implemented. The callbacks available depend on what you inherited from in IX_BEGIN_DECLARE_MODULE_CALLBACKS macro.
If you want to implement a new module widget (to have a new window within clarisse for specific purposes), here is a simple example:
It is possible to declare multiple modules in the same library. It means having a cid file and a cpp file with callbacks registration for each module, compiled in the same library. The module library entry point remains the same, the C function on_register_module.
There is currently only one restriction, abstract module classes (which are inherited by other classes like module.texture or module.geometry) must be stored in a module library that matches their name, for resolution purpose. By convention, these classes are stored alone in a module that has the same name. This is the case for module.texture, module.geometry, module.layer...
Structure Example of a module library "custom_modules" containing 3 classes:
main.cpp, custom_modules.h, custom_module1.cpp, custom_module2.cpp, custom_module3.cpp, custom_module1.cid, custom_module2.cid, custom_module3.cid
main.cpp
custom_modules.h
the other files are:
custom_module1.cpp, custom_module1.cid, custom_module2.cpp, custom_module2.cid, custom_module3.cpp, custom_module3.cid
Their content is exactly the same that they would be for a single class module library. See above example. The only difference remains in the declaration of "on_register_module" function which is now a function as declared in custom_modules.h and not a C callback.
Example with custom_module1.cpp:
The cid files are unchanged whether the module is alone in its library or not.