Learn Max 6 Tutorial: Stunning (Dis)Array Effects
Table of Contents
- Introduction
- The Cool Patch
- Creating the Camera Swoop
- Moving the Cubes into a Big Cube
- Computing the Row, Column, and Slice
- Setting the Cube Size
- Setting the Cube Movement Speed
- Testing and Debugging
- Controlling Cube Movement
- Conclusion
Introduction
Hey guys, it's your good buddy Sam here, and today we have another exciting patch to explore. In our previous tutorial, we created a patch that generated a bunch of bouncing cubes and enabled the camera to swoop through them. But today, we're going to take things to the next level. We're going to stack these cubes together and create one big cube comprised of smaller cubes. So let's dive right in and get started!
The Cool Patch
Before we begin, let's quickly review the cool patch we created in our last tutorial. This patch allowed us to generate multiple cubes and make them bounce around in space. We also added a camera that swooped through the cubes, giving us an exciting visual experience. If You haven't checked out that tutorial or tried the patch yet, I highly recommend going back and giving it a go. We'll be building off this patch in today's tutorial, so it's essential to familiarize yourself with it.
Creating the Camera Swoop
To get started with our new patch, let's open up the Multi Cube 3 project from the previous tutorial. This project should look identical to the Multi Cube 2 project, but with the added functionality of the camera swoop. If you haven't renamed the project yet, now is a good time to do so.
In this project, we have a cube with a size of 5x5x5. To achieve this size, we set the number of cubes in the Poly Cube object to 125. Now, let's check if everything is working as expected by triggering the metronome. If all goes well, the cubes should move to random positions in space. If they don't move, it's likely because the number values need to be reset. No worries, we can fix that easily.
We also have a camera swoop patch that we encapsulated and renamed as "Camera Swoop." This encapsulation allows us to keep the camera patch organized and out of the way while we work on the next steps.
Moving the Cubes into a Big Cube
Now, let's talk about our goal for this tutorial. We want to take each of the individual cubes and move them to a fixed point so that they form one big cube. This big cube should have a dimension of 5x5x5, which means we need a total of 125 cubes. To achieve this, we'll stack the cubes together, making sure they Align correctly.
To accomplish this, we need to assign a number to each cube that corresponds to its position in the big cube. We'll use slices, rows, and columns to determine each cube's position. Here's how it works:
- Slice: Each slice consists of 25 cubes and represents a layer of the big cube. We can calculate the slice number by dividing the cube's index by 25.
- Column: Within each slice, we have 5 columns of cubes. We can calculate the column number by taking the modulo of the cube's index by 25, then taking the modulo again by 5.
- Row: Within each column, we have 5 rows of cubes. We can calculate the row number by taking the modulo of the cube's index by 25, then dividing the result by 5.
By using these calculations, we can determine the position in XYZ space for each cube and set them accordingly.
Computing the Row, Column, and Slice
To compute the row, column, and slice for each cube, we'll use some simple math operations. First, let's make sure we're working with the correct cube by sending a message to the Poly object. We'll use the value from the uzi object to indicate which cube we're referring to.
Next, we'll calculate the slice by dividing the cube's index by 25. This will give us an integer value that represents the slice number.
For the column, we'll use the modulo operator (%). We'll take modulo 25 to ignore the slice and then take modulo 5 to determine the cube's column within that slice.
Lastly, for the row, we'll again use the modulo operator. This time, we'll take modulo 25 to disregard the slice and then divide the result by 5 to obtain the cube's row within that slice.
Let's also remember that the uzi object counts starting at 1, while we want our cubes to be indexed starting at 0. To adjust for this, we'll subtract 1 from the value coming out of the uzi object.
Setting the Cube Size
Now that we have determined the row, column, and slice for each cube, we can proceed to set their positions in space. But before that, let's define the size of the big cube. By default, we'll use a scaling factor of 5. However, you can modify this value to make the final cube bigger or smaller. Just keep in mind that if the value is too large, the individual cubes might not touch, resulting in visible gaps between them.
Setting the Cube Movement Speed
To make things more interesting, let's add some movement to our cubes. We'll use the ZL join object to combine the row, column, and slice values into a list of three floats. These values represent the position in XYZ space where each cube should move to.
To control the speed of the cube movement, we'll send a message to the JIT and M drive objects inside each Poly. By default, we'll set the movement speed to one Second, so all the cubes will reach their new positions within that timeframe. You can experiment with different speeds to achieve the desired effect.
Testing and Debugging
Now is a good time to test our patch and see if everything is working as expected. Start by turning off the metronome to stop the cubes from moving randomly. Then, send a bang to the fourth inlet of the Poly object to move the cubes to their intended positions. If all goes well, the cubes should align and form a 5x5x5 cube.
In case you encounter any issues, double-check the connections and values in your patch. Sometimes, a simple mistake can cause the desired behavior not to occur. Take your time to debug and troubleshoot any problems you may encounter.
Controlling Cube Movement
To provide more control over the cube movement, let's add a couple of user interactions. Pressing the "R" key can start the cubes moving around randomly, providing a dynamic and ever-changing display. Conversely, pressing the "I" key can move the cubes back to their initial positions, creating a static cube once again.
To implement this, we'll use the key object and connect it to a trigger object. The trigger will send a bang message to the Poly object, activating or deactivating the cube movement Based on the key press. By turning off the metronome and sending the cubes back to their initial positions, we can control the behavior of the patch effectively.
Conclusion
And there you have it - a new and cool project that takes our cube creation patch to new heights. We learned how to stack the cubes together to form a larger cube, computed the row, column, and slice positions for each cube, and set their movement speed and size. By testing and debugging our patch, we ensured that everything worked as expected and added some user-controlled movements to make things even more interesting.
I hope you enjoyed this tutorial, and don't forget to have fun and experiment with different parameters and values. Stay tuned for more exciting patches and projects coming your way. Good luck, and happy patching!
Highlights
- Create a patch that stacks individual cubes together to form a big cube.
- Use math operations to compute the row, column, and slice positions for each cube.
- Set the size and movement speed of the cubes to achieve the desired visual effect.
- Test and debug the patch to ensure everything works as expected.
- Add user interactions to control the cube movement.
FAQs
Q: Can I resize the big cube formed by the individual cubes?
A: Yes, you can modify the scaling factor to make the final cube bigger or smaller. Just be mindful that if the value is too large, there might be visible gaps between the cubes.
Q: How can I control the movement of the cubes?
A: Pressing the "R" key will start the cubes moving randomly, while pressing the "I" key will move them back to their initial positions.
Q: What if the cubes don't align properly to form the big cube?
A: Double-check the connections and values in your patch. Make sure the calculations for the row, column, and slice are correct. Debug any issues that may arise and ensure the Metronome and JIT objects are functioning properly.