Commit 2f698b2f authored by ATREVI Dieudonne's avatar ATREVI Dieudonne
Browse files

- Add a welcome interface with chaos's logo: Interface to display first

- Modification of the Menu:
  - Add a button to select the scenario folder
  - Add a first panel for scenario config parameters modification
parent 351130f8
{
"files.exclude":
{
"**/.DS_Store":true,
"**/.git":true,
"**/.gitignore":true,
"**/.gitmodules":true,
"**/*.booproj":true,
"**/*.pidb":true,
"**/*.suo":true,
"**/*.user":true,
"**/*.userprefs":true,
"**/*.unityproj":true,
"**/*.dll":true,
"**/*.exe":true,
"**/*.pdf":true,
"**/*.mid":true,
"**/*.midi":true,
"**/*.wav":true,
"**/*.gif":true,
"**/*.ico":true,
"**/*.jpg":true,
"**/*.jpeg":true,
"**/*.png":true,
"**/*.psd":true,
"**/*.tga":true,
"**/*.tif":true,
"**/*.tiff":true,
"**/*.3ds":true,
"**/*.3DS":true,
"**/*.fbx":true,
"**/*.FBX":true,
"**/*.lxo":true,
"**/*.LXO":true,
"**/*.ma":true,
"**/*.MA":true,
"**/*.obj":true,
"**/*.OBJ":true,
"**/*.asset":true,
"**/*.cubemap":true,
"**/*.flare":true,
"**/*.mat":true,
"**/*.meta":true,
"**/*.prefab":true,
"**/*.unity":true,
"build/":true,
"Build/":true,
"Library/":true,
"library/":true,
"obj/":true,
"Obj/":true,
"ProjectSettings/":true,
"temp/":true,
"Temp/":true
}
}
\ No newline at end of file
fileFormatVersion: 2
guid: 32c820026cb443a4abddb62220be4a7c
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: f9ac2c9f27e0bbaac9ce95afb3a513e7
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
......@@ -29,8 +29,8 @@ using System.Collections.Generic;
/// Main manager: Load the scene, create all the agents and manage users input
/// </summary>
public class LoadEnv : MonoBehaviour
{
{
#region attributes
List<GameObject> avatars; // List of agents
public GameObject cam; // Scene camera
......@@ -47,10 +47,10 @@ public class LoadEnv : MonoBehaviour
const float camMaxShiftPower = 1000.0f; // Maximun shift effect on camera speed
const float camRotationSpeed = 0.25f; // Rotation speed
Vector3 lastMouse = new Vector3(255, 255, 255); // Last mouse position to check its movement
float camShiftHold = 1.0f; // Control the effect of shift with holding time
float camShiftHold = 1.0f; // Control the effect of shift with holding time
#endregion
/// <summary>
/// Scene and agents initialization
/// </summary>
......@@ -65,11 +65,11 @@ public class LoadEnv : MonoBehaviour
cam_Movement.enabled = false;
menuM = gameObject.GetComponent<MenuManager>();
}
/// <summary>
/// Load a scenario: create stage and spawn agents
/// </summary>
}
/// <summary>
/// Load a scenario: create stage and spawn agents
/// </summary>
/// <param name="trajDir">The path to the scenario file</param>
public void loadScenario(string trajDir)
{
......@@ -105,11 +105,11 @@ public class LoadEnv : MonoBehaviour
cam_fc.saveOpticalFlow = ConfigReader.recordOpticalFlowImg;
//FB don't know why there this check
//JB to see if it is a relative path or full one
if (ConfigReader.recordingSaveDir[1] != ':')
cam_Rec.saveDir = Directory.GetCurrentDirectory().Replace("\\", "/") + "/" + ConfigReader.recordingSaveDir;
else
//FB don't know why there this check
//JB to see if it is a relative path or full one
if (ConfigReader.recordingSaveDir[1] != ':')
cam_Rec.saveDir = Directory.GetCurrentDirectory().Replace("\\", "/") + "/" + ConfigReader.recordingSaveDir;
else
cam_Rec.saveDir = ConfigReader.recordingSaveDir;
Camera.main.GetComponent<CamRecorder>().Init();
InitDeepRecorders();
......@@ -120,10 +120,10 @@ public class LoadEnv : MonoBehaviour
{
Destroy(a);
}
avatars.Clear();
// -------------
// CREATE AGENTS
avatars.Clear();
// -------------
// CREATE AGENTS
DirectoryInfo dir = new DirectoryInfo(trajDir);
FileInfo[] info = dir.GetFiles("*.csv");
if (info.Length == 0)
......@@ -135,16 +135,16 @@ public class LoadEnv : MonoBehaviour
object testRocketMan = Resources.Load("Prefabs/RocketBox/male/prefab_light/LS_m001_light");
foreach (FileInfo f in info)
{
// ------------------------------------------------------------
// IF NO ROCKETMAN (PROPRIETARY ASSETS), USE PLASTICMAN INSTEAD
GameObject character = (testRocketMan!=null) ? CreateAgent_RocketBox(i) : CreateAgent_PlasticMan(i);
character.transform.parent = crowdParentObject.transform;
// ------------------------------------------------------------
// IF NO ROCKETMAN (PROPRIETARY ASSETS), USE PLASTICMAN INSTEAD
GameObject character = (testRocketMan!=null) ? CreateAgent_RocketBox(i) : CreateAgent_PlasticMan(i);
character.transform.parent = crowdParentObject.transform;
avatars.Add(character);
// ---------------------
// SET NAME, TAG, AND ID
character.name += i.ToString("D4");
character.tag = "Player";
// ---------------------
// SET NAME, TAG, AND ID
character.name += i.ToString("D4");
character.tag = "Player";
character.GetComponent<GetMemberPosition>().ID = i;
// ----------------------------------
......@@ -153,20 +153,20 @@ public class LoadEnv : MonoBehaviour
tmpFollower = character.GetComponent<FollowTrajectory>();
tmpFollower.SetCsvFilename(f.FullName);
tmpFollower._SyncLaunchWithTrajectory = true; // start the character at the csv time
// -------------------------------
// Load animation controller from ressources
//string PathAnimeController = "PlasticMan/Animation/LocomotionFinal";
//Animator Anime = character.GetComponent<Animator>();
//Anime.runtimeAnimatorController = Resources.Load(PathAnimeController) as RuntimeAnimatorController;
//Anime.applyRootMotion = false;
// make sure that object on the floor (height 0)
character.transform.position = new Vector3(character.transform.position.x, 0.0f, character.transform.position.z);
// -------------------------------
// Load animation controller from ressources
//string PathAnimeController = "PlasticMan/Animation/LocomotionFinal";
//Animator Anime = character.GetComponent<Animator>();
//Anime.runtimeAnimatorController = Resources.Load(PathAnimeController) as RuntimeAnimatorController;
//Anime.applyRootMotion = false;
// make sure that object on the floor (height 0)
character.transform.position = new Vector3(character.transform.position.x, 0.0f, character.transform.position.z);
i++;
}
}
cam_Movement.updateTargetedObject();
cam_fc.OnSceneChange();
......@@ -176,114 +176,114 @@ public class LoadEnv : MonoBehaviour
/// Manage which deep recorder is used and initialize it
/// </summary>
private void InitDeepRecorders()
{
GameObject DeepRecorders = GameObject.FindGameObjectWithTag("DeepRecorders");
if (ConfigReader.recordBodyBoudingBoxes)
{
DeepRecorders.AddComponent<BodyBoundingBoxRecorder>();
DeepRecorders.GetComponent<BodyBoundingBoxRecorder>().Init(ConfigReader.recordingSaveDir);
}
if (ConfigReader.recordHeadBoundingBoxes)
{
DeepRecorders.AddComponent<HeadBoundingBoxRecorder>();
DeepRecorders.GetComponent<HeadBoundingBoxRecorder>().Init(ConfigReader.recordingSaveDir);
}
}
Color? GetColorForAgentId(int id)
{
if (ConfigReader.agentsColor != null && ConfigReader.agentsColor.Count > 0)
{
foreach (ConfigAgentColor c in ConfigReader.agentsColor)
{
if (id > c.firstAgent - 1 && id < c.lastAgent + 1 && (id - c.firstAgent) % c.step == 0)
return new Color(c.red, c.green, c.blue, 1);
}
}
return null;
}
Material CreateMaterialWithColor(Color color)
{
var tmpMaterial = new Material(Shader.Find("Legacy Shaders/Diffuse"));
tmpMaterial.color = color;
return tmpMaterial;
}
string GetModelName_RocketBox(int id)
{
string path;
int modelId;
if (id % 2 == 0)
{
path = "male/prefab_light/LS_m";
modelId = id / 2;
}
else
{
path = "female/prefab_light/LS_f";
modelId = (id - 1) / 2;
}
modelId = (modelId % 20) + 1;
return "Prefabs/RocketBox/" + path + modelId.ToString("D3") + "_light";
}
GameObject CreateAgent_RocketBox(int id)
{
// -------------------
// LOAD AGENT IN UNITY
GameObject gameObject = Instantiate(Resources.Load<GameObject>(GetModelName_RocketBox(id)));
// -------------------
// SET BOUNDING BOXES ITEM
gameObject.AddComponent<GetMemberPositionRocketBox>();
gameObject.AddComponent<FollowTrajectory>();
GameObject headBoundingBox = Instantiate(Resources.Load<GameObject>("HeadBoundingBoxes/Hbb_RocketBox"));
Transform Head = gameObject.transform.Find("Bip01/Bip01 Pelvis/Bip01 Spine/Bip01 Spine1/Bip01 Spine2/Bip01 Neck/Bip01 Head");
headBoundingBox.transform.parent = Head;
// ---------------------------------------------
// SET AGENT'S COLOR WHEN SPECIFY IN CONFIG FILE
var tmpColor = GetColorForAgentId(id);
if (tmpColor.HasValue)
{
var tmpMaterial = CreateMaterialWithColor(tmpColor.Value);
Material[] mats = new Material[] { tmpMaterial, tmpMaterial, tmpMaterial };
SkinnedMeshRenderer[] rendererList = gameObject.GetComponentsInChildren<SkinnedMeshRenderer>();
foreach (SkinnedMeshRenderer renderer in rendererList)
renderer.materials = mats;
}
return gameObject;
}
GameObject CreateAgent_PlasticMan(int id)
{
// -------------------
// LOAD AGENT IN UNITY
GameObject gameObject = Instantiate(Resources.Load<GameObject>("PlasticMan/plasticman"));
// -------------------
// SET BOUNDING BOXES ITEM
gameObject.AddComponent<GetMemberPositionPlasticMan>();
GameObject headBoundingBox = Instantiate(Resources.Load<GameObject>("HeadBoundingBoxes/Hbb_PlasticMan"));
Transform Head = gameObject.transform.Find("Plasticman:Reference/Plasticman:Hips/Plasticman:Spine/Plasticman:Spine1/Plasticman:Spine2/Plasticman:Spine3/Plasticman:Neck/Plasticman:Head");
headBoundingBox.transform.parent = Head;
// -----------------
// SET AGENT'S COLOR
var tmpColor = GetColorForAgentId(id);
if (!tmpColor.HasValue)
tmpColor = new Color(Random.value, Random.value, Random.value, 1);
var tmpRenderer = gameObject.GetComponentInChildren<SkinnedMeshRenderer>();
tmpRenderer.material = CreateMaterialWithColor(tmpColor.Value);
return gameObject;
}
{
GameObject DeepRecorders = GameObject.FindGameObjectWithTag("DeepRecorders");
if (ConfigReader.recordBodyBoudingBoxes)
{
DeepRecorders.AddComponent<BodyBoundingBoxRecorder>();
DeepRecorders.GetComponent<BodyBoundingBoxRecorder>().Init(ConfigReader.recordingSaveDir);
}
if (ConfigReader.recordHeadBoundingBoxes)
{
DeepRecorders.AddComponent<HeadBoundingBoxRecorder>();
DeepRecorders.GetComponent<HeadBoundingBoxRecorder>().Init(ConfigReader.recordingSaveDir);
}
}
Color? GetColorForAgentId(int id)
{
if (ConfigReader.agentsColor != null && ConfigReader.agentsColor.Count > 0)
{
foreach (ConfigAgentColor c in ConfigReader.agentsColor)
{
if (id > c.firstAgent - 1 && id < c.lastAgent + 1 && (id - c.firstAgent) % c.step == 0)
return new Color(c.red, c.green, c.blue, 1);
}
}
return null;
}
Material CreateMaterialWithColor(Color color)
{
var tmpMaterial = new Material(Shader.Find("Legacy Shaders/Diffuse"));
tmpMaterial.color = color;
return tmpMaterial;
}
string GetModelName_RocketBox(int id)
{
string path;
int modelId;
if (id % 2 == 0)
{
path = "male/prefab_light/LS_m";
modelId = id / 2;
}
else
{
path = "female/prefab_light/LS_f";
modelId = (id - 1) / 2;
}
modelId = (modelId % 20) + 1;
return "Prefabs/RocketBox/" + path + modelId.ToString("D3") + "_light";
}
GameObject CreateAgent_RocketBox(int id)
{
// -------------------
// LOAD AGENT IN UNITY
GameObject gameObject = Instantiate(Resources.Load<GameObject>(GetModelName_RocketBox(id)));
// -------------------
// SET BOUNDING BOXES ITEM
gameObject.AddComponent<GetMemberPositionRocketBox>();
gameObject.AddComponent<FollowTrajectory>();
GameObject headBoundingBox = Instantiate(Resources.Load<GameObject>("HeadBoundingBoxes/Hbb_RocketBox"));
Transform Head = gameObject.transform.Find("Bip01/Bip01 Pelvis/Bip01 Spine/Bip01 Spine1/Bip01 Spine2/Bip01 Neck/Bip01 Head");
headBoundingBox.transform.parent = Head;
// ---------------------------------------------
// SET AGENT'S COLOR WHEN SPECIFY IN CONFIG FILE
var tmpColor = GetColorForAgentId(id);
if (tmpColor.HasValue)
{
var tmpMaterial = CreateMaterialWithColor(tmpColor.Value);
Material[] mats = new Material[] { tmpMaterial, tmpMaterial, tmpMaterial };
SkinnedMeshRenderer[] rendererList = gameObject.GetComponentsInChildren<SkinnedMeshRenderer>();
foreach (SkinnedMeshRenderer renderer in rendererList)
renderer.materials = mats;
}
return gameObject;
}
GameObject CreateAgent_PlasticMan(int id)
{
// -------------------
// LOAD AGENT IN UNITY
GameObject gameObject = Instantiate(Resources.Load<GameObject>("PlasticMan/plasticman"));
// -------------------
// SET BOUNDING BOXES ITEM
gameObject.AddComponent<GetMemberPositionPlasticMan>();
GameObject headBoundingBox = Instantiate(Resources.Load<GameObject>("HeadBoundingBoxes/Hbb_PlasticMan"));
Transform Head = gameObject.transform.Find("Plasticman:Reference/Plasticman:Hips/Plasticman:Spine/Plasticman:Spine1/Plasticman:Spine2/Plasticman:Spine3/Plasticman:Neck/Plasticman:Head");
headBoundingBox.transform.parent = Head;
// -----------------
// SET AGENT'S COLOR
var tmpColor = GetColorForAgentId(id);
if (!tmpColor.HasValue)
tmpColor = new Color(Random.value, Random.value, Random.value, 1);
var tmpRenderer = gameObject.GetComponentInChildren<SkinnedMeshRenderer>();
tmpRenderer.material = CreateMaterialWithColor(tmpColor.Value);
return gameObject;
}
/// <summary>
/// Update camera state
/// </summary>
......@@ -398,5 +398,12 @@ public class LoadEnv : MonoBehaviour
else
Time.timeScale = 0;
}
// --------------------------
// p or P => Load the param setting panel
if (Input.GetKeyDown("p"))
{
menuM.configParams();
}
}
}
\ No newline at end of file
/* Crowd Simulator Engine
** Copyright (C) 2018 - Inria Rennes - Rainbow - Julien Pettre
**
** This program is free software; you can redistribute it and/or
** modify it under the terms of the GNU General Public License
** as published by the Free Software Foundation; either version 2
** of the License, or (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**
** Authors: Fabrice ATREVI
**
** Contact: crowd_group@inria.fr
*/
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.SceneManagement;
public class LoadWelcome : MonoBehaviour
{
public float timeToWait = 0.08f;
private Image _backgroundImage;
private Text _text1, _text2;
private float _fading;
private GameObject _currentPanel;
void Awake(){
DontDestroyOnLoad(gameObject);
}
void Start()
{
StartCoroutine("showWelcome");
}
private IEnumerator showWelcome(){
_currentPanel = GameObject.Find("Home/Panel");
_backgroundImage = _currentPanel.transform.Find("Image").GetComponent<Image>();
_text1 = _currentPanel.transform.Find("Text1").GetComponent<Text>();
_text2 = _currentPanel.transform.Find("Text2").GetComponent<Text>();
_backgroundImage.color = new Color(_backgroundImage.color.r,_backgroundImage.color.g,_backgroundImage.color.b,0f);
_text1.color = new Color(1f,1f,1f,0f);
_text2.color = new Color(1f,1f,1f,0f);
while(_fading < 1)
{
yield return new WaitForSeconds(timeToWait);
_fading += 0.013f;
_backgroundImage.color = new Color(_backgroundImage.color.r,_backgroundImage.color.g,_backgroundImage.color.b,_fading);
_text1.color = new Color(_text1.color.r,_text1.color.g,_text1.color.b,_fading);
_text2.color = new Color(_text2.color.r,_text2.color.g,_text2.color.b,_fading);
}
StartCoroutine("changeScene");
}
private IEnumerator changeScene(){
while(_fading > 0)
{
yield return new WaitForSeconds(timeToWait);
_fading -= 0.019f;
_backgroundImage.color = new Color(_backgroundImage.color.r,_backgroundImage.color.g,_backgroundImage.color.b,_fading);
_text1.color = new Color(_text1.color.r,_text1.color.g,_text1.color.b,_fading);
_text2.color = new Color(_text2.color.r,_text2.color.g,_text2.color.b,_fading);
}
SceneManager.LoadScene("startSc");
}
}
\ No newline at end of file
fileFormatVersion: 2
guid: 5e9ac710519b9f83c9f4d544f4987a39
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
......@@ -15,7 +15,8 @@
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**
** Authors: Julien Bruneau
** Authors: Julien Bruneau, Fabrice Atrevi
** Using of the standalonebrower package of Gökhan Gökçe: Copyright (c) 2017 Gökhan Gökçe
**
** Contact: crowd_group@inria.fr
*/
......@@ -26,47 +27,127 @@ using System.IO;
using UnityEditor;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.SceneManagement;
using SFB;
/// <summary>
/// Starting menu manager
/// <summary>
/// Starting menu manager
/// </summary>
public class MenuManager : MonoBehaviour
public class MenuManager : MonoBehaviour
{
Text pathText; // used to show the path of the selected scenario folder
string scenarioFolderPath; // path to the selected scenario folder
string configPath; // path to the selected scenario file
ObstaclesReader obstReader; // object loading/creating obstacles
Camera cam; // the main camera
InputField inputConfigPath; // GUI object to input the scenario folder
Dropdown configFilesMenu; // GUI object to select the scenario
GameObject menu; // the menu gameObject
GameObject panel; // the panel gameObject
GameObject configPanel; // the panel to set the config parameters
/// <summary>
/// initialize the menu
/// <summary>
/// initialize the menu
/// </summary>
void Start()
void Start()
{
configPath = null;
cam = Camera.main;
menu = GameObject.FindGameObjectWithTag("Menu");
menu = GameObject.FindGameObjectWithTag("Menu");
panel = GameObject.FindGameObjectWithTag("Panel");
configPanel = GameObject.FindGameObjectWithTag("configPanel");
obstReader = new ObstaclesReader();
string dataPath = defaultScenarioPath();
configFilesMenu = panel.GetComponentInChildren<Dropdown>();
if(configFilesMenu!=null)
configFilesMenu.options.Clear();
inputConfigPath = menu.GetComponentInChildren<InputField>();
inputConfigPath.text = dataPath;
Time.timeScale = 0;
}
configFilesMenu = menu.GetComponentInChildren<Dropdown>();
updateConfigList(dataPath);
/// <summary>
/// Open the folder explorer to select the scenario folder
/// Based on the standalonebrower package of Gökhan Gökçe
/// Copyright (c) 2017 Gökhan Gökçe