As the delivery of the hardware has been delayed, I decided to search for something else that I could do. I found a page on the wiki mentioning that there was a need for a big upload button. After asking, it seemed that they might drop the whole wiki, so maybe the button wouldn't be needed. I don't really understand why they would replace the wiki with something else, as a wiki keeps a history of both documentation and files, so it sounds like a stupid idea to replace it with something else to me.
Anyway, even if they do change the method of keeping the information, it will still require something similar to the upload button. For that reason I decided to make a script in php that would take a zip as input and give stl-files and the matching renders as png-files. I won't create something to integrate everything in mediawiki yet, until I know for sure that they will keep using it.
First of all, I had to re-install a linux os on one of my pcs. I downloaded kubuntu server edition, set up a lamp server in VMWare and added phpmyadmin on the server. The easyest part was already done. Now I had to install
povray and
stl2pov. I had no problems installing povray, as it was in multiverse of ubuntu (
here).
The problems started happening when I had to build stl2pov myself. It seemed I needed gcc, so I installed that one and uncommented the line in the makefile to make it use gcc. The installation instructions now said that everything should work when I used the make command. But it just gave me an ugly error:
Makefile:9: *** missing separator. Stop.
As that line was an include command, I just opened version.inc, copied everything in there and pasted that over the include command. So the first error was solved.
There was still a second error however. The program didn't recognize
.if !defined(NOPORTDOCS), I thought "this is a new installation, I bet it won't be defined for me" and removed the if-test. The compilation did work now. Once that was done, "sudo make install" installed everything just as expected.
Now that the software was installed, I searched for how to run it. Stl2pov was very straightforward and didn't need any parameters or settings files. It just converted the file. I was happy it didn't cause me more troubles. Povray however did require settings and parameters. The parameters were well documented on their site and I quickly found that -i is for the input file, -o is for the output file, +W is for the width of the image and +H for the height. I added 2 more options to the command: +GA for giving all errors in the terminal and -D for not showing the picture while rendering. So that makes the whole command for rendering an image:
povray -i\"render.pov\" +W600 +H600 -o\"$output\" +GA -D
Now I needed to find how to add settings to tell the program how to render the objects. After looking a little around the internet, I tried some different settings and
these seemed to work. I found a basic script on a site, but didn't save the url. Sorry, if it yours let me know and I'll add a link to give you credit. I changed the colors, rotation, light source and camera location a little, but didn't touch the things I didn't know what they were for like the global settings or sky sphere. It works and that's good enough for me.
The file requires an include-file that describes the object that has to be drawn. It expects the object to be called
MODELNAME. So in my script I had to replace the name stl2pov was giving it. A few simple lines of code later, my php script could rename the model. As the rendering is the most intensive part of the script, I didn't think about efficiency while replacing the name and just wrote something that is quick to code instead of quick to execute. My script was now able to render any given stl-file into a png. I uploaded it to the wiki.
After dinner I still had some free time and quickly added the extra feature of unzipping the contents of a given zip, looking for stl-files and matching png-images and rendering them if they were not found. That was basically just extracting files, looping over them and deleting unnecessary files, so I won't go into detail about that.
You can now find the script I just created in the wiki as
stl2png. I added a few lines of comments in there, but really not that much. If anything isn't clear about how it works, feel free to ask me.