Skip to content

Commit

Permalink
Merge pull request #15 from snlpatel001213/v0.0.6
Browse files Browse the repository at this point in the history
V0.0.6
  • Loading branch information
snlpatel001213 authored Feb 2, 2022
2 parents 09906b1 + fbdb835 commit 0dac199
Show file tree
Hide file tree
Showing 484 changed files with 22,559 additions and 5,817 deletions.
17 changes: 7 additions & 10 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
{
"files.exclude":
{
"**/.DS_Store":true,
"**/.git":true,
"**/.gitignore":true,
"**/.gitignore":false,
"**/.gitmodules":true,
"**/*.booproj":true,
"**/*.pidb":true,
Expand All @@ -17,11 +17,6 @@
"**/*.mid":true,
"**/*.midi":true,
"**/*.wav":true,
"**/*.gif":true,
"**/*.ico":true,
"**/*.jpg":true,
"**/*.jpeg":true,
"**/*.png":true,
"**/*.psd":true,
"**/*.tga":true,
"**/*.tif":true,
Expand All @@ -36,21 +31,23 @@
"**/*.MA":true,
"**/*.obj":true,
"**/*.OBJ":true,
"**/*.asset":true,
"**/*.cubemap":true,
"**/*.flare":true,
"**/*.mat":true,
"**/*.meta":true,
"**/*.prefab":true,
"**/*.unity":true,
"**/*.unity":false,
"build/":true,
"Build/":true,
"Build/":false,
"Library/":true,
"library/":true,
"obj/":true,
"Obj/":true,
"ProjectSettings/":true,
"temp/":true,
"Temp/":true
},
"editor.codeActionsOnSave": {
"source.organizeImports": true
}
}
86 changes: 86 additions & 0 deletions Assets/AirplanePhysics/Code/Level/GPSEncoder.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
//Copyright 2013 MichaelTaylor3D
//www.michaeltaylor3d.com
using UnityEngine;
using Communicator;
namespace AirControl
{

//Copyright 2013 MichaelTaylor3D
//www.michaeltaylor3d.com
//https://github.com/MichaelTaylor3D/UnityGPSConverter/

public class GPSEncoder : MonoBehaviour
{

#region Instance Variables
public Rigidbody rb;

private Vector2 _localOrigin = Vector2.zero;
private float _LatOrigin { get{ return _localOrigin.x; }}
private float _LonOrigin { get{ return _localOrigin.y; }}
private float MaxLongitude = 180f;
private float MaxLatitude = 90f;

private float metersPerLat;
private float metersPerLon;
#endregion

void Update(){
HandleLocation();
}


#region Instance Functions
public void FindMetersPerLat(float lat) // Compute lengths of degrees
{
float m1 = 1000f; // reducing the gloabe equatorail diameter, original : 111132.92f; // latitude calculation term 1
float m2 = -559.82f; // latitude calculation term 2
float m3 = 1.175f; // latitude calculation term 3
float m4 = -0.0023f; // latitude calculation term 4
float p1 = 1000f; // reducing the globe polar diameter, original : 111412.84f; // longitude calculation term 1
float p2 = -93.5f; // longitude calculation term 2
float p3 = 0.118f; // longitude calculation term 3

lat = lat * Mathf.Deg2Rad;

// Calculate the length of a degree of latitude and longitude in meters
metersPerLat = m1 + (m2 * Mathf.Cos(2 * (float)lat)) + (m3 * Mathf.Cos(4 * (float)lat)) + (m4 * Mathf.Cos(6 * (float)lat));
metersPerLon = (p1 * Mathf.Cos((float)lat)) + (p2 * Mathf.Cos(3 * (float)lat)) + (p3 * Mathf.Cos(5 * (float)lat));
}

public Vector3 ConvertGPStoUCS(Vector2 gps)
{
FindMetersPerLat(_LatOrigin);
float zPosition = metersPerLat * (gps.x - _LatOrigin); //Calc current lat
float xPosition = metersPerLon * (gps.y - _LonOrigin); //Calc current lat
return new Vector3((float)xPosition, 0, (float)zPosition);
}

public Vector2 ConvertUCStoGPS(Vector3 position)
{
FindMetersPerLat(_LatOrigin);
Vector2 geoLocation = new Vector2(0,0);
geoLocation.x = (_LatOrigin + (position.z)/metersPerLat); //Calc current lat
geoLocation.y = (_LonOrigin + (position.x)/metersPerLon); //Calc current lon
return geoLocation;
}


/// <summary>
/// Provides the location of the Aircraft in 3D coordinate system
/// </summary>
void HandleLocation()
{
//future functionality to provide the xyz location of the plane
Vector3 currentLocation = rb.position;
Vector2 latlong = ConvertUCStoGPS(currentLocation);
// Debug.Log(latlong);
float normalizedLatitude = latlong.x/MaxLatitude;
float normalizedLongitude = latlong.y/MaxLongitude;
// Add location to static function
StaticOutputSchema.Latitude = normalizedLatitude;
StaticOutputSchema.Longitude = normalizedLongitude;
}
#endregion
}
}
11 changes: 11 additions & 0 deletions Assets/AirplanePhysics/Code/Level/GPSEncoder.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions Assets/AirplanePhysics/Code/Level/LevelControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,30 @@ void Update()
StaticLevelSchema.LevelReload = false;
}
}

/// <summary>
/// Reset the level to startover
/// </summary>
public void RestartLevel() //Restarts the level
{
SceneManager.LoadScene(SceneManager.GetActiveScene().name);
}

/// <summary>
/// Function to quit the application from Python API
/// To be added in v0.2.0
/// </summary>
void applicationQuit()
{
#if UNITY_EDITOR
UnityEditor.EditorApplication.isPlaying = false;
#elif UNITY_WEBPLAYER
Application.OpenURL(webplayerQuitURL);
#else
Application.Quit();
#endif
}

}
}

2 changes: 1 addition & 1 deletion Assets/AirplanePhysics/Code/Level/Sun.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class Sun : MonoBehaviour
int minutes;

DateTime time;
Light light;
new Light light;

[SerializeField]
float timeSpeed = 1;
Expand Down
11 changes: 7 additions & 4 deletions Assets/AirplanePhysics/Code/Scripts/Audio/AC_Airplane_Audio.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,19 @@ void Update()
/// Switching audio as per the Input/Output from communicator
/// </summary>
#region IOSwitch
bool enableAudio = StaticUIAudioSchema.EnableAudio;
if(enableAudio != currentEnableAudio)

bool isActive = StaticAudioSchema.IsActive;
if(isActive)
{
bool enableAudio = StaticAudioSchema.EnableAudio;
idleSource.enabled = enableAudio;
fullThrottleSource.enabled = enableAudio;
currentEnableAudio = enableAudio;
//logging
string logString = "Audio set to : "+enableAudio;
string logString = " Audio set to : "+enableAudio;
StaticLogger.Log = logString;
Debug.unityLogger.Log(logString);
StaticLogger.Log += logString;
StaticAudioSchema.IsActive = false;
}
#endregion

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,16 @@ void Update()
bool isCapture = StaticCameraSchema.IsCapture;
int captureWidth = StaticCameraSchema.CaptureWidth;
int captureHeight = StaticCameraSchema.CaptureHeight;
string inputControlType = StaticCameraSchema.InputControlType;
if (inputControlType=="Code" && activeCamera != curentCameraIndex)
bool isActive = StaticCameraSchema.IsActive;
if (isActive)
{
curentCameraIndex = activeCamera;
selectCamera(activeCamera);
CreateCamera();
string logString = System.String.Format("Active scene camera - {0} Capture camera - {1} Width - {2} Height - {3}: ",curentCameraIndex, currentCaprtureCamera, captureWidth, captureHeight);
StaticLogger.Log = logString;
Debug.unityLogger.Log(logString);
StaticCameraSchema.IsActive = false;
}

