This commit is contained in:
Alexander Munch-Hansen 2019-05-09 16:29:16 +02:00
parent 5e14778402
commit ea64f2ccb5
2 changed files with 246 additions and 29 deletions

View File

@ -27,6 +27,8 @@ public class python_test : MonoBehaviour
public GameObject FbxQueen;
public GameObject FbxRook;
public List<GameObject> pieces;
Mat camImageMat;
Texture2D outputTexture;
int baselineWidth = 1500;
@ -48,6 +50,8 @@ public class python_test : MonoBehaviour
Texture2D _TextureFromCamera;
bool displayLoaded = false;
GameObject quad;
Renderer quadRend;
RestClient restClient;
Dictionary<int, GameObject> intToPiece = new Dictionary<int, GameObject>();
@ -65,6 +69,10 @@ public class python_test : MonoBehaviour
void Start()
{
baseObject = GameObject.Find("base_object");
quad = GameObject.Find("Quad");
quadRend = quad.GetComponent<Renderer>();
boardState = new List<List<int>>() {
new List<int>() {0, 1, 2, 4, 3, 2, 1, 0},
@ -106,7 +114,10 @@ public class python_test : MonoBehaviour
_webcamtex = new WebCamTexture("HD Pro Webcam C920 #3", 1920, 1080);
_webcamtex.Play();
_webcamtex.Play();
//DoStuff();
baseObject.SetActive(false);
}
@ -141,7 +152,40 @@ public class python_test : MonoBehaviour
string result = reader.ReadLine();
return (string)result;
}*/
}*/
void DoStuff()
{
Vector3 bp = baseObject.transform.position;
foreach (GameObject piece in pieces)
{
Destroy(piece);
}
pieces.Clear();
for (int i = 0; i < 8; i++)
{
for (int j = 0; j < 8; j++)
{
int intPiece = boardState[j][i];
if (intPiece == 6)
{
continue;
}
GameObject fbx = intToPiece[intPiece];
GameObject piece = Instantiate(fbx);
piece.transform.localScale = baseObject.transform.localScale;
piece.transform.position = new Vector3((float)(bp.x + i * 0.04),
bp.y,
(float)(bp.z + j * 0.04));
pieces.Add(piece);
}
}
}
@ -215,24 +259,9 @@ public class python_test : MonoBehaviour
HomographyAndState homographyAndState = JsonConvert.DeserializeObject<HomographyAndState>(pls);
boardState = homographyAndState.board;
Vector3 bp = baseObject.transform.position;
for (int i = 0; i < 8; i++) {
for (int j = 0; j < 8; j++) {
int intPiece = boardState[j][i];
if (intPiece == 6) {
continue;
}
GameObject fbx = intToPiece[intPiece];
GameObject piece = Instantiate(fbx);
piece.transform.localScale = baseObject.transform.localScale;
piece.transform.position = new Vector3((float)(bp.x + i * 0.04),
bp.y,
(float)(bp.z + j * 0.04));
}
}
DoStuff();
// MatDisplay.DisplayMat(loadedImage, MatDisplaySettings.FULL_BACKGROUND);
@ -242,10 +271,12 @@ public class python_test : MonoBehaviour
}
if (viewMarked == 0)
{
//MatDisplay.DisplayMat(camMatFromTexture, MatDisplaySettings.FULL_BACKGROUND);
{
//MatDisplay.DisplayMat(camMatFromTexture, MatDisplaySettings.FULL_BACKGROUND);
quadRend.sharedMaterial.mainTexture = _TextureFromCamera;
} else if (viewMarked == 1)
}
else if (viewMarked == 1)
{
MatDisplay.DisplayMat(loadedImage, MatDisplaySettings.FULL_BACKGROUND);
}

View File

