diff --git a/Example/Images/Lemon.jpg.meta b/Example/Images/Lemon.jpg.meta index 5d4b629..857427b 100644 --- a/Example/Images/Lemon.jpg.meta +++ b/Example/Images/Lemon.jpg.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 20ba80ff0f251284eb89a619b43ad34d +guid: b5b6ffb91889c8e47a57284eb19d70d9 TextureImporter: internalIDToNameTable: [] externalObjects: {} diff --git a/Example/Images/SPOILER_furstitchuwu.png.meta b/Example/Images/SPOILER_furstitchuwu.png.meta index e2d501b..f413270 100644 --- a/Example/Images/SPOILER_furstitchuwu.png.meta +++ b/Example/Images/SPOILER_furstitchuwu.png.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 150800b71b44ce24bb0768b246ea1b92 +guid: 075243ffb5ab1f14faedab08af1996bf TextureImporter: internalIDToNameTable: [] externalObjects: {} diff --git a/Example/Images/calibaration.png.meta b/Example/Images/calibaration.png.meta index 7cfde80..19ba9fb 100644 --- a/Example/Images/calibaration.png.meta +++ b/Example/Images/calibaration.png.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: c37553493efe5c64f8d272a8b63f3a2a +guid: 75e782a9ec2f1e349a927eb65a359d71 TextureImporter: internalIDToNameTable: [] externalObjects: {} diff --git a/Example/Images/color.png.meta b/Example/Images/color.png.meta index c5411ea..dd1e373 100644 --- a/Example/Images/color.png.meta +++ b/Example/Images/color.png.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 444dcee0246edcc4994f806d58f6df19 +guid: af53a8fc81631994a9b4917f425cac5b TextureImporter: internalIDToNameTable: [] externalObjects: {} diff --git a/Example/Images/kit.jpg.meta b/Example/Images/kit.jpg.meta index d7ccb1b..f9e8b03 100644 --- a/Example/Images/kit.jpg.meta +++ b/Example/Images/kit.jpg.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 1694040be6d39884b81e4760016af5f9 +guid: b84375df11d3fbd46bc7adc095fbee16 TextureImporter: internalIDToNameTable: [] externalObjects: {} diff --git a/Example/Images/nature.jpg.meta b/Example/Images/nature.jpg.meta index c014e67..376ed0f 100644 --- a/Example/Images/nature.jpg.meta +++ b/Example/Images/nature.jpg.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 04f2ba87b08d7264aaf7584a4c0da614 +guid: 24de427f3feed91438272cb215bc74a0 TextureImporter: internalIDToNameTable: [] externalObjects: {} diff --git a/Example/Images/qr-code.png.meta b/Example/Images/qr-code.png.meta index 399473a..52b5e31 100644 --- a/Example/Images/qr-code.png.meta +++ b/Example/Images/qr-code.png.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 96339aefa3650a94abca11bb70ceddaf +guid: c955cca55505c1e47ad808f23f065b7a TextureImporter: internalIDToNameTable: [] externalObjects: {} diff --git a/Example/Images/shyguyad.jpg.meta b/Example/Images/shyguyad.jpg.meta index 2c89043..af83530 100644 --- a/Example/Images/shyguyad.jpg.meta +++ b/Example/Images/shyguyad.jpg.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: df6016c82dac3564a82c99d43947c2db +guid: 8d2ba7a9460d1c9449a6f32e076ee79f TextureImporter: internalIDToNameTable: [] externalObjects: {} diff --git a/Example/Lemon.jpg.meta b/Example/Lemon.jpg.meta index a3ddc1b..5b11188 100644 --- a/Example/Lemon.jpg.meta +++ b/Example/Lemon.jpg.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 20ba80ff0f251284eb89a619b43ad34d +guid: 414dc51b526de814a98c3ad057574a79 TextureImporter: internalIDToNameTable: [] externalObjects: {} diff --git a/Example/SPOILER_furstitchuwu.png.meta b/Example/SPOILER_furstitchuwu.png.meta index 0351688..82e72ed 100644 --- a/Example/SPOILER_furstitchuwu.png.meta +++ b/Example/SPOILER_furstitchuwu.png.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 150800b71b44ce24bb0768b246ea1b92 +guid: dd426dda3dc107a49854d9767e27cfce TextureImporter: internalIDToNameTable: [] externalObjects: {} diff --git a/Example/calibaration.png.meta b/Example/calibaration.png.meta index 492e19b..547771e 100644 --- a/Example/calibaration.png.meta +++ b/Example/calibaration.png.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: c37553493efe5c64f8d272a8b63f3a2a +guid: 5a7eab22f3f2d4243b215219e7c47f41 TextureImporter: internalIDToNameTable: [] externalObjects: {} diff --git a/Example/color.png.meta b/Example/color.png.meta index 70b007f..df78e4a 100644 --- a/Example/color.png.meta +++ b/Example/color.png.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 444dcee0246edcc4994f806d58f6df19 +guid: 6b1a13f03c925fe40b67633f32e10904 TextureImporter: internalIDToNameTable: [] externalObjects: {} diff --git a/Example/kit.jpg.meta b/Example/kit.jpg.meta index ce194b5..3f53216 100644 --- a/Example/kit.jpg.meta +++ b/Example/kit.jpg.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 1694040be6d39884b81e4760016af5f9 +guid: 7112f3b8cd5a1cd4ca737bd16571c761 TextureImporter: internalIDToNameTable: [] externalObjects: {} diff --git a/Example/nature.jpg.meta b/Example/nature.jpg.meta index b8ef2ba..2b7cabf 100644 --- a/Example/nature.jpg.meta +++ b/Example/nature.jpg.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 04f2ba87b08d7264aaf7584a4c0da614 +guid: 0a0df4e934a146845ad4c67d6822e7f7 TextureImporter: internalIDToNameTable: [] externalObjects: {} diff --git a/Example/qr-code.png.meta b/Example/qr-code.png.meta index 399473a..64317d6 100644 --- a/Example/qr-code.png.meta +++ b/Example/qr-code.png.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 96339aefa3650a94abca11bb70ceddaf +guid: 6258f317e2edf504b965cd24c37eab3b TextureImporter: internalIDToNameTable: [] externalObjects: {} diff --git a/Example/shyguyad.jpg.meta b/Example/shyguyad.jpg.meta index bfd2735..1e5ce40 100644 --- a/Example/shyguyad.jpg.meta +++ b/Example/shyguyad.jpg.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: df6016c82dac3564a82c99d43947c2db +guid: 20ec70198e7d7514996e0c296fd7497f TextureImporter: internalIDToNameTable: [] externalObjects: {} diff --git a/GeometrizeVisualizer.cs b/GeometrizeVisualizer.cs index df01677..879cff7 100644 --- a/GeometrizeVisualizer.cs +++ b/GeometrizeVisualizer.cs @@ -87,8 +87,20 @@ public void Convert() case 32: createCircle(shape.data, shape.color, wichShape); break; + case 8: + createEllipse(shape.data, shape.color, wichShape); + break; + case 16: + createRotatedEllipse(shape.data, shape.color, wichShape); + break; + case 1: + createCube(shape.data, shape.color, wichShape); + break; + case 2: + createRotatedCube(shape.data, shape.color, wichShape); + break; default: - Debug.Log("Shape Type not supported!"); + Debug.Log("Shape Type: " + shape.type + " not supported"); break; } } @@ -131,107 +143,88 @@ void createCube(List data, List color, int position) // Create a new cube GameObject cube = Instantiate(cubePrefab, transform); // Set the position - cube.transform.localPosition = new Vector3(canvas.localScale.x / 2, canvas.localScale.y / 2, 0) - new Vector3(data[0], data[1], -(0.1f * position)); + //data[0] and data[1] are the x and y coordinates of the top left corner of the rectangle + //data[2] and data[3] are the x and y coordinates of the bottom right corner of the rectangle + + float middleOfXCorners = ((data[2] - data[0]) / 2) + data[0]; + float middleOfYCorners = ((data[3] - data[1]) / 2) + data[1]; + Vector3 vectorToMiddle = new Vector3(middleOfXCorners * globalSizeMultiplier, middleOfYCorners * globalSizeMultiplier, 0); + + cube.transform.localPosition = new Vector3(canvas.localScale.x / 2, canvas.localScale.y / 2, 0) - vectorToMiddle + new Vector3(0, 0, 0.0001f * position); + // Set the scale - cube.transform.localScale = new Vector3(data[2] * 2, data[3] * 2, 0.01f); + cube.transform.localScale = new Vector3((data[2] - data[0]) * globalSizeMultiplier, (data[3] - data[1]) * globalSizeMultiplier, 0.00001f); + // Set the color Color colorVar = new Color(color[0] / 255f, color[1] / 255f, color[2] / 255f); colorVar.a = color[3] / 255f; cube.GetComponent().Color = colorVar; - /* - cube.GetComponent().material.color = colorVar; - cube.GetComponent().material.SetFloat("_Mode", 3); - cube.GetComponent().material.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.SrcAlpha); - cube.GetComponent().material.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.OneMinusSrcAlpha); - cube.GetComponent().material.SetInt("_ZWrite", 0); - cube.GetComponent().material.DisableKeyword("_ALPHATEST_ON"); - cube.GetComponent().material.EnableKeyword("_ALPHABLEND_ON"); - cube.GetComponent().material.DisableKeyword("_ALPHAPREMULTIPLY_ON"); - cube.GetComponent().material.renderQueue = 3000; - */ + cube.GetComponent().Collidable = collidable; } - void createRotatedCube(List data, List color) + void createRotatedCube(List data, List color, int position) { // Create a new cube GameObject cube = Instantiate(cubePrefab, transform); // Set the position - cube.transform.localPosition = new Vector3(data[0], data[1], 0.01f); + //data[0] and data[1] are the x and y coordinates of the top left corner of the rectangle + //data[2] and data[3] are the x and y coordinates of the bottom right corner of the rectangle + + float middleOfXCorners = ((data[2] - data[0]) / 2) + data[0]; + float middleOfYCorners = ((data[3] - data[1]) / 2) + data[1]; + Vector3 vectorToMiddle = new Vector3(middleOfXCorners * globalSizeMultiplier, middleOfYCorners * globalSizeMultiplier, 0); + + cube.transform.localPosition = new Vector3(canvas.localScale.x / 2, canvas.localScale.y / 2, 0) - vectorToMiddle + new Vector3(0, 0, 0.0001f * position); + // Set the scale - cube.transform.localScale = new Vector3(data[2], data[3], 1); - // Set the rotation - cube.transform.localRotation = Quaternion.Euler(data[4], 0, 0); + cube.transform.localScale = new Vector3((data[2] - data[0]) * globalSizeMultiplier, (data[3] - data[1]) * globalSizeMultiplier, 0.00001f); + + //Set rotation + cube.transform.localRotation = Quaternion.Euler(0, 0, data[4]); + // Set the color Color colorVar = new Color(color[0] / 255f, color[1] / 255f, color[2] / 255f); colorVar.a = color[3] / 255f; cube.GetComponent().Color = colorVar; - /* - cube.GetComponent().material.color = colorVar; - cube.GetComponent().material.SetFloat("_Mode", 3); - cube.GetComponent().material.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.SrcAlpha); - cube.GetComponent().material.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.OneMinusSrcAlpha); - cube.GetComponent().material.SetInt("_ZWrite", 0); - cube.GetComponent().material.DisableKeyword("_ALPHATEST_ON"); - cube.GetComponent().material.EnableKeyword("_ALPHABLEND_ON"); - cube.GetComponent().material.DisableKeyword("_ALPHAPREMULTIPLY_ON"); - cube.GetComponent().material.renderQueue = 3000; - */ + cube.GetComponent().Collidable = collidable; } - void createEllipse(List data, List color) + void createEllipse(List data, List color, int position) { // Create a new sphere GameObject sphere = Instantiate(spherePrefab, transform); // Set the position - sphere.transform.localPosition = new Vector3(data[0], data[1], 0.01f); + sphere.transform.localPosition = new Vector3(canvas.localScale.x / 2, canvas.localScale.y / 2, 0) - new Vector3(data[0] * globalSizeMultiplier, data[1] * globalSizeMultiplier, -(0.0001f * position)); // Set the scale - sphere.transform.localScale = new Vector3(data[2], data[3], 1); + sphere.transform.localScale = new Vector3(data[2] * 2 * globalSizeMultiplier, 0.00001f, data[3] * 2 * globalSizeMultiplier); + //Set rotation + sphere.transform.localRotation = Quaternion.Euler(90, 0, 0); // Set the color Color colorVar = new Color(color[0] / 255f, color[1] / 255f, color[2] / 255f); colorVar.a = color[3] / 255f; sphere.GetComponent().Color = colorVar; - /* - sphere.GetComponent().material.color = colorVar; - sphere.GetComponent().material.SetFloat("_Mode", 3); - sphere.GetComponent().material.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.SrcAlpha); - sphere.GetComponent().material.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.OneMinusSrcAlpha); - sphere.GetComponent().material.SetInt("_ZWrite", 0); - sphere.GetComponent().material.DisableKeyword("_ALPHATEST_ON"); - sphere.GetComponent().material.EnableKeyword("_ALPHABLEND_ON"); - sphere.GetComponent().material.DisableKeyword("_ALPHAPREMULTIPLY_ON"); - sphere.GetComponent().material.renderQueue = 3000; - */ + sphere.GetComponent().Collidable = collidable; } - void createRotatedEllipse(List data, List color) + void createRotatedEllipse(List data, List color, int position) { // Create a new sphere GameObject sphere = Instantiate(spherePrefab, transform); // Set the position - sphere.transform.localPosition = new Vector3(data[0], data[1], 0.01f); + sphere.transform.localPosition = new Vector3(canvas.localScale.x / 2, canvas.localScale.y / 2, 0) - new Vector3(data[0] * globalSizeMultiplier, data[1] * globalSizeMultiplier, -(0.0001f * position)); // Set the scale - sphere.transform.localScale = new Vector3(data[2], data[3], 1); - // Set the rotation - sphere.transform.localRotation = Quaternion.Euler(data[4], 0, 0); + sphere.transform.localScale = new Vector3(data[2] * 2 * globalSizeMultiplier, 0.00001f, data[3] * 2 * globalSizeMultiplier); + //Set rotation + sphere.transform.localRotation = Quaternion.Euler(90f - data[4], 90, 90); // Set the color Color colorVar = new Color(color[0] / 255f, color[1] / 255f, color[2] / 255f); colorVar.a = color[3] / 255f; sphere.GetComponent().Color = colorVar; - /* - sphere.GetComponent().material.color = colorVar; - sphere.GetComponent().material.SetFloat("_Mode", 3); - sphere.GetComponent().material.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.SrcAlpha); - sphere.GetComponent().material.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.OneMinusSrcAlpha); - sphere.GetComponent().material.SetInt("_ZWrite", 0); - sphere.GetComponent().material.DisableKeyword("_ALPHATEST_ON"); - sphere.GetComponent().material.EnableKeyword("_ALPHABLEND_ON"); - sphere.GetComponent().material.DisableKeyword("_ALPHAPREMULTIPLY_ON"); - sphere.GetComponent().material.renderQueue = 3000; - */ + sphere.GetComponent().Collidable = collidable; } void createCircle(List data, List color, int position) @@ -250,17 +243,6 @@ void createCircle(List data, List color, int position) sphere.GetComponent().Color = colorVar; sphere.GetComponent().Collidable = collidable; - /* - sphere.GetComponent().material.color = colorVar; - sphere.GetComponent().material.SetFloat("_Mode", 3); - sphere.GetComponent().material.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.SrcAlpha); - sphere.GetComponent().material.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.OneMinusSrcAlpha); - sphere.GetComponent().material.SetInt("_ZWrite", 0); - sphere.GetComponent().material.DisableKeyword("_ALPHATEST_ON"); - sphere.GetComponent().material.EnableKeyword("_ALPHABLEND_ON"); - sphere.GetComponent().material.DisableKeyword("_ALPHAPREMULTIPLY_ON"); - sphere.GetComponent().material.renderQueue = 3000; - */ } public void clearChildren()