Wednesday, September 13, 2017

Throwing things in a perfect circle

How difficult do you think it can be to throw things in a circle?
Not as easy as you'd think or I'd like.
It took me 2-3 hours to figure the following tiny chunk of code. AND I have the background. Shit. Maybe I am just bad at what I'm doing, lol. Anyway, it felt like it was worth a short blog post.

var texts = array of things to throw around;
var count = texts.Length;
var circularUIRadius = how far to throw from the central point;
var depthUI = how close to the target object things should be;

//So here it starts - the target object position:
var targetCenter = Vector3.Lerp(this.transform.position, Camera.main.transform.position, depthUI);

//I want to get the direction vector from the target to the camera. What can be easier?
Vector3 facingCamera = (Camera.main.transform.position - targetCenter).normalized;

//Make sure things are happening as I think they are:
Debug.DrawRay(targetCenter, facingCamera, Color.blue, 5.0f, false);

//Here starts the fun - get the second vector to describe the plane, into which the circle of texts goes
//The first axis is Vector3.up, but this can still be improved totilt the plane up or down depending if the camera moves up or down. <TO BE DONE>
var directionPerpendicular = Vector3.Cross(facingCamera, Vector3.up).normalized; -// --> this didn't work! Quaternion.Euler(0, -90, 0) * direction;
Debug.DrawRay(targetCenter, directionPerpendicular, Color.yellow, 5.0f);

for (var i = 0; i < count; i++)
{

  // super advanced spatial geometry math from parametric-equation-of-a-circle-in-3d-space
  //Get the desired angle for the thing, we strive for equality and symmetry
  var angle = Math.PI * i * 2 / count;
  //Calculate the final location for the text
  var target = targetCenter + circularUIRadius * (float)Math.Cos(angle)*Vector3.up + circularUIRadius * (float)Math.Sin(angle)*directionPerpendicular; 
  texts[i].transform.position = target;

  //And the final touch - cherry, so to say...                    
  // rotate to camera - prevent text from being mirrored from lookat-in-opposite-direction
  texts[i].transform.LookAt(2*target - Camera.main.transform.position);
}




Result!
 


Wednesday, September 6, 2017

30 days 1 coursera course 1 game 5 songs

Conclusion: It is not difficult to find and explore new ideas, especially in a limited time period and the right goals.
Over time my relationship with inspiration was difficult.
The best time for music production was surprisingly, exams at the university. What would I not do to procrastinate and postpone studying questions.
After graduating it got impossible to do anything with music. Traveling, moving around the globe, getting out of bands and into totally new environments. Too distracting. I feel sad realizing that it were 4-5 years without composing and recording. Terrifying! The only activity I could stick to was singing, because it doesn't require equipment (almost).
I tried to get back to music 2 years ago, when I just moved back to Seattle, but there were too many other things: work and new house, so there was no energy for music.

The setup morphed into this:
After I have received the news that I am joining the Hololens team, I got all the energy I needed. Good timing with a gaming hackathon, where I was invited as a musician, so I started with producing an ambient soundtrack for a dark mood. I spent a couple evenings listening to American McGee's Alice and Baldur's Gate soundtrack, then I was done with ours the next evening. I also did all in-game sound effects, and even some voice acting in addition to coding and puzzle design. 
In parallel I took a Coursera course on Ableton, so I could use Ableton Live 9 30day trial most efficiently. It was hard to find time for all activities besides work, but it was exciting and challenging to follow the requirements for the next assignment. Here are the drafts:

My profile on Blend: InflunZa
After both the gaming hackathon and Ableton course deadlines arrived, I suddenly got some free time and with a week of the trial remaining and new knowledge from the course, I decided to remix the ambient track into a completed song. Still demo quality, but this is definitely faster than more than half a year for producing the previous song in free Zunewave Podium (note it was completely composed by the time I started).
How do you strike the balance between time, motivation and laziness? :)

Cheers, ~InflunZa

P.S. The game was published and is worth a separate post, so here's just the link (free)