Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
ease-ph
DeepLanguageUnderstanding
Physics Simulator
Commits
54300443
Verified
Commit
54300443
authored
Mar 06, 2020
by
Sebastian Höffner
Browse files
Adding context export.
parent
01f9ad24
Changes
8
Hide whitespace changes
Inline
Side-by-side
Assets/DLU/ModifiedAssets/glass.mat
View file @
54300443
...
...
@@ -197,7 +197,7 @@ Material:
-
_EnableGeometricSpecularAA
:
0
-
_EnergyConservingSpecularColor
:
1
-
_GlossMapScale
:
0.942
-
_Glossiness
:
0.
807
-
_Glossiness
:
0.
951
-
_GlossyReflections
:
1
-
_HdrpVersion
:
2
-
_HeightAmplitude
:
0.02
...
...
@@ -215,7 +215,7 @@ Material:
-
_IridescenceThickness
:
1
-
_LinkDetailsWithBase
:
0
-
_MaterialID
:
1
-
_Metallic
:
0.
48099676
-
_Metallic
:
0.
843
-
_Mode
:
2
-
_NormalMapSpace
:
0
-
_NormalScale
:
1
...
...
@@ -275,7 +275,7 @@ Material:
m_Colors
:
-
_BaseColor
:
{
r
:
1
,
g
:
1
,
b
:
1
,
a
:
0.14117648
}
-
_BaseColorMap_MipInfo
:
{
r
:
0
,
g
:
0
,
b
:
0
,
a
:
0
}
-
_Color
:
{
r
:
1
,
g
:
1
,
b
:
1
,
a
:
0.
14117648
}
-
_Color
:
{
r
:
1
,
g
:
1
,
b
:
1
,
a
:
0.
3764706
}
-
_DiffusionProfileAsset
:
{
r
:
0
,
g
:
0
,
b
:
0
,
a
:
0
}
-
_DoubleSidedConstants
:
{
r
:
1
,
g
:
1
,
b
:
-1
,
a
:
0
}
-
_EmissionColor
:
{
r
:
1
,
g
:
1
,
b
:
1
,
a
:
1
}
...
...
Assets/DLU/Resources/instruction.json
0 → 100644
View file @
54300443
[
{
"name"
:
"actor_0"
,
"is_a"
:
[
"http://www.ontologydesignpatterns.org/ont/dul/DUL.owl#PhysicalAgent"
],
"components"
:
{
"transform"
:
{
"position"
:
{
"x"
:
0
,
"y"
:
0
,
"z"
:
0
},
"orientation"
:
{
"x"
:
0
,
"y"
:
0
,
"z"
:
0
,
"w"
:
0
}
}
}
},
{
"name"
:
"table_0"
,
"is_a"
:
[
"http://www.ease-crc.org/ont/EASE.owl#Table"
],
"components"
:
{
"transform"
:
{
"position"
:
{
"x"
:
0
,
"y"
:
0
,
"z"
:
0
},
"orientation"
:
{
"x"
:
0
,
"y"
:
0
,
"z"
:
0
,
"w"
:
0
}
}
}
},
{
"name"
:
"?task_0"
,
"is_a"
:
[
"http://www.ease-crc.org/ont/EASE-ACT.owl#Placing"
],
"classifies"
:
[
"action_0"
],
"components"
:
{}
},
{
"name"
:
"cup_0"
,
"is_a"
:
[
"http://ease-ph.glpages.informatik.uni-bremen.de/dlu/dlu/EASE-DLUext.owl#Cup"
],
"isOntopOf"
:
[
"table_0"
],
"components"
:
{
"transform"
:
{
"position"
:
{
"x"
:
0
,
"y"
:
0
,
"z"
:
0
},
"orientation"
:
{
"x"
:
0
,
"y"
:
0
,
"z"
:
0
,
"w"
:
0
}
}
}
},
{
"name"
:
"action_0"
,
"is_a"
:
[
"http://www.ontologydesignpatterns.org/ont/dul/DUL.owl#Action"
],
"hasParticipant"
:
[
"actor_0"
,
"cup_0"
],
"components"
:
{}
}
]
\ No newline at end of file
Assets/DLU/Resources/
test
.json.meta
→
Assets/DLU/Resources/
instruction
.json.meta
View file @
54300443
fileFormatVersion: 2
guid:
de24df3b941ba4a44bc55ca1ecbc28bd
guid:
c43bcf70078a54744bec23911f7c7e7b
TextScriptImporter:
externalObjects: {}
userData:
...
...
Assets/DLU/Resources/test.json
deleted
100644 → 0
View file @
01f9ad24
[
{
"name"
:
"actor_1"
,
"is_a"
:
[
"PhysicalAgent"
],
"is_a_iri"
:
[
"http://www.ontologydesignpatterns.org/ont/dul/DUL.owl#PhysicalAgent"
],
"components"
:
{
"transform"
:
{
"position"
:
{
"x"
:
0
,
"y"
:
0
,
"z"
:
0
},
"orientation"
:
{
"x"
:
0
,
"y"
:
0
,
"z"
:
0
,
"w"
:
0
}
}
}
},
{
"name"
:
"table_45"
,
"is_a"
:
[
"Table"
],
"is_a_iri"
:
[
"http://www.ease-crc.org/ont/EASE.owl#Table"
],
"components"
:
{
"transform"
:
{
"position"
:
{
"x"
:
0
,
"y"
:
0
,
"z"
:
0
},
"orientation"
:
{
"x"
:
0
,
"y"
:
0
,
"z"
:
0
,
"w"
:
0
}
}
}
},
{
"name"
:
"action_82"
,
"is_a"
:
[
"Action"
],
"is_a_iri"
:
[
"http://www.ontologydesignpatterns.org/ont/dul/DUL.owl#Action"
],
"hasParticipant"
:
[
"cup_33"
,
"actor_1"
],
"components"
:
{}
},
{
"name"
:
"?task_var"
,
"is_a"
:
[
"Placing"
],
"is_a_iri"
:
[
"http://www.ease-crc.org/ont/EASE-ACT.owl#Placing"
],
"isOntopOf"
:
[
"table_45"
],
"classifies"
:
[
"action_82"
],
"components"
:
{}
},
{
"name"
:
"cup_33"
,
"is_a"
:
[
"DesignedContainer"
],
"is_a_iri"
:
[
"http://www.ease-crc.org/ont/EASE.owl#DesignedContainer"
],
"components"
:
{
"transform"
:
{
"position"
:
{
"x"
:
0
,
"y"
:
0
,
"z"
:
0
},
"orientation"
:
{
"x"
:
0
,
"y"
:
0
,
"z"
:
0
,
"w"
:
0
}
}
}
}
]
\ No newline at end of file
Assets/DLU/Scenes/Kitchen.unity
View file @
54300443
...
...
@@ -3535,13 +3535,13 @@ Transform:
m_PrefabInstance
:
{
fileID
:
0
}
m_PrefabAsset
:
{
fileID
:
0
}
m_GameObject
:
{
fileID
:
705507993
}
m_LocalRotation
:
{
x
:
0.
40821788
,
y
:
-0.2
345696
8
,
z
:
0.
10938163
,
w
:
0.8754261
}
m_LocalRotation
:
{
x
:
0.
22958693
,
y
:
-0.2
514017
8
,
z
:
0.
061517622
,
w
:
0.9382444
}
m_LocalPosition
:
{
x
:
0.276663
,
y
:
2.3360832
,
z
:
-0.34766424
}
m_LocalScale
:
{
x
:
1
,
y
:
1
,
z
:
1
}
m_Children
:
[]
m_Father
:
{
fileID
:
1143887711
}
m_RootOrder
:
0
m_LocalEulerAnglesHint
:
{
x
:
5
0
,
y
:
-30
,
z
:
0
}
m_LocalEulerAnglesHint
:
{
x
:
27.
5
,
y
:
-30
,
z
:
0
}
---
!u!114
&705507997
MonoBehaviour
:
m_ObjectHideFlags
:
0
...
...
Assets/DLU/Scripts/Editor/SceneControllerEditor.cs
View file @
54300443
using
UnityEngine
;
using
UnityEditor
;
using
System.Linq
;
using
SimpleJSON
;
using
System.IO
;
namespace
dlu
{
...
...
@@ -9,12 +11,15 @@ namespace dlu
public
class
SceneControllerEditor
:
Editor
{
private
bool
showLabels
;
private
bool
exportContext
;
public
override
void
OnInspectorGUI
()
{
SceneController
sc
=
(
SceneController
)
target
;
base
.
DrawDefaultInspector
();
EditorGUILayout
.
Space
();
this
.
ExportContext
(
sc
);
EditorGUILayout
.
Space
();
this
.
ShowSemanticLabels
(
sc
);
...
...
@@ -41,6 +46,27 @@ public class SceneControllerEditor : Editor
EditorGUILayout
.
ObjectField
(
label
,
sb
.
gameObject
,
typeof
(
GameObject
),
true
);
}
}
EditorGUILayout
.
EndFoldoutHeaderGroup
();
}
private
void
ExportContext
(
SceneController
sc
)
{
exportContext
=
EditorGUILayout
.
BeginFoldoutHeaderGroup
(
exportContext
,
"Export context"
);
if
(
exportContext
)
{
JSONArray
sceneJson
=
sc
.
GenerateContextJSON
();
EditorGUILayout
.
TextArea
(
sceneJson
.
ToString
());
string
exportFile
=
EditorGUILayout
.
TextField
(
"Export file"
,
"Assets/DLU/Resources/context.json"
);
if
(
GUILayout
.
Button
(
"Export to file"
))
{
File
.
WriteAllText
(
exportFile
,
sceneJson
.
ToString
());
}
}
EditorGUILayout
.
EndFoldoutHeaderGroup
();
}
}
...
...
Assets/DLU/Scripts/InstanceIdentifier.cs
View file @
54300443
...
...
@@ -3,7 +3,7 @@ using UnityEngine;
namespace
dlu
{
public
class
InstanceIdentifier
:
Mono
Behaviour
public
class
InstanceIdentifier
:
Semantic
Behaviour
{
public
new
string
name
;
}
...
...
Assets/DLU/Scripts/SceneController.cs
View file @
54300443
using
UnityEngine
;
using
SimpleJSON
;
using
System.Collections.Generic
;
namespace
dlu
{
public
class
SceneController
:
MonoBehaviour
{
public
string
json
=
"test
"
;
public
string
instructionJson
=
"instruction.json
"
;
public
string
contextJson
=
"context.json"
;
[
HideInInspector
]
public
SemanticBehaviour
[]
semanticBehaviours
;
...
...
@@ -18,29 +19,64 @@ public class SceneController : MonoBehaviour
FindSemanticLabels
();
}
string
jsonContent
=
Resources
.
Load
<
TextAsset
>(
json
).
text
;
// Debug.Log(JsonUtility.ToJson(GameObject.Find("Objects/cup").GetComponent<Entity>()));
// List<Entity> scene = JsonConvert.DeserializeObject<List<Entity>>(jsonContent);
JSONArray
scene
=
JSON
.
Parse
(
jsonContent
)
as
JSONArray
;
foreach
(
JSONObject
obj
in
scene
)
{
SetGameObjectState
(
obj
);
}
// string jsonContent = Resources.Load<TextAsset>(instructionJson).text;
// JSONArray scene = JSON.Parse(jsonContent) as JSONArray;
// foreach (JSONObject obj in scene)
// {
// SetGameObjectState(obj);
// }
}
// private void SetGameObjectState(JSONObject sceneObject)
// {
// string name = sceneObject["name"];
// // Debug.Log($"name {name}");
// GameObject go = GameObject.Find($"Objects/{name}");
// if (go != null) {
// // Debug.Log(go);
// }
// }
public
void
FindSemanticLabels
()
{
this
.
semanticBehaviours
=
GameObject
.
FindObjectsOfType
<
SemanticBehaviour
>();
}
p
rivate
void
SetGameObjectState
(
JSONObject
sceneObject
)
p
ublic
JSONArray
GenerateContextJSON
(
)
{
string
name
=
sceneObject
[
"name"
];
// Debug.Log($"name {name}");
GameObject
go
=
GameObject
.
Find
(
$"Objects/
{
name
}
"
);
if
(
go
!=
null
)
{
// Debug.Log(go);
if
(
this
.
semanticBehaviours
==
null
)
{
FindSemanticLabels
();
}
Dictionary
<
string
,
JSONObject
>
sceneDict
=
new
Dictionary
<
string
,
JSONObject
>();
JSONArray
sceneArray
=
new
JSONArray
();
foreach
(
SemanticBehaviour
sb
in
this
.
semanticBehaviours
)
{
JSONObject
jsonObject
=
null
;
if
(!
sceneDict
.
ContainsKey
(
sb
.
name
))
{
sceneDict
[
sb
.
name
]
=
new
JSONObject
();
sceneDict
[
sb
.
name
].
Add
(
"is_a"
,
new
JSONArray
());
sceneArray
.
Add
(
sceneDict
[
sb
.
name
]);
}
jsonObject
=
sceneDict
[
sb
.
name
];
jsonObject
[
"is_a"
].
Add
(
sb
.
is_a
);
switch
(
sb
)
{
case
InstanceIdentifier
identifier
:
HandleInstanceIdentifier
(
jsonObject
,
identifier
);
break
;
default
:
Debug
.
LogWarning
(
"Trying to add SemanticBehaviour to JSON, but no case exists."
,
sb
);
break
;
}
}
return
sceneArray
;
}
p
ublic
void
FindSemanticLabels
(
)
p
rivate
void
HandleInstanceIdentifier
(
JSONObject
jsonObject
,
InstanceIdentifier
identifier
)
{
this
.
semanticBehaviours
=
GameObject
.
FindObjectsOfType
<
SemanticBehaviour
>()
;
jsonObject
[
"name"
]
=
identifier
.
name
;
}
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a 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