Skip to content

Commit 0dac199

Browse files
Merge pull request #15 from snlpatel001213/v0.0.6
V0.0.6
2 parents 09906b1 + fbdb835 commit 0dac199

484 files changed

Lines changed: 22559 additions & 5817 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.vscode/settings.json

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
{
1+
{
22
"files.exclude":
33
{
44
"**/.DS_Store":true,
55
"**/.git":true,
6-
"**/.gitignore":true,
6+
"**/.gitignore":false,
77
"**/.gitmodules":true,
88
"**/*.booproj":true,
99
"**/*.pidb":true,
@@ -17,11 +17,6 @@
1717
"**/*.mid":true,
1818
"**/*.midi":true,
1919
"**/*.wav":true,
20-
"**/*.gif":true,
21-
"**/*.ico":true,
22-
"**/*.jpg":true,
23-
"**/*.jpeg":true,
24-
"**/*.png":true,
2520
"**/*.psd":true,
2621
"**/*.tga":true,
2722
"**/*.tif":true,
@@ -36,21 +31,23 @@
3631
"**/*.MA":true,
3732
"**/*.obj":true,
3833
"**/*.OBJ":true,
39-
"**/*.asset":true,
4034
"**/*.cubemap":true,
4135
"**/*.flare":true,
4236
"**/*.mat":true,
4337
"**/*.meta":true,
4438
"**/*.prefab":true,
45-
"**/*.unity":true,
39+
"**/*.unity":false,
4640
"build/":true,
47-
"Build/":true,
41+
"Build/":false,
4842
"Library/":true,
4943
"library/":true,
5044
"obj/":true,
5145
"Obj/":true,
5246
"ProjectSettings/":true,
5347
"temp/":true,
5448
"Temp/":true
49+
},
50+
"editor.codeActionsOnSave": {
51+
"source.organizeImports": true
5552
}
5653
}
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
//Copyright 2013 MichaelTaylor3D
2+
//www.michaeltaylor3d.com
3+
using UnityEngine;
4+
using Communicator;
5+
namespace AirControl
6+
{
7+
8+
//Copyright 2013 MichaelTaylor3D
9+
//www.michaeltaylor3d.com
10+
//https://github.com/MichaelTaylor3D/UnityGPSConverter/
11+
12+
public class GPSEncoder : MonoBehaviour
13+
{
14+
15+
#region Instance Variables
16+
public Rigidbody rb;
17+
18+
private Vector2 _localOrigin = Vector2.zero;
19+
private float _LatOrigin { get{ return _localOrigin.x; }}
20+
private float _LonOrigin { get{ return _localOrigin.y; }}
21+
private float MaxLongitude = 180f;
22+
private float MaxLatitude = 90f;
23+
24+
private float metersPerLat;
25+
private float metersPerLon;
26+
#endregion
27+
28+
void Update(){
29+
HandleLocation();
30+
}
31+
32+
33+
#region Instance Functions
34+
public void FindMetersPerLat(float lat) // Compute lengths of degrees
35+
{
36+
float m1 = 1000f; // reducing the gloabe equatorail diameter, original : 111132.92f; // latitude calculation term 1
37+
float m2 = -559.82f; // latitude calculation term 2
38+
float m3 = 1.175f; // latitude calculation term 3
39+
float m4 = -0.0023f; // latitude calculation term 4
40+
float p1 = 1000f; // reducing the globe polar diameter, original : 111412.84f; // longitude calculation term 1
41+
float p2 = -93.5f; // longitude calculation term 2
42+
float p3 = 0.118f; // longitude calculation term 3
43+
44+
lat = lat * Mathf.Deg2Rad;
45+
46+
// Calculate the length of a degree of latitude and longitude in meters
47+
metersPerLat = m1 + (m2 * Mathf.Cos(2 * (float)lat)) + (m3 * Mathf.Cos(4 * (float)lat)) + (m4 * Mathf.Cos(6 * (float)lat));
48+
metersPerLon = (p1 * Mathf.Cos((float)lat)) + (p2 * Mathf.Cos(3 * (float)lat)) + (p3 * Mathf.Cos(5 * (float)lat));
49+
}
50+
51+
public Vector3 ConvertGPStoUCS(Vector2 gps)
52+
{
53+
FindMetersPerLat(_LatOrigin);
54+
float zPosition = metersPerLat * (gps.x - _LatOrigin); //Calc current lat
55+
float xPosition = metersPerLon * (gps.y - _LonOrigin); //Calc current lat
56+
return new Vector3((float)xPosition, 0, (float)zPosition);
57+
}
58+
59+
public Vector2 ConvertUCStoGPS(Vector3 position)
60+
{
61+
FindMetersPerLat(_LatOrigin);
62+
Vector2 geoLocation = new Vector2(0,0);
63+
geoLocation.x = (_LatOrigin + (position.z)/metersPerLat); //Calc current lat
64+
geoLocation.y = (_LonOrigin + (position.x)/metersPerLon); //Calc current lon
65+
return geoLocation;
66+
}
67+
68+
69+
/// <summary>
70+
/// Provides the location of the Aircraft in 3D coordinate system
71+
/// </summary>
72+
void HandleLocation()
73+
{
74+
//future functionality to provide the xyz location of the plane
75+
Vector3 currentLocation = rb.position;
76+
Vector2 latlong = ConvertUCStoGPS(currentLocation);
77+
// Debug.Log(latlong);
78+
float normalizedLatitude = latlong.x/MaxLatitude;
79+
float normalizedLongitude = latlong.y/MaxLongitude;
80+
// Add location to static function
81+
StaticOutputSchema.Latitude = normalizedLatitude;
82+
StaticOutputSchema.Longitude = normalizedLongitude;
83+
}
84+
#endregion
85+
}
86+
}

Assets/AirplanePhysics/Code/Level/GPSEncoder.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/AirplanePhysics/Code/Level/LevelControl.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,30 @@ void Update()
2121
StaticLevelSchema.LevelReload = false;
2222
}
2323
}
24+
2425
/// <summary>
2526
/// Reset the level to startover
2627
/// </summary>
2728
public void RestartLevel() //Restarts the level
2829
{
2930
SceneManager.LoadScene(SceneManager.GetActiveScene().name);
3031
}
32+
33+
/// <summary>
34+
/// Function to quit the application from Python API
35+
/// To be added in v0.2.0
36+
/// </summary>
37+
void applicationQuit()
38+
{
39+
#if UNITY_EDITOR
40+
UnityEditor.EditorApplication.isPlaying = false;
41+
#elif UNITY_WEBPLAYER
42+
Application.OpenURL(webplayerQuitURL);
43+
#else
44+
Application.Quit();
45+
#endif
46+
}
47+
3148
}
3249
}
3350

