Bug fixing and code cleaning

This commit is contained in:
Alexander Munch-Hansen 2019-02-11 11:40:07 +01:00
parent dc01c13f70
commit eade5bfc05
4 changed files with 25 additions and 63 deletions

View File

@ -4,28 +4,22 @@ using UnityEngine;
public class AlignmentScript : MonoBehaviour public class AlignmentScript : MonoBehaviour
{ {
Transform shuttle;
Transform landing;
GameObject quad;
// Start is called before the first frame update // Start is called before the first frame update
void Start() void Start() {
{ shuttle = GameObject.Find("ShuttleTarget").transform;
landing = GameObject.Find("LandingTarget").transform;
quad = GameObject.Find("AlignmentQuad");
} }
// Update is called once per frame // Update is called once per frame
void Update() void Update() {
{
var shuttle = GameObject.Find("ShuttleTarget").transform;
var landing = GameObject.Find("LandingTarget").transform;
var quad = GameObject.Find("AlignmentQuad");
print($"Up {shuttle.up}, forward {shuttle.forward}");
var upDot = Vector3.Dot(shuttle.up, landing.up); var upDot = Vector3.Dot(shuttle.up, landing.up);
var forwardDot = Vector3.Dot(shuttle.forward, landing.forward); var forwardDot = Vector3.Dot(shuttle.forward, landing.forward);
print($"upDot: {upDot}, forwardDot: {forwardDot}");
var ratio = (upDot + forwardDot) / 2; var ratio = (upDot + forwardDot) / 2;
var color = new Color((1 - ratio)*2, ratio, 0); var color = new Color((1 - ratio)*2, ratio, 0);
print(color);
quad.GetComponent<Renderer>().material.color = color; quad.GetComponent<Renderer>().material.color = color;
} }

View File

@ -24,12 +24,7 @@ public class GPSScript : MonoBehaviour
void Update() void Update()
{ {
printString = ""; printString = "";
/*
Possible solution. Under the assumption we hold the
camera steadily, the earth stuff be done in the
Start() function.
This should be correct, according to slides.
*/
var shuttleLocalToWorld = shuttle.localToWorldMatrix; var shuttleLocalToWorld = shuttle.localToWorldMatrix;
var earthWorldToLocal = Matrix4x4.Inverse(Matrix4x4.TRS(earth.position, earth.rotation, Vector3.one)); var earthWorldToLocal = Matrix4x4.Inverse(Matrix4x4.TRS(earth.position, earth.rotation, Vector3.one));
@ -40,20 +35,10 @@ public class GPSScript : MonoBehaviour
} }
void compareToNose(Vector3 nosePosition) { void compareToNose(Vector3 nosePosition) {
print($"LossyScale: {earth.lossyScale}");
//var radius = new Vector2(earth.lossyScale.x, earth.lossyScale.z).magnitude / 2;
var radius = earth.lossyScale.magnitude / 4; var radius = earth.lossyScale.magnitude / 4;
//var radius = (new Vector2(earth.lossyScale.x, earth.lossyScale.z)).magnitude;
print($"Radius: {radius}");
var d = new Vector2(nosePosition.x, nosePosition.z).magnitude; var d = new Vector2(nosePosition.x, nosePosition.z).magnitude;
print($"D: {d}");
if (d <= radius && nosePosition.y <= 4) { if (d <= radius && nosePosition.y <= 4) {
print("Within");
if (nosePosition.z >= 0) { if (nosePosition.z >= 0) {
printString += "North"; printString += "North";
} else { } else {

View File

@ -6,15 +6,12 @@ public class RayScript : MonoBehaviour
{ {
// Start is called before the first frame update // Start is called before the first frame update
Transform topCannon; Transform topCannon;
Transform firstPoint; bool part1 = true;
Transform secondPoint;
bool part1 = false;
bool part2 = false; bool part2 = false;
bool part3 = true; bool part3 = false;
Material material; Material material;
bool fire = false; bool fire = false;
private Ray ray;
Vector3 leftCannon = new Vector3((float)0.077, 0, (float)0.450); Vector3 leftCannon = new Vector3((float)0.077, 0, (float)0.450);
Vector3 rightCannon = new Vector3((float)-0.077, 0, (float)0.450); Vector3 rightCannon = new Vector3((float)-0.077, 0, (float)0.450);
@ -65,6 +62,7 @@ public class RayScript : MonoBehaviour
} }
if (hit) { if (hit) {
print("Hit");
explosion.position = target.position; explosion.position = target.position;
explosion.GetComponent<ParticleSystem>().Play(); explosion.GetComponent<ParticleSystem>().Play();
} }

View File

@ -680,7 +680,7 @@ ParticleSystem:
startLifetime: startLifetime:
serializedVersion: 2 serializedVersion: 2
minMaxState: 0 minMaxState: 0
scalar: 5 scalar: 1
minScalar: 5 minScalar: 5
maxCurve: maxCurve:
serializedVersion: 2 serializedVersion: 2
@ -5357,7 +5357,7 @@ Mesh:
vertexCount: 4 vertexCount: 4
localAABB: localAABB:
m_Center: {x: 0, y: 0, z: 0} m_Center: {x: 0, y: 0, z: 0}
m_Extent: {x: 0.2887325, y: 0, z: 0.5} m_Extent: {x: 0.34927696, y: 0, z: 0.5}
m_Shapes: m_Shapes:
vertices: [] vertices: []
shapes: [] shapes: []
@ -5433,7 +5433,7 @@ Mesh:
format: 0 format: 0
dimension: 0 dimension: 0
m_DataSize: 128 m_DataSize: 128
_typelessdata: bfd493be00000000000000bf000000000000803f000000000000000000000000bfd493be000000000000003f000000000000803f00000000000000000000803fbfd4933e00000000000000bf000000000000803f000000000000803f00000000bfd4933e000000000000003f000000000000803f000000000000803f0000803f _typelessdata: 6ed4b2be00000000000000bf000000000000803f0000000000000000000000006ed4b2be000000000000003f000000000000803f00000000000000000000803f6ed4b23e00000000000000bf000000000000803f000000000000803f000000006ed4b23e000000000000003f000000000000803f000000000000803f0000803f
m_CompressedMesh: m_CompressedMesh:
m_Vertices: m_Vertices:
m_NumItems: 0 m_NumItems: 0
@ -5673,7 +5673,6 @@ GameObject:
- component: {fileID: 1554044213} - component: {fileID: 1554044213}
- component: {fileID: 1554044212} - component: {fileID: 1554044212}
- component: {fileID: 1554044211} - component: {fileID: 1554044211}
- component: {fileID: 1554044217}
- component: {fileID: 1554044218} - component: {fileID: 1554044218}
m_Layer: 0 m_Layer: 0
m_Name: FighterTarget m_Name: FighterTarget
@ -5763,14 +5762,14 @@ MonoBehaviour:
m_Script: {fileID: -1631628248, guid: bab6fa851cf5a1a4bba3cec5f191cb8e, type: 3} m_Script: {fileID: -1631628248, guid: bab6fa851cf5a1a4bba3cec5f191cb8e, type: 3}
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
mTrackableName: farge mTrackableName: other-figther
mPreserveChildSize: 0 mPreserveChildSize: 0
mInitializedInEditor: 1 mInitializedInEditor: 1
mDataSetPath: Vuforia/AR-1.xml mDataSetPath: Vuforia/AR-1.xml
mAspectRatio: 1.7317066 mAspectRatio: 1.4315287
mImageTargetType: 0 mImageTargetType: 0
mWidth: 0.06147 mWidth: 0.03251
mHeight: 0.106448 mHeight: 0.046539
--- !u!4 &1554044216 --- !u!4 &1554044216
Transform: Transform:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -5780,27 +5779,13 @@ Transform:
m_GameObject: {fileID: 1554044210} m_GameObject: {fileID: 1554044210}
m_LocalRotation: {x: 0, y: 1, z: 0, w: 0} m_LocalRotation: {x: 0, y: 1, z: 0, w: 0}
m_LocalPosition: {x: 0, y: 0, z: 0.2} m_LocalPosition: {x: 0, y: 0, z: 0.2}
m_LocalScale: {x: 0.106448, y: 0.106448, z: 0.106448} m_LocalScale: {x: 0.046539, y: 0.046539, z: 0.046539}
m_Children: m_Children:
- {fileID: 175087141} - {fileID: 175087141}
- {fileID: 879189355} - {fileID: 879189355}
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_RootOrder: 3 m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 0, y: 180, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 180, z: 0}
--- !u!64 &1554044217
MeshCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1554044210}
m_Material: {fileID: 0}
m_IsTrigger: 0
m_Enabled: 0
serializedVersion: 3
m_Convex: 0
m_CookingOptions: 14
m_Mesh: {fileID: 1256114398}
--- !u!65 &1554044218 --- !u!65 &1554044218
BoxCollider: BoxCollider:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -5812,8 +5797,8 @@ BoxCollider:
m_IsTrigger: 0 m_IsTrigger: 0
m_Enabled: 1 m_Enabled: 1
serializedVersion: 2 serializedVersion: 2
m_Size: {x: 0.6982015, y: 45425.61, z: 0.994512} m_Size: {x: 0.6982015, y: 0.1, z: 0.994512}
m_Center: {x: -0.00000008004663, y: -22712.805, z: -0.0027439184} m_Center: {x: 0, y: 0, z: 0}
--- !u!21 &2035685464 --- !u!21 &2035685464
Material: Material:
serializedVersion: 6 serializedVersion: 6
@ -5821,7 +5806,7 @@ Material:
m_CorrespondingSourceObject: {fileID: 0} m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0} m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
m_Name: 'fargeMaterial m_Name: 'other-figtherMaterial
-17572' -17572'
m_Shader: {fileID: 10752, guid: 0000000000000000f000000000000000, type: 0} m_Shader: {fileID: 10752, guid: 0000000000000000f000000000000000, type: 0}
@ -5836,7 +5821,7 @@ Material:
serializedVersion: 3 serializedVersion: 3
m_TexEnvs: m_TexEnvs:
- _MainTex: - _MainTex:
m_Texture: {fileID: 2800000, guid: 658ea795ec9e43018938dba1c7ab24bd, type: 3} m_Texture: {fileID: 2800000, guid: 26b1f498f267434a894321bf30760303, type: 3}
m_Scale: {x: 1, y: 1} m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0} m_Offset: {x: 0, y: 0}
m_Floats: [] m_Floats: []