@ -125,7 +125,7 @@ PrefabInstance:
objectReference: {fileID: 0}
- target: {fileID: 400000, guid: 99f0d192cd83c408381f8f6112fdf3dc, type: 3}
propertyPath: m_LocalPosition.x
value: -0.07
value: 0.075
objectReference: {fileID: 0}
- target: {fileID: 400000, guid: 99f0d192cd83c408381f8f6112fdf3dc, type: 3}
propertyPath: m_LocalPosition.y
@ -133,7 +133,7 @@ PrefabInstance:
objectReference: {fileID: 0}
- target: {fileID: 400000, guid: 99f0d192cd83c408381f8f6112fdf3dc, type: 3}
propertyPath: m_LocalPosition.z
value: 0.11
value: -0.03
objectReference: {fileID: 0}
- target: {fileID: 400000, guid: 99f0d192cd83c408381f8f6112fdf3dc, type: 3}
propertyPath: m_LocalRotation.x
@ -298,13 +298,106 @@ Transform:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 277462151}
m_LocalRotation: {x: 0, y: 0.7071068, z: 0, w: 0.7071068}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 0.12065, y: 0.12065, z: 0.12065}
m_Children: []
m_Children:
- {fileID: 857694817}
m_Father: {fileID: 0}
m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 0, y: 90, z: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &667526946
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 667526947}
- component: {fileID: 667526950}
- component: {fileID: 667526949}
- component: {fileID: 667526948}
m_Layer: 0
m_Name: Quad
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &667526947
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 667526946}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0.1464, y: -0.0783, z: 0.3743}
m_LocalScale: {x: 0.08, y: 0.05, z: 0.1}
m_Children: []
m_Father: {fileID: 1994725153}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!64 &667526948
MeshCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 667526946}
m_Material: {fileID: 0}
m_IsTrigger: 0
m_Enabled: 1
serializedVersion: 3
m_Convex: 0
m_CookingOptions: 14
m_Mesh: {fileID: 10210, guid: 0000000000000000e000000000000000, type: 0}
--- !u!23 &667526949
MeshRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 667526946}
m_Enabled: 1
m_CastShadows: 1
m_ReceiveShadows: 1
m_DynamicOccludee: 1
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 0
m_SelectedEditorRenderState: 3
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
--- !u!33 &667526950
MeshFilter:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 667526946}
m_Mesh: {fileID: 10210, guid: 0000000000000000e000000000000000, type: 0}
--- !u!1 &730623320
GameObject:
m_ObjectHideFlags: 0
@ -382,6 +475,98 @@ Material:
m_Floats: []
m_Colors:
- _Color: {r: 0.9607843, g: 0.10606851, b: 0.050980415, a: 1}
--- !u!1 &857694816
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 857694817}
- component: {fileID: 857694820}
- component: {fileID: 857694819}
- component: {fileID: 857694818}
m_Layer: 0
m_Name: tracker
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &857694817
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 857694816}
m_LocalRotation: {x: 0.7071068, y: 0, z: 0, w: 0.7071068}
m_LocalPosition: {x: -0.005, y: 0.14, z: 0.055}
m_LocalScale: {x: 0.2493839, y: 0.24037002, z: 0.24037002}
m_Children: []
m_Father: {fileID: 277462157}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 90, y: 0, z: 0}
--- !u!64 &857694818
MeshCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 857694816}
m_Material: {fileID: 0}
m_IsTrigger: 0
m_Enabled: 1
serializedVersion: 3
m_Convex: 0
m_CookingOptions: 14
m_Mesh: {fileID: 10210, guid: 0000000000000000e000000000000000, type: 0}
--- !u!23 &857694819
MeshRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 857694816}
m_Enabled: 1
m_CastShadows: 1
m_ReceiveShadows: 1
m_DynamicOccludee: 1
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: 2100000, guid: 2d51c10d244ae4abaa38fd20c0c3e54a, type: 2}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 0
m_SelectedEditorRenderState: 3
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
--- !u!33 &857694820
MeshFilter:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 857694816}
m_Mesh: {fileID: 10210, guid: 0000000000000000e000000000000000, type: 0}
--- !u!1 &1840619079
GameObject:
m_ObjectHideFlags: 0
@ -555,9 +740,10 @@ Transform:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1994725148}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalPosition: {x: -0.015, y: 0, z: 0.005}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Children:
- {fileID: 667526947}
m_Father: {fileID: 0}
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}