Assets/AirplanePhysics/Code/Level/Sun.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public class Sun : MonoBehaviour
2828
int minutes;
2929

3030
DateTime time;
31-
Light light;
31+
new Light light;
3232

3333
[SerializeField]
3434
float timeSpeed = 1;

Assets/AirplanePhysics/Code/Scripts/Audio/AC_Airplane_Audio.cs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,16 +56,19 @@ void Update()
5656
/// Switching audio as per the Input/Output from communicator
5757
/// </summary>
5858
#region IOSwitch
59-
bool enableAudio = StaticUIAudioSchema.EnableAudio;
60-
if(enableAudio != currentEnableAudio)
59+
60+
bool isActive = StaticAudioSchema.IsActive;
61+
if(isActive)
6162
{
63+
bool enableAudio = StaticAudioSchema.EnableAudio;
6264
idleSource.enabled = enableAudio;
6365
fullThrottleSource.enabled = enableAudio;
6466
currentEnableAudio = enableAudio;
6567
//logging
66-
string logString = "Audio set to : "+enableAudio;
68+
string logString = " Audio set to : "+enableAudio;
69+
StaticLogger.Log = logString;
6770
Debug.unityLogger.Log(logString);
68-
StaticLogger.Log += logString;
71+
StaticAudioSchema.IsActive = false;
6972
}
7073
#endregion
7174

Assets/AirplanePhysics/Code/Scripts/Cameras/AC_Airplane_CameraController.cs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,11 +125,16 @@ void Update()
125125
bool isCapture = StaticCameraSchema.IsCapture;
126126
int captureWidth = StaticCameraSchema.CaptureWidth;
127127
int captureHeight = StaticCameraSchema.CaptureHeight;
128-
string inputControlType = StaticCameraSchema.InputControlType;
129-
if (inputControlType=="Code" && activeCamera != curentCameraIndex)
128+
bool isActive = StaticCameraSchema.IsActive;
129+
if (isActive)
130130
{
131+
curentCameraIndex = activeCamera;
131132
selectCamera(activeCamera);
132133
CreateCamera();
134+
string logString = System.String.Format("Active scene camera - {0} Capture camera - {1} Width - {2} Height - {3}: ",curentCameraIndex, currentCaprtureCamera, captureWidth, captureHeight);
135+
StaticLogger.Log = logString;
136+
Debug.unityLogger.Log(logString);
137+
StaticCameraSchema.IsActive = false;
133138
}
134139