if (isCapture)
Expand All @@ -144,8 +149,8 @@ void Update()
ResetAllCaptureCam(capturePasses);
currentCaprtureCamera = captureCamera;
string logString = System.String.Format("Active scene camera - {0} Capture camera - {1} Width - {2} Height - {3}: ",curentCameraIndex, currentCaprtureCamera, captureWidth, captureHeight);
StaticLogger.Log = logString;
Debug.unityLogger.Log(logString);
StaticLogger.Log += logString;
}
OnCameraChange(cameras[currentCaprtureCamera]);// 1 indicate the outside camera
OnSceneChange();
Expand Down
47 changes: 35 additions & 12 deletions Assets/AirplanePhysics/Code/Scripts/Communicator/InputHandle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,8 @@ public void ParseInput(JObject inputJson)
#region Camera
else if (MsgType=="Camera") // if operation type is transaction
{

//input type
string inputControlType = inputJson["InputControlType"].ToString();
bool isActive = bool.Parse(inputJson["IsActive"].ToString());
//Scene Camera
int activeCamera = int.Parse(inputJson["ActiveCamera"].ToString());
bool isCapture = bool.Parse(inputJson["IsCapture"].ToString());
Expand All @@ -75,7 +74,7 @@ public void ParseInput(JObject inputJson)
//primary key
StaticCameraSchema.MsgType = "Camera";
// Camrera control
StaticCameraSchema.InputControlType = inputControlType;
StaticCameraSchema.IsActive = isActive;
StaticCameraSchema.ActiveCamera = activeCamera;
// which screen to capture
StaticCameraSchema.IsCapture = isCapture;
Expand Down Expand Up @@ -142,25 +141,40 @@ public void ParseInput(JObject inputJson)
}
#endregion

#region UIAudio
else if (MsgType=="UIAudio") // if operation type is transaction
#region Audio
else if (MsgType=="Audio") // if operation type is transaction
{
//input type
string inputControlType = inputJson["InputControlType"].ToString();
bool showUIElements = bool.Parse(inputJson["ShowUIElements"].ToString());
bool isActive = bool.Parse(inputJson["IsActive"].ToString());
bool enableAudio = bool.Parse(inputJson["EnableAudio"].ToString());

//primary key
StaticUIAudioSchema.MsgType = "UIAudio";
StaticAudioSchema.MsgType = "Audio";
// Camrera control
StaticCameraSchema.InputControlType = inputControlType;
//set if clouds are enabled
StaticUIAudioSchema.ShowUIElements = showUIElements;
StaticAudioSchema.IsActive = isActive;
//set if fog ia enabled
StaticUIAudioSchema.EnableAudio =enableAudio;
StaticAudioSchema.EnableAudio =enableAudio;
}
#endregion

#region UI
else if (MsgType=="UI") // if operation type is transaction
{
//input type
bool isActive = bool.Parse(inputJson["IsActive"].ToString());
bool showUIElements = bool.Parse(inputJson["ShowUIElements"].ToString());

//primary key
StaticUISchema.MsgType = "UI";
// Camrera control
StaticUISchema.IsActive = isActive;
//set if clouds are enabled
StaticUISchema.ShowUIElements = showUIElements;
}
#endregion



#region Lidar
else if (MsgType=="Lidar") // if operation type is transaction
{
Expand Down Expand Up @@ -191,6 +205,15 @@ public void ParseInput(JObject inputJson)
}
#endregion

// gived output if called
#region Output
else if (MsgType=="Output") // if operation type is transaction
{
// Do nothing output API will receive output
}
#endregion



}

Expand Down
Loading

0 comments on commit 0dac199

Please sign in to comment.