예제 #1
0
    public void RotateLayerCCW(CLayer aLayer)
    {
        var layer = this[aLayer];

        this[aLayer] = layer.RotateCCW();
        StartCoroutine(RotateLayer(layer, 90f, 5f));
    }
예제 #2
0
 /* Snap a given layer to the container & add to the manager list. */
 private void SnapLayerToContainer(CLayer layer)
 {
     layer.rigidbody.isKinematic         = true;
     layer.rigidbody.useGravity          = false;
     layer.gameObject.transform.position = this.transform.position;
     layer.gameObject.transform.rotation = Quaternion.Euler(new Vector3(-90, 0, 180));
 }
예제 #3
0
        public void removeTile(CLayer layer, Vector2 position, int offSetX = 0, int offSetY = 0)
        {
            position.X += offSetX;
            position.Y += offSetY;
            int index = layer.indexOfTileReverse(position);

            layer.removeTile(index);
        }
예제 #4
0
 public void SetLayer(CLayer layer)
 {
     activeLayer = layer;
     activeIndex = layer.GetIndex();
     if (activeIndex >= 0 && activeIndex < activations.Count)
     {
         SetTexture(activations[activeIndex]);
     }
 }
예제 #5
0
    public void LoadAllLayerActivations()
    {
        List <int> activationIndices = new List <int>();

        if (activations)
        {
            activations.Clear();
        }

        if (!LayerManager)
        {
            return;
        }
        if (LayerManager.Layers.Count == 0)
        {
            Debug.LogError("Error: No active layers found. ");
        }

        //StartCoroutine(LoadInputImage());

        // Load images into layer array:
        int imgIndex = 0;

        for (int i = 0; i < LayerManager.Layers.Count; i++)
        {
            StartCoroutine(LoadLocalImage(imgIndex, i));

            LayerManager.Layers[i].bakedIndex = imgIndex;

            //StartCoroutine(LoadActivationToList(imgIndex)); // Add layer activation for each layer
            activationIndices.Add(imgIndex);


            // Skip auto-generated activation layers from Conv/Dense layers
            CLayer CurLayer = LayerManager.Layers[i];
            if (CurLayer.layerType == CLayerType.Conv || CurLayer.layerType == CLayerType.Dense)
            {
                LayerManager.Layers[i].actIndex = imgIndex + 1;
                //StartCoroutine(LoadActivationToList(imgIndex + 1)); // Add corresponding activation
                activationIndices.Add(imgIndex + 1);
                imgIndex += 2; // Skip to the next image
            }
            else
            {
                imgIndex++;
            }
        }

        StartCoroutine(LoadAllActivations(activationIndices));

        if (activations)
        {
            activations.SetVisibility(true);              // Always activations after the first time
        }
    }
예제 #6
0
    /* Find and load a local image into the layer array. */
    IEnumerator LoadLocalImage(int imgID, int ContainerID)
    {
        bool bIsLookingForTex = true;

        imgID += 2; // b/c 2 existing in prebuild model
        string img = m_Path + "/" + TPrefix + imgID + ".png";

        while (bIsLookingForTex)
        {
            if (System.IO.File.Exists(img))
            {
                bIsLookingForTex = false;
                //Debug.LogWarning("Found");
                break;
            }
            else
            {
                Debug.Log("Waiting " + imgID);
                yield return(new WaitForSeconds(0.2f));

                continue;
                CLayer activeLayer = LayerManager.GetLayer(ContainerID);
                activeLayer.SetTexture(fillerTex_layer);
                yield break; // Stop the coroutine
                //Debug.LogWarning("Waiting");
            }
            yield return(new WaitForSeconds(0.2f));
        }
        bIsLookingForTex = true;
        yield return(new WaitForSeconds(0.2f));

        while (bIsLookingForTex)
        {
            WWW www = new WWW(img);
            while (!www.isDone)
            {
                yield return(null);
            }
            if (www.texture)
            {
                CLayer    activeLayer = LayerManager.GetLayer(ContainerID);
                Texture2D newTex      = www.texture;
                newTex.wrapMode   = TextureWrapMode.Clamp;
                newTex.filterMode = FilterMode.Point;
                activeLayer.SetTexture(newTex);
                bIsLookingForTex = false;
            }
            else
            {
                Debug.LogError("ERROR: Image not found #" + imgID);
            }
            yield return(new WaitForSeconds(0.2f));
        }
    }
예제 #7
0
 public void RotateLayer(CLayer aLayer, bool aCounterClockwise)
 {
     if (aCounterClockwise)
     {
         RotateLayerCCW(aLayer);
     }
     else
     {
         RotateLayerCW(aLayer);
     }
 }
