Skip to content

Commit 22bd9a2

Browse files
committed
It's pretty now
1 parent 1e18138 commit 22bd9a2

20 files changed

+5308
-64
lines changed

Assets/Cartoon SportCar B01/Prefab_Car-Toon/Cartoon_SportCar_B01.prefab

+1-1
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,7 @@ Transform:
512512
m_GameObject: {fileID: 136596}
513513
m_LocalRotation: {x: -8.881806e-14, y: 0, z: 0, w: 1}
514514
m_LocalPosition: {x: -0, y: 0, z: 0}
515-
m_LocalScale: {x: 1, y: 1, z: 1}
515+
m_LocalScale: {x: 0.5, y: 0.5, z: 0.5}
516516
m_Children:
517517
- {fileID: 402960}
518518
- {fileID: 427842}

Assets/Cartoon SportCar B01/models/Materials/body.mat

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,5 +72,5 @@ Material:
7272
- _UVSec: 0
7373
- _ZWrite: 1
7474
m_Colors:
75-
- _Color: {r: 1, g: 0, b: 0, a: 1}
75+
- _Color: {r: 0.9811321, g: 0.94833964, b: 0, a: 1}
7676
- _EmissionColor: {r: 0, g: 0, b: 0, a: 0}

Assets/GoogleARCore/Examples/HelloAR/Scenes/HelloAR.unity