135140
if (isCapture)
@@ -144,8 +149,8 @@ void Update()
144149
ResetAllCaptureCam(capturePasses);
145150
currentCaprtureCamera = captureCamera;
146151
string logString = System.String.Format("Active scene camera - {0} Capture camera - {1} Width - {2} Height - {3}: ",curentCameraIndex, currentCaprtureCamera, captureWidth, captureHeight);
152+
StaticLogger.Log = logString;
147153
Debug.unityLogger.Log(logString);
148-
StaticLogger.Log += logString;
149154
}
150155
OnCameraChange(cameras[currentCaprtureCamera]);// 1 indicate the outside camera
151156
OnSceneChange();

Assets/AirplanePhysics/Code/Scripts/Communicator/InputHandle.cs

Lines changed: 35 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,8 @@ public void ParseInput(JObject inputJson)
6161
#region Camera
6262
else if (MsgType=="Camera") // if operation type is transaction
6363
{
64-
6564
//input type
66-
string inputControlType = inputJson["InputControlType"].ToString();
65+
bool isActive = bool.Parse(inputJson["IsActive"].ToString());
6766
//Scene Camera
6867
int activeCamera = int.Parse(inputJson["ActiveCamera"].ToString());
6968
bool isCapture = bool.Parse(inputJson["IsCapture"].ToString());
@@ -75,7 +74,7 @@ public void ParseInput(JObject inputJson)
7574
//primary key
7675
StaticCameraSchema.MsgType = "Camera";
7776
// Camrera control
78-
StaticCameraSchema.InputControlType = inputControlType;
77+
StaticCameraSchema.IsActive = isActive;
7978
StaticCameraSchema.ActiveCamera = activeCamera;
8079
// which screen to capture
8180
StaticCameraSchema.IsCapture = isCapture;
@@ -142,25 +141,40 @@ public void ParseInput(JObject inputJson)
142141
}
143142
#endregion
144143

145-
#region UIAudio
146-
else if (MsgType=="UIAudio") // if operation type is transaction
144+
#region Audio
145+
else if (MsgType=="Audio") // if operation type is transaction
147146
{
148147
//input type
149-
string inputControlType = inputJson["InputControlType"].ToString();
150-
bool showUIElements = bool.Parse(inputJson["ShowUIElements"].ToString());
148+
bool isActive = bool.Parse(inputJson["IsActive"].ToString());
151149
bool enableAudio = bool.Parse(inputJson["EnableAudio"].ToString());
152150

153151
//primary key
154-
StaticUIAudioSchema.MsgType = "UIAudio";
152+
StaticAudioSchema.MsgType = "Audio";
155153
// Camrera control
156-
StaticCameraSchema.InputControlType = inputControlType;
157-
//set if clouds are enabled
158-
StaticUIAudioSchema.ShowUIElements = showUIElements;
154+
StaticAudioSchema.IsActive = isActive;
159155
//set if fog ia enabled
160-
StaticUIAudioSchema.EnableAudio =enableAudio;
156+
StaticAudioSchema.EnableAudio =enableAudio;
161157
}
162158
#endregion
163159

160+
#region UI
161+
else if (MsgType=="UI") // if operation type is transaction
162+
{
163+
//input type
164+
bool isActive = bool.Parse(inputJson["IsActive"].ToString());
165+
bool showUIElements = bool.Parse(inputJson["ShowUIElements"].ToString());
166+
167+
//primary key
168+
StaticUISchema.MsgType = "UI";
169+
// Camrera control
170+
StaticUISchema.IsActive = isActive;
171+
//set if clouds are enabled
172+
StaticUISchema.ShowUIElements = showUIElements;
173+
}
174+
#endregion
175+
176+
177+
164178
#region Lidar
165179
else if (MsgType=="Lidar") // if operation type is transaction
166180
{
@@ -191,6 +205,15 @@ public void ParseInput(JObject inputJson)
191205
}
192206
#endregion
193207

208+
// gived output if called
209+
#region Output
210+
else if (MsgType=="Output") // if operation type is transaction
211+
{
212+
// Do nothing output API will receive output
213+
}
214+
#endregion
215+
216+
194217

195218
}
196219

0 commit comments

Comments
 (0)