3D carousel display pictures

I made a very interesting gadget in the past two days~
The complete code download link
The display of pictures in a flat carousel is very monotonous, but the three-dimensional effect is much better~

1. Spherical display:
insert image description here
2. Spiral display:
insert image description here

3. Display in the form of text or letters:
insert image description here
When displaying letters or text, I had no idea at first, but later thought of using colored letters or text pictures on a white background, identifying the rgb value of pixels in the image to distinguish the foreground and background, and then traversing each row and each column (take the appropriate step size), map the pixel position of the letter or text to the world space, and then fill it with the picture.
The pixel position of the text or letter is mapped to the world space code as follows:
Pay attention to the selection of the appropriate step size for the row and column.

   List<Vector3> GetWordPosByTexture(Texture2D texture)
    {
    
    
        List<Vector3> posList = new List<Vector3>();
        int num = 0;
        if (texture != null)
        {
    
    
            int width = texture.width;
            int height = texture.height;
            Color[] colors = texture.GetPixels();
            int index;
            for (int i = 0; i < height; i += wordHeightStep)
            {
    
    
                for (int j = 0; j < width; j += wordWidthStep)
                {
    
    
                    index = i * width + j;
                    if (nearBlack(colors[index]))
                    {
    
    
                        num++;
                        Vector3 itemPos = new Vector3();
                        itemPos.x = width-j-(width/2);
                        itemPos.y = -(height-i-(height/2));
                        itemPos.z = 0;
                        posList.Add(itemPos);
                    }
                }
            }
            Debug.Log("wordPoint:" + num);
        }
        return posList;
    }
    bool nearBlack(Color color)
    {
    
    
        if (color.r < 0.8f || color.g <0.8f || color.b < 0.8f)
            return true;
        else
            return false;
    }
``

Guess you like

Origin blog.csdn.net/l17768346260/article/details/105032134