public void Reset()
 {
     catalogOrble       = null;
     foundSampleColor   = new Color();
     readingHistory     = new Color[readingHistorySize];
     readingIndex       = 0;
     currentProbedColor = new Color();
     averageColor       = new Color();
 }
Exemple #2
0
    public static void CreateCatalogOrble()
    {
        CatalogOrble newAsset = ScriptableObject.CreateInstance <CatalogOrble>();

        AssetDatabase.CreateAsset(newAsset, "Assets/Resources/Catalog/NewCatalogOrble.asset");
        AssetDatabase.SaveAssets();

        EditorUtility.FocusProjectWindow();

        Selection.activeObject = newAsset;
    }
    public override void OnInspectorGUI()
    {
        CatalogOrble catalogOrble = (CatalogOrble)target;

        catalogOrble.catalogNumber = EditorGUILayout.IntField("Catalog number", int.Parse(catalogOrble.name));
        EditorGUILayout.PropertyField(serializedObject.FindProperty("species"), true);

        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.PropertyField(serializedObject.FindProperty("typeId"), true);
        EditorGUILayout.LabelField(catalogOrble.TypeStringName());
        EditorGUILayout.EndHorizontal();

        EditorGUILayout.PropertyField(serializedObject.FindProperty("level"), true);

        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.PropertyField(serializedObject.FindProperty("colourId"), true);
        EditorGUILayout.LabelField(catalogOrble.ColorStringName());
        EditorGUILayout.EndHorizontal();

        serializedObject.ApplyModifiedProperties();
    }
Exemple #4
0
 void OnDeorbalize(Vector3 screenPosition, CatalogOrble catalogOrble)
 {
     orbleStage.PresentOrble(screenPosition, StagePresented);
 }
    void Update()
    {
        Vector3 probeScreenPosition           = arCamera.WorldToScreenPoint(this.transform.position);
        Vector2 normalizedProbeScreenPosition = new Vector2((float)probeScreenPosition.x / (float)Screen.width, (float)probeScreenPosition.y / (float)Screen.height);

        //for some odd reason vuforia is rendering backgroud upside down, inverting in Y axis to read the right pixel
        normalizedProbeScreenPosition = new Vector2(normalizedProbeScreenPosition.x, 1 - normalizedProbeScreenPosition.y);


        //probe for color
        if (isActive)
        {
            if (probingTexture == null)
            {
                //find probing texture
                if (GameObject.Find("BackgroundPlane") != null)
                {
                    probingTexture = (Texture2D)GameObject.Find("BackgroundPlane").GetComponent <Renderer>().sharedMaterial.mainTexture;
                }
                else
                {
                    Debug.LogError("Cannot find BackgroundPlane");
                }
            }
            else
            {
                //probe current pixel from buffer texture
                currentProbedColor = probingTexture.GetPixel(Mathf.RoundToInt(normalizedProbeScreenPosition.x * probingTexture.width),
                                                             Mathf.RoundToInt(normalizedProbeScreenPosition.y * probingTexture.height));


                readingHistory[readingIndex % readingHistorySize] = currentProbedColor;

                //reset index if we overflowing
                if (readingIndex < readingHistorySize)
                {
                    readingIndex++;
                }
                else
                {
                    readingIndex = 0;
                }


                averageColor = Extensions.CombineColors(readingHistory);

                //calculate closest color
                List <Color> sampleColors = new List <Color>();
                sampleColors.Add(samples[0].color);
                sampleColors.Add(samples[1].color);
                sampleColors.Add(samples[2].color);
                sampleColors.Add(samples[3].color);
                sampleColors.Add(samples[4].color);

                int closestIndex = closestColor1(sampleColors, averageColor);
                foundSampleColor = sampleColors[closestIndex];
                catalogOrble     = samples[closestIndex].catalogOrble;

                if (probingPreview != null)
                {
                    probingPreview.GetComponent <Renderer>().material.color = currentProbedColor;
                }
            }
        }
    }
 void OnDeorbalize(Vector3 screenSpace, CatalogOrble catalogOrble)
 {
     status.text = "Orble found, catalog number: " + catalogOrble.catalogNumber;
 }