Tutorial

Gravit Home / Documentation Index

Overview

To get your head around the usage of Gravit, I've written this tutorial. It is based on Gravit Version 0.4.1 and most of it may apply to other versions.

Basic Usage

Recording and Playback

The first step is to run Gravit. If you have problems read the Troubleshooting section. You should see a mostly black screen with some statistics on the top left and Gravit's message log on the bottom left.

Gravit has a console which you can type in commands and change settings. To access it press ` (which is normally to the left of 1 and under ESC). You should see a blue box on the bottom left of the screen underneath the message log. Type in spawn one-galaxy then hit ENTER. This should create 1000 particles shaped in a spiral form 1.

Now you're ready to start recording. Recording is when Gravit calculates gravity forces between each particle. Since this takes a lot of CPU power to work out, it is normally fairly slow to process. During a recording Gravit will update the screen on a regular basis so you can see what it's doing. There is a console command you can run to change this value. Get into the console again and type in recordingvideorefreshtime 1000 then hit ENTER. Now Gravit will only send an update to the screen every 1000ms or 1 second. This is especially handy if you have a slow video card, or you want Gravit to spend more time doing calculations then spending time rendering to the screen.

Let this run until there are 50 or so actual frames. Press F5. Now Gravit will replay your recording as fast as it can. This may be a little too fast. Try slowing it down by using the frameskip command. Go into the console and type in frameskip -50 and hit ENTER. This will slow down the simulation by showing each frame 50 times. Since Gravit only knows a set of positions of every particle for every frame, displaying each frame 50 times won't look too good. To fix this Gravit interpolates particle positions between frames when frameskip is negative. Feel free to change the frameskip value to your liking.

If you feel the need to continue recording at any time, press F6. You'll also want to be in playback mode (F5) when typing console commands.

At any time press F1 to see a quick reference on what keys do what. Also, check out Console Commands and Variables for some console reference.


  1. 1. Only if you have Lua installed with Gravit. If you don't, you'll see galaxies scattered around the place.

Pretty Graphics

Now that you've mastered recording and playback. I'll show you how to make it look pretty. For starters, lets increase the size of each particle. There are 2 settings for particle sizes. A minimum size and a maximum size 1. Increase the minimum particle size by pressing the = (equals) key several times. Be careful, the bigger the particles, the more each particle overlaps and the more your video card will slow down. Oops you've made them too large! Hit the - (minus) key to make the minimum size smaller. If you feel experimental the keys to increase and decrease the maximum particle size are [ and ].

Particles will be bigger when you are closer to a particle. At the moment most of the particles are the same distance away since we're looking at a spiral galaxy front on. Rotate your view by holding down the right mouse button2 and move the mouse around. The controls may be a little unusual (which I have yet to fix) but it doesn't take long to get accustomed to them. Use the A and Z keys to zoom in and out (or you can use your mouse wheel).

You may be wondering about those lines that follow each particle. These are called particle tails. Gravit remembers the history of each particle and is able to display the path of its travels. The look of them are highly customisable. All of the keys on the bottom row of a QWERTY keyboard (except for Z and /) control the look of particle tails. Apart from the bottom row of keys, there are the ; (semi-colon) and ' (quote) keys which control the thickness of every tail. To change the length use the B, N and M keys. B and N change the length to be shorter and larger while M is a toggle between no tail and an infinite length tail (this will draw the full path from the first frame to the current frame). There are more tail settings you can change but I'll leave you to experiment. Press F2 to see a list of what things you can do.

Before I finish up, I still need to tell you about particlecolourmode and blendmode. particlecolourmode is a setting that changes the colour of each particle depending on their current properties and state. They are mass, velocity, acceleration, momentum and kinetic energy. You can quickly switch between them by pressing the / (forward slash) key. blendmode changes how particles and particle tails overlap each other. By default it's set to 1 which adds overlapped colours together, so if you get many overlaps the colours will turn white. The others are left to your experimentation! Press L to switch between blend modes quickly.

There are many more visual settings you can change which I will leave to your spare time. As I mentioned before you can use F2 to see a list of visual effects keys and what they do. And of course you can always use the Console Commands and Variables to see what other settings you can change.


  1. 1. These will work differently with different particlerendermode settings.
  2. 2. The left mouse button will work too, but I want you to get used to the right mouse button because the left mouse button will be used for something else.

More To Come

Well that's it for now. I'll continue writing more in the weeks to come...