From e1aa2f92e73b7399466ca958ec8db7f144324eac Mon Sep 17 00:00:00 2001 From: Guney Ozsan Date: Sun, 27 Aug 2017 01:39:57 +0300 Subject: [PATCH 01/17] Convert array of Word objects of opening titles to Title class. Implement a constructor to Word class. --- Assets/Scripts/OpeningTitles.cs | 197 ++++++++++++++++++-------------- 1 file changed, 109 insertions(+), 88 deletions(-) diff --git a/Assets/Scripts/OpeningTitles.cs b/Assets/Scripts/OpeningTitles.cs index 102ea3b..e221cb2 100644 --- a/Assets/Scripts/OpeningTitles.cs +++ b/Assets/Scripts/OpeningTitles.cs @@ -25,36 +25,89 @@ public class OpeningTitles : MonoBehaviour Transform planetesimalPrefab; Transform planetesimal; - Word[] openingTitles; + Title openingTitles; + + + + class Title + { + private Word[] words; + + public Title(int wordCount) + { + words = new Word[wordCount]; + } + + public Word this[int index] + { + get + { + return words[index]; + } + set + { + words[index] = value; + } + } + + public int Length + { + get + { + return words.Length; + } + } + } + + class Word { - public Vector3 location; // position of the word in 3d space - public int verticalParticleSlotsPerLetter; // letter height and width in particle slots - public int horizontalParticleSlotsPerLetter; - public int horizontalParticlesPerSlot; - public int verticalParticlesPerSlot; - public float slotPadding; // space between each particle slot - public float particlePadding; // space between each particle in a single slot - public string code; // the letters written in empty and non-empty characters. - // code should fit the parameters for particle slots per letter. + public Vector3 Location { get; private set; } // position of the word in 3d space + public int VerticalParticleSlotsPerLetter { get; private set; } // letter height and width in particle slots + public int HorizontalParticleSlotsPerLetter { get; private set; } + public int HorizontalParticlesPerSlot { get; private set; } + public int VerticalParticlesPerSlot { get; private set; } + public float SlotPadding { get; private set; } // space between each particle slot + public float ParticlePadding { get; private set; } // space between each particle in a single slot + public string Code { get; private set; } // the letters written in empty and non-empty characters. + // code should fit the parameters for particle slots per letter. + + public Word(Vector3 location, + int verticalParticleSlotsPerLetter, int horizontalParticleSlotsPerLetter, + int horizontalParticlesPerSlot, int verticalParticlesPerSlot, + int slotPadding, float particlePadding, + string code) + { + Location = location; + VerticalParticleSlotsPerLetter = verticalParticleSlotsPerLetter; + HorizontalParticleSlotsPerLetter = horizontalParticleSlotsPerLetter; + HorizontalParticlesPerSlot = horizontalParticlesPerSlot; + VerticalParticlesPerSlot = verticalParticlesPerSlot; + SlotPadding = slotPadding; + ParticlePadding = particlePadding; + Code = code; + } } + void Start () { - openingTitles = InitializeOpeningTitles(); - + openingTitles = SetOpeningTitles(); + Transform gravityTarget = GetComponent().sun; Transform planetesimalParent = new GameObject("Planetesimals").transform; - for (int i = 0; i < openingTitles.Length; i++) { - float rowLength = openingTitles[i].code.Length / openingTitles[i].verticalParticleSlotsPerLetter; - float slotPadding = openingTitles[i].slotPadding; - int horizontalParticleSlotsPerLetter = openingTitles[i].horizontalParticleSlotsPerLetter; + for (int i = 0; i < openingTitles.Length; i++) + { + float rowLength = openingTitles[i].Code.Length / openingTitles[i].VerticalParticleSlotsPerLetter; + float slotPadding = openingTitles[i].SlotPadding; + int horizontalParticleSlotsPerLetter = openingTitles[i].HorizontalParticleSlotsPerLetter; - for (int j = 0; j < openingTitles[i].code.Length; j++) { - if (openingTitles[i].code[j].ToString() != " ") + for (int j = 0; j < openingTitles[i].Code.Length; j++) + { + if (openingTitles[i].Code[j].ToString() != " ") { float currentRow = Mathf.FloorToInt(j / rowLength); float y = -1 * slotPadding * currentRow; @@ -67,11 +120,11 @@ void Start () { float x = slotPadding * j + letterPadding + offsetLineToParagraphIndent; - for (int k = 0; k < openingTitles[i].horizontalParticlesPerSlot; k++) + for (int k = 0; k < openingTitles[i].HorizontalParticlesPerSlot; k++) { - for (int l = 0; l < openingTitles[i].verticalParticlesPerSlot; l++) + for (int l = 0; l < openingTitles[i].VerticalParticlesPerSlot; l++) { - planetesimal = Instantiate(planetesimalPrefab, openingTitles[i].location + new Vector3(x + k * openingTitles[i].particlePadding, y - l * openingTitles[i].particlePadding, 0), Quaternion.identity, planetesimalParent); + planetesimal = Instantiate(planetesimalPrefab, openingTitles[i].Location + new Vector3(x + k * openingTitles[i].ParticlePadding, y - l * openingTitles[i].ParticlePadding, 0), Quaternion.identity, planetesimalParent); planetesimal.GetComponent().SetTarget(gravityTarget); planetesimal.tag = "Planet"; } @@ -80,76 +133,44 @@ void Start () { } } } + - - Word[] InitializeOpeningTitles() + Title SetOpeningTitles() { - Word[] openingTitles = new Word[4]; - - openingTitles[0] = new Word() - { - location = new Vector3(-62f, 15f, 4.6f), - horizontalParticleSlotsPerLetter = 5, - verticalParticleSlotsPerLetter = 5, - horizontalParticlesPerSlot = 2, - verticalParticlesPerSlot = 2, - slotPadding = 2, - particlePadding = 0.96f, - code = "88888" + "8 8" + "8 8" + "88888" + "8 8" + - "8 " + "8 8" + "88 8" + "8 " + "8 8" + - "8 88" + "8 8" + "8 8 8" + "8888 " + " 8 8 " + - "8 8" + "8 8" + "8 88" + "8 " + " 8 " + - "88888" + "88888" + "8 8" + "88888" + " 8 " - }; - - openingTitles[1] = new Word() - { - location = new Vector3(10f, 15f, 4.6f), - horizontalParticleSlotsPerLetter = 5, - verticalParticleSlotsPerLetter = 5, - horizontalParticlesPerSlot = 2, - verticalParticlesPerSlot = 2, - slotPadding = 2, - particlePadding = 0.96f, - code = "88888" + "88888" + " 8888" + " 8 " + "8 8" + - "8 8" + " 8 " + "8 " + " 8 8 " + "88 8" + - "8 8" + " 8 " + " 888 " + " 888 " + "8 8 8" + - "8 8" + " 8 " + " 8" + "8 8" + "8 88" + - "88888" + "88888" + "8888 " + "8 8" + "8 8" - }; - - openingTitles[2] = new Word() - { - location = new Vector3(-50f, 0f, 4.6f), - horizontalParticleSlotsPerLetter = 5, - verticalParticleSlotsPerLetter = 5, - horizontalParticlesPerSlot = 2, - verticalParticlesPerSlot = 2, - slotPadding = 2, - particlePadding = 0.96f, - code = "88888" + "8 8" + "88888" + - "8 8" + "8 8" + " 8 " + - "8 8" + "8 8" + " 8 " + - "8 8" + "8 8" + " 8 " + - "88888" + "88888" + " 8 " - }; - - openingTitles[3] = new Word() - { - location = new Vector3(-2f, 0f, 4.6f), - horizontalParticleSlotsPerLetter = 5, - verticalParticleSlotsPerLetter = 5, - horizontalParticlesPerSlot = 2, - verticalParticlesPerSlot = 2, - slotPadding = 2, - particlePadding = 0.96f, - code = "88888" + "8 8" + "88888" + "8888 " + "88888" + - " 8 " + "8 8" + "8 " + "8 8" + "8 " + - " 8 " + "88888" + "8888 " + "8888 " + "8888 " + - " 8 " + "8 8" + "8 " + "8 8 " + "8 " + - " 8 " + "8 8" + "88888" + "8 8 " + "88888" - }; + Title openingTitles = new Title(4); + + openingTitles[0] = new Word(new Vector3(-62f, 15f, 4.6f), 5, 5, 2, 2, 2, 0.96f, + "88888" + "8 8" + "8 8" + "88888" + "8 8" + + "8 " + "8 8" + "88 8" + "8 " + "8 8" + + "8 88" + "8 8" + "8 8 8" + "8888 " + " 8 8 " + + "8 8" + "8 8" + "8 88" + "8 " + " 8 " + + "88888" + "88888" + "8 8" + "88888" + " 8 " + ); + + openingTitles[1] = new Word(new Vector3(10f, 15f, 4.6f), 5, 5, 2, 2, 2, 0.96f, + "88888" + "88888" + " 8888" + " 8 " + "8 8" + + "8 8" + " 8 " + "8 " + " 8 8 " + "88 8" + + "8 8" + " 8 " + " 888 " + " 888 " + "8 8 8" + + "8 8" + " 8 " + " 8" + "8 8" + "8 88" + + "88888" + "88888" + "8888 " + "8 8" + "8 8" + ); + + openingTitles[2] = new Word(new Vector3(-50f, 0f, 4.6f), 5, 5, 2, 2, 2, 0.96f, + "88888" + "8 8" + "88888" + + "8 8" + "8 8" + " 8 " + + "8 8" + "8 8" + " 8 " + + "8 8" + "8 8" + " 8 " + + "88888" + "88888" + " 8 " + ); + + openingTitles[3] = new Word(new Vector3(-2f, 0f, 4.6f), 5, 5, 2, 2, 2, 0.96f, + "88888" + "8 8" + "88888" + "8888 " + "88888" + + " 8 " + "8 8" + "8 " + "8 8" + "8 " + + " 8 " + "88888" + "8888 " + "8888 " + "8888 " + + " 8 " + "8 8" + "8 " + "8 8 " + "8 " + + " 8 " + "8 8" + "88888" + "8 8 " + "88888" + ); return openingTitles; } From a984193642de53dd73f8524f30c48a5b863a8055 Mon Sep 17 00:00:00 2001 From: Guney Ozsan Date: Sun, 27 Aug 2017 01:40:43 +0300 Subject: [PATCH 02/17] Rename OpeningTitles class to Titles. --- Assets/Scripts/{OpeningTitles.cs => Titles.cs} | 2 +- Assets/Scripts/{OpeningTitles.cs.meta => Titles.cs.meta} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename Assets/Scripts/{OpeningTitles.cs => Titles.cs} (99%) rename Assets/Scripts/{OpeningTitles.cs.meta => Titles.cs.meta} (100%) diff --git a/Assets/Scripts/OpeningTitles.cs b/Assets/Scripts/Titles.cs similarity index 99% rename from Assets/Scripts/OpeningTitles.cs rename to Assets/Scripts/Titles.cs index e221cb2..15124e7 100644 --- a/Assets/Scripts/OpeningTitles.cs +++ b/Assets/Scripts/Titles.cs @@ -19,7 +19,7 @@ using System.Collections.Generic; using UnityEngine; -public class OpeningTitles : MonoBehaviour +public class Titles : MonoBehaviour { [SerializeField] Transform planetesimalPrefab; diff --git a/Assets/Scripts/OpeningTitles.cs.meta b/Assets/Scripts/Titles.cs.meta similarity index 100% rename from Assets/Scripts/OpeningTitles.cs.meta rename to Assets/Scripts/Titles.cs.meta From c0e0198ef8b3d16461405d79b06cf2967cb37ffd Mon Sep 17 00:00:00 2001 From: Guney Ozsan Date: Sun, 27 Aug 2017 13:51:51 +0300 Subject: [PATCH 03/17] Introduce a letter class and a dictionary of letter templates that would function as a font. --- Assets/Scripts/Titles.cs | 201 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 200 insertions(+), 1 deletion(-) diff --git a/Assets/Scripts/Titles.cs b/Assets/Scripts/Titles.cs index 15124e7..efc7738 100644 --- a/Assets/Scripts/Titles.cs +++ b/Assets/Scripts/Titles.cs @@ -15,6 +15,7 @@ // along with this program. If not, see . // --------------------------------------------------------------------- +using System; using System.Collections; using System.Collections.Generic; using UnityEngine; @@ -71,7 +72,8 @@ class Word public float SlotPadding { get; private set; } // space between each particle slot public float ParticlePadding { get; private set; } // space between each particle in a single slot public string Code { get; private set; } // the letters written in empty and non-empty characters. - // code should fit the parameters for particle slots per letter. + // code should fit the parameters for particle slots per letter. + Letter[] letters; public Word(Vector3 location, int verticalParticleSlotsPerLetter, int horizontalParticleSlotsPerLetter, @@ -87,11 +89,208 @@ public Word(Vector3 location, SlotPadding = slotPadding; ParticlePadding = particlePadding; Code = code; + + /* + letters = new Letter[Code.Length]; + + for (int i = 0; i < letters.Length; i++) + { + letters[i] = new Letter(Code[i]); + } + */ } } + class Letter + { + public bool[,] Pixels { get; private set; } + + public Letter (char letter) + { + Pixels = new bool[letters[letter][0].Length, letters[letter].Length]; + + for (int i = 0; i < letters[letter].Length; i++) + { + for (int j = 0; j < letters[letter][i].Length; j++) + { + if (Char.IsWhiteSpace(letters[letter][i][j])) + { + Pixels[i, j] = false; + } + else + { + Pixels[i, j] = true; + } + print(Pixels[i, j]); + } + } + } + + Dictionary letters = new Dictionary + { + { 'A', new string[] { + " 0 ", + " 0 0 ", + " 000 ", + "0 0", + "0 0"} }, + { 'B', new string[] { + "0000 ", + "0 0", + "0000 ", + "0 0", + "0000 "} }, + { 'C', new string[] { + " 0000", + "0 ", + "0 ", + "0 ", + " 0000"} }, + { 'D', new string[] { + "0000 ", + "0 0", + "0 0", + "0 0", + "0000 "} }, + { 'E', new string[] { + "00000", + "0 ", + "0000 ", + "0 ", + "00000"} }, + { 'F', new string[] { + "00000", + "0 ", + "0000 ", + "0 ", + "0 "} }, + { 'G', new string[] { + "00000", + "0 ", + "0 00", + "0 0", + "00000"} }, + { 'H', new string[] { + "0 0", + "0 0", + "00000", + "0 0", + "0 0"} }, + { 'I', new string[] { + "00000", + " 0 ", + " 0 ", + " 0 ", + "00000"} }, + { 'J', new string[] { + "00000", + " 0 ", + " 0 ", + " 0 ", + "00 "} }, + { 'K', new string[] { + "0 0", + "0 0 ", + "000 ", + "0 0 ", + "0 0"} }, + { 'L', new string[] { + "0 ", + "0 ", + "0 ", + "0 ", + "00000"} }, + { 'M', new string[] { + "0 0", + "00 00", + "0 0 0", + "0 0", + "0 0"} }, + { 'N', new string[] { + "0 0", + "00 0", + "0 0 0", + "0 00", + "0 0"} }, + { 'O', new string[] { + " 000 ", + "0 0", + "0 0", + "0 0", + " 000 "} }, + { 'P', new string[] { + "0000 ", + "0 0", + "0000 ", + "0 ", + "0 "} }, + { 'Q', new string[] { + " 000 ", + "0 0", + "0 0 0", + "0 00", + " 0000"} }, + { 'R', new string[] { + "0000 ", + "0 0", + "0000 ", + "0 0 ", + "0 0"} }, + { 'S', new string[] { + " 0000", + "0 ", + " 000 ", + " 0", + "0000 "} }, + { 'T', new string[] { + "00000", + " 0 ", + " 0 ", + " 0 ", + " 0 "} }, + { 'U', new string[] { + "0 0", + "0 0", + "0 0", + "0 0", + " 000 "} }, + { 'V', new string[] { + "0 0", + "0 0", + " 0 0 ", + " 0 0 ", + " 0 "} }, + { 'W', new string[] { + "0 0", + "0 0", + "0 0 0", + "00 00", + "0 0"} }, + { 'X', new string[] { + "0 0", + " 0 0 ", + " 0 ", + " 0 0 ", + "0 0"} }, + { 'Y', new string[] { + "0 0", + " 0 0 ", + " 0 ", + " 0 ", + " 0 "} }, + { 'Z', new string[] { + "00000", + " 0 ", + " 0 ", + " 0 ", + "00000"} } + }; + } + + + void Start () { openingTitles = SetOpeningTitles(); From 057a62298562a7fbdf55f1dcfcb45aea6b980230 Mon Sep 17 00:00:00 2001 From: Guney Ozsan Date: Thu, 7 Sep 2017 20:31:21 +0300 Subject: [PATCH 04/17] Introduce MathUtility class and a method for finding the closest int cube root to be used in initial generation of required number of planetesimals in cube form. --- Assets/Scripts/Utility.meta | 9 +++++++ Assets/Scripts/Utility/MathUtility.cs | 28 ++++++++++++++++++++++ Assets/Scripts/Utility/MathUtility.cs.meta | 12 ++++++++++ 3 files changed, 49 insertions(+) create mode 100644 Assets/Scripts/Utility.meta create mode 100644 Assets/Scripts/Utility/MathUtility.cs create mode 100644 Assets/Scripts/Utility/MathUtility.cs.meta diff --git a/Assets/Scripts/Utility.meta b/Assets/Scripts/Utility.meta new file mode 100644 index 0000000..be7f809 --- /dev/null +++ b/Assets/Scripts/Utility.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: e6a230b83526fd84b9de0980a9b9b814 +folderAsset: yes +timeCreated: 1504800649 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Utility/MathUtility.cs b/Assets/Scripts/Utility/MathUtility.cs new file mode 100644 index 0000000..eda334b --- /dev/null +++ b/Assets/Scripts/Utility/MathUtility.cs @@ -0,0 +1,28 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public static class MathUtility { + + public static int ClosestCubeRoot(int source, bool inclusive) + { + int root = 0; + float rootPower = Mathf.Pow(root, 3); + + while (rootPower < source) + { + root++; + rootPower = Mathf.Pow(root, 3); + } + + if (inclusive) + { + return root; + } + else + { + return root - 1; + } + } + +} diff --git a/Assets/Scripts/Utility/MathUtility.cs.meta b/Assets/Scripts/Utility/MathUtility.cs.meta new file mode 100644 index 0000000..95bf3fc --- /dev/null +++ b/Assets/Scripts/Utility/MathUtility.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 9db4869cf8fe89c46be8f8a6c460df61 +timeCreated: 1504800781 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: From a4b3ddda992ee52abdd16fc1eccb1457236c77fb Mon Sep 17 00:00:00 2001 From: Guney Ozsan Date: Thu, 7 Sep 2017 20:35:08 +0300 Subject: [PATCH 05/17] Requried number of planetesimals are instantiated independent of the title text and titles will be formed later. --- Assets/Scripts/Titles.cs | 189 +++++++++++++++++++++++++-------------- 1 file changed, 123 insertions(+), 66 deletions(-) diff --git a/Assets/Scripts/Titles.cs b/Assets/Scripts/Titles.cs index efc7738..48d7ea4 100644 --- a/Assets/Scripts/Titles.cs +++ b/Assets/Scripts/Titles.cs @@ -26,8 +26,6 @@ public class Titles : MonoBehaviour Transform planetesimalPrefab; Transform planetesimal; - Title openingTitles; - class Title @@ -58,6 +56,27 @@ public int Length return words.Length; } } + + public int ParticleCount + { + get + { + int particleCount = 0; + + for (int i = 0; i < words.Length; i++) + { + int particlesPerSlot = words[i].HorizontalParticlesPerSlot * words[i].VerticalParticlesPerSlot; + + for (int j = 0; j < words[i].Length; j++) + { + particleCount += particlesPerSlot * words[i][j].OccupiedSlotsCount; + } + + } + + return particleCount; + } + } } @@ -90,14 +109,32 @@ public Word(Vector3 location, ParticlePadding = particlePadding; Code = code; - /* letters = new Letter[Code.Length]; for (int i = 0; i < letters.Length; i++) { letters[i] = new Letter(Code[i]); } - */ + } + + public Letter this[int index] + { + get + { + return letters[index]; + } + set + { + letters[index] = value; + } + } + + public int Length + { + get + { + return letters.Length; + } } } @@ -105,11 +142,15 @@ public Word(Vector3 location, class Letter { - public bool[,] Pixels { get; private set; } + public bool[,] Slots { get; private set; } + + int occupiedSlotsCount; public Letter (char letter) { - Pixels = new bool[letters[letter][0].Length, letters[letter].Length]; + Slots = new bool[letters[letter][0].Length, letters[letter].Length]; + + occupiedSlotsCount = 0; for (int i = 0; i < letters[letter].Length; i++) { @@ -117,17 +158,29 @@ public Letter (char letter) { if (Char.IsWhiteSpace(letters[letter][i][j])) { - Pixels[i, j] = false; + Slots[i, j] = false; } else { - Pixels[i, j] = true; + Slots[i, j] = true; + occupiedSlotsCount++; } - print(Pixels[i, j]); } } } + + + public int OccupiedSlotsCount + { + get + { + return occupiedSlotsCount; + } + } + + + Dictionary letters = new Dictionary { { 'A', new string[] { @@ -292,42 +345,73 @@ public Letter (char letter) void Start () { - openingTitles = SetOpeningTitles(); + Title openingTitles = SetOpeningTitles(); Transform gravityTarget = GetComponent().sun; Transform planetesimalParent = new GameObject("Planetesimals").transform; - for (int i = 0; i < openingTitles.Length; i++) + //for (int i = 0; i < openingTitles.Length; i++) + //{ + // int particlesPerSlot = openingTitles[i].HorizontalParticlesPerSlot * openingTitles[i].VerticalParticlesPerSlot; + // for (int j = 0; j < openingTitles[i].Length; j++) + // { + // openingTitleParticleCount += particlesPerSlot * openingTitles[i][j].OccupiedSlotsCount; + // } + + + // float rowLength = openingTitles[i].Code.Length / openingTitles[i].VerticalParticleSlotsPerLetter; + // float slotPadding = openingTitles[i].SlotPadding; + // int horizontalParticleSlotsPerLetter = openingTitles[i].HorizontalParticleSlotsPerLetter; + + // for (int j = 0; j < openingTitles[i].Code.Length; j++) + // { + // if (openingTitles[i].Code[j].ToString() != " ") + // { + // float currentRow = Mathf.FloorToInt(j / rowLength); + // float y = -1 * slotPadding * currentRow; + + // // Puts space between letters + // float letterPadding = slotPadding * (j / horizontalParticleSlotsPerLetter); + + // // Because the word is coded as a single string, this offsets each line of particle slots back to paragraph indent. + // float offsetLineToParagraphIndent = -1 * currentRow * slotPadding * (rowLength + rowLength / horizontalParticleSlotsPerLetter); + + // float x = slotPadding * j + letterPadding + offsetLineToParagraphIndent; + + // for (int k = 0; k < openingTitles[i].HorizontalParticlesPerSlot; k++) + // { + // for (int l = 0; l < openingTitles[i].VerticalParticlesPerSlot; l++) + // { + // planetesimal = Instantiate(planetesimalPrefab, openingTitles[i].Location + new Vector3(x + k * openingTitles[i].ParticlePadding, y - l * openingTitles[i].ParticlePadding, 0), Quaternion.identity, planetesimalParent); + // planetesimal.GetComponent().SetTarget(gravityTarget); + // planetesimal.tag = "Planet"; + // } + // } + // } + // } + //} + + int cubeSideLength = MathUtility.ClosestCubeRoot(openingTitles.ParticleCount, true); + + float particlePadding = 0.998f; + float alignmentAdjustment = cubeSideLength / 2; + + for (int i = 0; i < cubeSideLength; i++) { - float rowLength = openingTitles[i].Code.Length / openingTitles[i].VerticalParticleSlotsPerLetter; - float slotPadding = openingTitles[i].SlotPadding; - int horizontalParticleSlotsPerLetter = openingTitles[i].HorizontalParticleSlotsPerLetter; + float x = i * particlePadding - alignmentAdjustment; - for (int j = 0; j < openingTitles[i].Code.Length; j++) + for (int j = 0; j < cubeSideLength; j++) { - if (openingTitles[i].Code[j].ToString() != " ") - { - float currentRow = Mathf.FloorToInt(j / rowLength); - float y = -1 * slotPadding * currentRow; - - // Puts space between letters - float letterPadding = slotPadding * (j / horizontalParticleSlotsPerLetter); - - // Because the word is coded as a single string, this offsets each line of particle slots back to paragraph indent. - float offsetLineToParagraphIndent = -1 * currentRow * slotPadding * (rowLength + rowLength / horizontalParticleSlotsPerLetter); + float y = j * particlePadding - alignmentAdjustment; - float x = slotPadding * j + letterPadding + offsetLineToParagraphIndent; + for (int k = 0; k < cubeSideLength; k++) + { + float z = k * particlePadding - alignmentAdjustment; - for (int k = 0; k < openingTitles[i].HorizontalParticlesPerSlot; k++) - { - for (int l = 0; l < openingTitles[i].VerticalParticlesPerSlot; l++) - { - planetesimal = Instantiate(planetesimalPrefab, openingTitles[i].Location + new Vector3(x + k * openingTitles[i].ParticlePadding, y - l * openingTitles[i].ParticlePadding, 0), Quaternion.identity, planetesimalParent); - planetesimal.GetComponent().SetTarget(gravityTarget); - planetesimal.tag = "Planet"; - } - } + planetesimal = Instantiate(planetesimalPrefab, new Vector3(x, y, z), Quaternion.identity, planetesimalParent); + planetesimal.GetComponent().SetTarget(gravityTarget); + planetesimal.tag = "Planet"; } } } @@ -339,37 +423,10 @@ Title SetOpeningTitles() { Title openingTitles = new Title(4); - openingTitles[0] = new Word(new Vector3(-62f, 15f, 4.6f), 5, 5, 2, 2, 2, 0.96f, - "88888" + "8 8" + "8 8" + "88888" + "8 8" + - "8 " + "8 8" + "88 8" + "8 " + "8 8" + - "8 88" + "8 8" + "8 8 8" + "8888 " + " 8 8 " + - "8 8" + "8 8" + "8 88" + "8 " + " 8 " + - "88888" + "88888" + "8 8" + "88888" + " 8 " - ); - - openingTitles[1] = new Word(new Vector3(10f, 15f, 4.6f), 5, 5, 2, 2, 2, 0.96f, - "88888" + "88888" + " 8888" + " 8 " + "8 8" + - "8 8" + " 8 " + "8 " + " 8 8 " + "88 8" + - "8 8" + " 8 " + " 888 " + " 888 " + "8 8 8" + - "8 8" + " 8 " + " 8" + "8 8" + "8 88" + - "88888" + "88888" + "8888 " + "8 8" + "8 8" - ); - - openingTitles[2] = new Word(new Vector3(-50f, 0f, 4.6f), 5, 5, 2, 2, 2, 0.96f, - "88888" + "8 8" + "88888" + - "8 8" + "8 8" + " 8 " + - "8 8" + "8 8" + " 8 " + - "8 8" + "8 8" + " 8 " + - "88888" + "88888" + " 8 " - ); - - openingTitles[3] = new Word(new Vector3(-2f, 0f, 4.6f), 5, 5, 2, 2, 2, 0.96f, - "88888" + "8 8" + "88888" + "8888 " + "88888" + - " 8 " + "8 8" + "8 " + "8 8" + "8 " + - " 8 " + "88888" + "8888 " + "8888 " + "8888 " + - " 8 " + "8 8" + "8 " + "8 8 " + "8 " + - " 8 " + "8 8" + "88888" + "8 8 " + "88888" - ); + openingTitles[0] = new Word(new Vector3(-62f, 15f, 4.6f), 5, 5, 2, 2, 2, 0.96f, "GUNEY"); + openingTitles[1] = new Word(new Vector3(10f, 15f, 4.6f), 5, 5, 2, 2, 2, 0.96f, "OZSAN"); + openingTitles[2] = new Word(new Vector3(-50f, 0f, 4.6f), 5, 5, 2, 2, 2, 0.96f, "OUT"); + openingTitles[3] = new Word(new Vector3(-2f, 0f, 4.6f), 5, 5, 2, 2, 2, 0.96f, "THERE"); return openingTitles; } From b2e1797265bd31625821ee1983fba1f1ccba1b1a Mon Sep 17 00:00:00 2001 From: Guney Ozsan Date: Thu, 7 Sep 2017 20:37:14 +0300 Subject: [PATCH 06/17] Gravity class uses position as its target instead of Transform to allow assigning different gravity targets for different planetesimals. --- Assets/Scripts/Gravity.cs | 6 +++--- Assets/Scripts/Titles.cs | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Assets/Scripts/Gravity.cs b/Assets/Scripts/Gravity.cs index f85b226..7a38ffe 100644 --- a/Assets/Scripts/Gravity.cs +++ b/Assets/Scripts/Gravity.cs @@ -26,7 +26,7 @@ public class Gravity : MonoBehaviour { Rigidbody body; - Transform target; + Vector3 target; [NonSerialized] public int forceMultiplier = 0; @@ -37,10 +37,10 @@ void Start() void Update () { - body.AddForce(forceMultiplier * (transform.position - target.position) / Mathf.Pow(Vector3.Distance(transform.position, target.position), 2)); + body.AddForce(forceMultiplier * (transform.position - target) / Mathf.Pow(Vector3.Distance(transform.position, target), 2)); } - public void SetTarget(Transform target) + public void SetTarget(Vector3 target) { this.target = target; } diff --git a/Assets/Scripts/Titles.cs b/Assets/Scripts/Titles.cs index 48d7ea4..2536787 100644 --- a/Assets/Scripts/Titles.cs +++ b/Assets/Scripts/Titles.cs @@ -410,7 +410,7 @@ void Start () { float z = k * particlePadding - alignmentAdjustment; planetesimal = Instantiate(planetesimalPrefab, new Vector3(x, y, z), Quaternion.identity, planetesimalParent); - planetesimal.GetComponent().SetTarget(gravityTarget); + planetesimal.GetComponent().SetTarget(gravityTarget.position); planetesimal.tag = "Planet"; } } From 441035819eee570b8032c2a1d5d6b49b8e2604c9 Mon Sep 17 00:00:00 2001 From: Guney Ozsan Date: Thu, 7 Sep 2017 20:46:39 +0300 Subject: [PATCH 07/17] Introduce static Space class and add planetesimals to a list in it to replace tags for keeping track of planetesimals. --- Assets/Scripts/Space.cs | 8 ++++++++ Assets/Scripts/Space.cs.meta | 12 ++++++++++++ Assets/Scripts/Titles.cs | 2 +- 3 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 Assets/Scripts/Space.cs create mode 100644 Assets/Scripts/Space.cs.meta diff --git a/Assets/Scripts/Space.cs b/Assets/Scripts/Space.cs new file mode 100644 index 0000000..baea9eb --- /dev/null +++ b/Assets/Scripts/Space.cs @@ -0,0 +1,8 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public static class Space +{ + public static List planetesimals = new List(); +} diff --git a/Assets/Scripts/Space.cs.meta b/Assets/Scripts/Space.cs.meta new file mode 100644 index 0000000..2d0d3bb --- /dev/null +++ b/Assets/Scripts/Space.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: c794c950c7ade494da76203b5a6affae +timeCreated: 1504805274 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Titles.cs b/Assets/Scripts/Titles.cs index 2536787..732dcf8 100644 --- a/Assets/Scripts/Titles.cs +++ b/Assets/Scripts/Titles.cs @@ -411,7 +411,7 @@ void Start () { planetesimal = Instantiate(planetesimalPrefab, new Vector3(x, y, z), Quaternion.identity, planetesimalParent); planetesimal.GetComponent().SetTarget(gravityTarget.position); - planetesimal.tag = "Planet"; + Space.planetesimals.Add(planetesimal); } } } From 04d14d5bd222f2b0d7570a5c1b302f775f8236a7 Mon Sep 17 00:00:00 2001 From: Guney Ozsan Date: Fri, 8 Sep 2017 01:55:43 +0300 Subject: [PATCH 08/17] Transform lights and camera -13 on z axis to fit transposing sun and planetesimals to origin. --- Assets/Scenes/OutThere-MusicVideo.unity | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/Assets/Scenes/OutThere-MusicVideo.unity b/Assets/Scenes/OutThere-MusicVideo.unity index 02b3b13..dc72260 100644 --- a/Assets/Scenes/OutThere-MusicVideo.unity +++ b/Assets/Scenes/OutThere-MusicVideo.unity @@ -181,7 +181,7 @@ Transform: m_PrefabInternal: {fileID: 0} m_GameObject: {fileID: 89987690} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 1.71} + m_LocalPosition: {x: 0, y: 0, z: -11.29} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] m_Father: {fileID: 0} @@ -210,7 +210,7 @@ Transform: m_PrefabInternal: {fileID: 0} m_GameObject: {fileID: 184312932} m_LocalRotation: {x: 0.40821794, y: -0.23456973, z: 0.10938166, w: 0.8754261} - m_LocalPosition: {x: 31.3848, y: -8.248707, z: 46.58443} + m_LocalPosition: {x: 31.3848, y: -8.248707, z: 33.58443} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] m_Father: {fileID: 0} @@ -289,7 +289,7 @@ Transform: m_PrefabInternal: {fileID: 0} m_GameObject: {fileID: 204063246} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 1.71} + m_LocalPosition: {x: 0, y: 0, z: -11.29} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] m_Father: {fileID: 0} @@ -370,7 +370,7 @@ Transform: m_PrefabInternal: {fileID: 0} m_GameObject: {fileID: 1210266818} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: 2.12, y: 0.28, z: -76.22} + m_LocalPosition: {x: 2.12, y: 0.28, z: -89.22} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] m_Father: {fileID: 0} @@ -491,7 +491,6 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: newSun: {fileID: 400000, guid: 8b1f3da1ad7f8c5418f95bafdc7078e5, type: 2} - sun: {fileID: 0} --- !u!114 &1368347922 MonoBehaviour: m_ObjectHideFlags: 0 From 39b866483c0b1e6fa016a3c792865b59a09b5c45 Mon Sep 17 00:00:00 2001 From: Guney Ozsan Date: Fri, 8 Sep 2017 01:58:36 +0300 Subject: [PATCH 09/17] Sun is instantiated at the sound at 4th bar, the beginning of Region 2, in the middle of planetesimals to give an explosion effect. --- Assets/Scripts/Gravity.cs | 2 +- Assets/Scripts/PlayAnimation.cs | 22 ++++++++-------------- Assets/Scripts/Titles.cs | 4 ++-- 3 files changed, 11 insertions(+), 17 deletions(-) diff --git a/Assets/Scripts/Gravity.cs b/Assets/Scripts/Gravity.cs index 7a38ffe..abc4fdb 100644 --- a/Assets/Scripts/Gravity.cs +++ b/Assets/Scripts/Gravity.cs @@ -37,7 +37,7 @@ void Start() void Update () { - body.AddForce(forceMultiplier * (transform.position - target) / Mathf.Pow(Vector3.Distance(transform.position, target), 2)); + //body.AddForce(forceMultiplier * (transform.position - target) / Mathf.Pow(Vector3.Distance(transform.position, target), 2)); } public void SetTarget(Vector3 target) diff --git a/Assets/Scripts/PlayAnimation.cs b/Assets/Scripts/PlayAnimation.cs index f69f8c6..5d613f1 100644 --- a/Assets/Scripts/PlayAnimation.cs +++ b/Assets/Scripts/PlayAnimation.cs @@ -31,19 +31,7 @@ public class PlayAnimation : MonoBehaviour int compareBar; Gravity gravity; - - - - void Awake() - { - sun = Instantiate(newSun, new Vector3(0, 0, 13), Quaternion.identity); - sun.localScale = new Vector3(5, 5, 5); - sun.tag = "Sun"; -#if UNITY_EDITOR - sun.name = "PyramidSun"; -#endif - } - + void Start() @@ -56,10 +44,16 @@ void Start() void Update() { - sun.transform.Rotate(0, 50 * Time.deltaTime, 0); + //sun.transform.Rotate(0, 50 * Time.deltaTime, 0); if (sequencer.currentRegionId == 2 && compareBar != sequencer.currentBar) { + sun = Instantiate(newSun, new Vector3(0, 0, 0), Quaternion.identity); + sun.localScale = new Vector3(5, 5, 5); + sun.tag = "Sun"; +#if UNITY_EDITOR + sun.name = "PyramidSun"; +#endif SwitchAnimation(0, 10, 0); compareBar = sequencer.currentBar; } diff --git a/Assets/Scripts/Titles.cs b/Assets/Scripts/Titles.cs index 732dcf8..c191b73 100644 --- a/Assets/Scripts/Titles.cs +++ b/Assets/Scripts/Titles.cs @@ -394,7 +394,7 @@ void Start () { int cubeSideLength = MathUtility.ClosestCubeRoot(openingTitles.ParticleCount, true); - float particlePadding = 0.998f; + float particlePadding = 1f; float alignmentAdjustment = cubeSideLength / 2; for (int i = 0; i < cubeSideLength; i++) @@ -410,7 +410,7 @@ void Start () { float z = k * particlePadding - alignmentAdjustment; planetesimal = Instantiate(planetesimalPrefab, new Vector3(x, y, z), Quaternion.identity, planetesimalParent); - planetesimal.GetComponent().SetTarget(gravityTarget.position); + planetesimal.GetComponent().SetTarget(Vector3.zero); Space.planetesimals.Add(planetesimal); } } From 8d108083b1a22db60469b3b0f6edb0664b4876c1 Mon Sep 17 00:00:00 2001 From: Guney Ozsan Date: Fri, 8 Sep 2017 02:14:44 +0300 Subject: [PATCH 10/17] Fix PlayAnimation Update instantiates a sun each bar at Region 2. --- Assets/Scripts/PlayAnimation.cs | 25 ++++++++++++++++--------- Assets/Scripts/Sun.cs | 12 ++++++++++++ Assets/Scripts/Sun.cs.meta | 12 ++++++++++++ 3 files changed, 40 insertions(+), 9 deletions(-) create mode 100644 Assets/Scripts/Sun.cs create mode 100644 Assets/Scripts/Sun.cs.meta diff --git a/Assets/Scripts/PlayAnimation.cs b/Assets/Scripts/PlayAnimation.cs index 5d613f1..1214149 100644 --- a/Assets/Scripts/PlayAnimation.cs +++ b/Assets/Scripts/PlayAnimation.cs @@ -29,6 +29,7 @@ public class PlayAnimation : MonoBehaviour Sequencer sequencer; int compareBar; + int currentRegion = 0; Gravity gravity; @@ -44,18 +45,24 @@ void Start() void Update() { - //sun.transform.Rotate(0, 50 * Time.deltaTime, 0); - - if (sequencer.currentRegionId == 2 && compareBar != sequencer.currentBar) + if (sequencer.currentRegionId == 2) { - sun = Instantiate(newSun, new Vector3(0, 0, 0), Quaternion.identity); - sun.localScale = new Vector3(5, 5, 5); - sun.tag = "Sun"; + if (currentRegion != sequencer.currentRegionId) + { + sun = Instantiate(newSun, new Vector3(0, 0, 0), Quaternion.identity); + sun.localScale = new Vector3(5, 5, 5); + sun.tag = "Sun"; #if UNITY_EDITOR - sun.name = "PyramidSun"; + sun.name = "PyramidSun"; #endif - SwitchAnimation(0, 10, 0); - compareBar = sequencer.currentBar; + currentRegion = sequencer.currentRegionId; + } + + if (compareBar != sequencer.currentBar) + { + SwitchAnimation(0, 10, 0); + compareBar = sequencer.currentBar; + } } else if (sequencer.currentRegionId == 3 && compareBar != sequencer.currentBar) { diff --git a/Assets/Scripts/Sun.cs b/Assets/Scripts/Sun.cs new file mode 100644 index 0000000..2897674 --- /dev/null +++ b/Assets/Scripts/Sun.cs @@ -0,0 +1,12 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class Sun : MonoBehaviour { + + void Update () + { + transform.Rotate(0, 50 * Time.deltaTime, 0); + } + +} diff --git a/Assets/Scripts/Sun.cs.meta b/Assets/Scripts/Sun.cs.meta new file mode 100644 index 0000000..5c3684f --- /dev/null +++ b/Assets/Scripts/Sun.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: bdb06355703ea0546967ff77317879bf +timeCreated: 1504825140 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: From ddbfd2b78e5139458a508691d336c40e52811b60 Mon Sep 17 00:00:00 2001 From: Guney Ozsan Date: Fri, 8 Sep 2017 03:11:09 +0300 Subject: [PATCH 11/17] Convert some Sequencer parameters to static and read only from outside. --- Assets/Scripts/DebugGUI.cs | 17 +-- Assets/Scripts/PlayAnimation.cs | 34 +++--- Assets/Scripts/Sequencer.cs | 192 ++++++++++++++++---------------- 3 files changed, 114 insertions(+), 129 deletions(-) diff --git a/Assets/Scripts/DebugGUI.cs b/Assets/Scripts/DebugGUI.cs index 56ea178..99fbf84 100644 --- a/Assets/Scripts/DebugGUI.cs +++ b/Assets/Scripts/DebugGUI.cs @@ -24,23 +24,16 @@ public class DebugGUI : MonoBehaviour { - Sequencer sequencer; - - void Start() - { - sequencer = GetComponent(); - } - void OnGUI() { GUI.Label( new Rect(10, 10, 200, 100), - "Bar: " + sequencer.currentBar + ":" + sequencer.currentBeat - + " Time: " + (int)(sequencer.musicDebug.time * 1000) + " ms" + Environment.NewLine + "Bar: " + Sequencer.CurrentBar + ":" + Sequencer.CurrentBeat + + " Time: " + (int)(Sequencer.MusicDebug.time * 1000) + " ms" + Environment.NewLine + "-------------------------------------------" + Environment.NewLine - + "Part: " + sequencer.currentPart + Environment.NewLine - + "Region: " + sequencer.currentRegionId + Environment.NewLine - + sequencer.currentRegionDescription + + "Part: " + Sequencer.CurrentPart + Environment.NewLine + + "Region: " + Sequencer.CurrentRegionId + Environment.NewLine + + Sequencer.CurrentRegionDescription ); } } diff --git a/Assets/Scripts/PlayAnimation.cs b/Assets/Scripts/PlayAnimation.cs index 1214149..98a27db 100644 --- a/Assets/Scripts/PlayAnimation.cs +++ b/Assets/Scripts/PlayAnimation.cs @@ -27,7 +27,6 @@ public class PlayAnimation : MonoBehaviour [NonSerialized] public Transform sun; - Sequencer sequencer; int compareBar; int currentRegion = 0; @@ -37,17 +36,16 @@ public class PlayAnimation : MonoBehaviour void Start() { - sequencer = GetComponent(); - compareBar = sequencer.fastForwardToBar; + compareBar = 0; //sequencer.fastForwardToBar; } void Update() { - if (sequencer.currentRegionId == 2) + if (Sequencer.CurrentRegionId == 2) { - if (currentRegion != sequencer.currentRegionId) + if (currentRegion != Sequencer.CurrentRegionId) { sun = Instantiate(newSun, new Vector3(0, 0, 0), Quaternion.identity); sun.localScale = new Vector3(5, 5, 5); @@ -55,39 +53,39 @@ void Update() #if UNITY_EDITOR sun.name = "PyramidSun"; #endif - currentRegion = sequencer.currentRegionId; + currentRegion = Sequencer.CurrentRegionId; } - if (compareBar != sequencer.currentBar) + if (compareBar != Sequencer.CurrentBar) { SwitchAnimation(0, 10, 0); - compareBar = sequencer.currentBar; + compareBar = Sequencer.CurrentBar; } } - else if (sequencer.currentRegionId == 3 && compareBar != sequencer.currentBar) + else if (Sequencer.CurrentRegionId == 3 && compareBar != Sequencer.CurrentBar) { SwitchAnimation(2, 0, -70); - compareBar = sequencer.currentBar; + compareBar = Sequencer.CurrentBar; } - else if (sequencer.currentRegionId == 4 && compareBar != sequencer.currentBar) + else if (Sequencer.CurrentRegionId == 4 && compareBar != Sequencer.CurrentBar) { SwitchAnimation(2, 0, -70); - compareBar = sequencer.currentBar; + compareBar = Sequencer.CurrentBar; } - else if (sequencer.currentRegionId >= 5 && sequencer.currentRegionId <= 8 && compareBar != sequencer.currentBar) + else if (Sequencer.CurrentRegionId >= 5 && Sequencer.CurrentRegionId <= 8 && compareBar != Sequencer.CurrentBar) { SwitchAnimation(0, -300, 0); - compareBar = sequencer.currentBar; + compareBar = Sequencer.CurrentBar; } - else if (sequencer.currentRegionId >= 10 && sequencer.currentRegionId <= 24 && compareBar != sequencer.currentBar) + else if (Sequencer.CurrentRegionId >= 10 && Sequencer.CurrentRegionId <= 24 && compareBar != Sequencer.CurrentBar) { SwitchAnimation(1, -300, 0); - compareBar = sequencer.currentBar; + compareBar = Sequencer.CurrentBar; } - else if (sequencer.currentRegionId == 9 || sequencer.currentRegionId == 25) + else if (Sequencer.CurrentRegionId == 9 || Sequencer.CurrentRegionId == 25) { TurnOffAnimation(0); - compareBar = sequencer.currentBar; + compareBar = Sequencer.CurrentBar; sun.GetComponent().enabled = false; sun.GetComponent().enabled = false; sun.GetComponent().localScale = Vector3.Lerp(sun.GetComponent().localScale, new Vector3(0.1f, 0.1f, 0.1f), Time.deltaTime); diff --git a/Assets/Scripts/Sequencer.cs b/Assets/Scripts/Sequencer.cs index d2947c9..b81bb68 100644 --- a/Assets/Scripts/Sequencer.cs +++ b/Assets/Scripts/Sequencer.cs @@ -24,25 +24,19 @@ public class Sequencer : MonoBehaviour { AudioSource music; #if UNITY_EDITOR - [NonSerialized] - public AudioSource musicDebug; + public static AudioSource MusicDebug { get; private set; } #endif - [NonSerialized] - public int currentRegionId; + public static int CurrentRegionId { get; private set; } #if UNITY_EDITOR - [NonSerialized] - public CurrentPart currentPart; - [NonSerialized] - public string currentRegionDescription; + public static Part CurrentPart { get; private set; } + public static string CurrentRegionDescription { get; private set; } - public enum CurrentPart { Intro, Part1Probe, Part2Approach }; + public enum Part { Intro, Part1Probe, Part2Approach }; - [NonSerialized] - public int currentBeat; + public static int CurrentBeat { get; private set; } #endif - [NonSerialized] - public int currentBar; + public static int CurrentBar { get; private set; } int BPM; double beatDuration; @@ -71,11 +65,11 @@ void Start() music.time = 0; music.Play(); #if UNITY_EDITOR - musicDebug = music; + MusicDebug = music; #endif - currentBar = 1; - currentBeat = 1; + CurrentBar = 1; + CurrentBeat = 1; } @@ -112,7 +106,7 @@ void FastForward() { throw new NotImplementedException(); //Debug.Log(Time.timeScale + " " + doFastForward); - if (currentBar < fastForwardToBar && Time.timeScale != fastForwardSpeed) + if (CurrentBar < fastForwardToBar && Time.timeScale != fastForwardSpeed) { Time.timeScale = fastForwardSpeed; } @@ -129,202 +123,202 @@ void SetCurrentRegion() { if (music.time < 9.350) { - currentRegionId = 1; + CurrentRegionId = 1; #if UNITY_EDITOR - currentPart = CurrentPart.Intro; - currentRegionDescription = "wind intro"; + CurrentPart = Part.Intro; + CurrentRegionDescription = "wind intro"; #endif } else if (music.time < 15.584) { - currentRegionId = 2; + CurrentRegionId = 2; #if UNITY_EDITOR - currentPart = CurrentPart.Part1Probe; - currentRegionDescription = "explosion"; + CurrentPart = Part.Part1Probe; + CurrentRegionDescription = "explosion"; #endif } else if (music.time < 21.818) { - currentRegionId = 3; + CurrentRegionId = 3; #if UNITY_EDITOR - currentPart = CurrentPart.Part1Probe; - currentRegionDescription = "ping sound!"; + CurrentPart = Part.Part1Probe; + CurrentRegionDescription = "ping sound!"; #endif } else if (music.time < 46.753) { - currentRegionId = 4; + CurrentRegionId = 4; #if UNITY_EDITOR - currentPart = CurrentPart.Part1Probe; - currentRegionDescription = "musical base"; + CurrentPart = Part.Part1Probe; + CurrentRegionDescription = "musical base"; #endif } else if (music.time < 96.623) { - currentRegionId = 5; + CurrentRegionId = 5; #if UNITY_EDITOR - currentPart = CurrentPart.Part1Probe; - currentRegionDescription = "melody"; + CurrentPart = Part.Part1Probe; + CurrentRegionDescription = "melody"; #endif } else if (music.time < 121.558) { - currentRegionId = 6; + CurrentRegionId = 6; #if UNITY_EDITOR - currentPart = CurrentPart.Part1Probe; - currentRegionDescription = "bass"; + CurrentPart = Part.Part1Probe; + CurrentRegionDescription = "bass"; #endif } else if (music.time < 146.493) { - currentRegionId = 7; + CurrentRegionId = 7; #if UNITY_EDITOR - currentPart = CurrentPart.Part1Probe; - currentRegionDescription = "hihat and full bass"; + CurrentPart = Part.Part1Probe; + CurrentRegionDescription = "hihat and full bass"; #endif } else if (music.time < 171.428) { - currentRegionId = 8; + CurrentRegionId = 8; #if UNITY_EDITOR - currentPart = CurrentPart.Part1Probe; - currentRegionDescription = "bass syncopation"; + CurrentPart = Part.Part1Probe; + CurrentRegionDescription = "bass syncopation"; #endif } else if (music.time < 183.896) { - currentRegionId = 9; + CurrentRegionId = 9; #if UNITY_EDITOR - currentPart = CurrentPart.Part1Probe; - currentRegionDescription = "Part 1 to 2 bridge"; + CurrentPart = Part.Part1Probe; + CurrentRegionDescription = "Part 1 to 2 bridge"; #endif } else if (music.time < 233.766) { - currentRegionId = 10; + CurrentRegionId = 10; #if UNITY_EDITOR - currentPart = CurrentPart.Part2Approach; - currentRegionDescription = "A: musical base"; + CurrentPart = Part.Part2Approach; + CurrentRegionDescription = "A: musical base"; #endif } else if (music.time < 258.701) { - currentRegionId = 11; + CurrentRegionId = 11; #if UNITY_EDITOR - currentPart = CurrentPart.Part2Approach; - currentRegionDescription = "A: melody"; + CurrentPart = Part.Part2Approach; + CurrentRegionDescription = "A: melody"; #endif } else if (music.time < 283.636) { - currentRegionId = 12; + CurrentRegionId = 12; #if UNITY_EDITOR - currentPart = CurrentPart.Part2Approach; - currentRegionDescription = "AB bridge"; + CurrentPart = Part.Part2Approach; + CurrentRegionDescription = "AB bridge"; #endif } else if (music.time < 308.571) { - currentRegionId = 13; + CurrentRegionId = 13; #if UNITY_EDITOR - currentPart = CurrentPart.Part2Approach; - currentRegionDescription = "B: musical base"; + CurrentPart = Part.Part2Approach; + CurrentRegionDescription = "B: musical base"; #endif } else if (music.time < 333.506) { - currentRegionId = 14; + CurrentRegionId = 14; #if UNITY_EDITOR - currentPart = CurrentPart.Part2Approach; - currentRegionDescription = "B: melody"; + CurrentPart = Part.Part2Approach; + CurrentRegionDescription = "B: melody"; #endif } else if (music.time < 358.441) { - currentRegionId = 15; + CurrentRegionId = 15; #if UNITY_EDITOR - currentPart = CurrentPart.Part2Approach; - currentRegionDescription = "AB bridge"; + CurrentPart = Part.Part2Approach; + CurrentRegionDescription = "AB bridge"; #endif } else if (music.time < 383.376) { - currentRegionId = 16; + CurrentRegionId = 16; #if UNITY_EDITOR - currentPart = CurrentPart.Part2Approach; - currentRegionDescription = "B: melody"; + CurrentPart = Part.Part2Approach; + CurrentRegionDescription = "B: melody"; #endif } else if (music.time < 408.311) { - currentRegionId = 17; + CurrentRegionId = 17; #if UNITY_EDITOR - currentPart = CurrentPart.Part2Approach; - currentRegionDescription = "AB bridge"; + CurrentPart = Part.Part2Approach; + CurrentRegionDescription = "AB bridge"; #endif } else if (music.time < 433.246) { - currentRegionId = 18; + CurrentRegionId = 18; #if UNITY_EDITOR - currentPart = CurrentPart.Part2Approach; - currentRegionDescription = "A: melody"; + CurrentPart = Part.Part2Approach; + CurrentRegionDescription = "A: melody"; #endif } else if (music.time < 458.181) { - currentRegionId = 19; + CurrentRegionId = 19; #if UNITY_EDITOR - currentPart = CurrentPart.Part2Approach; - currentRegionDescription = "AB bridge"; + CurrentPart = Part.Part2Approach; + CurrentRegionDescription = "AB bridge"; #endif } else if (music.time < 483.116) { - currentRegionId = 20; + CurrentRegionId = 20; #if UNITY_EDITOR - currentPart = CurrentPart.Part2Approach; - currentRegionDescription = "Part 2 to 1 bridge"; + CurrentPart = Part.Part2Approach; + CurrentRegionDescription = "Part 2 to 1 bridge"; #endif } else if (music.time < 508.051) { - currentRegionId = 21; + CurrentRegionId = 21; #if UNITY_EDITOR - currentPart = CurrentPart.Part1Probe; - currentRegionDescription = "Part 1 rhythm + melody + hihat"; + CurrentPart = Part.Part1Probe; + CurrentRegionDescription = "Part 1 rhythm + melody + hihat"; #endif } else if (music.time < 532.986) { - currentRegionId = 22; + CurrentRegionId = 22; #if UNITY_EDITOR - currentPart = CurrentPart.Part1Probe; - currentRegionDescription = "Part 1 rhythm + melody"; + CurrentPart = Part.Part1Probe; + CurrentRegionDescription = "Part 1 rhythm + melody"; #endif } else if (music.time < 557.922) { - currentRegionId = 23; + CurrentRegionId = 23; #if UNITY_EDITOR - currentPart = CurrentPart.Part1Probe; - currentRegionDescription = "Part 1 melody + bass"; + CurrentPart = Part.Part1Probe; + CurrentRegionDescription = "Part 1 melody + bass"; #endif } else if (music.time < 582.857) { - currentRegionId = 24; + CurrentRegionId = 24; #if UNITY_EDITOR - currentPart = CurrentPart.Part1Probe; - currentRegionDescription = "Part 1 melody + bass + hihat"; + CurrentPart = Part.Part1Probe; + CurrentRegionDescription = "Part 1 melody + bass + hihat"; #endif } else { // if (music.time < 595.324) { - currentRegionId = 25; + CurrentRegionId = 25; #if UNITY_EDITOR - currentPart = CurrentPart.Part1Probe; - currentRegionDescription = "Part 1 to 2 bridge"; + CurrentPart = Part.Part1Probe; + CurrentRegionDescription = "Part 1 to 2 bridge"; #endif } } @@ -333,16 +327,16 @@ void SetCurrentRegion() #if UNITY_EDITOR void SetBeats() { - if (music.time > ((currentBar - 1) * 4 + currentBeat) * beatDuration) + if (music.time > ((CurrentBar - 1) * 4 + CurrentBeat) * beatDuration) { - if (currentBeat < 4) + if (CurrentBeat < 4) { - currentBeat++; + CurrentBeat++; } else { - currentBeat = 1; - currentBar++; + CurrentBeat = 1; + CurrentBar++; } } } @@ -355,10 +349,10 @@ void LoopMusicTo(int loopToBar) { music.time = (float)((loopToBar - 1d) * 4d * beatDuration); music.Play(); - currentBar = this.loopToBar; + CurrentBar = this.loopToBar; #if UNITY_EDITOR - currentBeat = 1; + CurrentBeat = 1; #endif } } From e80c4fe054617201ee0d70967425c274a8448f96 Mon Sep 17 00:00:00 2001 From: Guney Ozsan Date: Fri, 8 Sep 2017 22:52:10 +0300 Subject: [PATCH 12/17] Fix planetesimals instantiated at gravity origin give divide by zero error. --- Assets/Scripts/Gravity.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Assets/Scripts/Gravity.cs b/Assets/Scripts/Gravity.cs index abc4fdb..afb6d20 100644 --- a/Assets/Scripts/Gravity.cs +++ b/Assets/Scripts/Gravity.cs @@ -37,7 +37,10 @@ void Start() void Update () { - //body.AddForce(forceMultiplier * (transform.position - target) / Mathf.Pow(Vector3.Distance(transform.position, target), 2)); + if (Mathf.Pow(Vector3.Distance(transform.position, target), 2) != 0) + { + body.AddForce(forceMultiplier * (transform.position - target) / Mathf.Pow(Vector3.Distance(transform.position, target), 2)); + } } public void SetTarget(Vector3 target) From c766e3d72d44e128a3a9c478fae140d3763e8190 Mon Sep 17 00:00:00 2001 From: Guney Ozsan Date: Fri, 8 Sep 2017 23:11:42 +0300 Subject: [PATCH 13/17] Implemented ability to move each planetesimal to a designated point to be used for forming title texts. PlayAnimation class becomes AnimationManager as central control for animations. Titles class is no longer a Monobehavior and is only a collection of classes for Title, Letter and Word. --- Assets/Prefabs/CubicPlanetesimal.prefab | 12 + Assets/Prefabs/PyramidSun.prefab | 12 + Assets/Scenes/OutThere-MusicVideo.unity | 16 +- Assets/Scripts/AnimationManager.cs | 213 ++++++ ...ation.cs.meta => AnimationManager.cs.meta} | 0 Assets/Scripts/Mover.cs | 25 + Assets/Scripts/Mover.cs.meta | 12 + Assets/Scripts/Planetesimal.cs | 17 + Assets/Scripts/Planetesimal.cs.meta | 12 + Assets/Scripts/PlayAnimation.cs | 127 ---- Assets/Scripts/Space.cs | 4 +- Assets/Scripts/Titles.cs | 626 ++++++++---------- 12 files changed, 587 insertions(+), 489 deletions(-) create mode 100644 Assets/Scripts/AnimationManager.cs rename Assets/Scripts/{PlayAnimation.cs.meta => AnimationManager.cs.meta} (100%) create mode 100644 Assets/Scripts/Mover.cs create mode 100644 Assets/Scripts/Mover.cs.meta create mode 100644 Assets/Scripts/Planetesimal.cs create mode 100644 Assets/Scripts/Planetesimal.cs.meta delete mode 100644 Assets/Scripts/PlayAnimation.cs diff --git a/Assets/Prefabs/CubicPlanetesimal.prefab b/Assets/Prefabs/CubicPlanetesimal.prefab index 0df13d0..6cfe8ca 100644 --- a/Assets/Prefabs/CubicPlanetesimal.prefab +++ b/Assets/Prefabs/CubicPlanetesimal.prefab @@ -13,6 +13,7 @@ GameObject: - component: {fileID: 2300000} - component: {fileID: 5400000} - component: {fileID: 114109005215857388} + - component: {fileID: 114019300782292422} m_Layer: 0 m_Name: CubicPlanetesimal m_TagString: Untagged @@ -110,6 +111,17 @@ Prefab: m_ParentPrefab: {fileID: 0} m_RootGameObject: {fileID: 100000} m_IsPrefabParent: 1 +--- !u!114 &114019300782292422 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 100000} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 53f20caaf5d4fe049b27f263adb4bb42, type: 3} + m_Name: + m_EditorClassIdentifier: --- !u!114 &114109005215857388 MonoBehaviour: m_ObjectHideFlags: 1 diff --git a/Assets/Prefabs/PyramidSun.prefab b/Assets/Prefabs/PyramidSun.prefab index 3b269b3..dc137f7 100644 --- a/Assets/Prefabs/PyramidSun.prefab +++ b/Assets/Prefabs/PyramidSun.prefab @@ -12,6 +12,7 @@ GameObject: - component: {fileID: 2300000} - component: {fileID: 6400000} - component: {fileID: 5400000} + - component: {fileID: 114617478562814894} m_Layer: 0 m_Name: PyramidSun m_TagString: Untagged @@ -111,3 +112,14 @@ Prefab: m_ParentPrefab: {fileID: 0} m_RootGameObject: {fileID: 100000} m_IsPrefabParent: 1 +--- !u!114 &114617478562814894 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 100000} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: bdb06355703ea0546967ff77317879bf, type: 3} + m_Name: + m_EditorClassIdentifier: diff --git a/Assets/Scenes/OutThere-MusicVideo.unity b/Assets/Scenes/OutThere-MusicVideo.unity index dc72260..f71e4c7 100644 --- a/Assets/Scenes/OutThere-MusicVideo.unity +++ b/Assets/Scenes/OutThere-MusicVideo.unity @@ -439,9 +439,8 @@ GameObject: - component: {fileID: 1368347923} - component: {fileID: 1368347922} - component: {fileID: 1368347921} - - component: {fileID: 1368347920} m_Layer: 0 - m_Name: Master + m_Name: Scripts m_TagString: Untagged m_Icon: {fileID: 0} m_NavMeshLayer: 0 @@ -467,18 +466,6 @@ AudioListener: m_PrefabInternal: {fileID: 0} m_GameObject: {fileID: 1368347917} m_Enabled: 1 ---- !u!114 &1368347920 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 1368347917} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 7b0e0b75168ae9743a481fd6acab5c4f, type: 3} - m_Name: - m_EditorClassIdentifier: - planetesimalPrefab: {fileID: 400000, guid: 65d917f28a73d004d89f2d3d12a05876, type: 2} --- !u!114 &1368347921 MonoBehaviour: m_ObjectHideFlags: 0 @@ -490,6 +477,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: a9a79ccf60fd05d4aa55ba645f13ff49, type: 3} m_Name: m_EditorClassIdentifier: + planetesimalPrefab: {fileID: 400000, guid: 65d917f28a73d004d89f2d3d12a05876, type: 2} newSun: {fileID: 400000, guid: 8b1f3da1ad7f8c5418f95bafdc7078e5, type: 2} --- !u!114 &1368347922 MonoBehaviour: diff --git a/Assets/Scripts/AnimationManager.cs b/Assets/Scripts/AnimationManager.cs new file mode 100644 index 0000000..8c8e44e --- /dev/null +++ b/Assets/Scripts/AnimationManager.cs @@ -0,0 +1,213 @@ +// Guney Ozsan - Out There (Music Video) - Real time music video in demoscene style for Unity 3D. +// Copyright (C) 2017 Guney Ozsan + +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// --------------------------------------------------------------------- + +using System; +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class AnimationManager : MonoBehaviour +{ + [SerializeField] + Transform planetesimalPrefab; + + public static Title openingTitles; + + public Transform newSun; + + [NonSerialized] + public Transform sun; + + int currentBar = 0; + int currentRegion = 0; + + Gravity gravity; + + + + void Start() + { + openingTitles = new Title(new Word[] { + new Word(new Vector3(-62f, 15f, 4.6f), 5, 5, 2, 2, 2, 0.96f, "GUNEY"), + new Word(new Vector3(10f, 15f, 4.6f), 5, 5, 2, 2, 2, 0.96f, "OZSAN"), + new Word(new Vector3(-50f, 0f, 4.6f), 5, 5, 2, 2, 2, 0.96f, "OUT"), + new Word(new Vector3(-2f, 0f, 4.6f), 5, 5, 2, 2, 2, 0.96f, "THERE") + }); + + Transform gravityTarget = GetComponent().sun; + Transform planetesimalParent = new GameObject("Planetesimals").transform; + + int cubeSideLength = MathUtility.ClosestCubeRoot(openingTitles.ParticleCount, true); + float particlePadding = 1f; + float alignmentAdjustment = cubeSideLength / 2; + + for (int i = 0; i < cubeSideLength; i++) + { + float x = i * particlePadding - alignmentAdjustment; + + for (int j = 0; j < cubeSideLength; j++) + { + float y = j * particlePadding - alignmentAdjustment; + + for (int k = 0; k < cubeSideLength; k++) + { + float z = k * particlePadding - alignmentAdjustment; + + Space.planetesimals.Add(new Planetesimal(Instantiate(planetesimalPrefab, new Vector3(x, y, z), Quaternion.identity, planetesimalParent))); + } + } + } + + //for (int i = 0; i < openingTitles.Length; i++) + //{ + // int particlesPerSlot = openingTitles[i].HorizontalParticlesPerSlot * openingTitles[i].VerticalParticlesPerSlot; + // for (int j = 0; j < openingTitles[i].Length; j++) + // { + // openingTitleParticleCount += particlesPerSlot * openingTitles[i][j].OccupiedSlotsCount; + // } + + + // float rowLength = openingTitles[i].Code.Length / openingTitles[i].VerticalParticleSlotsPerLetter; + // float slotPadding = openingTitles[i].SlotPadding; + // int horizontalParticleSlotsPerLetter = openingTitles[i].HorizontalParticleSlotsPerLetter; + + // for (int j = 0; j < openingTitles[i].Code.Length; j++) + // { + // if (openingTitles[i].Code[j].ToString() != " ") + // { + // float currentRow = Mathf.FloorToInt(j / rowLength); + // float y = -1 * slotPadding * currentRow; + + // // Puts space between letters + // float letterPadding = slotPadding * (j / horizontalParticleSlotsPerLetter); + + // // Because the word is coded as a single string, this offsets each line of particle slots back to paragraph indent. + // float offsetLineToParagraphIndent = -1 * currentRow * slotPadding * (rowLength + rowLength / horizontalParticleSlotsPerLetter); + + // float x = slotPadding * j + letterPadding + offsetLineToParagraphIndent; + + // for (int k = 0; k < openingTitles[i].HorizontalParticlesPerSlot; k++) + // { + // for (int l = 0; l < openingTitles[i].VerticalParticlesPerSlot; l++) + // { + // planetesimal = Instantiate(planetesimalPrefab, openingTitles[i].Location + new Vector3(x + k * openingTitles[i].ParticlePadding, y - l * openingTitles[i].ParticlePadding, 0), Quaternion.identity, planetesimalParent); + // planetesimal.GetComponent().SetTarget(gravityTarget); + // planetesimal.tag = "Planet"; + // } + // } + // } + // } + //} + + } + + + + void Update() + { + if (Sequencer.CurrentRegionId == 1) + { + if (currentRegion != Sequencer.CurrentRegionId) + { + currentRegion = Sequencer.CurrentRegionId; + + sun = Instantiate(newSun, new Vector3(0, 0, 0), Quaternion.identity); + sun.localScale = new Vector3(5, 5, 5); + sun.tag = "Sun"; +#if UNITY_EDITOR + sun.name = "PyramidSun"; +#endif + } + + if (currentBar != Sequencer.CurrentBar) + { + currentBar = Sequencer.CurrentBar; + } + } + else if (Sequencer.CurrentRegionId == 2) + { + if (currentRegion != Sequencer.CurrentRegionId) + { + currentRegion = Sequencer.CurrentRegionId; + Title.FormTitle(openingTitles, 9.35f); + } + + if (currentBar != Sequencer.CurrentBar) + { + currentBar = Sequencer.CurrentBar; + } + } + //else if (Sequencer.CurrentRegionId == 4 && currentBar != Sequencer.CurrentBar) + //{ + // currentRegion = Sequencer.CurrentRegionId; + // SwitchAnimation(2, 0, -70); + // currentBar = Sequencer.CurrentBar; + //} + //else if (Sequencer.CurrentRegionId >= 5 && Sequencer.CurrentRegionId <= 8 && currentBar != Sequencer.CurrentBar) + //{ + // currentRegion = Sequencer.CurrentRegionId; + // SwitchAnimation(0, -300, 0); + // currentBar = Sequencer.CurrentBar; + //} + //else if (Sequencer.CurrentRegionId >= 10 && Sequencer.CurrentRegionId <= 24 && currentBar != Sequencer.CurrentBar) + //{ + // currentRegion = Sequencer.CurrentRegionId; + // SwitchAnimation(1, -300, 0); + // currentBar = Sequencer.CurrentBar; + //} + //else if (Sequencer.CurrentRegionId == 9 || Sequencer.CurrentRegionId == 25) + //{ + // currentRegion = Sequencer.CurrentRegionId; + // TurnOffAnimation(0); + // currentBar = Sequencer.CurrentBar; + // sun.GetComponent().enabled = false; + // sun.GetComponent().enabled = false; + // sun.GetComponent().localScale = Vector3.Lerp(sun.GetComponent().localScale, new Vector3(0.1f, 0.1f, 0.1f), Time.deltaTime); + //} + } + + + + void SwitchAnimation(int switcher, int gravityForce, int antiGravityForce) + { + if (currentBar % 2 == switcher) + { + foreach (Planetesimal planetesimal in Space.planetesimals) + { + planetesimal.Gravity.forceMultiplier = gravityForce; + } + } + else + { + foreach (Planetesimal planetesimal in Space.planetesimals) + { + planetesimal.Gravity.forceMultiplier = antiGravityForce; + } + } + } + + + + void TurnOffAnimation(int antiGravityForce) + { + foreach (GameObject planet in GameObject.FindGameObjectsWithTag("Planet")) + { + gravity = planet.GetComponent(); + gravity.forceMultiplier = antiGravityForce; + } + } +} diff --git a/Assets/Scripts/PlayAnimation.cs.meta b/Assets/Scripts/AnimationManager.cs.meta similarity index 100% rename from Assets/Scripts/PlayAnimation.cs.meta rename to Assets/Scripts/AnimationManager.cs.meta diff --git a/Assets/Scripts/Mover.cs b/Assets/Scripts/Mover.cs new file mode 100644 index 0000000..84fd837 --- /dev/null +++ b/Assets/Scripts/Mover.cs @@ -0,0 +1,25 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class Mover : MonoBehaviour { + + public void MoveTo(Vector3 target, float time) + { + StartCoroutine(MoveThisTo(target, time)); + } + + IEnumerator MoveThisTo(Vector3 target, float time) + { + Vector3 start = transform.position; + + float t = 0; + + while (transform.position != target) + { + transform.position = Vector3.Lerp(start, target, Mathf.SmoothStep(0, 1, t)); + t += Time.deltaTime / time; + yield return null; + } + } +} diff --git a/Assets/Scripts/Mover.cs.meta b/Assets/Scripts/Mover.cs.meta new file mode 100644 index 0000000..c075d45 --- /dev/null +++ b/Assets/Scripts/Mover.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 53f20caaf5d4fe049b27f263adb4bb42 +timeCreated: 1504898707 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Planetesimal.cs b/Assets/Scripts/Planetesimal.cs new file mode 100644 index 0000000..f99ca8c --- /dev/null +++ b/Assets/Scripts/Planetesimal.cs @@ -0,0 +1,17 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class Planetesimal { + + public Transform Transform { get; private set; } + public Gravity Gravity { get; private set; } + public Mover Mover { get; private set; } + + public Planetesimal(Transform planetesimal) + { + Transform = planetesimal.transform; + Gravity = planetesimal.GetComponent(); + Mover = planetesimal.GetComponent(); + } +} diff --git a/Assets/Scripts/Planetesimal.cs.meta b/Assets/Scripts/Planetesimal.cs.meta new file mode 100644 index 0000000..639ecb4 --- /dev/null +++ b/Assets/Scripts/Planetesimal.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 0df802a0e497a734dbaf65f1776df9f9 +timeCreated: 1504898802 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/PlayAnimation.cs b/Assets/Scripts/PlayAnimation.cs deleted file mode 100644 index 98a27db..0000000 --- a/Assets/Scripts/PlayAnimation.cs +++ /dev/null @@ -1,127 +0,0 @@ -// Guney Ozsan - Out There (Music Video) - Real time music video in demoscene style for Unity 3D. -// Copyright (C) 2017 Guney Ozsan - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . -// --------------------------------------------------------------------- - -using System; -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -public class PlayAnimation : MonoBehaviour -{ - public Transform newSun; - - [NonSerialized] - public Transform sun; - - int compareBar; - int currentRegion = 0; - - Gravity gravity; - - - - void Start() - { - compareBar = 0; //sequencer.fastForwardToBar; - } - - - - void Update() - { - if (Sequencer.CurrentRegionId == 2) - { - if (currentRegion != Sequencer.CurrentRegionId) - { - sun = Instantiate(newSun, new Vector3(0, 0, 0), Quaternion.identity); - sun.localScale = new Vector3(5, 5, 5); - sun.tag = "Sun"; -#if UNITY_EDITOR - sun.name = "PyramidSun"; -#endif - currentRegion = Sequencer.CurrentRegionId; - } - - if (compareBar != Sequencer.CurrentBar) - { - SwitchAnimation(0, 10, 0); - compareBar = Sequencer.CurrentBar; - } - } - else if (Sequencer.CurrentRegionId == 3 && compareBar != Sequencer.CurrentBar) - { - SwitchAnimation(2, 0, -70); - compareBar = Sequencer.CurrentBar; - } - else if (Sequencer.CurrentRegionId == 4 && compareBar != Sequencer.CurrentBar) - { - SwitchAnimation(2, 0, -70); - compareBar = Sequencer.CurrentBar; - } - else if (Sequencer.CurrentRegionId >= 5 && Sequencer.CurrentRegionId <= 8 && compareBar != Sequencer.CurrentBar) - { - SwitchAnimation(0, -300, 0); - compareBar = Sequencer.CurrentBar; - } - else if (Sequencer.CurrentRegionId >= 10 && Sequencer.CurrentRegionId <= 24 && compareBar != Sequencer.CurrentBar) - { - SwitchAnimation(1, -300, 0); - compareBar = Sequencer.CurrentBar; - } - else if (Sequencer.CurrentRegionId == 9 || Sequencer.CurrentRegionId == 25) - { - TurnOffAnimation(0); - compareBar = Sequencer.CurrentBar; - sun.GetComponent().enabled = false; - sun.GetComponent().enabled = false; - sun.GetComponent().localScale = Vector3.Lerp(sun.GetComponent().localScale, new Vector3(0.1f, 0.1f, 0.1f), Time.deltaTime); - } - } - - - - void SwitchAnimation(int switcher, int gravityForce, int antiGravityForce) - { - if (compareBar % 2 == switcher) - { - foreach (GameObject planet in GameObject.FindGameObjectsWithTag("Planet")) - { - gravity = planet.GetComponent(); - gravity.forceMultiplier = gravityForce; - } - } - else - { - foreach (GameObject planet in GameObject.FindGameObjectsWithTag("Planet")) - { - gravity = planet.GetComponent(); - gravity.forceMultiplier = antiGravityForce; - } - } - } - - - - void TurnOffAnimation(int antiGravityForce) - { - foreach (GameObject planet in GameObject.FindGameObjectsWithTag("Planet")) - { - gravity = planet.GetComponent(); - gravity.forceMultiplier = antiGravityForce; - } - } -} diff --git a/Assets/Scripts/Space.cs b/Assets/Scripts/Space.cs index baea9eb..6554cf9 100644 --- a/Assets/Scripts/Space.cs +++ b/Assets/Scripts/Space.cs @@ -4,5 +4,5 @@ public static class Space { - public static List planetesimals = new List(); -} + public static List planetesimals = new List(); +} \ No newline at end of file diff --git a/Assets/Scripts/Titles.cs b/Assets/Scripts/Titles.cs index c191b73..59605c4 100644 --- a/Assets/Scripts/Titles.cs +++ b/Assets/Scripts/Titles.cs @@ -20,415 +20,349 @@ using System.Collections.Generic; using UnityEngine; -public class Titles : MonoBehaviour -{ - [SerializeField] - Transform planetesimalPrefab; - Transform planetesimal; +public class Title +{ + Word[] words; - class Title + public Title(Word[] words) { - private Word[] words; + this.words = new Word[words.Length]; - public Title(int wordCount) + for (int i = 0; i < words.Length; i++) { - words = new Word[wordCount]; + this.words[i] = words[i]; } + } - public Word this[int index] + public Word this[int index] + { + get { - get - { - return words[index]; - } - set - { - words[index] = value; - } + return words[index]; } - - public int Length + set { - get - { - return words.Length; - } + words[index] = value; } + } - public int ParticleCount + public int Length + { + get { - get - { - int particleCount = 0; - - for (int i = 0; i < words.Length; i++) - { - int particlesPerSlot = words[i].HorizontalParticlesPerSlot * words[i].VerticalParticlesPerSlot; - - for (int j = 0; j < words[i].Length; j++) - { - particleCount += particlesPerSlot * words[i][j].OccupiedSlotsCount; - } - - } - - return particleCount; - } + return words.Length; } } - - - class Word + public int ParticleCount { - public Vector3 Location { get; private set; } // position of the word in 3d space - public int VerticalParticleSlotsPerLetter { get; private set; } // letter height and width in particle slots - public int HorizontalParticleSlotsPerLetter { get; private set; } - public int HorizontalParticlesPerSlot { get; private set; } - public int VerticalParticlesPerSlot { get; private set; } - public float SlotPadding { get; private set; } // space between each particle slot - public float ParticlePadding { get; private set; } // space between each particle in a single slot - public string Code { get; private set; } // the letters written in empty and non-empty characters. - // code should fit the parameters for particle slots per letter. - Letter[] letters; - - public Word(Vector3 location, - int verticalParticleSlotsPerLetter, int horizontalParticleSlotsPerLetter, - int horizontalParticlesPerSlot, int verticalParticlesPerSlot, - int slotPadding, float particlePadding, - string code) + get { - Location = location; - VerticalParticleSlotsPerLetter = verticalParticleSlotsPerLetter; - HorizontalParticleSlotsPerLetter = horizontalParticleSlotsPerLetter; - HorizontalParticlesPerSlot = horizontalParticlesPerSlot; - VerticalParticlesPerSlot = verticalParticlesPerSlot; - SlotPadding = slotPadding; - ParticlePadding = particlePadding; - Code = code; - - letters = new Letter[Code.Length]; - - for (int i = 0; i < letters.Length; i++) - { - letters[i] = new Letter(Code[i]); - } - } + int particleCount = 0; - public Letter this[int index] - { - get - { - return letters[index]; - } - set + for (int i = 0; i < words.Length; i++) { - letters[index] = value; - } - } + int particlesPerSlot = words[i].HorizontalParticlesPerSlot * words[i].VerticalParticlesPerSlot; + + for (int j = 0; j < words[i].Length; j++) + { + particleCount += particlesPerSlot * words[i][j].OccupiedSlotsCount; + } - public int Length - { - get - { - return letters.Length; } + + return particleCount; } } + Vector3 velocity = Vector3.zero; - - class Letter + public static void FormTitle(Title title, float time) { - public bool[,] Slots { get; private set; } - - int occupiedSlotsCount; + int planetesimalIndex = 0; - public Letter (char letter) + for (int i = 0; i < title.Length; i++) { - Slots = new bool[letters[letter][0].Length, letters[letter].Length]; - - occupiedSlotsCount = 0; - - for (int i = 0; i < letters[letter].Length; i++) + for (int j = 0; j < title[i].Length; j++) { - for (int j = 0; j < letters[letter][i].Length; j++) + for (int k = 0; k < title[i][j].Slots.GetLength(0); k++) { - if (Char.IsWhiteSpace(letters[letter][i][j])) + for (int l = 0; l < title[i][j].Slots.GetLength(1); l++) { - Slots[i, j] = false; - } - else - { - Slots[i, j] = true; - occupiedSlotsCount++; + if (title[i][j].Slots[k, l]) + { + Vector3 target = 5 * Vector3.one * (i + j + k + l); + Space.planetesimals[planetesimalIndex].Mover.MoveTo(target, time); + planetesimalIndex++; + } } } } } + } +} - public int OccupiedSlotsCount +public class Word +{ + public Vector3 Location { get; private set; } // position of the word in 3d space + public int VerticalParticleSlotsPerLetter { get; private set; } // letter height and width in particle slots + public int HorizontalParticleSlotsPerLetter { get; private set; } + public int HorizontalParticlesPerSlot { get; private set; } + public int VerticalParticlesPerSlot { get; private set; } + public float SlotPadding { get; private set; } // space between each particle slot + public float ParticlePadding { get; private set; } // space between each particle in a single slot + public string Code { get; private set; } // the letters written in empty and non-empty characters. + // code should fit the parameters for particle slots per letter. + Letter[] letters; + + public Word(Vector3 location, + int verticalParticleSlotsPerLetter, int horizontalParticleSlotsPerLetter, + int horizontalParticlesPerSlot, int verticalParticlesPerSlot, + int slotPadding, float particlePadding, + string code) + { + Location = location; + VerticalParticleSlotsPerLetter = verticalParticleSlotsPerLetter; + HorizontalParticleSlotsPerLetter = horizontalParticleSlotsPerLetter; + HorizontalParticlesPerSlot = horizontalParticlesPerSlot; + VerticalParticlesPerSlot = verticalParticlesPerSlot; + SlotPadding = slotPadding; + ParticlePadding = particlePadding; + Code = code; + + letters = new Letter[Code.Length]; + + for (int i = 0; i < letters.Length; i++) { - get - { - return occupiedSlotsCount; - } + letters[i] = new Letter(Code[i]); } + } - - - Dictionary letters = new Dictionary + public Letter this[int index] + { + get + { + return letters[index]; + } + set { - { 'A', new string[] { - " 0 ", - " 0 0 ", - " 000 ", - "0 0", - "0 0"} }, - { 'B', new string[] { - "0000 ", - "0 0", - "0000 ", - "0 0", - "0000 "} }, - { 'C', new string[] { - " 0000", - "0 ", - "0 ", - "0 ", - " 0000"} }, - { 'D', new string[] { - "0000 ", - "0 0", - "0 0", - "0 0", - "0000 "} }, - { 'E', new string[] { - "00000", - "0 ", - "0000 ", - "0 ", - "00000"} }, - { 'F', new string[] { - "00000", - "0 ", - "0000 ", - "0 ", - "0 "} }, - { 'G', new string[] { - "00000", - "0 ", - "0 00", - "0 0", - "00000"} }, - { 'H', new string[] { - "0 0", - "0 0", - "00000", - "0 0", - "0 0"} }, - { 'I', new string[] { - "00000", - " 0 ", - " 0 ", - " 0 ", - "00000"} }, - { 'J', new string[] { - "00000", - " 0 ", - " 0 ", - " 0 ", - "00 "} }, - { 'K', new string[] { - "0 0", - "0 0 ", - "000 ", - "0 0 ", - "0 0"} }, - { 'L', new string[] { - "0 ", - "0 ", - "0 ", - "0 ", - "00000"} }, - { 'M', new string[] { - "0 0", - "00 00", - "0 0 0", - "0 0", - "0 0"} }, - { 'N', new string[] { - "0 0", - "00 0", - "0 0 0", - "0 00", - "0 0"} }, - { 'O', new string[] { - " 000 ", - "0 0", - "0 0", - "0 0", - " 000 "} }, - { 'P', new string[] { - "0000 ", - "0 0", - "0000 ", - "0 ", - "0 "} }, - { 'Q', new string[] { - " 000 ", - "0 0", - "0 0 0", - "0 00", - " 0000"} }, - { 'R', new string[] { - "0000 ", - "0 0", - "0000 ", - "0 0 ", - "0 0"} }, - { 'S', new string[] { - " 0000", - "0 ", - " 000 ", - " 0", - "0000 "} }, - { 'T', new string[] { - "00000", - " 0 ", - " 0 ", - " 0 ", - " 0 "} }, - { 'U', new string[] { - "0 0", - "0 0", - "0 0", - "0 0", - " 000 "} }, - { 'V', new string[] { - "0 0", - "0 0", - " 0 0 ", - " 0 0 ", - " 0 "} }, - { 'W', new string[] { - "0 0", - "0 0", - "0 0 0", - "00 00", - "0 0"} }, - { 'X', new string[] { - "0 0", - " 0 0 ", - " 0 ", - " 0 0 ", - "0 0"} }, - { 'Y', new string[] { - "0 0", - " 0 0 ", - " 0 ", - " 0 ", - " 0 "} }, - { 'Z', new string[] { - "00000", - " 0 ", - " 0 ", - " 0 ", - "00000"} } - }; + letters[index] = value; + } } + public int Length + { + get + { + return letters.Length; + } + } +} - void Start () { - Title openingTitles = SetOpeningTitles(); - - Transform gravityTarget = GetComponent().sun; - - Transform planetesimalParent = new GameObject("Planetesimals").transform; - - //for (int i = 0; i < openingTitles.Length; i++) - //{ - // int particlesPerSlot = openingTitles[i].HorizontalParticlesPerSlot * openingTitles[i].VerticalParticlesPerSlot; - // for (int j = 0; j < openingTitles[i].Length; j++) - // { - // openingTitleParticleCount += particlesPerSlot * openingTitles[i][j].OccupiedSlotsCount; - // } - - - // float rowLength = openingTitles[i].Code.Length / openingTitles[i].VerticalParticleSlotsPerLetter; - // float slotPadding = openingTitles[i].SlotPadding; - // int horizontalParticleSlotsPerLetter = openingTitles[i].HorizontalParticleSlotsPerLetter; - - // for (int j = 0; j < openingTitles[i].Code.Length; j++) - // { - // if (openingTitles[i].Code[j].ToString() != " ") - // { - // float currentRow = Mathf.FloorToInt(j / rowLength); - // float y = -1 * slotPadding * currentRow; - - // // Puts space between letters - // float letterPadding = slotPadding * (j / horizontalParticleSlotsPerLetter); - - // // Because the word is coded as a single string, this offsets each line of particle slots back to paragraph indent. - // float offsetLineToParagraphIndent = -1 * currentRow * slotPadding * (rowLength + rowLength / horizontalParticleSlotsPerLetter); - // float x = slotPadding * j + letterPadding + offsetLineToParagraphIndent; +public class Letter +{ + public bool[,] Slots { get; private set; } - // for (int k = 0; k < openingTitles[i].HorizontalParticlesPerSlot; k++) - // { - // for (int l = 0; l < openingTitles[i].VerticalParticlesPerSlot; l++) - // { - // planetesimal = Instantiate(planetesimalPrefab, openingTitles[i].Location + new Vector3(x + k * openingTitles[i].ParticlePadding, y - l * openingTitles[i].ParticlePadding, 0), Quaternion.identity, planetesimalParent); - // planetesimal.GetComponent().SetTarget(gravityTarget); - // planetesimal.tag = "Planet"; - // } - // } - // } - // } - //} + int occupiedSlotsCount; - int cubeSideLength = MathUtility.ClosestCubeRoot(openingTitles.ParticleCount, true); + public Letter(char letter) + { + Slots = new bool[alphabet[letter][0].Length, alphabet[letter].Length]; - float particlePadding = 1f; - float alignmentAdjustment = cubeSideLength / 2; + occupiedSlotsCount = 0; - for (int i = 0; i < cubeSideLength; i++) + for (int i = 0; i < alphabet[letter].Length; i++) { - float x = i * particlePadding - alignmentAdjustment; - - for (int j = 0; j < cubeSideLength; j++) + for (int j = 0; j < alphabet[letter][i].Length; j++) { - float y = j * particlePadding - alignmentAdjustment; - - for (int k = 0; k < cubeSideLength; k++) + if (Char.IsWhiteSpace(alphabet[letter][i][j])) { - float z = k * particlePadding - alignmentAdjustment; - - planetesimal = Instantiate(planetesimalPrefab, new Vector3(x, y, z), Quaternion.identity, planetesimalParent); - planetesimal.GetComponent().SetTarget(Vector3.zero); - Space.planetesimals.Add(planetesimal); + Slots[i, j] = false; + } + else + { + Slots[i, j] = true; + occupiedSlotsCount++; } } } } - - Title SetOpeningTitles() + + public int OccupiedSlotsCount { - Title openingTitles = new Title(4); + get + { + return occupiedSlotsCount; + } + } - openingTitles[0] = new Word(new Vector3(-62f, 15f, 4.6f), 5, 5, 2, 2, 2, 0.96f, "GUNEY"); - openingTitles[1] = new Word(new Vector3(10f, 15f, 4.6f), 5, 5, 2, 2, 2, 0.96f, "OZSAN"); - openingTitles[2] = new Word(new Vector3(-50f, 0f, 4.6f), 5, 5, 2, 2, 2, 0.96f, "OUT"); - openingTitles[3] = new Word(new Vector3(-2f, 0f, 4.6f), 5, 5, 2, 2, 2, 0.96f, "THERE"); - return openingTitles; - } - + + Dictionary alphabet = new Dictionary + { + { 'A', new string[] { + " 0 ", + " 0 0 ", + " 000 ", + "0 0", + "0 0"} }, + { 'B', new string[] { + "0000 ", + "0 0", + "0000 ", + "0 0", + "0000 "} }, + { 'C', new string[] { + " 0000", + "0 ", + "0 ", + "0 ", + " 0000"} }, + { 'D', new string[] { + "0000 ", + "0 0", + "0 0", + "0 0", + "0000 "} }, + { 'E', new string[] { + "00000", + "0 ", + "0000 ", + "0 ", + "00000"} }, + { 'F', new string[] { + "00000", + "0 ", + "0000 ", + "0 ", + "0 "} }, + { 'G', new string[] { + "00000", + "0 ", + "0 00", + "0 0", + "00000"} }, + { 'H', new string[] { + "0 0", + "0 0", + "00000", + "0 0", + "0 0"} }, + { 'I', new string[] { + "00000", + " 0 ", + " 0 ", + " 0 ", + "00000"} }, + { 'J', new string[] { + "00000", + " 0 ", + " 0 ", + " 0 ", + "00 "} }, + { 'K', new string[] { + "0 0", + "0 0 ", + "000 ", + "0 0 ", + "0 0"} }, + { 'L', new string[] { + "0 ", + "0 ", + "0 ", + "0 ", + "00000"} }, + { 'M', new string[] { + "0 0", + "00 00", + "0 0 0", + "0 0", + "0 0"} }, + { 'N', new string[] { + "0 0", + "00 0", + "0 0 0", + "0 00", + "0 0"} }, + { 'O', new string[] { + " 000 ", + "0 0", + "0 0", + "0 0", + " 000 "} }, + { 'P', new string[] { + "0000 ", + "0 0", + "0000 ", + "0 ", + "0 "} }, + { 'Q', new string[] { + " 000 ", + "0 0", + "0 0 0", + "0 00", + " 0000"} }, + { 'R', new string[] { + "0000 ", + "0 0", + "0000 ", + "0 0 ", + "0 0"} }, + { 'S', new string[] { + " 0000", + "0 ", + " 000 ", + " 0", + "0000 "} }, + { 'T', new string[] { + "00000", + " 0 ", + " 0 ", + " 0 ", + " 0 "} }, + { 'U', new string[] { + "0 0", + "0 0", + "0 0", + "0 0", + " 000 "} }, + { 'V', new string[] { + "0 0", + "0 0", + " 0 0 ", + " 0 0 ", + " 0 "} }, + { 'W', new string[] { + "0 0", + "0 0", + "0 0 0", + "00 00", + "0 0"} }, + { 'X', new string[] { + "0 0", + " 0 0 ", + " 0 ", + " 0 0 ", + "0 0"} }, + { 'Y', new string[] { + "0 0", + " 0 0 ", + " 0 ", + " 0 ", + " 0 "} }, + { 'Z', new string[] { + "00000", + " 0 ", + " 0 ", + " 0 ", + "00000"} } + }; } From b96b192ac9a0c175e1f14091d4aeaa02e0b8eb0e Mon Sep 17 00:00:00 2001 From: Guney Ozsan Date: Sat, 9 Sep 2017 04:51:05 +0300 Subject: [PATCH 14/17] Forming title texts by animating planetesimals as pixels is functional. Opening titles and Part I titles are implemented. --- Assets/Scripts/AnimationManager.cs | 113 ++++++++++++++++++++--------- Assets/Scripts/Mover.cs | 4 +- Assets/Scripts/Planetesimal.cs | 2 + Assets/Scripts/Titles.cs | 59 +++++++++++++-- 4 files changed, 137 insertions(+), 41 deletions(-) diff --git a/Assets/Scripts/AnimationManager.cs b/Assets/Scripts/AnimationManager.cs index 8c8e44e..a083f8c 100644 --- a/Assets/Scripts/AnimationManager.cs +++ b/Assets/Scripts/AnimationManager.cs @@ -26,6 +26,9 @@ public class AnimationManager : MonoBehaviour Transform planetesimalPrefab; public static Title openingTitles; + public static Title openingTitlesWide; + public static Title partOneTitles; + public static Title partOneTitlesWide; public Transform newSun; @@ -42,10 +45,27 @@ public class AnimationManager : MonoBehaviour void Start() { openingTitles = new Title(new Word[] { - new Word(new Vector3(-62f, 15f, 4.6f), 5, 5, 2, 2, 2, 0.96f, "GUNEY"), - new Word(new Vector3(10f, 15f, 4.6f), 5, 5, 2, 2, 2, 0.96f, "OZSAN"), - new Word(new Vector3(-50f, 0f, 4.6f), 5, 5, 2, 2, 2, 0.96f, "OUT"), - new Word(new Vector3(-2f, 0f, 4.6f), 5, 5, 2, 2, 2, 0.96f, "THERE") + new Word(new Vector3(-62f, 15f, -8.4f), 5, 5, 2, 2, 2, 1.1f, "GUNEY"), + new Word(new Vector3(10f, 15f, -8.4f), 5, 5, 2, 2, 2, 1.1f, "OZSAN"), + new Word(new Vector3(-50f, 0f, -8.4f), 5, 5, 2, 2, 2, 1.1f, "OUT"), + new Word(new Vector3(-2f, 0f, -8.4f), 5, 5, 2, 2, 2, 1.1f, "THERE") + }); + + openingTitlesWide = new Title(new Word[] { + new Word(new Vector3(-66f, 15f, -8.4f), 5, 5, 2, 2, 2, 1.5f, "GUNEY"), + new Word(new Vector3(6f, 15f, -8.4f), 5, 5, 2, 2, 2, 1.5f, "OZSAN"), + new Word(new Vector3(-54f, 0f, -8.4f), 5, 5, 2, 2, 2, 1.5f, "OUT"), + new Word(new Vector3(-6f, 0f, -8.4f), 5, 5, 2, 2, 2, 1.5f, "THERE") + }); + + partOneTitles = new Title(new Word[] { + new Word(new Vector3(-35f, 15f, -8.4f), 5, 5, 2, 2, 2, 1.1f, "PART I"), + new Word(new Vector3(-30f, 0f, -8.4f), 5, 5, 2, 2, 2, 1.1f, "PROBE"), + }); + + partOneTitlesWide = new Title(new Word[] { + new Word(new Vector3(-39f, 15f, -8.4f), 5, 5, 2, 2, 2, 1.5f, "PART I"), + new Word(new Vector3(-34f, 0f, -8.4f), 5, 5, 2, 2, 2, 1.5f, "PROBE"), }); Transform gravityTarget = GetComponent().sun; @@ -119,7 +139,7 @@ void Start() void Update() { - if (Sequencer.CurrentRegionId == 1) + if (Sequencer.CurrentRegionId == 2) { if (currentRegion != Sequencer.CurrentRegionId) { @@ -138,12 +158,17 @@ void Update() currentBar = Sequencer.CurrentBar; } } - else if (Sequencer.CurrentRegionId == 2) + else if (Sequencer.CurrentRegionId == 4) { if (currentRegion != Sequencer.CurrentRegionId) { currentRegion = Sequencer.CurrentRegionId; - Title.FormTitle(openingTitles, 9.35f); + Title.FormTitle(openingTitles, 18.70125f); + } + + if (Sequencer.CurrentBar == 14 && currentBar != 14) + { + Title.FormTitle(openingTitlesWide, 6.33f); } if (currentBar != Sequencer.CurrentBar) @@ -151,33 +176,53 @@ void Update() currentBar = Sequencer.CurrentBar; } } - //else if (Sequencer.CurrentRegionId == 4 && currentBar != Sequencer.CurrentBar) - //{ - // currentRegion = Sequencer.CurrentRegionId; - // SwitchAnimation(2, 0, -70); - // currentBar = Sequencer.CurrentBar; - //} - //else if (Sequencer.CurrentRegionId >= 5 && Sequencer.CurrentRegionId <= 8 && currentBar != Sequencer.CurrentBar) - //{ - // currentRegion = Sequencer.CurrentRegionId; - // SwitchAnimation(0, -300, 0); - // currentBar = Sequencer.CurrentBar; - //} - //else if (Sequencer.CurrentRegionId >= 10 && Sequencer.CurrentRegionId <= 24 && currentBar != Sequencer.CurrentBar) - //{ - // currentRegion = Sequencer.CurrentRegionId; - // SwitchAnimation(1, -300, 0); - // currentBar = Sequencer.CurrentBar; - //} - //else if (Sequencer.CurrentRegionId == 9 || Sequencer.CurrentRegionId == 25) - //{ - // currentRegion = Sequencer.CurrentRegionId; - // TurnOffAnimation(0); - // currentBar = Sequencer.CurrentBar; - // sun.GetComponent().enabled = false; - // sun.GetComponent().enabled = false; - // sun.GetComponent().localScale = Vector3.Lerp(sun.GetComponent().localScale, new Vector3(0.1f, 0.1f, 0.1f), Time.deltaTime); - //} + else if (Sequencer.CurrentRegionId == 5) + { + if (currentRegion != Sequencer.CurrentRegionId) + { + currentRegion = Sequencer.CurrentRegionId; + Title.SetPlanetesimalsFree(); + } + + if (Sequencer.CurrentBar == 18 && currentBar != 18) + { + Title.FormTitle(partOneTitles, 12.4675f); + } + else if (Sequencer.CurrentBar == 22 && currentBar != 22) + { + Title.FormTitle(partOneTitlesWide, 6.33f); + } + else if (Sequencer.CurrentBar == 24 && currentBar != 24) + { + Title.SetPlanetesimalsFree(); + } + + if (currentBar != Sequencer.CurrentBar) + { + currentBar = Sequencer.CurrentBar; + } + } + else if (Sequencer.CurrentRegionId >= 6 && Sequencer.CurrentRegionId <= 8 && currentBar != Sequencer.CurrentBar) + { + currentRegion = Sequencer.CurrentRegionId; + SwitchAnimation(0, -300, 0); + currentBar = Sequencer.CurrentBar; + } + else if (Sequencer.CurrentRegionId >= 10 && Sequencer.CurrentRegionId <= 24 && currentBar != Sequencer.CurrentBar) + { + currentRegion = Sequencer.CurrentRegionId; + SwitchAnimation(1, -300, 0); + currentBar = Sequencer.CurrentBar; + } + else if (Sequencer.CurrentRegionId == 9 || Sequencer.CurrentRegionId == 25) + { + currentRegion = Sequencer.CurrentRegionId; + TurnOffAnimation(0); + currentBar = Sequencer.CurrentBar; + sun.GetComponent().enabled = false; + sun.GetComponent().enabled = false; + sun.GetComponent().localScale = Vector3.Lerp(sun.GetComponent().localScale, new Vector3(0.1f, 0.1f, 0.1f), Time.deltaTime); + } } diff --git a/Assets/Scripts/Mover.cs b/Assets/Scripts/Mover.cs index 84fd837..edf908a 100644 --- a/Assets/Scripts/Mover.cs +++ b/Assets/Scripts/Mover.cs @@ -15,9 +15,9 @@ IEnumerator MoveThisTo(Vector3 target, float time) float t = 0; - while (transform.position != target) + while (true) { - transform.position = Vector3.Lerp(start, target, Mathf.SmoothStep(0, 1, t)); + transform.position = Vector3.Slerp(start, target, Mathf.SmoothStep(0, 1, t)); t += Time.deltaTime / time; yield return null; } diff --git a/Assets/Scripts/Planetesimal.cs b/Assets/Scripts/Planetesimal.cs index f99ca8c..548695e 100644 --- a/Assets/Scripts/Planetesimal.cs +++ b/Assets/Scripts/Planetesimal.cs @@ -5,12 +5,14 @@ public class Planetesimal { public Transform Transform { get; private set; } + public Rigidbody Rigidbody { get; private set; } public Gravity Gravity { get; private set; } public Mover Mover { get; private set; } public Planetesimal(Transform planetesimal) { Transform = planetesimal.transform; + Rigidbody = planetesimal.GetComponent(); Gravity = planetesimal.GetComponent(); Mover = planetesimal.GetComponent(); } diff --git a/Assets/Scripts/Titles.cs b/Assets/Scripts/Titles.cs index 59605c4..1cc7a47 100644 --- a/Assets/Scripts/Titles.cs +++ b/Assets/Scripts/Titles.cs @@ -81,27 +81,70 @@ public int ParticleCount public static void FormTitle(Title title, float time) { - int planetesimalIndex = 0; + StopPlanetesimals(); + SetPlanetesimalsFree(); + int planetesimalIndex = (Space.planetesimals.Count - title.ParticleCount) / 2; + + Vector3 xVector = new Vector3(1, 0, 0); + Vector3 yVector = new Vector3(0, 1, 0); + + // word for (int i = 0; i < title.Length; i++) { + Vector3 wordLocation = title[i].Location; + float letterSize = (title[i].SlotPadding + Mathf.Max(0, title[i].ParticlePadding - 1)) * (title[i].HorizontalParticleSlotsPerLetter + 1); + + // letter for (int j = 0; j < title[i].Length; j++) { + Vector3 letterLocation = (j * letterSize) * xVector; + + // slot y for (int k = 0; k < title[i][j].Slots.GetLength(0); k++) { + Vector3 slotLocationY = k * (title[i].SlotPadding + Mathf.Max(0, title[i].ParticlePadding - 1)) * yVector; + + // slot x for (int l = 0; l < title[i][j].Slots.GetLength(1); l++) { + Vector3 slotLocationX = l * (title[i].SlotPadding + Mathf.Max(0, title[i].ParticlePadding - 1)) * xVector; + if (title[i][j].Slots[k, l]) { - Vector3 target = 5 * Vector3.one * (i + j + k + l); - Space.planetesimals[planetesimalIndex].Mover.MoveTo(target, time); - planetesimalIndex++; + Vector3 slotLocation = wordLocation + letterLocation + slotLocationX - slotLocationY; + + for (int m = 0; m < title[i].VerticalParticlesPerSlot; m++) + { + for (int n = 0; n < title[i].HorizontalParticlesPerSlot; n++) + { + Vector3 target = slotLocation + new Vector3(m * title[i].ParticlePadding, n * title[i].ParticlePadding, 0); + Space.planetesimals[planetesimalIndex].Mover.MoveTo(target, time); + planetesimalIndex++; + } + } } } } } } } + + public static void StopPlanetesimals() + { + for (int i = 0; i < Space.planetesimals.Count; i++) + { + Space.planetesimals[i].Rigidbody.velocity = Vector3.zero; + } + } + + public static void SetPlanetesimalsFree() + { + for (int i = 0; i < Space.planetesimals.Count; i++) + { + Space.planetesimals[i].Mover.StopAllCoroutines(); + } + } } @@ -363,6 +406,12 @@ public int OccupiedSlotsCount " 0 ", " 0 ", " 0 ", - "00000"} } + "00000"} }, + { ' ', new string[] { + " ", + " ", + " ", + " ", + " "} } }; } From f8c4a4dec4d24566c512805f746c43425485f413 Mon Sep 17 00:00:00 2001 From: Guney Ozsan Date: Sat, 9 Sep 2017 17:44:37 +0300 Subject: [PATCH 15/17] Added license terms to new scripts. --- Assets/Scripts/Mover.cs | 19 ++++++++++++++++++- Assets/Scripts/Planetesimal.cs | 19 ++++++++++++++++++- Assets/Scripts/Space.cs | 19 ++++++++++++++++++- Assets/Scripts/Sun.cs | 19 ++++++++++++++++++- Assets/Scripts/Utility/MathUtility.cs | 19 ++++++++++++++++++- 5 files changed, 90 insertions(+), 5 deletions(-) diff --git a/Assets/Scripts/Mover.cs b/Assets/Scripts/Mover.cs index edf908a..df72478 100644 --- a/Assets/Scripts/Mover.cs +++ b/Assets/Scripts/Mover.cs @@ -1,4 +1,21 @@ -using System.Collections; +// Guney Ozsan - Out There (Music Video) - Real time procedural music video in demoscene style for Unity 3D. +// Copyright (C) 2017 Guney Ozsan + +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// --------------------------------------------------------------------- + +using System.Collections; using System.Collections.Generic; using UnityEngine; diff --git a/Assets/Scripts/Planetesimal.cs b/Assets/Scripts/Planetesimal.cs index 548695e..cc35b87 100644 --- a/Assets/Scripts/Planetesimal.cs +++ b/Assets/Scripts/Planetesimal.cs @@ -1,4 +1,21 @@ -using System.Collections; +// Guney Ozsan - Out There (Music Video) - Real time procedural music video in demoscene style for Unity 3D. +// Copyright (C) 2017 Guney Ozsan + +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// --------------------------------------------------------------------- + +using System.Collections; using System.Collections.Generic; using UnityEngine; diff --git a/Assets/Scripts/Space.cs b/Assets/Scripts/Space.cs index 6554cf9..7a27875 100644 --- a/Assets/Scripts/Space.cs +++ b/Assets/Scripts/Space.cs @@ -1,4 +1,21 @@ -using System.Collections; +// Guney Ozsan - Out There (Music Video) - Real time procedural music video in demoscene style for Unity 3D. +// Copyright (C) 2017 Guney Ozsan + +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// --------------------------------------------------------------------- + +using System.Collections; using System.Collections.Generic; using UnityEngine; diff --git a/Assets/Scripts/Sun.cs b/Assets/Scripts/Sun.cs index 2897674..438d53b 100644 --- a/Assets/Scripts/Sun.cs +++ b/Assets/Scripts/Sun.cs @@ -1,4 +1,21 @@ -using System.Collections; +// Guney Ozsan - Out There (Music Video) - Real time procedural music video in demoscene style for Unity 3D. +// Copyright (C) 2017 Guney Ozsan + +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// --------------------------------------------------------------------- + +using System.Collections; using System.Collections.Generic; using UnityEngine; diff --git a/Assets/Scripts/Utility/MathUtility.cs b/Assets/Scripts/Utility/MathUtility.cs index eda334b..5ed36f3 100644 --- a/Assets/Scripts/Utility/MathUtility.cs +++ b/Assets/Scripts/Utility/MathUtility.cs @@ -1,4 +1,21 @@ -using System.Collections; +// Guney Ozsan - Out There (Music Video) - Real time procedural music video in demoscene style for Unity 3D. +// Copyright (C) 2017 Guney Ozsan + +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// --------------------------------------------------------------------- + +using System.Collections; using System.Collections.Generic; using UnityEngine; From bebf27c00566871da524c9a5103b3bfdc893aff8 Mon Sep 17 00:00:00 2001 From: Guney Ozsan Date: Sat, 9 Sep 2017 17:45:11 +0300 Subject: [PATCH 16/17] Added the term procedural to the definiton of the project in license terms. --- Assets/Scripts/AnimationManager.cs | 2 +- Assets/Scripts/DebugGUI.cs | 2 +- Assets/Scripts/Gravity.cs | 2 +- Assets/Scripts/Sequencer.cs | 2 +- Assets/Scripts/Titles.cs | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Assets/Scripts/AnimationManager.cs b/Assets/Scripts/AnimationManager.cs index a083f8c..c30e23d 100644 --- a/Assets/Scripts/AnimationManager.cs +++ b/Assets/Scripts/AnimationManager.cs @@ -1,4 +1,4 @@ -// Guney Ozsan - Out There (Music Video) - Real time music video in demoscene style for Unity 3D. +// Guney Ozsan - Out There (Music Video) - Real time procedural music video in demoscene style for Unity 3D. // Copyright (C) 2017 Guney Ozsan // This program is free software: you can redistribute it and/or modify diff --git a/Assets/Scripts/DebugGUI.cs b/Assets/Scripts/DebugGUI.cs index 99fbf84..f08ab97 100644 --- a/Assets/Scripts/DebugGUI.cs +++ b/Assets/Scripts/DebugGUI.cs @@ -1,4 +1,4 @@ -// Guney Ozsan - Out There (Music Video) - Real time music video in demoscene style for Unity 3D. +// Guney Ozsan - Out There (Music Video) - Real time procedural music video in demoscene style for Unity 3D. // Copyright (C) 2017 Guney Ozsan // This program is free software: you can redistribute it and/or modify diff --git a/Assets/Scripts/Gravity.cs b/Assets/Scripts/Gravity.cs index afb6d20..fe09662 100644 --- a/Assets/Scripts/Gravity.cs +++ b/Assets/Scripts/Gravity.cs @@ -1,4 +1,4 @@ -// Guney Ozsan - Out There (Music Video) - Real time music video in demoscene style for Unity 3D. +// Guney Ozsan - Out There (Music Video) - Real time procedural music video in demoscene style for Unity 3D. // Copyright (C) 2017 Guney Ozsan // This program is free software: you can redistribute it and/or modify diff --git a/Assets/Scripts/Sequencer.cs b/Assets/Scripts/Sequencer.cs index b81bb68..4c1d339 100644 --- a/Assets/Scripts/Sequencer.cs +++ b/Assets/Scripts/Sequencer.cs @@ -1,4 +1,4 @@ -// Guney Ozsan - Out There (Music Video) - Real time music video in demoscene style for Unity 3D. +// Guney Ozsan - Out There (Music Video) - Real time procedural music video in demoscene style for Unity 3D. // Copyright (C) 2017 Guney Ozsan // This program is free software: you can redistribute it and/or modify diff --git a/Assets/Scripts/Titles.cs b/Assets/Scripts/Titles.cs index 1cc7a47..265e4f3 100644 --- a/Assets/Scripts/Titles.cs +++ b/Assets/Scripts/Titles.cs @@ -1,4 +1,4 @@ -// Guney Ozsan - Out There (Music Video) - Real time music video in demoscene style for Unity 3D. +// Guney Ozsan - Out There (Music Video) - Real time procedural music video in demoscene style for Unity 3D. // Copyright (C) 2017 Guney Ozsan // This program is free software: you can redistribute it and/or modify From d3bb33030805acc2577ce69743eb634f66f90bd1 Mon Sep 17 00:00:00 2001 From: Guney Ozsan Date: Tue, 12 Sep 2017 13:31:56 +0300 Subject: [PATCH 17/17] Introduced release history text. --- ReleaseHistory.txt | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 ReleaseHistory.txt diff --git a/ReleaseHistory.txt b/ReleaseHistory.txt new file mode 100644 index 0000000..5e64bcf --- /dev/null +++ b/ReleaseHistory.txt @@ -0,0 +1,17 @@ +RELEASE NOTES +------ +v0.4.0 +- Implemented system for forming title texts on screen with planetesimals. +- The starting scene now starts with a single blue cube that explodes to form small planetesimals in sync with the explosion sound in the intro. + +------ +v0.3.0 +- Organize code structure for better architecture. + +------ +v0.2.0 +- JavaScript prototype is converted to C#. + +------ +v0.1.0 +- Initial prototype made with JavaScript \ No newline at end of file