Commit 3310afa5 authored by JOVANE Alberto's avatar JOVANE Alberto
Browse files

Removed the Default mode, added the reset button, and fixed some default values

parent 6cff071a
......@@ -3366,6 +3366,7 @@ MonoBehaviour:
followOnY: 0
lockFirstPersonView: 0
smoothFirstPersonView: 0
reset_active: 0
--- !u!114 &275588656
MonoBehaviour:
m_ObjectHideFlags: 0
......@@ -10663,7 +10664,7 @@ MonoBehaviour:
m_HorizontalOverflow: 0
m_VerticalOverflow: 0
m_LineSpacing: 1
m_Text: Default
m_Text: Free_Movement
--- !u!222 &914841688
CanvasRenderer:
m_ObjectHideFlags: 0
......@@ -12301,8 +12302,6 @@ MonoBehaviour:
m_Value: 0
m_Options:
m_Options:
- m_Text: Default
m_Image: {fileID: 0}
- m_Text: Free_Movement
m_Image: {fileID: 0}
- m_Text: Follow
......
......@@ -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,13 +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");
......@@ -113,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,6 +169,11 @@ 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;
......@@ -171,7 +187,9 @@ public class CamMvt : MonoBehaviour
}
//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)
......@@ -206,7 +224,7 @@ public class CamMvt : MonoBehaviour
panelMovCamera.transform.Find("Followat").GetComponent<Toggle>().isOn = false;
}
//update
current_camera_mode = camSelect.options[camSelect.value].text;
......@@ -291,8 +309,58 @@ 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 +369,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 +408,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 +435,7 @@ public class CamMvt : MonoBehaviour
_position_torsum = agent_torsum_transform.position;
// --------------------------------
// TRANSLATION - FOLLOWING AN AGENT
if (current_camera_mode == FOLLOW)
{
......@@ -384,8 +459,11 @@ public class CamMvt : MonoBehaviour
#endregion
}
#region Additional Functions
//additional functions
///--------------------------------------------
///----- additional functions -----------------
///--------------------------------------------
/// <summary>
/// Find the head transform and return it
......
......@@ -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