예제 #8
0
    /* Spawn a new layer instance when the user removes one. */
    private void OnTriggerExit(Collider other)
    {
        CLayer layer = other.GetComponent <CLayer>();

        if (layer != null)
        {
            if (LayerObj)
            {
                if (layer.isNew && layer.layerType == this.layerType)
                {
                    Instantiate(LayerObj, this.transform.position, this.transform.rotation);
                }
            }
        }
    }
예제 #9
0
    private void Awake()
    {
        Layer = GetComponent <CLayer>();

        listableManager = FindObjectOfType <CListableManager>();
        grabbable       = GetComponent <OVRGrabbable>();
        rigidbody       = GetComponent <Rigidbody>();

        if (listableManager)
        {
            Speed = listableManager.Speed;
        }

        TargetLoc       = transform.position;
        bActiveListable = false;
    }
예제 #10
0
    /* Called when the containers bounds are entered. */
    private void OnTriggerEnter(Collider other)
    {
        CLayer layer = other.GetComponent <CLayer>();

        if (layer != null)
        {
            // Case: collision when falling / not held.
            if (!layer.isBeingHeld())
            {
                ActiveLayer = layer;
                ActiveLayer.ParentContainer = this;
                SnapLayerToContainer(ActiveLayer);
                //if (manager) { manager.OnAddLayer(); }
            }
        }
    }
예제 #11
0
    private void SwapNodes(int thisIndex, int desiredIndex)
    {
        if (desiredIndex >= Nodes.Count || desiredIndex < 0)
        {
            return;
        }
        else
        {
            CListable temp = Nodes[desiredIndex];
            Nodes[desiredIndex] = Nodes[thisIndex];
            Nodes[thisIndex]    = temp;

            CLayer temp2 = layerManager.Layers[desiredIndex];
            layerManager.Layers[desiredIndex] = layerManager.Layers[thisIndex];
            layerManager.Layers[thisIndex]    = temp2;
        }
    }
예제 #12
0
    public CubeLayer this[CLayer layer]
    {
        get
        {
            var c = cubes;
            switch (layer)
            {
            default:
            case CLayer.F: return(new CubeLayer(c[8], c[0], c[4], c[5], c[1], Vector3.forward));

            case CLayer.R: return(new CubeLayer(c[8], c[1], c[5], c[7], c[3], -Vector3.right));

            case CLayer.U: return(new CubeLayer(c[8], c[4], c[6], c[7], c[5], -Vector3.up));

            case CLayer.L: return(new CubeLayer(c[8], c[2], c[6], c[4], c[0], Vector3.right));

            case CLayer.B: return(new CubeLayer(c[8], c[2], c[3], c[7], c[6], -Vector3.forward));

            case CLayer.D: return(new CubeLayer(c[8], c[0], c[1], c[3], c[2], Vector3.up));
            }
        }
        set
        {
            var c = cubes;
            var v = value;
            switch (layer)
            {
            case CLayer.F:
                c[8] = v.center;
                c[0] = v.c2;
                c[4] = v.c3;
                c[5] = v.c0;
                c[1] = v.c1;
                break;

            case CLayer.U:
                c[8] = v.center;
                c[0] = v.c1;
                c[4] = v.c0;
                c[5] = v.c3;
                c[1] = v.c2;
                break;
            }
        }
    }
예제 #13
0
        public void dropTile(CTile tile, CLayer layer, int offSetX = 0, int offSetY = 0)
        {
            CTile test    = tile as CAnimatedTile;
            CTile newTile = null;

            if (test == null)
            {
                newTile = new CTile(tile);
            }
            else
            {
                newTile = new CAnimatedTile((CAnimatedTile)tile);
            }

            Vector2 position = _getMouseSnap(offSetX, offSetY);

            newTile.tileCoords = position;
            layer.addTile(newTile);
        }
예제 #14
0
    private void OnTriggerExit(Collider other)
    {
        ActiveLayer = null; //ADDED

        CLayer layer = other.GetComponent <CLayer>();

        if (layer != null)
        {
            if (ActiveLayer)
            {
                ActiveLayer.ParentContainer = null;
            }

            ActiveLayer = null;

            //layer.rigidbody.isKinematic = false;
            //layer.rigidbody.useGravity = false;
            //if (manager) { manager.OnRemoveLayer(); }
        }
    }
예제 #15
0
    private void OnTriggerStay(Collider other)
    {
        CLayer layer = other.GetComponent <CLayer>();

        if (layer != null)
        {
            // Case: already within the collision bounds & released from being held:
            if (!layer.isBeingHeld())
            {
                SnapLayerToContainer(layer);

                if (ActiveLayer != layer)
                {
                    ActiveLayer = layer;
                    ActiveLayer.ParentContainer = this;
                    //if (manager) { manager.OnAddLayer(); }
                }
            }
        }
    }