By James on Monday 18 March 2013, 14:07 - Permalink
I thought it was about time I started blogging about project Blue Comb, also known as The Origami Game.
Blue Comb has been in development for a rather long time now, and for most of that time I haven't been entirely sure just what it is. It grew out of an idea I was working on for a story-based game. I was thinking about the sort of feel and style I wanted for it, and what was achievable for a tiny team on a tiny budget. Origami seemed like the perfect theme, with low-polygon models (easy for the machine to handle; easy for me to create) and the opportunity for a beautiful papery visual style. I started coming up with a design where you'd explore a world made up of collages, and along the way you'd discover new Origami models that you could transform into - a fish would allow you to swim, a bird would let you fly and so on.
So I sat down and started coding. Clearly the first thing I needed was some sort of editor to create the models… and that's where I got trapped. It turns out that creating an editor for Origami is really tricky and really interesting. Eventually it became apparent that this game was going to be mostly about the editor, and the exploring portion was off at a bit of weird angle to it.
For a while I decided that I would do away with any game aspect - it would be purely an app for learning, creating and sharing Origami designs. Eventually I settled on the minimum viable game for it - a puzzle where you unlock Origami designs by matching patterns as you fold, but with a sandbox mode that contains All The Work.
In this Blog post, I'd like to talk a bit about some of the folds that exist in Origami, and how to achieve them in a simulation.
The first type of fold is the valley or mountain fold. This is where you simply bend the paper along a line. If you bend it towards you, the crease is like a valley. If you bend it away, it's a tiny mountain. Simulating this is easy - if you drag any point on the paper, we just need to create a crease line half way between where the drag started and where it is now. A valley fold puts the action where you can see it, so we do that by default; to create a mountain fold, you'll need to turn the paper over and create a valley from the other side.
This video shows some aimless valley fold creation, and also shows how it tries snapping the fold to likely points and edges.
The first few folds are straightforward enough, but we soon hit what turns out to be quite a tricky problem with simulated Origami. You can put a crease across wherever you like and you'll have a valid fold, but there are situations where moving a crease a small amount will result in a large change in the folded result. The following video shows how I handle the situation where dragging a crease will suddenly involve a previously unfolded part of the paper. The active fold uncurls a little way while the newly involved fold curls up to join it. With a mouse this is easy enough, but on the iPad it means that your finger starts getting ahead of the drag point. I experimented with various way of resolving the offset. The best solution I found was simply zeroing the physics when the catchup curl is complete, so that it slowly accelerates to rejoin your finger (allowing you time to adjust where you're pointing).
During the catchup curl, you have the opportunity to decide whether you really mean to involve the new flap of paper - it takes a certain distance to commit to it (which is proportional to the size of the flap), so there's time to stop and go back if your intention is to snap to the edge of the flap.
Mountain and valley folds are all very well, but most of the interesting models involve some slightly more complex moves. (There is an Origami discipline called Pureland which aims to use only those folds, and it's fun to see how much expression you can achieve within such constraints). I was going to be disappointed if I couldn't create the classic crane model within my simulator. In fact, my goal was to be able to create it using intuitive prods at the onscreen model, with no buttons or obscure gestures.
This sort of model requires a few techniques. First, there is the squash fold, which looks like this:
To perform a squash fold, you first need to have a model that has creases defining two flaps which hinge over, and a flap carried between them. Where you'd start a valley fold by picking a vertex or a silhouette edge to start dragging, for a squash fold you put your finger in the middle of a crease and smudge it sideways. The simulation searches for a valid pivot point and collects all the affected faces, and drags them around. If there are multiple valid squash folds, you smudge back past the starting point and in again, and it will cycle to the next possibility.
Then there's the petal fold:
If you look carefully, you'll see that the petal fold is just two squash folds stuck together in the middle. The tricky part is that we can't choose a starting point for the drag which says unambiguously that this is a petal fold rather than a valley fold. What happens is the simulation assumes that if a petal fold is possible from your start point then it's probably what you want. Again, multiple valid petal folds can exist at one location, so the same trick of dragging back and coming in again cycles through them, and this is where you can cycle on to the valley fold if wanted.
Cycling through possible folds is shown in this video:
And a related technique, dragging back to gather multiple flaps into a fold, is shown here:
The last major fold required for the crane (and most of the traditional models) is the inside reverse fold. This often used for heads, beaks, legs and so on, and involves opening up a flap enough to flip it inside out, like this:
It's achieved by pushing on the edge of the fold. The simulation just assumes that picking an edge that is reversible should invoke an inside reverse. If you actually want to perform a valley fold, you pick the pointy end instead.
There is another reverse fold, the outside reverse, which is very similar but ends with the flap folding around outside of itself rather than flipping inside. I currently handle this with some restrictions that I'm hoping to overcome. Models such as the traditional swan can be folded, but require an additional step to set up.
That's probably enough for this update, but I'll finish with a couple more video clips. This one is me folding (most of) the bird base:
And this one shows how you can scrub through a folding sequence if you're learning how to fold a model for reals. (The simulation automatically combines multiple symmetrical folds into a single step where that would improve clarity.)