Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • CreatiCode
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo

CreatiCode Scratch Forum

  1. CreatiCode Forum
  2. Knowledge Base
  3. Tutorials
  4. 3D - 3D Art with Random Boxes (Difficulty: 2)

3D - 3D Art with Random Boxes (Difficulty: 2)

Scheduled Pinned Locked Moved Tutorials
1 Posts 1 Posters 2.0k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • CreatiCodeI Offline
    CreatiCodeI Offline
    CreatiCode
    wrote on last edited by admin
    #1

     

    Key Topics Covered

    • Using boxes
    • Picking a random number
    • 3D coordinates and positions
    • Working with colors
    • Picking a random number

     
     

    Introduction

    In this tutorial, you will build a 3D world using a lot of boxes, and you will learn how to make use of randomness in creating 3D art.

    https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/21dcb7ca-3e41-4b16-9d2a-3ca5c386fbce.gif" width="510" style="border-radius: 5px; border: 1px solid #29622d;">

     
     

    Step 1 - Create a New Project

    First, please create a new project on the CreatiCode playground, remove Sprite1, and add the following blocks to the Empty1 sprite:

    https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/b7539842-17c9-4a93-859a-63b92c93576d.png" width="400" style="">
     
    An empty 3D scene will be created.

     
     

    Step 2 - Add 10 Boxes Repeatedly

    Next, let’s use a repeat loop to add 10 boxes. You can pick any color for the boxes.

    https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/f805fb7c-abfe-43e9-b5dd-18612fa6c086.png" width="550" style="">
     
    Note that since the boxes are all overlapping, it would appear you only have one box:

    https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/7b7ca040-9fd4-46a7-a35e-efb896d7e66c.gif" width="480" style="border-radius: 5px; border: 1px solid #29622d;">

     
     

    Step 3 - Move Boxes to Random Positions

    To separate the boxes, we can move them to random X/Y/Z positions, using the “pick random” block.

    https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/1b173c75-dfd9-4f90-8da1-a40943e16fb7.png" width="1100" style="">
     
    The value of the X position of each box will be a random number between -300 and 300, and the same for the Y and Z positions:

    https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/62924281-a1fb-49ea-b61d-796d8477ab50.gif" width="480" style="border-radius: 5px; border: 1px solid #29622d;">

     
     

    Step 4 - Random Box Shapes

    Next, let’s change each box to a random shape. Since the shape of a box is controlled by its width/height/depth, we can set all 3 numbers randomly.

    https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/fe2687e6-fbcd-456f-8615-b970e5fbdb9e.png" width="1000" style="">
     
    Note that the size of the box should not be negative in any dimension, so we are making them random numbers between 10 and 100.

    https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/3ef4e839-0ba6-4028-b4b1-3e3654133b33.gif" width="490" style="border-radius: 5px; border: 1px solid #29622d;">

     
     

    Step 5 - Random Box Colors

    Now let’s make the box colors random as well. To do that, we can not use the color picker dropdown to set the color. Instead, we need to use the color calculator block. In this example, we’ll make the color and saturation random, and keep the brightness at 100.

    https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/c9e39e04-25ed-4742-80f7-4dcb562c9f8d.gif" width="1000" style="">
     
    As a result, every time we would get boxes of different colors. Since we are setting the “color” value to be random between 1 and 30, the resulting colors will be randomly selected between red and green.

    https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/83db3308-507e-493c-b9e5-73e6f675a86a.gif" width="500" style="border-radius: 5px; border: 1px solid #29622d;">

     
     

    Step 6 - More Boxes

    Now let’s try to use more boxes, and expand the range of colors and position values:

    https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/6ba60339-0864-45cb-918d-855757a8146a.png" width="1000" style="">
     
    You’ll find the result more interesting, but it will also take longer to run:

    https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/bbe4bf2f-bef1-4923-837d-05ab8545e807.gif" width="490" style="border-radius: 5px; border: 1px solid #29622d;">

     
     

    Step 7 - Speed Up

    To speed up the program, a very common solution is to avoid screen refreshes: instead of updating the computer screen after adding each box, we can just wait until all boxes are added, then refresh the screen only once.

    To do that, make a new block called “add boxes”, and check “Run without screen refresh”:

    https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/9dc29af0-fa23-4e98-ab8b-cf2449bd8f25.png" width="700" style="border-radius: 5px; border: 1px solid #29622d;">
     
    Next, move the repeat loop into the definition of “add boxes”:

    https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/54e3a81f-8abd-4176-b528-2890e260d4f4.png" width="700" style="">
     
    Now our program will run at least 10 times faster!

    https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/a701671d-7c3e-46ac-83fa-d85f4500b296.gif" width="500" style="border-radius: 5px; border: 1px solid #29622d;">

     
     

    Step 8 - Set a Sky Background

    Lastly, to make our scene look really nice, we can add a star-like sky. Note that we would also need to move the camera closer after setting the sky to a starfield:

    https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/1223499b-5bc9-420b-a908-f96e7b35ee35.png" width="400" style="">

     
    And here is the final demo:

    https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/21dcb7ca-3e41-4b16-9d2a-3ca5c386fbce.gif" width="510" style="border-radius: 5px; border: 1px solid #29622d;">

     
     

    Next Steps

    Try to apply the new techniques you learned to build some new artwork. Here are some ideas:

    • Different Shapes: instead of using only boxes, why not try other shapes?
    • Different Angles: you can rotate the shapes randomly as well, right?
    • Shapes on the ground: you can try to place the shapes all on the ground, such as on the gra*s land.
    1 Reply Last reply
    0
    • CreatiCodeI CreatiCode pinned this topic on

    Hello! It looks like you're interested in this conversation, but you don't have an account yet.

    Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

    With your input, this post could be even better 💗

    Register Login
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • CreatiCode