Skip to content
GitLab
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
52eca66d
Commit
52eca66d
authored
Mar 06, 2020
by
ATREVI Dieudonne
Browse files
Add comments to the code
parent
7a0f2a61
Changes
6
Hide whitespace changes
Inline
Side-by-side
Assets/Scripts/LoadEnv.cs
View file @
52eca66d
...
...
@@ -108,6 +108,7 @@ public class LoadEnv : MonoBehaviour
//FB don't know why there this check
//JB to see if it is a relative path or full one
//FA don't work on my computer. Got trouble to save images. I change little bit to make it works. Have to check on windows
if
(
ConfigReader
.
recordingSaveDir
[
0
]
==
'.'
)
cam_Rec
.
saveDir
=
Directory
.
GetCurrentDirectory
().
Replace
(
"\\"
,
"/"
)
+
"/"
+
ConfigReader
.
recordingSaveDir
;
else
...
...
@@ -408,6 +409,10 @@ public class LoadEnv : MonoBehaviour
}
}
/// <summary>
/// Update the current scenario without destroy the previous one
/// </summary>
/// <param name="trajDir">The path to the scenario file</param>
public
void
updateScenario
(
string
trajDir
)
{
// ---------------------------------
...
...
Assets/Scripts/LoadWelcome.cs
View file @
52eca66d
...
...
@@ -26,14 +26,17 @@ using UnityEngine;
using
UnityEngine.UI
;
using
UnityEngine.SceneManagement
;
/// <summary>
/// Manage the welcome page: Show the logo of Chaos before to show the main menu
/// </summary>
public
class
LoadWelcome
:
MonoBehaviour
{
public
float
timeToWait
=
0.08f
;
public
float
timeToWait
=
0.08f
;
// Control the duration to show the logo
private
Image
_backgroundImage
;
private
Text
_text1
,
_text2
;
private
float
_fading
;
private
GameObject
_currentPanel
;
private
Image
_backgroundImage
;
// Background image
private
Text
_text1
,
_text2
;
// Text to show the copyrigth and the definition of chaos
private
float
_fading
;
// Control the fading speed
private
GameObject
_currentPanel
;
// Contain the current panel
void
Awake
(){
DontDestroyOnLoad
(
gameObject
);
...
...
@@ -42,9 +45,11 @@ public class LoadWelcome : MonoBehaviour
{
StartCoroutine
(
"showWelcome"
);
}
/// <summary>
/// Coroutine to show the welcome panel
/// </summary>
private
IEnumerator
showWelcome
(){
_currentPanel
=
GameObject
.
Find
(
"Home/Panel"
);
_currentPanel
=
GameObject
.
Find
(
"Home/Panel"
);
// Avoid to use lot of tags.
_backgroundImage
=
_currentPanel
.
transform
.
Find
(
"Image"
).
GetComponent
<
Image
>();
_text1
=
_currentPanel
.
transform
.
Find
(
"Text1"
).
GetComponent
<
Text
>();
_text2
=
_currentPanel
.
transform
.
Find
(
"Text2"
).
GetComponent
<
Text
>();
...
...
@@ -73,6 +78,6 @@ public class LoadWelcome : MonoBehaviour
_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"
);
SceneManager
.
LoadScene
(
"startSc"
);
// Load the main menu
}
}
\ No newline at end of file
Assets/Scripts/Menu/MenuManager.cs
View file @
52eca66d
...
...
@@ -45,7 +45,7 @@ public class MenuManager : MonoBehaviour
GameObject
menu
;
// the menu gameObject
GameObject
panel
;
// the panel gameObject
GameObject
configPanel
;
// the panel to set the config parameters
LoadEnv
env
;
LoadEnv
env
;
// Contain datas for the environnement
/// <summary>
/// initialize the menu
...
...
@@ -118,7 +118,7 @@ public class MenuManager : MonoBehaviour
env
=
gameObject
.
GetComponent
<
LoadEnv
>();
env
.
loadScenario
(
ConfigReader
.
trajectoriesDir
);
//
ConfigReader.camResolution = CommandLine.GetCamResolution();
ConfigReader
.
camResolution
=
CommandLine
.
GetCamResolution
();
menu
.
SetActive
(
false
);
configPanel
.
SetActive
(
false
);
...
...
Assets/Scripts/Tools/ConfigManager.cs
View file @
52eca66d
...
...
@@ -35,9 +35,13 @@ using SFB;
/// </summary>
public
class
ConfigManager
:
MonoBehaviour
{
// GameObject to store differents panel in the canvas
public
static
GameObject
PanelCamera
,
PanelRecording
,
PanelStageEnv
;
public
static
InputField
LookAgent
,
FollowAgent
;
/// <summary>
/// Method to show on the panel the parameters from the config file.
/// </summary>
public
static
void
showConfig
()
{
/// Get Camera Config
...
...
@@ -90,6 +94,10 @@ public class ConfigManager : MonoBehaviour
PanelStageEnv
.
transform
.
Find
(
"ObstFilePathVal"
).
GetComponent
<
Text
>().
text
=
ConfigReader
.
obstaclesFile
;
}
/// <summary>
/// Method to set the config file using information from the interface.
/// </summary>
/// <param name="configPath"> path to the config file</param>
public
static
void
SaveConfig
(
string
configPath
)
{
//// Set Camera Config
...
...
@@ -140,6 +148,10 @@ public class ConfigManager : MonoBehaviour
ConfigReader
.
SaveConfig
(
configPath
);
}
/// <summary>
/// Method to select the save directory.
/// </summary>
public
void
saveDirBrowse
()
{
// Save Path
...
...
@@ -156,14 +168,15 @@ public class ConfigManager : MonoBehaviour
}
else
{
//string[] splitPath = newPath.Split('/');
//newPath = "./"+splitPath[splitPath.Length-1]+"/";
newPath
=
newPath
+
"/"
;
ConfigReader
.
recordingSaveDir
=
newPath
;
PanelRecording
.
transform
.
Find
(
"savedirVal"
).
GetComponent
<
Text
>().
text
=
newPath
;
}
}
/// <summary>
/// Method to select the environnement directory
/// </summary>
public
void
envDirBrowse
()
{
// Save Path
...
...
@@ -185,6 +198,10 @@ public class ConfigManager : MonoBehaviour
PanelStageEnv
.
transform
.
Find
(
"EnvFilePathVal"
).
GetComponent
<
Text
>().
text
=
newPath
;
}
}
/// <summary>
/// Method to select the obstacle definition file.
/// </summary>
public
void
obstacleFileBrowse
()
{
// File Path
...
...
@@ -206,6 +223,10 @@ public class ConfigManager : MonoBehaviour
}
}
/// <summary>
/// Method to open the browser to select a folder.
/// </summary>
/// <returns> selected folder's path</returns>
public
string
OpenFolderExplorer
()
{
var
folderPath
=
StandaloneFileBrowser
.
OpenFolderPanel
(
"Choose a folder"
,
""
,
false
);
...
...
@@ -216,6 +237,12 @@ public class ConfigManager : MonoBehaviour
}
return
path
;
}
/// <summary>
/// Method to open the browser to select a file.
/// </summary>
/// <param name="extension"> filter the files in the folder by the extension </param>
/// <returns> selected file's path</returns>
public
string
OpenFileExplorer
(
string
extension
)
{
string
[]
filePath
=
StandaloneFileBrowser
.
OpenFilePanel
(
"Choose a File"
,
""
,
extension
,
false
);
...
...
Assets/Scripts/Tools/ConfigReader.cs
View file @
52eca66d
...
...
@@ -104,6 +104,7 @@ public static class ConfigReader
static
public
ConfigStage
stageInfos
{
get
{
return
data
.
env_stageInfos
;
}
set
{
data
.
env_stageInfos
=
value
;
}
}
/// <summary>
/// Path to the file containing the obstacles definition
...
...
Scenarios/ExampleFollow.xml
View file @
52eca66d
...
...
@@ -8,15 +8,15 @@
<rotation
x=
"0"
y=
"0"
z=
"0"
/>
</env_stageInfos>
<cam>
<position
x=
"-
2
8"
y=
"-3"
z=
"5"
/>
<rotation
x=
"30.0000
076
"
y=
"0"
z=
"90"
/>
<position
x=
"-
3
8"
y=
"-3"
z=
"5"
/>
<rotation
x=
"30.0000
1
"
y=
"0"
z=
"90"
/>
<lookAtAgent
agentID=
"-1"
/>
<followAgent
agentID=
"0"
followOnX=
"true"
followOnY=
"false"
/>
<CamResolution
x=
"-1"
y=
"-1"
/>
</cam>
<recording
start=
"
1
"
end=
"
3
"
framerate=
"15"
>
<recording
start=
"
0
"
end=
"
0
"
framerate=
"15"
>
<saveDir>
/home/fabrice/Documents/OCSR/chaos/output2/
</saveDir>
<savedData
ImgOriginal=
"true"
ImgSegmentation=
"false"
ImgCategories=
"false"
ImgDepth=
"false"
ImgNormals=
"false"
ImgOpticalFlow=
"false"
BodyBoundingBoxes=
"false"
HeadBoundingBoxes=
"false"
/>
</recording>
<AgentColorList
/>
</ConfigData>
</ConfigData>
\ No newline at end of file
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment