Verified Commit 6476d56c authored by Sebastian Höffner's avatar Sebastian Höffner
Browse files

Generating correct target position and visualizing it.

parent e80b819d
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 6
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: Target
m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0}
m_ShaderKeywords: _ALPHABLEND_ON _EMISSION
m_LightmapFlags: 2
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
m_CustomRenderQueue: 3000
stringTagMap:
RenderType: Transparent
disabledShaderPasses: []
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
- _BumpMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailAlbedoMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailMask:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailNormalMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _EmissionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MainTex:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MetallicGlossMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _OcclusionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _ParallaxMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Floats:
- _BumpScale: 1
- _Cutoff: 0.5
- _DetailNormalMapScale: 1
- _DstBlend: 10
- _GlossMapScale: 1
- _Glossiness: 0.488
- _GlossyReflections: 1
- _Metallic: 0.144
- _Mode: 2
- _OcclusionStrength: 1
- _Parallax: 0.02
- _SmoothnessTextureChannel: 0
- _SpecularHighlights: 1
- _SrcBlend: 5
- _UVSec: 0
- _ZWrite: 0
m_Colors:
- _Color: {r: 0.5802195, g: 0.9433962, b: 0.5562478, a: 0.57254905}
- _EmissionColor: {r: 0.1796578, g: 0.3729852, b: 0.15817697, a: 1}
fileFormatVersion: 2
guid: 423d2cbeec7334fe1bcb3f16b4d072d1
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 0
userData:
assetBundleName:
assetBundleVariant:
This diff is collapsed.
[
{
"name": "actor_0",
"components": {},
"name": "?task_0",
"is_a": [
"http://www.ontologydesignpatterns.org/ont/dul/DUL.owl#PhysicalAgent"
"http://www.ease-crc.org/ont/EASE-ACT.owl#Placing"
],
"classifies": [
"action_0"
]
},
{
"components": {},
"name": "action_0",
"is_a": [
"http://www.ontologydesignpatterns.org/ont/dul/DUL.owl#Action"
],
"hasParticipant": [
"cup_0",
"actor_0"
]
},
{
"components": {
"transform": {
"position": {
"x": 0,
"y": 0,
"z": 0
"x": 0.5925120115280159,
"y": 0.653468012809754,
"z": -1.600627094507217
},
"orientation": {
"x": -1.3969840395589e-8,
"y": -0.918447494506836,
"z": 1.11758726717426e-8,
"w": -0.395542949438095
}
},
"bounds": {
"center": {
"x": 0,
"y": 0,
"z": 0,
"w": 0
"y": 0.0600000023841858,
"z": 0.0177846029400826
},
"extents": {
"x": 0,
"y": 0.0600000023841858,
"z": 0.0177846029400826
},
"size": {
"x": 0,
"y": 0.0600000023841858,
"z": 0.0177846029400826
}
}
}
},
{
"name": "table_0",
},
"containerVolume": [
{
"type": "BoxCollider",
"center": {
"x": -2.57680034637451,
"y": 0.902314186096191,
"z": 1.73480021953583
},
"size": {
"x": 0.105839252471924,
"y": 0.104725956916809,
"z": 0.104326486587524
},
"extents": {
"x": 0.0529196262359619,
"y": 0.0523629784584045,
"z": 0.0521632432937622
}
},
{
"type": "BoxCollider",
"center": {
"x": -2.57640409469604,
"y": 0.902528047561646,
"z": 1.736492395401
},
"size": {
"x": 0.0742592811584473,
"y": 0.105153679847717,
"z": 0.100225448608398
},
"extents": {
"x": 0.0371296405792236,
"y": 0.0525768399238586,
"z": 0.0501127243041992
}
},
{
"type": "BoxCollider",
"center": {
"x": -2.57640409469604,
"y": 0.902442157268524,
"z": 1.73649263381958
},
"size": {
"x": 0.102631092071533,
"y": 0.104981899261475,
"z": 0.0802216529846191
},
"extents": {
"x": 0.0513155460357666,
"y": 0.0524909496307373,
"z": 0.0401108264923096
}
}
]
},
"name": "cup_0",
"is_a": [
"http://www.ease-crc.org/ont/EASE.owl#Table"
"http://ease-ph.glpages.informatik.uni-bremen.de/dlu/dlu/EASE-DLUext.owl#Cup",
"http://www.ease-crc.org/ont/EASE.owl#DesignedContainer"
],
"isOntopOf": [
"table_0"
]
},
{
"components": {
"transform": {
"position": {
......@@ -36,54 +130,34 @@
"x": 0,
"y": 0,
"z": 0,
"w": 0
"w": 1
}
}
}
},
{
"name": "?task_0",
},
"name": "actor_0",
"is_a": [
"http://www.ease-crc.org/ont/EASE-ACT.owl#Placing"
],
"classifies": [
"action_0"
],
"components": {}
"http://www.ontologydesignpatterns.org/ont/dul/DUL.owl#PhysicalAgent"
]
},
{
"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,
"x": 1.43400001525879,
"y": 0,
"z": 0
"z": -2.04800009727478
},
"orientation": {
"x": 0,
"y": 0,
"z": 0,
"w": 0
"w": 1
}
}
}
},
{
"name": "action_0",
},
"name": "table_0",
"is_a": [
"http://www.ontologydesignpatterns.org/ont/dul/DUL.owl#Action"
],
"hasParticipant": [
"actor_0",
"cup_0"
],
"components": {}
"http://www.ease-crc.org/ont/EASE.owl#Table"
]
}
]
\ No newline at end of file
......@@ -2870,6 +2870,36 @@ Transform:
m_Father: {fileID: 1899308096}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &580399489
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 580399490}
m_Layer: 0
m_Name: ComparisonPosition
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &580399490
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 580399489}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0.59, y: 0.713, z: -1.58}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 5
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1001 &591176976
PrefabInstance:
m_ObjectHideFlags: 0
......@@ -7878,7 +7908,7 @@ Rigidbody:
m_IsKinematic: 0
m_Interpolate: 0
m_Constraints: 0
m_CollisionDetection: 2
m_CollisionDetection: 3
--- !u!114 &1331286837
MonoBehaviour:
m_ObjectHideFlags: 0
......
......@@ -65,10 +65,7 @@ public class SceneControllerEditor : Editor
private void ExportContext(SceneController sc)
{
string exportFile = EditorGUILayout.TextField("Export Context File", "Assets/DLU/Resources/context.json");
if (sceneJson == null)
{
sceneJson = GenerateContextJSON(sc);
}
sceneJson = GenerateContextJSON(sc);
if (GUILayout.Button("Export to file"))
{
File.WriteAllText(exportFile, sceneJson.ToString());
......@@ -129,14 +126,21 @@ public class SceneControllerEditor : Editor
transform["orientation"] = entity.transform.rotation;
jsonObject["components"]["transform"] = transform;
Vector3 scale = entity.transform.lossyScale;
MeshFilter meshFilter = entity.GetComponent<MeshFilter>();
if (meshFilter != null)
{
Mesh mesh = meshFilter.sharedMesh;
Vector3 boundsCenterWorld = mesh.bounds.center;
boundsCenterWorld.Scale(scale);
Vector3 boundsExtentsWorld = mesh.bounds.center;
boundsExtentsWorld.Scale(scale);
Vector3 boundsSizeWorld = mesh.bounds.center;
boundsSizeWorld.Scale(scale);
JSONObject bounds = new JSONObject();
bounds["center"] = mesh.bounds.center;
bounds["extents"] = mesh.bounds.extents;
bounds["size"] = mesh.bounds.size;
bounds["center"] = boundsCenterWorld;
bounds["extents"] = boundsExtentsWorld;
bounds["size"] = boundsSizeWorld;
jsonObject["components"]["bounds"] = bounds;
}
}
......
......@@ -15,7 +15,7 @@ public class SceneController : MonoBehaviour
[HideInInspector]
public JSONArray instruction = null;
private SemanticBehaviour[] _semanticBehaviours;
private Dictionary<string, GameObject> sceneDict; // = new Dictionary<string, GameObject>();
private Dictionary<string, GameObject> sceneDict;
[HideInInspector]
public SemanticBehaviour[] semanticBehaviours {
......@@ -98,16 +98,28 @@ public class SceneController : MonoBehaviour
Debug.Log($"Participant: {participant}");
foreach(JSONNode is_a in taskDict[participant]["is_a"])
{
// TODO(@shoeffner): This is not good: we should query the ontology and don't use is_a which are also PhysicalAgents etc., also just add participants once
if (is_a != "http://www.ontologydesignpatterns.org/ont/dul/DUL.owl#PhysicalAgent")
{
participants.Add(participant);
break;
}
}
}
foreach (string participant in participants)
{
GameObject participantGO = sceneDict[participant];
GameObject targetGO = new GameObject($"Target of {participant}");
// Setup visuals
GameObject renderer = new GameObject("RenderComponents");
renderer.transform.SetParent(targetGO.transform);
renderer.transform.localScale = participantGO.transform.lossyScale;
MeshFilter mesh = renderer.AddComponent<MeshFilter>();
mesh.mesh = participantGO.GetComponent<MeshFilter>().mesh;
MeshRenderer mr = renderer.AddComponent<MeshRenderer>();
mr.material = Resources.Load<Material>("Target");
Vector3 position = taskDict[participant]["components"]["transform"]["position"];
Quaternion orientation = taskDict[participant]["components"]["transform"]["orientation"];
targetGO.transform.SetPositionAndRotation(position, orientation);
......@@ -118,7 +130,7 @@ public class SceneController : MonoBehaviour
arguments["position"] = targetGO.transform;
arguments["speed"] = speed;
iTween.MoveTo(sceneDict[participant], arguments);
iTween.MoveTo(participantGO, arguments);
}
yield return null;
}
......
Supports Markdown
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