No matter what 3D software, it is always a struggle to find complete information on how to compile a plugin. It is more complicated when the 3D artist wants to write the plugin in C programming language. To code in C is necessary for more specific stuff, like creating nodes, or to make plugins that deals better with memory management, for example.
I've been trying to collect information for both Python and C language plugin writing for Lightwave 3D and I've found very little (almost nothing) information. The Python and SDK official documentation are old and not didactic in a friendly way. In this tutorial I show how a 3D artist can compile a C plugin for Lightwave 3D, with minimum setup.
Time to make our hands dirty. Below are the steps to make a .p file (which actually is a .dll file), i.e. a Lightwave 3D plugin written in C programming language:
Download the MinGW-w64 for Windows.
2. Extract the file to a folder of your choice. In my case, I extract it in my root folder C:/.
3. Now we have to put the mingw64 folder executable files in the system path.
4. It is necessary to unzip the Lightwave 3D SDK, which is located on the Lightwave 3D installation folder.
5. Go to where you put the SDK files and copy all content inside the include folder to the homonym folder inside the mingw64 directory.
6. Go to the Lightwave SDK source folder.
7. It is time to compile the library sources. You do this by typing the following command: gcc -c -D_MSWIN -D_X64_ -O6 -I$(LWSDK_INCL) servmain.c servdesc.c username.c startup.c shutdown.c
And then, press ENTER.
8. Now we have to assemble the library. For this, we type ar r libserver.a servdesc.o username.o startup.o shutdown.o
And then, ENTER.
9. Now it is the final step: the creation of the plugin. I created a folder named box01 inside the source directory for organization purposes.
Then, I copied the sample code box.c from the SDK Modeler samples folder to the box01 directory.
Inside the box01 folder, Type gcc -c -D_MSWIN -D_X64_ -O6 -I$(LWSDK_INCL) box.c and ENTER to compile the source code.
The last step is to link the object file to the SDK library and generate the box.p file, our plugin. Fpr this, you type dllwrap -o box.p --export-all --dllname box.p box.o ../servmain.o ../libserver.a and ENTER. Note the (../) before servmain.o and libserver.a. This is necessary because we are inside the box01 folder located under the source folder. Servmain.o and libserver.a are inside the source folder, exactly one level up. The (../) is exactly to access the files in the folder above.
10. Loading the plugin in Lightwave 3D.
11. What's next? The Lightwave SDK documentation has a lot of other examples. The Lightwave artist must read the SDK doc to get familiar with the Lightwave C plugin code nuances. To know Lscript would help a lot, have no doubt. This is the beginning of a long journey.
One last thing you should know:
Slick3d.art was selected as one of the Top 20 3D Art Blogs on the web by FeedSpot. It is a great victory to me. It is a huge effort in very hard times. Besides, Slick3d.art encompasses my love for design and writing that started in my teen years. I am very grateful for the recognition that was a total surprise. Click here to go to FeedSpot Top 20 list or click on the image down below.
And do not forget: Donation = Loving ❤
Help me to do more tutorials. Please, consider to make a donation if this content helped you.