tutorials:advanced:create-module-lib
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| tutorials:advanced:create-module-lib [2025/04/02 15:39] – [Use a module lib] gaetan | tutorials:advanced:create-module-lib [2025/04/02 16:26] (current) – gaetan | ||
|---|---|---|---|
| Line 2: | Line 2: | ||
| In this tutorial we will cover how to create, and use module libraries (which are compiled libraries of groimp projects). | In this tutorial we will cover how to create, and use module libraries (which are compiled libraries of groimp projects). | ||
| + | |||
| + | |||
| + | ====== Create an example project ====== | ||
| + | |||
| + | Let's create a very simple project from the '' | ||
| + | |||
| + | **Rename the Model.rgg file to An.rgg** (or any other name). It is not required but it gets confusing when all modules come from Model classes. | ||
| + | |||
| + | Let's include a custom shader from an image to the project (steps correspond to image bellow): | ||
| + | - Open the image explorer | ||
| + | - Import any image | ||
| + | - Create a new shader in the shader explorer | ||
| + | - In the attribute editor edit the shader to use the imported image | ||
| + | |||
| + | {{: | ||
| + | |||
| + | |||
| + | Now, let's use this shader on the '' | ||
| + | |||
| + | <code java> | ||
| + | module A(float len) extends Sphere(0.1) | ||
| + | { | ||
| + | {setShader(shader(" | ||
| + | } | ||
| + | </ | ||
| ===== Export ===== | ===== Export ===== | ||
| - | To export | + | We can now export |
| + | |||
| + | {{: | ||
| ==== Package name ==== | ==== Package name ==== | ||
| + | |||
| + | You will need to provide a package name. The package name NEEDS to follow java specifications on package names (no weird characters). The package name will be used to identify the library with an unique name. | ||
| + | |||
| + | Let's use '' | ||
| ==== Plugin name ==== | ==== Plugin name ==== | ||
| + | You will need to provide a Plugin name. This name will be used when accessing the resources from this library. | ||
| + | The combination of package name + plugin name needs to be unique for GroIMP. | ||
| + | |||
| + | Let's use '' | ||
| + | |||
| + | ==== Select a directory ==== | ||
| + | |||
| + | You decide where the project is exported to. The creation of a module lib create three or four files (depending on whether the project contains resources or not). | ||
| + | |||
| + | * A plugin.xml file - contains the information for GroIMP on how to load the library | ||
| + | * A plugin.property file - contains the additional properties for the library (its name). | ||
| + | * A .jar file - contains the compiled classes. | ||
| + | * A .grz file - contains the resources. | ||
| ===== Import ===== | ===== Import ===== | ||
| + | |||
| + | Now that the module library has been created, we can adds it to GroIMP as a plugin. | ||
| + | |||
| + | ==== Add lib to GroIMP ==== | ||
| + | |||
| + | Create a directory with the name of your library ('' | ||
| + | Move the directory in the GroIMP [[: | ||
| + | |||
| + | Then, restart GroIMP to load the library. | ||
| + | |||
| + | Now let's open a new project ('' | ||
| ==== Type ==== | ==== Type ==== | ||
| + | |||
| + | The types from the module library can be imported in the project like any other classes: | ||
| + | '' | ||
| + | |||
| + | The pattern is: '' | ||
| + | |||
| + | Notice that the name of the file is required in the import. GroIMP implicitly create classes with the name of the files to wrap all types defined in .rgg classes. | ||
| + | |||
| + | **Note:** in the '' | ||
| + | |||
| + | The Node An.A have the shader from their original project, i.e. the one with the image. | ||
| + | |||
| ==== Resources ==== | ==== Resources ==== | ||
| + | Resources from module lib can also be used without classes. You can use the shader '' | ||
| + | |||
| + | <code java> | ||
| + | module A(float len) extends Sphere(0.1) | ||
| + | { | ||
| + | {setShader(shader(" | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | The Shader reference use the path: '' | ||
tutorials/advanced/create-module-lib.1743601185.txt.gz · Last modified: 2025/04/02 15:39 by gaetan
