This quick post will describe in some detail and provide some example code to turn an SPH/N-Body
simulation into an interactive three dimensional Sketchfab model as depicted above. I'll probalby
make this into a fuller tutorial soon and include some ways to output these directly from Blender,
but this shall have to suffice for the time being.
The basic idea is that we can combine
and a "sketchfab.timeframe" file into
a three dimensional stop motion animation as described in
examples of different file formats and options will be discussed here, but feel free to contact me if
anything is unclear or you need info about how to convert your model!
A FINAL NOTE: you'll definitely want to play around with some of
Sketchfab's 3D-settings. For example, I like using shadeless shading
for my point particle simulations personally.
From an SPH-text File
If you've formatted your SPH data in an SPH-text file as described in
the simple SPH movie tutorial you can
use this quick python code to convert
your SPH-text files into PLY files + a sketchfab.timeframe file. This makes the header
Sketchfab movie above if you use the zipped SPH-text files
linked here (26M).
But what if you have large SPH-text files and need to save less points in order to
be able to upload your model to Sketchfab? Check out
this Python script right here
which reads in a series of higher resolution SPH-text files and only outputs a
subset in a series of PLY files
to upload onto Sketchfab. NOTE: because the origional simulation was produced by others in the
collaboration, I cannot give the public access to the particular data set, but hopefully one
can get an idea of how to apply it to your own data.
From a Simple Gadget-2 Simulation with a Python HDF5 Reader
The example outlined in this bit of Python
code is a method to turn Gadget-2 data directly into a set of
PLY files +
sketchfab.timeframe file. This particular data set comes the
Astrobites Gadget-2 Tutorial.
If you want to directly mess around with the snapshot files instead of running your own
Gadget-2 simulation feel free to
download the data here, but there are only a few
snapshots so you're really better off re-running the simulation if you want a nicer movie.
From a yt Script
Finally, lets use yt to do all of the fancy data reading for us,
and use a bit of extra Python code to reformat things into PLY files.
For this example I'm using the
dataset, but any particle dataset should work (famous last words... but really, it should!).
The example outlined in this example Python script
turns particle data into PLY + sketchfab.timeframe file for upload onto Sketchfab. Note: there is a
parameter which allows you to randomly downsample your data. Since Sketchfab maxes out at 200Mb, you
might need to decimate your data to make an interactive movie.