Create POV-Ray animations of your Spacechem solutions!
Not quite automatically, though; you're going to have to enter your solution below. And the interface is bad; I'll just prepare you for that now.
(There's a small gallery at the end of this page if you're just here to see what it can do.)
Anyway, To get a nice POV-Ray animation of your Spacechem solution you'll enter it here and the page will run it through the same process it would get in the game... almost. There are a few differences, mostly for simplicity's sake:
Some Spacechem solutions may not work here, namely some that depend on certain things happening in a certain order within the same cycle (i.e. bonder priority).
Some solutions that work here may not work in Spacechem. For instance, there's hardly any collision detection here. Here you could animate atoms going through each other or rotating outside the reactor walls and the simulation wouldn't care as long as they all ended up back inside on unoccupied squares for the next cycle.
If you send multiple separate molecules through a single output with a single output instruction, molecule departure order here may differ from that in Spacechem.
Probably other minor things, too. Not too much, though, I think.
To start, you will need the following:
Spacechem. None of this makes any sense at all without that, does it?
The "cyrvetic.ttf" truetype font. I'm pretty sure it comes with POV-Ray.
The "times.ttf" truetype font in some location that POV-Ray checks. Probably all of you already have this. I sure hope it's the same one I have, because some letter positioning depends on it.
See the troubleshooting section for an alternate font that can be used.
This include file (right-click, "save as"). When you get your scene files, below, they will need this. Put it somewhere your scene files can find it.
Javascript. All the neat stuff that this page does happens in javascript. If you're the sort that disables all javascript on the pages you visit, well, I can't blame you, but this page will be useless to you unless you make an exception.
Some video editing software and knowledge of how to use it.
Patience. You will likely wait a very long time while your animation renders.
How to use this thing:
In section 1, replicate your solution's waldo programs and the placement of your reactor devices such as bonders, sensors, etc., on the reactor grid. This is, admittedly, the worst of this interface, but perhaps it's best to get that over with quickly.
In section 2, create molecules and assign them to input sequences and output labels. (Technically, a single atom in a single molecule in a single input sequence is all that is needed to successfully create the bare minimum animated scene.)
In section 3, generate and render a preview to make sure you've set everything as you expect, or set simulation and animation parameters and generate the full animated scene for your solution.
And in all cases, if you press a button and nothing or something other than what you expect happens, scroll way back up to the output log for some possibly useful information.
Check the gallery at the end of this page for a walkthrough video.
To reset absolutely everything, reload this page. On Firefox, you may need to do a hard refresh (Ctrl-F5).
An output log of what's been happening. Check back up here if something seems to go wrong:
The background will flash briefly on warnings and errors. Try it now:
Section 1: Place reactor devices and add waldo instructions in this section. Make it look like the solution you're trying to replicate, at least as well as it can on this HTML grid.
Click on a grid number to quickly select that cell.
What the grid currently looks like:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
Add or change something on the grid:
Grid position:
Object type:
Color:
Direction:
Atom (for sensor redirects):
Putting it there or taking it back out?
Clear the grid and start over:
Really clear the grid?
Some notes:
Settings irrelevant to particular devices are ignored. For instance, it does not matter how "Direction" is set when placing "Grab" controls.
Fusion and fission targets take up two side-by-side grid spaces. When placing a target, these controls refer to the left side of those devices. As such, that left side cannot be placed in the rightmost column.
There must be exactly 0 or 2 quantum tunnels in your solution.
Section 2: Set input molecules and add input and output labels in this section. You must have at least one input molecule, and an input sequence that includes that molecule, or the reaction will not run.
First of all, select whether your reactor has standard outputs ψ and ω or single large output ψ:
Now, use this thing below to draw a molecule. Select atoms with the drop-down menus and indicate bond strength with the checkboxes. Use the white areas only, unless you are drawing a label for large output ψ.
Now here's what you can do with that molecule:
Current α input sequence:
Current β input sequence:
Some more notes:
Use only the upper white boxes unless you are creating a label for large output ψ. Any use of the lower gray boxes for anything other than large output ψ will be rejected.
As in Spacechem, a molecule's position in the label matches the position it will arrive in the input region.
Each input can supply up to three molecule types. These molecules will be shown as preview labels in the blank space beside the input areas.
The input sequences describe the order in which the molecules assigned as A1-A3 and B1-B3 will arrive at their respective inputs.
If the end of an input sequence is reached, the sequence repeats from the beginning.
If an input only sends in a single type of molecule, a single molecule type symbol is sufficient for the entire input sequence (i.e. all that would be needed for the input sequence could be just "A1").
Input sequences can be arbitrarily long.
If Spacechem sends your in-game solution different molecules in random order, pay close attention to the ordering you end up getting and replicate it here. (Or mix it up; a well-built solution should be able to handle that, right?)
Each output can display a single molecule as a preview label in the blank space beside the output area.
Output labels are not enforced. Each output takes any molecule that fits when its output control is called. Output labels are strictly for decoration and reminder of what the solution is supposed to be doing.
Creating a molecule in which an atom has more bonds than it can usually make will produce a warning, but is not strictly prohibited since such molecules do work in Spacechem.
Section 3: And here's where you can get the results of all that.
Generate a preview scene to make sure all your reactor parts are in the right place (this will be a single, static image showing the reactor state before reactions begin):
Your preview .ini file is here:
(Note: the preview .ini file will be the same one every time; you won't need to save a new one for every different preview.)
And your preview scene file (.pov) is here:
Save them both somewhere, open the scene file in POV-Ray, choose a resolution in the top-left, click the "Ini" button along the top, and choose that .ini file you just made. Render it and compare the resulting image with what you expected to get. (Don't forget the include file!)
OR...
Simulate the reaction and generate the real, animated, thing-you-came-here-for scene:
Run until...
(optional: ... and for this many cycles beyond that: )
(Note that I've put in a hard limit of 10,000 cycles to keep things somewhat reasonable.)
Frames per cycle:
At this point you should think ahead to the video you're going to stitch together from the pile of sequential static images your scene is going to give you. You should consider what sort of framerate you want and how long each cycle should last. Then you should math those numbers together and get a number for the frames-per-cycle box above.
As a hopefully helpful reference for where to start, I usually make my videos at 60fps. At that framerate, I find that 24 frames per cycle works well for shorter animations, while 18 frames per cycle can keep longer animations from dragging on too long and still keep clear what the reaction is doing.
Be sure to check the log output back at the top of the page for any warnings or errors, so that you don't spend several hours rendering a mistake.
And finally, here's your actual .ini file:
(Note: the actual .ini likely will be different each time, so be sure to save each new one.)
... and your actual scene file (.pov):
Save them both somewhere, open the scene file in POV-Ray, click the "Ini" button along the top, and choose that .ini file you just made. Select a resolution from the dropdown in the top-left, below the main toolbar, and then go find something else to do, because once you click "Render," your computer will be a bit busy.
You may want to try the "[Anim (test render) 640x360]" resolution first. This will produce a small and ugly animation of your solution, but it will produce it very quickly. This way you can verify that your solution worked correctly before you invest a lot of time rendering the real thing.
Troubleshooting
My long render failed halfway through
Yeah it might do that, perhaps a few thousand frames in. This appears to be a problem with POV-Ray. But all is not lost! you can resume your render from the point it failed. Here's how:
Go to the directory where POV-Ray put its output images.
Find the last image it produced and note the number at the end of it.
Open your .ini file in your favorite text editor. If you don't have a favorite, you can open it in POV-Ray by clicking the "Ini" button on the toolbar and then clicking the "Edit" button in the "Ini file:" section.
Find the section for the resolution you chose. This will be headed by one of the bracketed lines such as "[Anim 1920x1080]".
Find the line in that section that begins "Subset_Start_Frame=". If you haven't tried this method before, the number after that should be 0.
Change that number to the number you noted above and save the file.
Go to POV-Ray and start the render. It will pick up from that point.
Repeat as (hopefully minimally) necessary.
Of course, if you want to start over later, change that line back to "Subset_Start_Frame=0".
POV-Ray can't find "times.ttf" or Several characters are badly misaligned
You may not have the Times New Roman font (times.ttf) or you may have a different version than I do. Fortunately I have found a different suitable font from a free, reputable source:
Click the "1 Family Selected" tab that pops up at the bottom of the screen.
Download the font. The download button is at the top-right of the box that expands from that tab.
Unpack that .zip file; read and decide whether to agree to the license terms, as you surely do for all licenses.
Assuming you agreed, copy the file "NotoSerif-Regular.ttf" to somewhere POV-Ray can find it, for instance to the same directory as the include or scene files.
Open the include file (povchem.inc) in your favorite text editor and find the line that reads "#declare use_Noto = 0;"
Change that to "#declare use_Noto = 1;" and save the file.
Your render should now proceed correctly. Or at least it should no longer have that problem.
The Gallery
PovChem Walkthrough: a tutorial showing how to make an example scene
Delta-Pseudopolyethylene 2834: A somewhat inefficient solution to the "Suspicious Behavior" assignment (spoilers!) but one that makes for a good showcase of what PovChem can do.
All the PovChem elements lined up posing for a photograph in front of the reactor grid. They didn't quite fit.
That's all. Thanks for visiting. I hope this was useful and/or fun.
By Shmoot
Possibly necessary fine print: I and this project have no affiliation with Spacechem, POV-Ray, or anyone who made those. Also I probably should have considered earlier that there might already be something called PovChem that generates POV-Ray scenes of slightly less fake molecular models because of course there is. There's no affiliation with that or its creator either.