Creating and editing 3D boxes
In Inkscape, 3D boxes are actually two-dimensional objects arranged according to a defined perspective, in order to provide the illusion of an additional dimension. This recipe shows us the basic options available to manipulate boxes in our fake but very convincing 3D space.
Getting ready
The default positions of the perspective vanishing points are the center of the vertical page edges. That is why it is recommended to start creating a box somewhere inside the page area. To prepare for this recipe open Inkscape and zoom to page size using the Zoom to fit page in window toolbar button (or the 5 key), Zoom to fit page width in window (Ctrl + E or 6) on the Zoom (F3 or Z) toolbar.
How to do it...
The following steps will show you how to create 3D boxes:
1. Select the 3D box tool (Shift + F4 or X) and click and drag in the page center area to create the left-hand side of the box. Notice that the other box sides will be created automatically, some of them will be hidden from view. The vanishing points are located on vertical page edges.
2. There is a small cross at the box center that can be dragged to change the box position with respect to the current perspective. Move the box by dragging that cross in all directions and see how the box changes, then return it to the center.
3. Switch to the Selector tool (Space) and move the box object upwards.
4. Switch to the 3D box tool (Space, Shift + F4, or X) again and notice how the vanishing points moved with the box preserving the box shape.
5. Grab the top box corner handle that is closest to the viewer and drag it downwards while holding Ctrl to make the movement vertical.
6. Grab the bottom box corner handle that is closest to the viewer and drag it upwards while holding Ctrl to make the movement vertical. The top and bottom sides of the box shouldn't be visible:
7. Grab the left corner handle of the left box side and drag it towards the right while holding Ctrl to constrain the movement along the converging line.
8. Grab the right corner handle of the right box side and drag it towards left while holding Ctrl to constrain the movement along the converging line. The box should become narrower.
9. Duplicate the box (Ctrl + D) and move it left while holding Shift to constrain the movement to the Z direction. Release when the two boxes stop overlapping.
10. Duplicate the box (Ctrl + D) and move it behind all the others by using End or Page Down keys, or the Lower selection to bottom button on the toolbar. Move it right by dragging the cross handle while holding Shift to constrain the movement to the Z direction. Release when it appears next to our original box.
11. Select the middle box by clicking on it.
12. Duplicate the box (Ctrl + D) and move it behind all the other ones by using End or Page Down keys. Move it towards the top while holding Ctrl to constrain the movement to the Y direction. Release when you can see its bottom side appear behind the middle box.
13. Duplicate the box (Ctrl + D) and move it behind all the others by using End or Page Down keys. Move it downwards while holding Ctrl to constrain the movement to the Y direction. Release when you can see its top side appear behind the middle box.
14. Move the left vanishing point towards the box, and move the right vanishing point away from the box (outside of the page area) to change the perspective. Notice how all the boxes change together because they all share the same perspective.
15. Move both of the vanishing points downwards and notice how the bottom box doesn't seem in the correct position with respect to the rest of them. Select that box and bring it to the front by using the Home or Page Up keys, or by clicking on the Raise selection to front button on the toolbar.
How it works...
3D boxes are actually groups of six quadrilaterals (shapes with four corners) assembled together for a three dimensional effect. The box sides can change some of its attributes independently while being parts of the box (color for example). However, if we need to perform some other functions on the box we need to convert it to a path (Shift + Ctrl + C). With that conversion we will lose the ability to edit it using the 3D Box tool.
We can enter the 3D box so we can select the individual sides using the Selector tool by using the Ctrl + Enter shortcut. The Node tool can select individual sides even without entering the group.
There's more...
When there's more than one box sharing the perspective, holding Shift while clicking and dragging a vanishing point can change that box's perspective without affecting the other objects.
Isometric projection and 1, 2, and 3-point perspectives
The examples we used in this recipe all use 2-point perspective (two vanishing points), but 1-point and 3-point perspectives are also possible. To create a 1-point perspective we need to set X and Y vanishing points to infinity by using their respective parallel buttons on the 3D Box toolbar. Set Angle X: to 180 and Angle Y: to 90. Make sure that the Z parallel button is off and drag the Z vanishing point to the drawing center. Toggling the parallel buttons can be done using the keyboard shortcuts: Shift + X, Shift + Y, and Shift + Z.
To create a 3-point perspective toggle off all three parallel buttons and drag the vanishing points where you like them (usually X and Z vanishing points are at the same level on opposite sides of the object).
An Isometric projection can also be achieved with the 3D box tool. To create it all the parallel buttons must be on and the angles set to X: 150, Y: 90, Z: 30.
See also
For more information, refer to the recipe on Assembling a modern chair using the 3D Box tool in Chapter 8.