Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question help with code to cut up an image into concentric rings

Discussion in '2D' started by IamJavaGod, Aug 26, 2023.

  1. IamJavaGod

    IamJavaGod

    Joined:
    Feb 25, 2014
    Posts:
    2
    Hello - I am wanting to create a puzzle similar to one in Assassins creed. I want to create a version of the concentric ring puzzle. For those that don't know, the puzzle is comprised of an image that has been cut up into multiple concentric sections, like a dart board (but without the radiating lines). The goal of the puzzle is to get the image to line up correctly by rotating the individual rings about the center axis.

    I am having issues figuring out how to take an image (any) and carve it out onto the separate rings. I originally thought about just duplicating the image for each ring and using masks for the display. I would just then rotate the whole image and the mask would do the work, but that seems exceptionally expensive memory wise, but maybe not. Does anyone know of some code that I can use that will cut up the image into the individual pieces? Or am I on the right track using masks, and I am just overthinking it?
    Thanks,
    John
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,563
    I don't think you want to "cut up the image." You probably want to leave the image as-is and then map chunks of circular / ring-shaped geometry and map the UVs to it.

    This is a fairly advanced topic, doing procedural generation, so you probably want to simply cut up the image with your own Photoshop / Gimp / Krita image editor and drop the separate rings into the game.

    Alternately, use Blender to make your concentric rings, then line them up and map the entire texture to all of them at once, then import them into Unity and rotate them appropriately.

    If you feel like tucking into procedural generation of geometry, mapped out to pieces of your image, you're welcome to see what is involved in examples in my MakeGeo project.

    MakeGeo is presently hosted at these locations:

    https://bitbucket.org/kurtdekker/makegeo

    https://github.com/kurtdekker/makegeo

    https://gitlab.com/kurtdekker/makegeo

    https://sourceforge.net/p/makegeo
     
  3. sildeflask

    sildeflask

    Joined:
    Aug 16, 2023
    Posts:
    142
    masking like 10 images is not expensive memory wise

    come back when you are masking 1000
     
  4. IamJavaGod

    IamJavaGod

    Joined:
    Feb 25, 2014
    Posts:
    2
    Cool stuff! Thanks for the reply, but I was definitely overthinking it. Sat back with my beer last night and went back to basics. I was thinking in terms of rings when this is just a solution of circles. From the ring standpoint, the inner radius of any ring is the outer radius of the ring below it...which is just a circle. So with some standard circle sizes for my puzzle, I can do some Texture2D kung fu and masking with my circles in sequence, ending up with multiple images each with a corresponding "ring" showing and everything else alpha'd out.
     
    Kurt-Dekker likes this.