So I got interested into terrain editing software. Of the little free stuff I tried, I was marveled by lithosphere.
However it lacked some important UX enhancements (like undo/redo, saving to PNG, or a useful open/save file dialog).
It’s Open Source written in Python, so I tried to give it a shot myself. Problem is, it doesn’t come with instructions, and some of its dependencies are quite old. To run from source, you’ll need:
- Clone lithosphere.
- Clone halogen and use commit 22b876641fc0.
- Clone gletools and use commit 5d9354d78633.
- Get pyglet (more on this later)
- Setuptools 0.6c11-py2.6 (more on this later)
- Fresh installation of Python 2.6. I used Windows 10. On Ubuntu 14.04 I had Python2.7 installed and it didn’t want to run. I don’t know if this is because of python 2.7, or some other incompatibility. It sounds like the app is trying to seek in egg files and seek operation for egg files may have been removed from Python 2.7 (egg is just a renamed zip). Just a guess.
You could try cloning pyglet’s forked version of the author or the official pyglet version. But you’ll still have to figure which version he used. Luckily, the on lithosphere’s repo the binary egg files are included (btw. the egg files include both binary and source) inside lithosphere/dist/lithosphere.zip/lithosphere/pyglet-1.2dev-py2.6.egg
Copy-paste pyglet-1.2dev-py2.6.egg into C:\Python26\Lib\site-packages\pyglet-1.2dev-py2.6.egg
You don’t actually need setuptools, but it comes handy. You could try to download the latest version from the internet (setuptools-20.9.0-py2.6 at the time of writing), which works halogen and gletools, but it won’t work on lithosphere because of a missing “app” directive.
Like pyglet, just copy paste lithosphere/dist/lithosphere.zip/lithosphere/setuptools-0.6c11-py2.6.egg into C:\Python26\Lib\site-packages\setuptools-0.6c11-py2.6.egg
Building halogen & gletools
Go to halogen root dir and type:
C:\Python26\Python.exe setup.py install
Then repeat the same on gletools’ root dir.
This should create “halogen-0.1.1-py2.6.egg” and “gletools-0.1.0-py2.6.egg” in C:\Python26\Lib\site-packages
You can also use the binaries from /dist/lithosphere.zip; but it’s nice at least to be able to build this from the right source rather than magical solutions.
I don’t use setuptools here; since I’m intending to work very often on the program to do modifications, then run again. So a packaging step gets in the way. You’re going to need some modifications to get it to run:
1. Comment “#version” in all of the shader files (they’re on repo/lithosphere/shaders). They all say either “#version 120 core” or “#version 130 core” and this is causing GLSL compiler errors on AMD drivers. Dunno about other vendors. So just comment them. It’s a lot of files, so you may want to use Find & Replace in files.
2. Open lithosphere/main.py and add the following lines:
At line 2:
import sys, os, traceback sys.path.append( '../' ) #<--- new line from pyglet.gl import *
This will cause the “import lithosphere” to work as expected.
At the end of file:
Without this the app will only load some python code, then exist right away.
Now go to lithosphere’s root folder and type:
cd lithosphere C:\Python26\Python.exe main.py
And it should be running!
Avoid installing halogen & gletools
If you plan on working on these two as well, you can avoid installation by adding their paths to sys.path:
import sys, os, traceback sys.path.append( '../' ) #Add lithosphere sys.path.append( 'G:/path_to/halogen' ) #Path to halogen's repo sys.path.append( 'G:/path_to/gletools' ) #Path to gletools' repo from pyglet.gl import *
After doing this, you may run into a few errors but those are easy to solve (missing module imports which are solved by opening the python file with the error, and adding the import line)
This trick is needed if you didn’t want to use setuptools.
As an interesting remark, the code provided in lithosphere 0.1.2 Alpha does not match any of the commits from the lithosphere repo. This version has ambient occlusion, which the repo lacks. This leads me to believe the binary version is a little more recent than the repo’s.
However the repo contains #version 130 in some of its files, while the binary only contains commented #version 120; which leads me to believe the repo version is more recent.
Anyway, you can open the egg file from lithosphere’s “binary” distribution, and copy paste the py files into the ones from the repo; and it will run and you’ll have the Ambient Occlusion feature.
Now back to studying this code so I can add some features.