Commit 1e23a6f9 authored by JOVANE Alberto's avatar JOVANE Alberto
Browse files

first commit

parent a347d4fc
......@@ -85,6 +85,7 @@ public class LoadEnv : MonoBehaviour
// CAMERA CONFIG
cam_Rec.enabled = true;
cam_Movement.enabled = true;
cam_Movement._camera_type = (CamMvt.CameraType)ConfigReader.camType;
cam.transform.position = ConfigReader.camPosition;
cam.transform.rotation = Quaternion.Euler(ConfigReader.camRotation);
cam_Movement.lookAt_Id = ConfigReader.camLookAtTarget;
......
......@@ -36,11 +36,12 @@ public class CamMvt : MonoBehaviour
Default, //the option defined by the scenario
Follow, // follow the agent if defined by the scenario
First_Person, // First Person View
Torsum // Torsum view
Torsum, // Torsum view
Free_Movement // Free Movement
}
[SerializeField()]
private CameraType _camera_type;
public CameraType _camera_type;
// Rotation - Looking at an agent
public bool activateLookAt = false; // if true: lock the view to look at the selected agent - else : free movment
......@@ -77,14 +78,15 @@ public class CamMvt : MonoBehaviour
void Start()
{
//_camera_type = CameraType.Default;
lockFirstPersonView = false;
}
/// <summary>
/// Initialize the targets of the camera movement
/// Initialize the targets of the camera movement with parameters of config file
/// </summary>
public void initializeTargetObjects()
{
//default setting
// initialize the ids
if (lookAt_Id >= 0)
activateLookAt = true;
else
......@@ -93,8 +95,25 @@ public class CamMvt : MonoBehaviour
lookAt_Id = 0;
}
Debug.Log("Initial camera Type :" + _camera_type);
// initialize camera type
if (_camera_type == CameraType.Follow || _camera_type == CameraType.First_Person || _camera_type == CameraType.Torsum)
{
if (follow_Id < 0)
follow_Id = 0;
}
// to di initialize the Panel
//camTypePanel = GameObject.Find("/controlCanvas/cameraMovPanel");
//Dropdown camSelect = camTypePanel.transform.Find("cameraType").GetComponent<Dropdown>();
//camSelect.options[camSelect.value].text = get_CameraType(_camera_type);
// initialize the look at and follow target
update_look_at_target();
update_follow_target();
// initialize the follow position with the starting camera position
_position_follow = transform.position;
}
/// <summary>
/// Update the target of look at camera
......@@ -203,7 +222,7 @@ public class CamMvt : MonoBehaviour
delta.x = 0;
if (follow_LockZ)
delta.z = 0;
_position_follow = transform.position + delta;
_position_follow = _position_follow + delta;
_position_first_person = agent_head_transform.position;
......@@ -211,7 +230,7 @@ public class CamMvt : MonoBehaviour
// --------------------------------
// TRANSLATION - FOLLOWING AN AGENT
/*if (_camera_type == CameraType.Follow || _camera_type == CameraType.Default )
{
transform.position = _position_follow;
......@@ -319,5 +338,69 @@ public class CamMvt : MonoBehaviour
return null;
}
}
//CAMERA TYPE parser
/// <summary>
/// Get the camera Type from the string
/// </summary>
/// <param name="camera_type"> string defining the camera type </param>
/// <returns> correspondent CameraType </returns>
private CameraType get_CameraType(string camera_type)
{
CameraType returned_camera_type;
if (camera_type == "Default")
{
returned_camera_type = CameraType.Default;
}
else if (camera_type == "Follow")
{
returned_camera_type = CameraType.Follow;
}
else if (camera_type == "First_Person")
{
returned_camera_type = CameraType.First_Person;
}
else if (camera_type == "Torsum")
{
returned_camera_type = CameraType.Torsum;
}
else
{
returned_camera_type = CameraType.Default;
}
return returned_camera_type;
}
/// <summary>
/// Get the correspondent string from the camera type
/// </summary>
/// <param name="camera_type"> the selected camera type </param>
/// <returns> correspondent string </returns>
private string get_CameraType(CameraType camera_type)
{
string returned_camera_type;
if (camera_type == CameraType.Default)
{
returned_camera_type = "Default";
}
else if (camera_type == CameraType.Follow)
{
returned_camera_type = "Follow";
}
else if (camera_type == CameraType.First_Person)
{
returned_camera_type = "First_Person";
}
else if (camera_type == CameraType.Torsum)
{
returned_camera_type = "Torsum";
}
else
{
returned_camera_type = "Default";
}
return returned_camera_type;
}
#endregion
}
\ No newline at end of file
......@@ -117,6 +117,14 @@ public static class ConfigReader
/// <summary>
/// Starting camera position
/// </summary>
static public int camType
{
get { return data.cam.cameraType.id; }
set { data.cam.cameraType.id = (int)value; }
}
/// <summary>
/// Starting camera position
/// </summary>
static public Vector3 camPosition
{
get { return data.cam.position.vect; }
......@@ -377,6 +385,7 @@ public class ConfigStage
/// </summary>
public class ConfigCam
{
public ConfigCamType cameraType;
public ConfigVect3 position;
public ConfigVect3 rotation;
......@@ -454,7 +463,16 @@ public class ConfigVect3
get { return new Vector3(x, z, y); }
}
}
public class ConfigCamType
{
[XmlAttribute("typeID")]
public int id;
public ConfigCamType()
{
id = 0;
}
}
/// <summary>
/// Camera behavior configuration to be serialize in XML config
/// </summary>
......
......@@ -8,6 +8,7 @@
<rotation x="0" y="0" z="0" />
</env_stageInfos>
<cam>
<cameraType typeID="0"/>
<position x="-30" y="-3" z="5" />
<rotation x="30.32365" y="0" z="92.53606" />
<lookAtAgent agentID="-1" />
......
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