Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
OCSR
ChAOS
Commits
60108bcc
Commit
60108bcc
authored
Jan 08, 2019
by
BRUNEAU Julien
Browse files
Merge branch 'master' into 'master'
Master See merge request
!3
parents
43fc985e
3daa4c02
Changes
12
Hide whitespace changes
Inline
Side-by-side
.gitignore
View file @
60108bcc
...
...
@@ -36,3 +36,4 @@ sysinfo.txt
*.unitypackage
Output
Release/
/Bin/
Assets/
Scene/LoadMultipleTrajectories
.meta
→
Assets/
Materials/Logo
.meta
View file @
60108bcc
fileFormatVersion: 2
guid:
e7b9e93325cae8a4e97a1d3af4a24d03
guid:
3d2eed066614c9c43bd556953f8f90e9
folderAsset: yes
DefaultImporter:
externalObjects: {}
...
...
Assets/Materials/Logo/PlasticMan2.png
0 → 100644
View file @
60108bcc
72.4 KB
Assets/Materials/Logo/PlasticMan2.png.meta
0 → 100644
View file @
60108bcc
fileFormatVersion: 2
guid: d27769d02344a004a98658455b687290
TextureImporter:
fileIDToRecycleName: {}
externalObjects: {}
serializedVersion: 7
mipmaps:
mipMapMode: 0
enableMipMap: 0
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: -1
aniso: -1
mipBias: -100
wrapU: 1
wrapV: 1
wrapW: 1
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 1
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 100
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 8
textureShape: 1
singleChannelComponent: 0
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
platformSettings:
- serializedVersion: 2
buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
bones: []
spriteID: 50f338692d1ca964a8d0f67b7deb5d56
vertices: []
indices:
edges: []
weights: []
spritePackingTag:
pSDRemoveMatte: 0
pSDShowRemoveMatteOption: 0
userData:
assetBundleName:
assetBundleVariant:
Assets/Scene/LoadMultipleTrajectories.unity
View file @
60108bcc
No preview for this file type
Assets/Scripts/FollowTrajectory/FollowTrajectory.cs
View file @
60108bcc
...
...
@@ -498,5 +498,6 @@ public class FollowTrajectory : MonoBehaviour
public
void
SetCsvFilename
(
string
csv_filename
)
{
_TrajectroryFilename
=
csv_filename
;
this
.
Start
();
}
}
Assets/Scripts/LoadEnv.cs
View file @
60108bcc
...
...
@@ -29,14 +29,14 @@ 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
List
<
GameObject
>
avatars
;
// List of agents
public
GameObject
cam
;
// Scene camera
private
CamRecorder
cam_Rec
;
// Control scene recording
private
CamMvt
cam_Movement
;
// Control camera movement behavior
private
MenuManager
menuM
;
private
MenuManager
menuM
;
// Control the starting menu
//private float rotSpeed = 5;
// --------------------------
...
...
@@ -46,10 +46,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>
...
...
@@ -63,9 +63,12 @@ public class LoadEnv : MonoBehaviour
cam_Movement
.
enabled
=
false
;
menuM
=
gameObject
.
GetComponent
<
MenuManager
>();
}
}
/// <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
)
{
// --------------------------------------------------
...
...
@@ -104,10 +107,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
)
...
...
@@ -211,10 +214,18 @@ public class LoadEnv : MonoBehaviour
tmpFollower
.
SetCsvFilename
(
f
.
FullName
);
tmpFollower
.
_SyncLaunchWithTrajectory
=
true
;
// start the character at the csv time
i
++;
}
}
cam_Movement
.
updateTargetedObject
();
}
/// <summary>
/// Update camera state
/// </summary>
private
void
Update
()
{
ConfigReader
.
camPosition
=
cam
.
transform
.
position
;
...
...
Assets/Scripts/Menu/MenuManager.cs
View file @
60108bcc
...
...
@@ -27,22 +27,29 @@ using UnityEditor;
using
UnityEngine
;
using
UnityEngine.UI
;
public
class
MenuManager
:
MonoBehaviour
{
string
configPath
;
ObstaclesReader
obstReader
;
Camera
cam
;
InputField
inputConfigPath
;
Dropdown
configFilesMenu
;
GameObject
menu
;
// Use this for initialization
void
Start
()
{
/// <summary>
/// Starting menu manager
/// </summary>
public
class
MenuManager
:
MonoBehaviour
{
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
/// <summary>
/// initialize the menu
/// </summary>
void
Start
()
{
configPath
=
null
;
cam
=
Camera
.
main
;
menu
=
GameObject
.
FindGameObjectWithTag
(
"Menu"
);
menu
=
GameObject
.
FindGameObjectWithTag
(
"Menu"
);
obstReader
=
new
ObstaclesReader
();
string
dataPath
=
defaultScenarioPath
();
...
...
@@ -57,6 +64,10 @@ public class MenuManager : MonoBehaviour {
}
/// <summary>
/// Build the default scenarios folder path from the application path
/// </summary>
/// <returns>default scenarios folder path</returns>
public
string
defaultScenarioPath
()
{
string
pathPlayer
=
Application
.
dataPath
;
...
...
@@ -71,13 +82,17 @@ public class MenuManager : MonoBehaviour {
return
dataPath
;
}
/// <summary>
/// update the dropdown menu listing the scenarios
/// </summary>
/// <param name="NewPath">path to the current scenario folder</param>
public
void
updateConfigList
(
string
NewPath
)
{
if
(
configFilesMenu
==
null
)
return
;
DirectoryInfo
dir
;
if
(
Directory
.
Exists
(
inputConfigPath
.
text
))
if
(
Directory
.
Exists
(
inputConfigPath
.
text
))
dir
=
new
DirectoryInfo
(
inputConfigPath
.
text
);
else
{
...
...
@@ -90,12 +105,16 @@ public class MenuManager : MonoBehaviour {
configFilesMenu
.
options
.
Add
(
new
Dropdown
.
OptionData
(
"NONE"
));
foreach
(
FileInfo
i
in
infos
)
{
configFilesMenu
.
options
.
Add
(
new
Dropdown
.
OptionData
(
i
.
Name
.
Remove
(
i
.
Name
.
Length
-
4
)));
configFilesMenu
.
options
.
Add
(
new
Dropdown
.
OptionData
(
i
.
Name
.
Remove
(
i
.
Name
.
Length
-
4
)));
}
configFilesMenu
.
value
=
0
;
configFilesMenu
.
RefreshShownValue
();
}
/// <summary>
/// Update the current scenario file
/// </summary>
/// <param name="i">the id of the selection from the dropdown menu</param>
public
void
updateConfigFile
(
int
i
)
{
if
(
configFilesMenu
==
null
||
configFilesMenu
.
value
==
0
)
...
...
@@ -108,10 +127,14 @@ public class MenuManager : MonoBehaviour {
}
// Update is called once per frame
void
Update
()
{
void
Update
()
{
}
/// <summary>
/// Load the current scenario file and remove the menu
/// </summary>
public
void
startScenario
()
{
if
(
configPath
==
null
||
configFilesMenu
.
value
==
0
)
...
...
@@ -121,21 +144,30 @@ public class MenuManager : MonoBehaviour {
obstReader
.
clear
();
obstReader
.
createObstacles
(
ConfigReader
.
obstaclesFile
,
ConfigReader
.
stageInfos
);
LoadEnv
env
=
gameObject
.
GetComponent
<
LoadEnv
>();
LoadEnv
env
=
gameObject
.
GetComponent
<
LoadEnv
>();
env
.
loadScenario
(
ConfigReader
.
trajectoriesDir
);
menu
.
SetActive
(
false
);
}
/// <summary>
/// show/hide menu
/// </summary>
public
void
toogleMenu
()
{
menu
.
SetActive
(!
menu
.
activeSelf
);
}
/// <summary>
/// save the current scenario file
/// </summary>
public
void
saveConfig
()
{
ConfigReader
.
SaveConfig
(
configPath
);
}
/// <summary>
/// quit the application
/// </summary>
public
void
exit
()
{
Application
.
Quit
();
...
...
Assets/Scripts/Tools/CamMvt.cs
View file @
60108bcc
...
...
@@ -24,7 +24,8 @@ using System.Collections;
using
System.Collections.Generic
;
using
UnityEngine
;
public
class
CamMvt
:
MonoBehaviour
{
public
class
CamMvt
:
MonoBehaviour
{
#region attributes
...
...
@@ -45,57 +46,52 @@ public class CamMvt : MonoBehaviour {
{
}
/// <summary>
/// Update the target of the camera movement
/// </summary>
public
void
updateTargetedObject
()
{
GameObject
[]
list
=
GameObject
.
FindGameObjectsWithTag
(
"Player"
);
if
(
lookAt_Id
>=
0
&&
list
.
Length
>
0
)
{
if
(
lookAt_Id
>
list
.
Length
-
1
)
lookAt_Id
=
list
.
Length
-
1
;
lookAt_Agent
=
list
[
lookAt_Id
];
}
if
(
follow_Id
>=
0
&&
list
.
Length
>
0
)
{
if
(
follow_Id
>
list
.
Length
-
1
)
follow_Id
=
list
.
Length
-
1
;
follow_Agent
=
list
[
follow_Id
];
follow_LastPosition
=
follow_Agent
.
transform
.
position
;
}
}
// Update is called once per frame
void
Update
()
{
#
region
ROTATION
#region ROTATION
// ------------------------------
// ROTATION - LOOKING AT AN AGENT
if
(
lookAt_Id
>=
0
)
{
if
(
lookAt_Agent
==
null
)
{
GameObject
[]
list
=
GameObject
.
FindGameObjectsWithTag
(
"Player"
);
if
(
lookAt_Agent
!=
null
)
transform
.
LookAt
(
lookAt_Agent
.
transform
);
#endregion
if
(
list
.
Length
>
0
)
{
if
(
lookAt_Id
>
list
.
Length
-
1
)
lookAt_Id
=
list
.
Length
-
1
;
lookAt_Agent
=
list
[
lookAt_Id
];
}
}
transform
.
LookAt
(
lookAt_Agent
.
transform
);
}
#
endregion
#
region
TRANSLATION
#region TRANSLATION
// --------------------------------
// TRANSLATION - FOLLOWING AN AGENT
if
(
follow_
Id
>=
0
)
if
(
follow_
Agent
!=
null
)
{
if
(
follow_Agent
==
null
)
{
GameObject
[]
list
=
GameObject
.
FindGameObjectsWithTag
(
"Player"
);
if
(
list
.
Length
>
0
)
{
if
(
follow_Id
>
list
.
Length
-
1
)
follow_Id
=
list
.
Length
-
1
;
follow_Agent
=
list
[
follow_Id
];
follow_LastPosition
=
follow_Agent
.
transform
.
position
;
}
}
else
{
Vector3
delta
=
follow_Agent
.
transform
.
position
-
follow_LastPosition
;
follow_LastPosition
=
follow_Agent
.
transform
.
position
;
if
(
follow_LockX
)
delta
.
x
=
0
;
if
(
follow_LockZ
)
delta
.
z
=
0
;
transform
.
position
=
transform
.
position
+
delta
;
}
Vector3
delta
=
follow_Agent
.
transform
.
position
-
follow_LastPosition
;
follow_LastPosition
=
follow_Agent
.
transform
.
position
;
if
(
follow_LockX
)
delta
.
x
=
0
;
if
(
follow_LockZ
)
delta
.
z
=
0
;
transform
.
position
=
transform
.
position
+
delta
;
}
#
endregion
#endregion
}
}
Assets/Scripts/Tools/ConfigReader.cs
View file @
60108bcc
...
...
@@ -50,17 +50,24 @@ public static class ConfigReader
data
=
new
ConfigData
();
}
/// <summary>
/// Load a scenario file
/// </summary>
/// <param name="path">Path of the scenario file to load</param>
static
public
void
LoadConfig
(
string
path
)
{
configFileName
=
path
;
if
(
File
.
Exists
(
path
))
{
data
=
XMLLoader
.
LoadXML
<
ConfigData
>(
path
);
data
=
XMLLoader
.
LoadXML
<
ConfigData
>(
path
);
}
}
/// <summary>
/// Save current parameters in a scenario file
/// </summary>
/// <param name="path">Path of the scenario file to save</param>
public
static
void
SaveConfig
(
string
path
)
{
XMLLoader
.
CreateXML
<
ConfigData
>(
path
,
data
);
...
...
@@ -83,67 +90,109 @@ public static class ConfigReader
}
#
region
get_set
/// <summary>
/// Folder of the trajectory files
/// </summary>
static
public
string
trajectoriesDir
{
get
{
return
data
.
env_filesPath
;
}
}
/// <summary>
/// Data about an AssetBundle to load
/// </summary>
static
public
ConfigStage
stageInfos
{
get
{
return
data
.
env_stageInfos
;
}
}
/// <summary>
/// Path to the file containing the obstacles definition
/// </summary>
static
public
string
obstaclesFile
{
get
{
return
data
.
env_obstFile
;
}
}
/// <summary>
/// Starting camera position
/// </summary>
static
public
Vector3
camPosition
{
get
{
return
data
.
cam
.
position
.
vect
;
}
set
{
data
.
cam
.
position
=
new
ConfigVect3
(
value
);
}
}
/// <summary>
/// Starting camera rotation
/// </summary>
static
public
Vector3
camRotation
{
get
{
return
data
.
cam
.
rotation
.
vect
;
}
set
{
data
.
cam
.
rotation
=
new
ConfigVect3
(
value
);
}
}
/// <summary>
/// ID of the agent to look at
/// </summary>
static
public
int
camLookAtTarget
{
get
{
return
data
.
cam
.
lookAtAgent
==
null
?
-
1
:
data
.
cam
.
lookAtAgent
.
id
;
}
}
/// <summary>
/// ID of the agent to follow with the camera
/// </summary>
static
public
int
camFollowTarget
{
get
{
return
data
.
cam
.
followAgent
==
null
?
-
1
:
data
.
cam
.
followAgent
.
id
;
}
}
/// <summary>
/// Boolean, true if camera follow an agent's translation of the axe X
/// </summary>
static
public
bool
camFollowOnX
{
get
{
return
data
.
cam
.
followAgent
==
null
?
false
:
data
.
cam
.
followAgent
.
followX
;
}
}
/// <summary>
/// Boolean, true if camera follow an agent's translation of the axe Y
/// </summary>
static
public
bool
camFollowOnY
{
get
{
return
data
.
cam
.
followAgent
==
null
?
false
:
data
.
cam
.
followAgent
.
followY
;
}
}
/// <summary>
/// Boolean, true if the animation should be recorded
/// </summary>
static
public
bool
recording
{
get
{
return
data
.
recording
.
end
>
data
.
recording
.
start
;
}
get
{
return
data
.
recording
.
end
>
data
.
recording
.
start
;
}
}
/// <summary>
/// time to start the recording of the animation
/// </summary>
static
public
float
recordingStart
{
get
{
return
data
.
recording
.
start
;
}
}
/// <summary>
/// Time to stop the recording of the animation
/// </summary>
static
public
float
recordingEnd
{
get
{
return
data
.
recording
.
end
;
}
}
/// <summary>
/// Framerate used for the recording of the animation
/// </summary>
static
public
int
recordingFramerate
{
get
{
return
data
.
recording
.
framerate
;
}
}
/// <summary>
/// Folder where all the images from the animation are recorded
/// </summary>
static
public
string
recordingSaveDir
{
get
{
return
data
.
recording
.
saveDir
;
}
}
/// <summary>
/// List of colors for the agents
/// </summary>
static
public
List
<
ConfigAgentColor
>
agentsColor
{
get
{
return
data
.
colorList
;
}
...
...
@@ -159,7 +208,7 @@ public static class ConfigReader
/// </summary>
public
class
ConfigData
{
// Evironnement config
public
string
env_filesPath
;
public
string
env_obstFile
;
...
...
@@ -209,7 +258,8 @@ public class ConfigStage
public
ConfigVect3
position
;
public
ConfigVect3
rotation
;
public
ConfigStage
()
{
public
ConfigStage
()
{
stageName
=
""
;
file
=
""
;
position
=
new
ConfigVect3
();
...
...
@@ -323,7 +373,7 @@ public class ConfigRecording
end
=
0
;
framerate
=
15
;
saveDir
=
".\\Output\\"
;
saveDir
=
".\\Output\\"
;
}
}
...
...
Assets/Scripts/Tools/ObstaclesReader.cs
View file @
60108bcc
/* 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: Julien Bruneau, Florian Berton
**
** Contact: crowd_group@inria.fr
*/