Commit 41a74315 authored by ATREVI Dieudonne's avatar ATREVI Dieudonne
Browse files

Merge branch 'dev' of https://gitlab.inria.fr/OCSR/chaos into #24_real_menu

- Update interface
parents 579cf50c 3310afa5
This diff is collapsed.
......@@ -60,7 +60,6 @@ public class LoadEnv : MonoBehaviour
/// </summary>
void Start()
{
Debug.Log("Load Env");
avatars = new List<GameObject>();
cam_Rec = cam.GetComponent<CamRecorder>();
cam_Movement = cam.GetComponent<CamMvt>();
......
......@@ -257,12 +257,18 @@ public class MenuManager : MonoBehaviour
public void showCameraMovPanel(){
cameraMovPanel.SetActive(true);
cameraMovPanel.transform.Find("cameraType").GetComponent<Dropdown>().value = ConfigReader.camType;
cameraMovPanel.transform.Find("Lookat").GetComponent<Toggle>().isOn = ConfigReader.lookAtAgent;
cameraMovPanel.transform.Find("LookAgentID").GetComponent<InputField>().text = ConfigReader.camLookAtTarget.ToString();
cameraMovPanel.transform.Find("Followat").GetComponent<Toggle>().isOn = ConfigReader.followAgent;
cameraMovPanel.transform.Find("FollowAgentID").GetComponent<InputField>().text = ConfigReader.camFollowTarget.ToString();
cameraMovPanel.transform.Find("FollowX").GetComponent<Toggle>().isOn = ConfigReader.camFollowOnX;
cameraMovPanel.transform.Find("FollowY").GetComponent<Toggle>().isOn = ConfigReader.camFollowOnY;
Dropdown camSelect = cameraMovPanel.transform.Find("cameraType").GetComponent<Dropdown>();
if(camSelect.options[camSelect.value].text == "Look_At")
cameraMovPanel.transform.Find("AgentID").GetComponent<InputField>().text = ConfigReader.camLookAtTarget.ToString();
else if(camSelect.options[camSelect.value].text == "Follow")
cameraMovPanel.transform.Find("AgentID").GetComponent<InputField>().text = ConfigReader.camFollowTarget.ToString();
else
cameraMovPanel.transform.Find("AgentID").GetComponent<InputField>().text = "0";
cameraMovPanel.transform.Find("FollowX").GetComponent<Toggle>().isOn = ConfigReader.camFollowOnX;
cameraMovPanel.transform.Find("FollowY").GetComponent<Toggle>().isOn = ConfigReader.camFollowOnY;
cameraMovPanel.transform.Find("LockPerson").GetComponent<Toggle>().isOn = ConfigReader.camLockFirstPerson;
}
/// <summary>
......@@ -302,26 +308,19 @@ public class MenuManager : MonoBehaviour
/// </summary>
public void checkLookatToggleOnScene(){
GameObject PanelMovCamera = GameObject.Find("/controlCanvas/cameraMovPanel");
GameObject LookAgentIDtxt = GameObject.Find("/controlCanvas/cameraMovPanel/LookAgentIDtxt");
GameObject LookAgentID = GameObject.Find("/controlCanvas/cameraMovPanel/LookAgentID");
GameObject FollowAgentIDtxt = GameObject.Find("/controlCanvas/cameraMovPanel/FollowAgentIDtxt");
GameObject FollowAgentID = GameObject.Find("/controlCanvas/cameraMovPanel/FollowAgentID");
bool activateLookAt = PanelMovCamera.transform.Find("Lookat").GetComponent<Toggle>().isOn;
bool activateFollow = PanelMovCamera.transform.Find("Followat").GetComponent<Toggle>().isOn;
LookAgentIDtxt.SetActive(activateLookAt);
LookAgentID.SetActive(activateLookAt);
FollowAgentIDtxt.SetActive(activateFollow);
FollowAgentID.SetActive(activateFollow);
PanelMovCamera.transform.Find("FollowX").GetComponent<Toggle>().interactable = activateFollow;
PanelMovCamera.transform.Find("FollowY").GetComponent<Toggle>().interactable = activateFollow;
Dropdown camSelect = PanelMovCamera.transform.Find("cameraType").GetComponent<Dropdown>();
bool showLockFirstPerson = camSelect.options[camSelect.value].text == "First_Person" || camSelect.options[camSelect.value].text == "Torsum";
bool activateLookAt = camSelect.options[camSelect.value].text == "Look_At";
bool activateFollow = camSelect.options[camSelect.value].text == "Follow";
PanelMovCamera.transform.Find("LockPerson").GetComponent<Toggle>().interactable = showLockFirstPerson&&activateFollow;
PanelMovCamera.transform.Find("AgentID").GetComponent<InputField>().interactable = activateLookAt||activateFollow||showLockFirstPerson;
PanelMovCamera.transform.Find("FollowX").GetComponent<Toggle>().interactable = activateFollow;
PanelMovCamera.transform.Find("FollowY").GetComponent<Toggle>().interactable = activateFollow;
PanelMovCamera.transform.Find("LockPerson").GetComponent<Toggle>().interactable = showLockFirstPerson;
PanelMovCamera.transform.Find("SmoothView").GetComponent<Toggle>().interactable = showLockFirstPerson;
}
/// <summary>
......
......@@ -39,7 +39,6 @@ public class CamMvt : MonoBehaviour
#endregion
#region attributes
// Parameters interface
public GameObject panelMovCamera; // panel with the camera parameters on the interface
......@@ -84,12 +83,17 @@ public class CamMvt : MonoBehaviour
private Vector3 _position_follow; // the current follow position
private Vector3 _position_first_person; // the current first person position
private Vector3 _position_torsum; // the current torsum position
#endregion
//reset
public bool reset_active = false;
#endregion
// Use this for initialization
#region initialization functions
///--------------------------------------------
///----- initialization functions -------------
///--------------------------------------------
void Start()
{
panelMovCamera = GameObject.Find("/controlCanvas/cameraMovPanel");
......@@ -112,6 +116,14 @@ public class CamMvt : MonoBehaviour
// initialize the follow position with the starting camera position
_position_follow = transform.position;
}
#endregion
#region run time functions
///--------------------------------------------
///----- run - time functions -----------------
///--------------------------------------------
/// <summary>
/// Update the target of look at camera
/// </summary>
......@@ -158,20 +170,25 @@ public class CamMvt : MonoBehaviour
_previous_follow_Id = follow_Id;
}
}
/// <summary>
/// Reads the parameter of the Usear Interface at every frame
/// </summary>
public void readCameraMovParamOnScene()
{
activateLookAt = panelMovCamera.transform.Find("Lookat").GetComponent<Toggle>().isOn;
activateFollow = panelMovCamera.transform.Find("Followat").GetComponent<Toggle>().isOn;
lookAt_Id = int.Parse(panelMovCamera.transform.Find("LookAgentID").GetComponent<InputField>().text);
follow_Id = int.Parse(panelMovCamera.transform.Find("FollowAgentID").GetComponent<InputField>().text);
{
lookAt_Id = int.Parse(panelMovCamera.transform.Find("AgentID").GetComponent<InputField>().text);
follow_Id = int.Parse(panelMovCamera.transform.Find("AgentID").GetComponent<InputField>().text);
followOnX = panelMovCamera.transform.Find("FollowX").GetComponent<Toggle>().isOn;
followOnY = panelMovCamera.transform.Find("FollowY").GetComponent<Toggle>().isOn;
lockFirstPersonView = panelMovCamera.transform.Find("LockPerson").GetComponent<Toggle>().isOn;
//smoothFirstPersonView = panelMovCamera.transform.Find("smoothPerson").GetComponent<Toggle>().isOn;
smoothFirstPersonView = panelMovCamera.transform.Find("SmoothView").GetComponent<Toggle>().isOn;
}
//It detects changes in the Current Camera Mode and intialize the parameters accordingly
/// <summary>
/// It detects changes in the Current Camera Mode and intialize the parameters accordingly at every frame
/// </summary>
private void check_mode_changes_and_initialize()
{
if(current_camera_mode != camSelect.options[camSelect.value].text)
......@@ -188,25 +205,21 @@ public class CamMvt : MonoBehaviour
else if (current_camera_mode == FOLLOW)
{
activateFollow = false;
panelMovCamera.transform.Find("Followat").GetComponent<Toggle>().isOn = false;
}
else if (current_camera_mode == LOOK_AT)
{
activateLookAt = false;
panelMovCamera.transform.Find("Lookat").GetComponent<Toggle>().isOn = false;
}
else if (current_camera_mode == FIRST_PERSON)
{
activateFollow = false;
panelMovCamera.transform.Find("Followat").GetComponent<Toggle>().isOn = false;
}
else if (current_camera_mode == TORSUM)
{
activateFollow = false;
panelMovCamera.transform.Find("Followat").GetComponent<Toggle>().isOn = false;
}
//update
current_camera_mode = camSelect.options[camSelect.value].text;
......@@ -226,10 +239,9 @@ public class CamMvt : MonoBehaviour
if (follow_Id < 0 && list.Length > 0)
{
follow_Id = 0;
panelMovCamera.transform.Find("FollowAgentID").GetComponent<InputField>().text = follow_Id.ToString();
panelMovCamera.transform.Find("AgentID").GetComponent<InputField>().text = follow_Id.ToString();
}
activateFollow = true;
panelMovCamera.transform.Find("Followat").GetComponent<Toggle>().isOn = true;
//set default rotation
transform.eulerAngles = _default_rotation;
......@@ -241,10 +253,9 @@ public class CamMvt : MonoBehaviour
if (lookAt_Id < 0 && list.Length > 0)
{
lookAt_Id = 0;
panelMovCamera.transform.Find("LookAgentID").GetComponent<InputField>().text = lookAt_Id.ToString();
panelMovCamera.transform.Find("AgentID").GetComponent<InputField>().text = lookAt_Id.ToString();
}
activateLookAt = true;
panelMovCamera.transform.Find("Lookat").GetComponent<Toggle>().isOn = true;
//set default position and rotation
transform.eulerAngles = _default_rotation;
......@@ -258,10 +269,9 @@ public class CamMvt : MonoBehaviour
if (follow_Id < 0 && list.Length > 0)
{
follow_Id = 0;
panelMovCamera.transform.Find("FollowAgentID").GetComponent<InputField>().text = follow_Id.ToString();
panelMovCamera.transform.Find("AgentID").GetComponent<InputField>().text = follow_Id.ToString();
}
activateFollow = true;
panelMovCamera.transform.Find("Followat").GetComponent<Toggle>().isOn = true;
//set default rotation
update_follow_target();
......@@ -277,10 +287,9 @@ public class CamMvt : MonoBehaviour
if (follow_Id < 0 && list.Length > 0)
{
follow_Id = 0;
panelMovCamera.transform.Find("FollowAgentID").GetComponent<InputField>().text = follow_Id.ToString();
panelMovCamera.transform.Find("AgentID").GetComponent<InputField>().text = follow_Id.ToString();
}
activateFollow = true;
panelMovCamera.transform.Find("Followat").GetComponent<Toggle>().isOn = true;
//set default rotation
update_follow_target();
......@@ -291,8 +300,57 @@ public class CamMvt : MonoBehaviour
}
}
}
// Update is called once per frame
#endregion
#region events functions
///--------------------------------------------
///-------------- event functions -------------
///--------------------------------------------
public void reset_position()
{
reset_active = true;
}
/// <summary>
/// chek for events every frame
/// </summary>
private void check_for_events()
{
if(reset_active)
{
if (current_camera_mode == FREE_MOVMENT)
{
transform.eulerAngles = _default_rotation;
transform.position = _default_position;
}
if (current_camera_mode == FOLLOW)
{
transform.eulerAngles = _default_rotation;
}
if (current_camera_mode == LOOK_AT)
{
transform.eulerAngles = _default_rotation;
transform.position = _default_position;
}
if(current_camera_mode == FIRST_PERSON)
{
transform.forward = agent_reference_transform.forward;
}
if (current_camera_mode == TORSUM)
{
transform.forward = agent_reference_transform.forward;
}
reset_active = false;
}
}
#endregion
///--------------------------------------------
///---------------- main loop -----------------
///--------------------------------------------
void Update()
{
#region UPDATE VALUES
......@@ -301,6 +359,7 @@ public class CamMvt : MonoBehaviour
// update follow id
readCameraMovParamOnScene();
check_mode_changes_and_initialize();
check_for_events();
if (follow_Id != _previous_follow_Id && activateFollow)
{
......@@ -339,10 +398,17 @@ public class CamMvt : MonoBehaviour
#endregion
#region TRANSLATION
// --------------------------------
// TRANSLATION --------------------
// --------------------------------
if (current_camera_mode == DEFAULT)
{
transform.position = _default_position;
}
if(current_camera_mode == LOOK_AT)
{
transform.position = new Vector3(transform.position.x, _default_position.y, transform.position.z);
}
if (follow_Agent != null && activateFollow)
{
Vector3 delta = follow_Agent.transform.position - follow_LastPosition;
......@@ -359,8 +425,6 @@ public class CamMvt : MonoBehaviour
_position_torsum = agent_torsum_transform.position;
// --------------------------------
// TRANSLATION - FOLLOWING AN AGENT
if (current_camera_mode == FOLLOW)
{
......@@ -384,8 +448,11 @@ public class CamMvt : MonoBehaviour
#endregion
}
#region Additional Functions
//additional functions
///--------------------------------------------
///----- additional functions -----------------
///--------------------------------------------
/// <summary>
/// Find the head transform and return it
......
......@@ -29,7 +29,6 @@ using UnityEngine.UI;
using System.Collections.Generic;
using SFB;
/// <summary>
/// Static class used to set the simulation parameters from the interface.
/// </summary>
......
......@@ -8,7 +8,7 @@
<rotation x="0" y="0" z="0" />
</env_stageInfos>
<cam>
<cameraType typeID="2" />
<cameraType typeID="1" />
<position x="-26.90744" y="-2.035934" z="4.73512" />
<rotation x="31.03411" y="-1.992795E-06" z="85.52567" />
<lookAtAgent agentID="-1" />
......
......@@ -8,7 +8,7 @@
<rotation x="0" y="0" z="0" />
</env_stageInfos>
<cam>
<cameraType typeID="2" />
<cameraType typeID="1" />
<position x="-28" y="-3" z="5" />
<rotation x="30.00002" y="0" z="90" />
<lookAtAgent agentID="-1" />
......
......@@ -8,7 +8,7 @@
<rotation x="0" y="0" z="90" />
</env_stageInfos>
<cam>
<cameraType typeID="3" />
<cameraType typeID="2" />
<position x="15" y="2" z="5" />
<rotation x="12.94866" y="4.380253E-07" z="115.3439" />
<lookAtAgent agentID="22" />
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment