Sced Tutorial 2

Making a Top Hat

CSG and More Constraints

In this tutorial you will model a top-hat using CSG (Constructive Solid Geometry) and an assortment of constraints. Remember, there is an undo button on the Edit Window. You can use it to go back if something goes wrong.

Start Sced and open the CSG editing window by clicking on the CSG Window button in the Scene Window. The CSG editing window will pop up. It looks like the scene window but has an extra region at the bottom, in which CSG trees will be displayed as they are created.

To begin our top hat, create a new cylinder, by selecting Object:New and clicking on the cylinder. The cylinder will appear, as will a little name label in the bottom region on the screen. That label is actually a menu, and you'll use some of the items on it in the coming steps.

The cylinder will become the brim of the hat, so it must be squashed into a disk. You are also being careful about other issues in this tutorial. In particular, to make it easier to later place the hat, you want its origin to be at the base of the brim. You also want it to be about the right size, which translates to about 0.3 units in diameter.

To edit the cylinder, hold down the Ctrl key and drag over the cylinder (or any of its edges) with the left mouse button. The edit window should pop up. You could also edit the cylinder by dragging over the cylinder with the left button, and no modifiers, and then selecting Object:Edit from the menu. The Ctrl key is just a shortcut.

To get the origin right, you need to line the base of the cylinder up with the origin of the base coordinate system. Setting the position of an object like this is done through the Origin point, which is the green (by default) dot in the center of the cylinder. But you want to use the base of the cylinder as your reference point, so you need to move the Origin point to the base. To do that, click on the Origin point with the middle mouse button, and choose Point from the menu. Then, with any mouse button, click on the point in the middle of the base of the cylinder as you drag the mouse over it. The Origin point should jump to the point you selected. You could also change the Origin point by selecting Origin:Point from the menu in the Edit Window, and proceeding in the same way.

Now you want the Origin point to be at the world origin - you want to add a constraint. Click on the green Origin point with the right mouse button, and select Point from the menu. A little window pops up, requesting the info required for the new constraint. To specify a point constraint, you need to specify the point you want the Origin to be constrained to. So, move the mouse over the origin of the world axes, and hold down the left mouse button. The cylinder will change color, indicating that you are about to select the center of the cylinder as the point. You don't want to do that, so keep the right button down and move the mouse around a little until the cylinder goes back to its original color and the axes change color slightly. Now you are selecting the center of the world axes as the point, which is what you want. Let go of the mouse button. 0 0 0 should appear in the point dialog where the ? ? ? were.

If you get it wrong, a dialog will come up saying that a Reference specifier [was] changed to Absolute. Acknowledge that and try again. The error came up because you cannot use a point from the object you are constraining (the cylinder) as a point to constrain to, unless you are using the current location of the point (Absolute) as opposed to having the constraint follow the selected point around (Reference). Normally, reference constraints are more useful, because if you change something, the things constrained to it will move appropriately. You'll see this shortly.

At this stage you should have a Point dialog up with 0 0 0 in it. The label saying "Point 0" is the name of the constraint. This is only useful for keeping track of which constraint is which - Sced itself only uses it as a label. To the right of the name is a Selected toggle button. Click on it to activate the toggle, because you want this constraint to be enforced immediately. You would not choose Selected if you didn't actually want to use the constraint right now, but were creating it for later use.

Now click on Done. Lots of things will happen. The cylinder will move, so that the green Origin point is now at the center of the world axes. A little circle will appear around that point, which indicates that the net result of all the active constraints on the Origin of the cylinder is a point. In the Edit Window, a new button will have appeared under the Origin label. It should be highlighted and have a label of "Point 0", the name of the constraint. It's a toggle which controls whether the constraint is active (selected) or not. Only active constraints have any effect on the constrained object. If you click on the "Point 0" toggle, the circle around the Origin point should disappear, indicating that the origin is no longer constrained. Clicking again will re-activate the constraint, and the circle will reappear.

Now that you have the cylinder in the right place, you have to make it the right size. That requires scaling. I recommend zooming in so that the cylinder fills most of the view, but the pink Scaling point is still in view (the easiest way to zoom in is to hit the + key). You'll do the scaling in two steps. First, get the height right. Click on the Minor Plane and then the Other Plane buttons under the Scaling label. In the view window, a line should appear passing vertically through the pink Scaling point. That indicates that the Scaling point is constrained to move along that vertical line. Clicking on the Scaling point and dragging will result in the point moving up and down on the line, and the object scaling. Scale it down until the thickness looks about right. If you do it in one drag, you can see the size of the scaling being applied by watching the text at the very bottom of the CSG Window. It shows the transformation being applied by the current drag.

The brim is still too big (it has a 2m diameter), but we'll fix that later.

The brim should be all done by now. Click on Finish in the Edit Window to close up. You could also click on the right button anywhere in the view window and choose Finish from the menu. You should also deselect the cylinder by dragging over it with the right bouse button.

Now you need to create the body of the hat. Create a new cylinder (Object:New). Then start editing the cylinder. The method I'll describe may seem a little counter intuitive, but stick with it.

First, note that you want the center of the upper cylinder to lie on a vertical line through the center of the brim. To achieve this, use the Add menu under the Origin label in the Edit Window. Select Line from this menu. This is the same as clicking on the Origin point with the right mouse button, which is the shortcut way of doing it.

A Line dialog will appear, it asks for lots of info, but you don't need to provide most of it. You want the Origin to be constrained to the line that passes through the center of the brim. So simply use the left mouse button to select 2 distinct points on the centerline of the brim. As you select these points, the brim should turn red, to indicate that the constraint line is based on the brim's shape. As you select the points, the top 2 labels in the Line dialog should show the location of the points you chose. If you select the wrong point, click on the little pointing button to the right of the label, and retry. Make sure the Normal point is NOT specified. If it shows something other than ?? ?? ??, hit cancel and start again. You would use that point if you wanted to specify the line by specifying a point on it and the direction of the line, as opposed to simply giving 2 points on the line (which is what you want to do).

Select the "Line 0" constraint (either in the Line dialog or by clicking on the "Line 0" toggle under Origin). You should now be able to drag the upper cylinder around on the line, but dragging the green Origin point. Just shift it to somewhere above the brim for the moment.

You want the diameter of the upper part to be somewhat smaller than the brim diameter, and you want the upper part to contact the top of the brim. This means a scaling constraint. The best point to constrain is one on the bottom of the upper cylinder, so click on the pink Scaling point with the middle button, select Point and click on one of the points around the bottom of the upper cylinder. If you choose particular points, constraints will automatically come on. If that happens, try again. The constraints come on because the point you chose lies on one of the planes defined by the cylinder's internal coordinate system. If the scaling point lies on that plane, it cannot be scaled off it, so a constraint comes on to make sure you don't try. One way is to avoid using that point, the other is to redefine the coordinate system, by changing the Major Axis or Manor Axis.

To achieve the desired scaling, you should use a ratio point constraint. In particular, you want the Scaling point you just chose to lie a fixed distance between 2 points on the top side of the brim. Click with the right button on the pink Scaling point, and select Ratio Point. With the left mouse button, click on the point closest to the Scaling point on the top edge of the brim, and then the point on the opposite side of the brim on the lower edge. By choosing one point on the upper edge, and one on the lower edge, the upper cylinder will edge up penetrating slightly into the brim, which is better for most renderers (avoiding aliasing errors). After choosing the points, change the Ratio in the RatioPt dialog. You want something like 1:5, indicating that the Scling point should be 5 times further from the far point than it is from the near point. Click on Selected and then Done. The upper cylinder should snap into position with the right radius and with the bottom in the right position.

To get the height right, simply drag the Origin point up and down. The Scaling point will keep the base in the right place. When you're happy, Finish the editing.

The hat is probably too big. To make it smaller, select the brim for editing. Deactivate any Scaling constraints and activate the Change Rad constraint. This allows you to change the radius of the brim cylinder without changing its height. As you drag the Scaling point, the upper part of the hat will change too, because it is constrained to the lower part. That's why you used the left button to select points for the constraint - so that as the points move, so does the constraint.

By adjusting the radius of the brim and the height (via the Origin) of the upper, you can make the hat whatever size you like - all with only 2 mouse drags.

Now you need to combine the 2 cylinders using CSG. Click on the "Cylinder_1" menu in the bottom part of the window, and select Attach. Then, move the box on top of the the "Cylinder_0" menu, and click with the left button to select Union from the menu. The display should now show a U connecting the 2 cylinder labels, indicating that they will be unioned in the CSG operation. If you have a buggy XFree86 distribution, it won't look right.

To actually create the CSG object, select Complete from the menu on the U button. The Complete dialog will appear. Change the name to something useful, and hit Complete. It will chuck for a second, and then you'll get a window showing the final object. At this point, you must select a default Scaling point for the new object. The Origin point and body coordinate frame came from the world frame at the time the object was created. For the Scaling point, choose the point on the top closest to you.

You're all done. To create an instance of the hat, click on Object:New:CSG Object in the main scene window, and select the hat. You can now treat it like any other object.