Tuesday, 27 September 2016

Sound and Motion

A couple of new experiments testing the Maximo system for use in Unity, and synchronising animation and sound together. I feel Unity is missing a sound bar in the animation timeline, which would enable more accurate synching, and be a big help with the animation.
The figure is again from my forthcoming AR book about the universe.

WebGL demo

Monday, 26 September 2016

We Are All Made of Stars...

I've been playing around with this fantastic dataset HYG. It contains 120,000 star positions and magnitudes. I've coupled it with the constellations from NASA and made a Sky map, that isn't a skymap. That is to say, it's made of particles rather than the traditional bitmap image.
Several advantages there. First I stripped down the data to the 10,000 stars visible to the naked eye.
The resulting dataset is about 450Kb, compared to several megs for a comparable image map.
Then I've changed the colour from pitch black to a inky blue, which is more the color you see most nights. Obviously that can be easily selected from the Camera background colour. The stars also shimmer ever so slightly. To add a bit of interest the constellations are interactive and display their name on mouse over.

This is part of a children's book I'm writing about the universe. More on that later...
Try it for yourself :) Mouse Wheel to zoom out and see the "star globe".

Monday, 12 September 2016

Fun with Particles

No matter what platform you use, sooner of later you're going to want to have a mess with particles.
The "fun" involved is trying to get them to do what you want. I've been playing with the Unity Particle system for a couple of days now. A lot can be achieved in the UI manually, but who wants to do things manually? So, getting to grips with the system via C# seemed (at first) the best way to go about it. The system has many ahem, idiosyncrasies that at times had me going mental, but in the end I managed to beat it into submission.

The result? I like to call it home. A little old place called the Milky Way...

The whole thing starts with a Big Bang (I am a stickler for details, so this does too).
Basically, you first have to generate all the necessary particles. It would be nice if you could set their size via script, but that would be too easy. Not all the properties you have at your disposal in the UI are available through the API, though there are workarounds for a few of them. I found I had to generate the particles first, then go back and scale them individually, not something you want in your Update function.

Issue 2. After piffling about drawing Force graphs to emit the particles in a nice spiral, I found it was WAY easier to rotate the emitter as it was generating the particles. This was great, only I had to do it in WORLD coordinates. No problem, except after generating them, you can't then rotate them, by rotating the parent object. So, after a few shandies I managed to figure out how to generate in world coordinates and then switch to LOCAL afterwards. All well and good, except for a strange anomaly.
When changing emitter to LOCAL (actually finished emitting at that point), the transformation the parent object already had somehow get's lost. So to summarize, first create your emitters, facing in the direction you want and spew your particles into world space. When finished change to LOCAL, and apply the transformation the parent object had before you switched. Simples!

I could write a short book about the ForceOverLifetime module, but I doubt it would be a best seller. If you ever mess with it, to attempt a circular motion, Good Luck! Just remember that if you apply a force in one direction you need to double the force to make it go in the other, so the usual SIN/COS technique for a circular path simply doesn't apply.

There's 40400 particles here, and I must admit I'm impressed with the performance, even on my 3 year old mobile.

It wasn't purely for fun, this is a to illustrate a page an AR book I'm writing for children to learn the wonders of the universe, from the Big Bang to the Special and General relativity. Hopefully that will be a best seller...