Страници

Tuesday, November 28, 2017

Domino line-up using Curves as guide

You haven't used Blender Physics Engine if you didn't toppled a few dominoes.It's fun and introduce you to the awesome world of physics in Blender.One problem is that you probably arranged the dominoes painstakingly one by one and you don't have the whole time in the world for that.There are few good resources of how to set up a domino toppling, but it's rare to find a good one that uses the aid of the Curve object in order to arrange a great looking line of dominoes.Added some links at the bottom of the page.So let's get into it.This tutorial requires some basic knowledge of Blenders Interface and navigation through the program.For anyone who is new to Blender don't feel discouraged. Please, ask your relevant question in the comments below and I will try to answer shortly and clearly as possible.

Preparing the domino tile

Start with the default blender scene.

This is not a modeling tutorial so we'll just create a basic shape of a domino, that could be easily replaced later on with more complex model.
Using the basic Cube object enter the following values for its dimensions (Fig. 1):

X - 1.0Y - 0.3Z - 2.0
I read somewhere that those are one of the classic proportions of a domino tile, so I believe its true.

Name the object Domino.

Figure 1. Creating the Domino model from the default Cube (here shown for comparison). You are forbidden to move on without completing this step!

You will notice that the Scale values above Dimensions also change. We have to bring each of them back to 1 to make sure the simulation will be correct. To do this lets apply the scale and rotation of the object. Pres Ctrl+A and select Scale in the Apply menu (Fig. 2).

Figure 2. Reset any transformations made to the object.

Creating the Curve object

There are many ways of creating curves and different types of them to pick. You are free to experiment and to find the best way for your artistic needs. Me, I will stick with creating a simple Path curve.
Go to Top view and press Shift+A to Add a Path curve. In edit mode, shape the curve, extrude the points, until you get the desired look (Fig. 3). Just make sure the first point is near our domino object. Notice the little arrows of the curve hinting where is the beginning and where is the end! Also our curve should be flat on XY plane!

Figure 3. Building the curve that will shape our domino line-up.

With that we have all we need to begin. But here we'll split the creation process into two variants:

Variant A - Duplication based on FramesVariant B - Text on Curve
So save this file as starting point by creating a copy.
Feel free to explore each of them by returning to the starting file.

Variant A - Duplication based on Frames

From the starting file (Fig. 3) in Top view. Make sure you're in Object Mode. Select the Domino and then the Path. Press Ctrl+P and select Follow Path command (Fig. 4).

Figure 4. Parent the domino to the path using Follow Path option.

This will parent the Domino to the Path and if you play the animation you will notice that the domino travels alongside of it. To fix the offset position of the Domino, go to first frame, select the Domino and move it so its center is very close to the beginning of the curve. Also rotate the domino along Z axis to face the direction of the curve (Fig. 5).

Figure 5. Position the domino on the first frame of the animation over the beginning of the path and rotate it appropriately.
While playing the animation you may notice that the Domino is animated until frame 100, where it reaches the end of the path. Now depending on the length of the created path the Domino may travel in too big steps each frame and that could be a problem when duplicating the object (the spacing between the duplicates may be too big to collide with each other).

Figure 6. Set the Path Animation do desired number of frames (resp. number of duplicate objects)

To ensure good distance between each domino tile lets stretch the animation to be a little longer. Select the Path object and in Object Data panel find Path Animation and enter 250 for Frames parameter (Fig. 6).

Also make sure your animation also have 250 frames.

Now we are ready to duplicate the object based on its position during the animation.

In order for this to work we have to bake the object positions as keyframes for each frame. Select the domino object and press the Spacebar to search for the Bake Action command (Fig. 7). Check the options:Only SelectedVisual KeyingClear ConstraintsClear Parents

Figure 7. Bake Action command will set keyframe for each frame of the animation. Check the options shown.
After pressing OK the timeline will be filled with keyframes up to the last frame.
With the object still selected go to Object Properties panel and Check Duplication - Frames (Fig. 8)
Enter 2 for End value. You should see a duplicate of the Domino on each frame.

Figure 8. Duplication based on frames is where the fun begins.

That is too dense for our goal. To lower the count of the duplicates we'll take advantage of the Off property (Fig. 8) on the right side of the End property. It controls how many frames to skip for duplication. Entering a value of 8 seems to work for my case (Fig. 9).

Figure 9. A value of 8 for the Off property gives a decent spacing between the tiles.
You may notice that the objects have darker outline compared to the original Domino and are not accessible as separate objects. To convert them to real objects go to the end frame select the Domino object and press Ctrl+Shift+A or search for Make Duplicates Real command. This will make every object available for simulation.
Finally the original Domino is still animated so we have to erase its animation data. To locate the animated domino make sure you're on the last frame (250), our object should be the last on the line. Select it and search for Remove Animation. This command will effectively dispose of all keyframes and will make the object still.
Delete the path object or move it on another layer.

1. Create a Plane and scale it to encompass all of the dominoes. Move the Plane -1 units along Z. To avoid sudden jumps at the beginning of the simulation you could move it down a little further for example -1.03 units

2. In the Tools Shelf go to the Physics Tab and with the plane still selected press the Add Passive button.

3. Select only the domino tiles and press the Add Active button.

4. Select the first domino tile and rotate it slightly forward to make it unstable (Fig. 10). You can also rotate and reposition some of the tiles in Top view in order to make better collisions.

Figure 10. Final touches. Tilt the first tile slightly forward and rearrange some tiles for better collision.

5. Press Play (Alt+A)and enjoy your simulation of domino toppling.

6. Additionally in Scene panel - Rigid Body World you can play with the Speed property to make the simulation executing faster and looking more realistic. I changed the speed from 1 to 2.

Here is the final simulation:

Variant B - Text on Curve

Start with the file that we saved earlier (Fig. 3)
The procedure here is more simple. First rename the Domino object to "Domino-a".
In Top view create a text object and add the Path object as Text on Curve deforming object. Also in Object Font text field write "Domino-" (Fig. 11). This instructs the text object whenever the character "a" is typed to display the custom font character - in this case it is our domino tile.

Figure 11. Text on Curve option places the characters of the text along the selected curve without distorting their shapes. Enabling Object Font will add custom mesh whenever you type specific letter in this example typing "a" will add our Domino mesh where the character is located.

Now delete the default text and type the sequence: "a a a a a a a a a..." (note, I added two spaces between the 'a's). In Object Properties of the Text object enable Verts Duplication. You should get similar result (Fig. 12)

Figure 12. To see the duplicated objects the Verts option in Duplication panel must be enabled for the Text object.
As you can see the objects are not oriented correctly. And the original mesh must be rotated (-90) degrees along Z axis. To do that select the Domino object, rotate it around Z axis (-90) degrees, then Ctrl+A to apply Rotation.
Keep adding duplicates by typing "a"s and adding some spaces between the characters.
To make the duplicates real objects, select the Text object in Object Mode and Ctrl+Shift+A to make duplicates real (Fig. 13).

Figure 13. Converting the duplicate dominoes to real objects is easy as Ctrl+Shift+A. The original Domino and Text and path object can be moved to another layer or deleted.

Move the original object, path and text to different layer or delete them if not needed.
Then proceed to simulation setup process as described above (go there).

With that this tutorial ends!

For anyone who is new to Blender don't feel discouraged. Please, ask your relevant question in the comments below and I will try to answer shortly and clearly as possible.