+3-1
Original file line numberDiff line numberDiff line change
@@ -273,14 +273,16 @@ MonoBehaviour:
273273
AndyPointPrefab: {fileID: 1190091649889860, guid: b27e8d7fe70df464188ea5dcf2af0bb3,
274274
type: 2}
275275
SearchingForPlaneUI: {fileID: 1133631540}
276-
prefab: {fileID: 1662330583938526, guid: e9da76b81b7671d42823ac38f022d8a1, type: 2}
276+
prefab: {fileID: 1996245458792640, guid: 5b8b93680df36d24297bbcd2cf2395c0, type: 2}
277+
boost: {fileID: 198631920856243186, guid: ccafa74804815a642a1948ef0fa3123d, type: 2}
277278
field: {fileID: 1622367642563872, guid: 6d6fcfec73dec3e478b7d834e44057d5, type: 2}
278279
ball: {fileID: 1696128692082718, guid: 33876e2cf22a5ef44b587d8584f418c5, type: 2}
279280
namePrefab: {fileID: 1093890370552692, guid: 92931170967238b4380ff3a2aecdffa1, type: 2}
280281
scaleFactor: 1000
281282
orangeCar: {fileID: 2100000, guid: 930ec488361a897478032696d5b19d8b, type: 2}
282283
blueCar: {fileID: 2100000, guid: ca59746023ec83d42a7d216a4d131eb3, type: 2}
283284
planeGenerator: {fileID: 2083512464}
285+
testing: 0
284286
--- !u!20 &896679035 stripped
285287
Camera:
286288
m_CorrespondingSourceObject: {fileID: 20155940112608238, guid: c10877f7cd5764de18d46d7b777d1faa,

Assets/GoogleARCore/Examples/HelloAR/Scripts/HelloARController.cs

+126-28
Original file line numberDiff line numberDiff line change
@@ -88,13 +88,15 @@ public class HelloARController : MonoBehaviour
8888

8989
// Settable parameters
9090
public GameObject prefab;
91+
public ParticleSystem boost;
9192
public GameObject field;
9293
public GameObject ball;
9394
public GameObject namePrefab;
9495
public float scaleFactor = 1000f;
9596
public Material orangeCar;
9697
public Material blueCar;
9798
public GameObject planeGenerator;
99+
public Texture goalIndicator;
98100

99101
// Instance objects
100102
private GameObject ballObject;
@@ -104,18 +106,27 @@ public class HelloARController : MonoBehaviour
104106
private int currentFrame = 0;
105107
private List<GameObject> cars = new List<GameObject>();
106108
private List<GameObject> names = new List<GameObject>();
109+
private List<ParticleSystem> boosts = new List<ParticleSystem>();
107110
private float hSliderValue = 1000f;
108111
private float localScale = 15f;
109-
112+
private Dictionary<string, int> playerTeamMap = new Dictionary<string, int>();
110113

111114
private string dataMsg;
112115
private string protoMsg;
113116

114117

115-
private bool testing = true;
118+
public bool testing = true;
119+
120+
public void Start()
121+
{
122+
Debug.Log("Proto: " + StaticReplayScript.proto);
123+
}
124+
125+
116126
private void Spawn(Vector3 position, Quaternion rotation, Transform parent)
117127
{
118128
var gameData = StaticReplayScript.gameData;
129+
Proto proto = StaticReplayScript.proto;
119130
// Choose the Andy model for the Trackable that got hit.
120131
// Instantiate Andy model at the hit pose.
121132
fieldObject = Instantiate(this.field, position, rotation);
@@ -133,7 +144,7 @@ private void Spawn(Vector3 position, Quaternion rotation, Transform parent)
133144
rootObject.transform.localScale = new Vector3(1 / scaleFactor, 1 / scaleFactor, 1 / scaleFactor);
134145
fieldObject.transform.parent = rootObject.transform;
135146
fieldObject.transform.localPosition = new Vector3(0f, -10f, 0f);
136-
fieldObject.transform.localScale = new Vector3(63 * 1000 / scaleFactor, 63 * 1000 / scaleFactor, 63 * 1000 / scaleFactor);
147+
fieldObject.transform.localScale = new Vector3(65 * 1000 / scaleFactor, 65 * 1000 / scaleFactor, 65 * 1000 / scaleFactor);
137148
fieldObject.transform.localRotation = Quaternion.Euler(0f, -90f, 0f);
138149
for (int i = 0; i < gameData.players.Count; i++)
139150
{
@@ -144,16 +155,41 @@ private void Spawn(Vector3 position, Quaternion rotation, Transform parent)
144155
car.transform.parent = rootObject.transform;
145156
car.transform.localPosition = new Vector3(x, y, z);
146157
//car.transform.localScale = new Vector3(120 * 1000 / scaleFactor, 120 * 1000 / scaleFactor, 120 * 1000 / scaleFactor);
147-
car.GetComponent<Renderer>().material = gameData.colors[i] == 0 ? blueCar : orangeCar;
158+
var renderer = car.transform.Find("carrosserie").GetComponent<Renderer>();
159+
var materials = renderer.materials;
160+
materials[0] = gameData.colors[i] == 0 ? blueCar : orangeCar;
161+
renderer.materials = materials;
162+
163+
164+
var animatable = car.transform.Find("Animatable");
165+
foreach (Transform child in animatable)
166+
{
167+
var childRenderer = child.GetComponent<Renderer>();
168+
var childMaterials = childRenderer.materials;
169+
childMaterials[0] = gameData.colors[i] == 0 ? blueCar : orangeCar;
170+
childRenderer.materials = childMaterials;
171+
}
172+
//car.GetComponent<Renderer>().material = gameData.colors[i] == 0 ? blueCar : orangeCar;
148173
car.name = gameData.names[i];
149174
cars.Add(car);
150175

151-
176+
var boostObj = Instantiate(this.boost, new Vector3(0f, 0f, 0f), Quaternion.identity);
177+
boostObj.transform.parent = car.transform;
178+
boostObj.transform.localPosition = new Vector3(0f, 0f, 0f);
179+
boostObj.transform.localRotation = Quaternion.Euler(-180f, 0f, 0f);
180+
var boostScale = 50f;
181+
boostObj.transform.localScale = new Vector3(1 / boostScale, 1 / boostScale, 1 / boostScale);
182+
boostObj.GetComponent<ParticleSystem>().Stop();
183+
boosts.Add(boostObj);
152184
var name = Instantiate(namePrefab, new Vector3(0f, 0f, 0f), Quaternion.identity);
153185
name.GetComponent<TextMesh>().text = gameData.names[i];
154186
name.transform.parent = rootObject.transform;
155187
name.transform.localPosition = new Vector3(x, y + 1.0f, z);
156188
names.Add(name); // needed so we can look at camera all the time
189+
Debug.Log("Count " + (proto == null));
190+
Debug.Log(proto.players[i]);
191+
Debug.Log(proto.players[i].isOrange);
192+
playerTeamMap[proto.players[i].id.id] = proto.players[i].isOrange;
157193
}
158194
ballObject = Instantiate(ball, new Vector3(0f, 0f, 0f), Quaternion.identity);
159195
ballObject.transform.parent = rootObject.transform;
@@ -169,10 +205,10 @@ public void Update()
169205
{
170206
if (!testing)
171207
{
172-
173208
_UpdateApplicationLifecycle();
174209
}
175210
var gameData = StaticReplayScript.gameData;
211+
var proto = StaticReplayScript.proto;
176212
if (!testing)
177213
{
178214
// Hide snackbar when currently tracking at least one plane.
@@ -197,16 +233,16 @@ public void Update()
197233
{
198234
//SceneManager.LoadScene("LoadData");
199235
}
200-
if (testing && gameData != null)
236+
if (testing && gameData != null && proto != null)
201237
{
202238
GameObject empty = new GameObject("Empty");
203239
scaleFactor = 1000f;
204240
Spawn(new Vector3(0f, 0f, 0f), Quaternion.identity, empty.transform);
205-
241+
206242
FirstPersonCamera.transform.position = new Vector3(0.5f, 0.5f, 0.5f);
207243
FirstPersonCamera.transform.LookAt(empty.transform);
208244
}
209-
else
245+
else if (!testing)
210246
{
211247

212248
Touch touch;
@@ -234,7 +270,7 @@ public void Update()
234270
{
235271
var anchor = hit.Trackable.CreateAnchor(hit.Pose);
236272
Spawn(hit.Pose.position, hit.Pose.rotation, anchor.transform);
237-
273+
238274
}
239275
}
240276
}
@@ -253,10 +289,10 @@ public void Update()
253289
for (int i = 0; i < cars.Count; i++)
254290
{
255291
var frameData = gameData.players[i][currentFrame];
256-
float x = (float) (double) frameData[0] / localScale;
257-
float y = (float) (double) frameData[2] / localScale;
258-
float z = (float) (double) frameData[1] / localScale;
259-
292+
float x = (float)(double)frameData[0] / localScale;
293+
float y = (float)(double)frameData[2] / localScale;
294+
float z = (float)(double)frameData[1] / localScale;
295+
260296
var PI = (double)3.14159265;
261297

262298
var xOffset = (double)0;
@@ -270,17 +306,33 @@ public void Update()
270306
var rotY = ((double)frameData[4] / (2 * PI) + yOffset) * yCoeff * 360; // yaw
271307
var rotZ = ((double)frameData[5] / (2 * PI) + zOffset) * zCoeff * 360; // roll
272308

273-
var rotation = Quaternion.AngleAxis((float)rotY, Vector3.up)* // yaw
309+
var rotation = Quaternion.AngleAxis((float)rotY, Vector3.up) * // yaw
274310
Quaternion.AngleAxis((float)rotX, Vector3.right) *
275-
Quaternion.AngleAxis((float) rotZ, Vector3.forward);
311+
Quaternion.AngleAxis((float)rotZ, Vector3.forward);
276312
cars[i].transform.localPosition = new Vector3(x, y, z);
277313
//cars[i].transform.localEulerAngles = new Vector3((float) rotZ, (float) rotY + 90, (float) rotX);
278314
cars[i].transform.localRotation = rotation;
315+
316+
if (frameData[6] is bool)
317+
{
318+
319+
ParticleSystem boostObj = boosts[i].GetComponent<ParticleSystem>();
320+
bool shouldBeEmitting = (bool)frameData[6];
321+
if (shouldBeEmitting && boostObj.isStopped)
322+
{
323+
boostObj.Play();
324+
}
325+
else if (!shouldBeEmitting && !boostObj.isStopped)
326+
{
327+
boostObj.Stop();
328+
}
329+
330+
}
279331
names[i].transform.localPosition = new Vector3(x, y + 0.5f, z);
280332
names[i].transform.LookAt(FirstPersonCamera.transform);
281333
names[i].transform.Rotate(Vector3.up - new Vector3(0, 180, 0));
282334
}
283-
335+
284336
float ballx = (float)gameData.ball[currentFrame][0] / localScale;
285337
float bally = (float)gameData.ball[currentFrame][2] / localScale;
286338
float ballz = (float)gameData.ball[currentFrame][1] / localScale;
@@ -291,7 +343,7 @@ public void Update()
291343

292344
var currentFrameTime = gameData.frames[currentFrame][2];
293345
var nextFrameTime = gameData.frames[currentFrame + 1][2];
294-
Debug.Log(currentFrameTime.ToString());
346+
//Debug.Log(currentFrameTime.ToString());
295347
if (currentTime > nextFrameTime)
296348
{
297349
currentFrame += 1;
@@ -311,7 +363,8 @@ void DrawQuad(Rect position, Color color)
311363
public void OnGUI()
312364
{
313365
var width = Screen.width;
314-
var zoomOut = GUI.Button(new Rect(width * 2/10, 25, width / 25, width / 25), "-");
366+
var height = Screen.height;
367+
var zoomOut = GUI.Button(new Rect(width * 2 / 10, 25, width / 25, width / 25), "-");
315368
var zoomIn = GUI.Button(new Rect(width * 3 / 10, 25, width / 25, width / 25), "+");
316369
if (zoomOut)
317370
{
@@ -328,7 +381,7 @@ public void OnGUI()
328381
// Scoreboard
329382
int offset = 100;
330383
Color orange = new Color(1F, 0.64F, 0F);
331-
var halfway = width/2;
384+
var halfway = width / 2;
332385
GUIStyle timeStyle = new GUIStyle();
333386
timeStyle.fontSize = 30;
334387
timeStyle.fontStyle = FontStyle.Bold;
@@ -341,8 +394,30 @@ public void OnGUI()
341394
timeRemaining = (int)StaticReplayScript.gameData.frames[currentFrame][1];
342395
}
343396
//int timeRemaining = 175;
344-
int minRemaining = timeRemaining/60;
397+
int minRemaining = timeRemaining / 60;
345398
GUI.Label(new Rect(halfway, 35, 50, 50), String.Format("{0}:{1:D2}", minRemaining, timeRemaining % (minRemaining * 60)), timeStyle);
399+
400+
401+
var team0Score = 0;
402+
var team1Score = 0;
403+
if (StaticReplayScript.proto != null)
404+
{
405+
foreach (Goal g in StaticReplayScript.proto.gameMetadata.goals)
406+
{
407+
if (g.frameNumber < currentFrame)
408+
{
409+
int playerTeam = playerTeamMap[g.playerId.id];
410+
if (playerTeam == 0)
411+
{
412+
team0Score += 1;
413+
}
414+
else
415+
{
416+
team1Score += 1;
417+
}
418+
}
419+
}
420+
}
346421
for (int i = 0; i < 2; i++)
347422
{
348423
Color teamColor = (i == 0) ? Color.blue : (orange);
@@ -356,11 +431,11 @@ public void OnGUI()
356431
///style.font = new Font("Liberation Sans");
357432
style.fontSize = 30;
358433
style.fontStyle = FontStyle.Bold;
359-
434+
360435
style.normal.textColor = Color.white;
361436
style.alignment = TextAnchor.MiddleCenter;
362-
363-
GUI.Label(position, i.ToString(), style);
437+
438+
GUI.Label(position, (i == 0 ? team0Score : team1Score).ToString(), style);
364439
//Color oldColor = GUI.backgroundColor;
365440
//GUI.backgroundColor = (i == 0) ? Color.blue : Color.red*Color.yellow;
366441
//GUI.backgroundColor = oldColor;
@@ -369,10 +444,33 @@ public void OnGUI()
369444

370445
}
371446
RootObject gameData = StaticReplayScript.gameData;
372-
if (gameData != null)
447+
Proto proto = StaticReplayScript.proto;
448+
if (gameData != null && proto != null && fieldObject != null)
373449
{
374-
currentTime = GUI.HorizontalSlider(new Rect(250 + 150, 35, 200, 30), currentTime, (float)gameData.frames[0][2], (float) gameData.frames[gameData.frames.Count - 1][2]);
375-
450+
var logoWidth = width/60;
451+
var nextFrame = (int)GUI.HorizontalSlider(new Rect(0, 19 / 20f * height, width, height / 20f), currentFrame, 0, gameData.frames.Count);
452+
if (nextFrame != currentFrame)
453+
{
454+
currentFrame = nextFrame;
455+
currentTime = (float) gameData.frames[nextFrame][2];
456+
}
457+
for (int i = 0; i < proto.gameMetadata.goals.Count; i++)
458+
{
459+
Goal g = proto.gameMetadata.goals[i];
460+
var frame = g.frameNumber;
461+
var size = new Rect((width * frame / (float)gameData.frames.Count) - logoWidth / 2, 18 / 20f * height, logoWidth, logoWidth);
462+
if (playerTeamMap.ContainsKey(g.playerId.id))
463+
{
464+
Color teamColor = playerTeamMap[g.playerId.id] == 0 ? Color.blue : (orange);
465+
DrawQuad(size, teamColor);
466+
}
467+
else
468+
{
469+
Debug.Log(string.Format("{0} is not in {1}", g.playerId.id, playerTeamMap.Keys.Count));
470+
}
471+
472+
GUI.Box(size, goalIndicator);
473+
}
376474
}
377475

378476

@@ -389,7 +487,7 @@ public void OnGUI()
389487
var style = new GUIStyle();
390488
style.fontSize = 20;
391489
style.fontStyle = FontStyle.Bold;
392-
GUI.Label(new Rect(0, width/10, width / 5, width / 10), dataMsg, style);
490+
GUI.Label(new Rect(0, width / 10, width / 5, width / 10), dataMsg, style);
393491
}
394492
if (protoMsg != null)
395493
{

Assets/GoogleARCore/SDK/InstantPreview/Scripts/InstantPreview.apk.meta

+7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)