mirror of
https://github.com/Mukheem/TwinTurbine.git
synced 2025-05-05 12:00:36 +02:00
Merge pull request #6 from Mukheem/Fixing_Rotation_issue
Fixing rotation issue
This commit is contained in:
commit
af1f18f463
Assets
SharedSpatialAnchors
Wind_Turbine/Scripts
@ -1532,7 +1532,7 @@ PrefabInstance:
|
|||||||
objectReference: {fileID: 1160440965950818012}
|
objectReference: {fileID: 1160440965950818012}
|
||||||
- target: {fileID: 4293156749170067433, guid: ebcaad662ef2ae14ca92fbcd7a67ee56, type: 3}
|
- target: {fileID: 4293156749170067433, guid: ebcaad662ef2ae14ca92fbcd7a67ee56, type: 3}
|
||||||
propertyPath: _whenSelect.m_PersistentCalls.m_Calls.Array.data[0].m_MethodName
|
propertyPath: _whenSelect.m_PersistentCalls.m_Calls.Array.data[0].m_MethodName
|
||||||
value: RPC_EmergencyButtonClick
|
value: emergencyButtonClick
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 4293156749170067433, guid: ebcaad662ef2ae14ca92fbcd7a67ee56, type: 3}
|
- target: {fileID: 4293156749170067433, guid: ebcaad662ef2ae14ca92fbcd7a67ee56, type: 3}
|
||||||
propertyPath: _whenSelect.m_PersistentCalls.m_Calls.Array.data[0].m_TargetAssemblyTypeName
|
propertyPath: _whenSelect.m_PersistentCalls.m_Calls.Array.data[0].m_TargetAssemblyTypeName
|
||||||
|
@ -8,7 +8,7 @@ using TMPro;
|
|||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.Networking;
|
using UnityEngine.Networking;
|
||||||
using WebSocketSharp;
|
using WebSocketSharp;
|
||||||
using System.Linq;
|
|
||||||
//https://github.com/GlitchEnzo/NuGetForUnity
|
//https://github.com/GlitchEnzo/NuGetForUnity
|
||||||
// Creating the data structure according to the expected Json
|
// Creating the data structure according to the expected Json
|
||||||
[Serializable]
|
[Serializable]
|
||||||
@ -47,7 +47,7 @@ public class API : MonoBehaviourPunCallbacks, IPunObservable
|
|||||||
public TextMeshProUGUI windSpeedValue;
|
public TextMeshProUGUI windSpeedValue;
|
||||||
private float LatestT;
|
private float LatestT;
|
||||||
public float latestWD = 0.0f;
|
public float latestWD = 0.0f;
|
||||||
public float latestWS;
|
public float latestWS = 0.01f;
|
||||||
private String windDirectionInDirectionTerms;
|
private String windDirectionInDirectionTerms;
|
||||||
private string unit;
|
private string unit;
|
||||||
private GameObject webSocketController;
|
private GameObject webSocketController;
|
||||||
@ -58,9 +58,7 @@ public class API : MonoBehaviourPunCallbacks, IPunObservable
|
|||||||
private AudioController audioControllerScript;
|
private AudioController audioControllerScript;
|
||||||
public bool turn_WT_on_Y_Axis = false;
|
public bool turn_WT_on_Y_Axis = false;
|
||||||
|
|
||||||
public GameObject windTurbineWithMap;
|
|
||||||
private GameObject windTurbineController;
|
|
||||||
private Windturbine windTurbineControllerScript;
|
|
||||||
|
|
||||||
void Start()
|
void Start()
|
||||||
{
|
{
|
||||||
@ -68,7 +66,7 @@ public class API : MonoBehaviourPunCallbacks, IPunObservable
|
|||||||
//TestFromJsonToData();
|
//TestFromJsonToData();
|
||||||
//EmergencyButtonClick();
|
//EmergencyButtonClick();
|
||||||
photonView = PhotonView.Get(this);
|
photonView = PhotonView.Get(this);
|
||||||
photonView.RPC("RPC_EmergencyButtonClick", RpcTarget.All);
|
photonView.RPC("RPC_EmergencyButtonClick", RpcTarget.All,false,0.0f);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -89,23 +87,33 @@ public class API : MonoBehaviourPunCallbacks, IPunObservable
|
|||||||
|
|
||||||
public void OnButtonClick()
|
public void OnButtonClick()
|
||||||
{
|
{
|
||||||
|
webSocketController = GameObject.FindGameObjectWithTag("WebController");
|
||||||
|
webSocketControllerScript = webSocketController.GetComponent<WebSocketController>();
|
||||||
webSocketControllerScript.ConnectWithESP32();
|
webSocketControllerScript.ConnectWithESP32();
|
||||||
StartCoroutine(GetText());
|
StartCoroutine(GetText());
|
||||||
|
|
||||||
|
avatar = GameObject.FindGameObjectWithTag("Avatar");
|
||||||
|
audioControllerScript = avatar.GetComponent<AudioController>();
|
||||||
audioControllerScript.fn_call_AudioNarration2();
|
audioControllerScript.fn_call_AudioNarration2();
|
||||||
|
Debug.Log("Button is Clicked");
|
||||||
}
|
}
|
||||||
|
public void emergencyButtonClick()
|
||||||
[PunRPC]
|
|
||||||
public void RPC_EmergencyButtonClick()
|
|
||||||
{
|
{
|
||||||
isButtonPressed = false;
|
photonView = PhotonView.Get(this);
|
||||||
|
photonView.RPC("RPC_EmergencyButtonClick", RpcTarget.All, false, 0.0f);
|
||||||
|
}
|
||||||
|
[PunRPC]
|
||||||
|
public void RPC_EmergencyButtonClick(bool isButtonPressedVal, float latestWS_val)
|
||||||
|
{
|
||||||
|
isButtonPressed = isButtonPressedVal;
|
||||||
|
latestWS = latestWS_val;
|
||||||
|
|
||||||
loc.SetText("----");
|
loc.SetText("----");
|
||||||
windDirValue.SetText("----");
|
windDirValue.SetText("----");
|
||||||
temperatureValue.SetText("----");
|
temperatureValue.SetText("----");
|
||||||
voltageValue.SetText("----");
|
voltageValue.SetText("----");
|
||||||
windSpeedValue.SetText("----");
|
windSpeedValue.SetText("----");
|
||||||
|
|
||||||
}
|
}
|
||||||
IEnumerator GetText()
|
IEnumerator GetText()
|
||||||
{
|
{
|
||||||
@ -178,36 +186,22 @@ public void ExtractDataFromJson(string json)
|
|||||||
Debug.Log("Latest WS is - "+latestWS);
|
Debug.Log("Latest WS is - "+latestWS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
photonView = PhotonView.Get(this);
|
photonView = PhotonView.Get(this);
|
||||||
photonView.RPC("RPC_GreenButtonClick", RpcTarget.All,windDirectionInDirectionTerms,LatestT+" C","Kista",latestWS+" m/s",true);
|
photonView.RPC("RPC_GreenButtonClick", RpcTarget.All,windDirectionInDirectionTerms,LatestT+" C","Kista",latestWS+" m/s",true,latestWD,latestWS);
|
||||||
}
|
}
|
||||||
|
|
||||||
[PunRPC]
|
[PunRPC]
|
||||||
public void RPC_GreenButtonClick(String windDirection,String locationTemperature,String location,String windSpeed,bool turn_WT_on_Y_Axis_val)
|
public void RPC_GreenButtonClick(String windDirection,String locationTemperature,String location,String windSpeed,bool turn_WT_on_Y_Axis_val,float latestWD_val, float latestWS_val)
|
||||||
{
|
{
|
||||||
windTurbineWithMap = GameObject.FindGameObjectWithTag("Wind_Turbine_withMap");
|
|
||||||
webSocketController = GameObject.FindGameObjectWithTag("WebController");
|
latestWD = latestWD_val; // Just for RPC purposes
|
||||||
webSocketControllerScript = webSocketController.GetComponent<WebSocketController>();
|
latestWS = latestWS_val; // Just for RPC purposes
|
||||||
avatar = GameObject.FindGameObjectWithTag("Avatar");
|
|
||||||
audioControllerScript = avatar.GetComponent<AudioController>();
|
|
||||||
|
|
||||||
|
|
||||||
windTurbineController = windTurbineWithMap.transform.GetChild(0).gameObject;
|
|
||||||
windTurbineControllerScript = windTurbineController.GetComponent<Windturbine>();
|
|
||||||
|
|
||||||
|
|
||||||
Debug.Log("Latest WS is - " + windSpeed);
|
|
||||||
windDirValue.SetText(windDirection);
|
windDirValue.SetText(windDirection);
|
||||||
temperatureValue.SetText(locationTemperature);
|
temperatureValue.SetText(locationTemperature);
|
||||||
loc.SetText(location);
|
loc.SetText(location);
|
||||||
windSpeedValue.SetText(windSpeed);
|
windSpeedValue.SetText(windSpeed);
|
||||||
turn_WT_on_Y_Axis = turn_WT_on_Y_Axis_val; // flag set to true so that WT can rotate on it's Y axis.
|
turn_WT_on_Y_Axis = turn_WT_on_Y_Axis_val; // flag set to true so that WT can rotate on it's Y axis.
|
||||||
|
|
||||||
|
|
||||||
Debug.Log("Flag value to turn the Y Axis:" + turn_WT_on_Y_Axis);
|
|
||||||
|
|
||||||
windTurbineControllerScript.WT_TurnOnIts_Y_Axis();
|
|
||||||
}
|
}
|
||||||
[PunRPC]
|
[PunRPC]
|
||||||
public void RPC_VoltageUpdate(String voltageGenerated)
|
public void RPC_VoltageUpdate(String voltageGenerated)
|
||||||
@ -231,10 +225,12 @@ public void ExtractDataFromJson(string json)
|
|||||||
if (stream.IsWriting)
|
if (stream.IsWriting)
|
||||||
{
|
{
|
||||||
stream.SendNext(turn_WT_on_Y_Axis);
|
stream.SendNext(turn_WT_on_Y_Axis);
|
||||||
|
stream.SendNext(isButtonPressed);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
turn_WT_on_Y_Axis = (bool)stream.ReceiveNext();
|
turn_WT_on_Y_Axis = (bool)stream.ReceiveNext();
|
||||||
|
isButtonPressed = (bool)stream.ReceiveNext();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -42,10 +42,10 @@ public class WebSocketController : MonoBehaviour
|
|||||||
};
|
};
|
||||||
ws.OnMessage += (sender, e) =>
|
ws.OnMessage += (sender, e) =>
|
||||||
{
|
{
|
||||||
Debug.Log("Received message: " + e.Data);
|
//Debug.Log("Received message: " + e.Data);
|
||||||
//Debug.Log();
|
//Debug.Log();
|
||||||
voltageValue = e.Data.Split(':')[1].ToString();
|
voltageValue = e.Data.Split(':')[1].ToString();
|
||||||
Debug.Log(voltageValue);
|
// Debug.Log(voltageValue);
|
||||||
//Voltage:180.0
|
//Voltage:180.0
|
||||||
if (e.Data.Equals("Start Narration", StringComparison.OrdinalIgnoreCase)){
|
if (e.Data.Equals("Start Narration", StringComparison.OrdinalIgnoreCase)){
|
||||||
// narrationControllerScript.startNarration = true;
|
// narrationControllerScript.startNarration = true;
|
||||||
|
@ -37,11 +37,13 @@ public class Windturbine : MonoBehaviour
|
|||||||
photonView = PhotonView.Get(this);
|
photonView = PhotonView.Get(this);
|
||||||
photonView.RPC("RPC_WT_Turn", RpcTarget.All);
|
photonView.RPC("RPC_WT_Turn", RpcTarget.All);
|
||||||
|
|
||||||
if(apiScript.turn_WT_on_Y_Axis)
|
if(apiScript.turn_WT_on_Y_Axis) //From Base class
|
||||||
{
|
{
|
||||||
|
Debug.Log("FLAG IS TRUE");
|
||||||
WT_TurnOnIts_Y_Axis();
|
WT_TurnOnIts_Y_Axis();
|
||||||
apiScript.turn_WT_on_Y_Axis = false;
|
apiScript.turn_WT_on_Y_Axis = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Method to turn the 'Turbine blades' as per the SPEED of wind that is fetched from API
|
// Method to turn the 'Turbine blades' as per the SPEED of wind that is fetched from API
|
||||||
@ -72,6 +74,7 @@ public class Windturbine : MonoBehaviour
|
|||||||
// Method to turn the 'Turbine' on its Y axis as per the DIRECTION of wind that is fetched from API
|
// Method to turn the 'Turbine' on its Y axis as per the DIRECTION of wind that is fetched from API
|
||||||
IEnumerator RotateObject(float startAngle, float endAngle, float duration)
|
IEnumerator RotateObject(float startAngle, float endAngle, float duration)
|
||||||
{
|
{
|
||||||
|
Debug.Log("Rotate On it's Y-Axis- COROUTINE");
|
||||||
yield return new WaitForSeconds(2f);
|
yield return new WaitForSeconds(2f);
|
||||||
float timeElapsed = 0f;
|
float timeElapsed = 0f;
|
||||||
Quaternion startRotation = Quaternion.Euler(0, startAngle, 0);
|
Quaternion startRotation = Quaternion.Euler(0, startAngle, 0);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user