Explaining context in depth is beyond the scope of a novice level tutorial, but my goal for this next series of posts is to get you started down that road and to, perhaps, change your perception or mental approach to modeling by giving you a glimpse of just how powerful context can be for your work.
In this, and all of my tutorials, I assume that you have swapped your mouse button assignment to make the left mouse button the "select/confirm action" and the right mouse button your "cancel action" button. See the Virgins and Mice tutorial for how to do this highly user-friendly change.
RefresherJust to give you a very quick "refresher" of what we're talking about, a lot of modeling will boil down to a few simple things:
- starting with a very basic object
- adding more geometry to it via extrusion and/or loop-cutting and/or joining it with other objects
- transforming both the entire object and individual bits of change its shape and size and overall appearance
- repeat ad nausium until that you eventually have the final model that you want to export for upload to Opensim
"Context" isn't an official Blender term. It's the word I use to describe the inter-related considerations of transform orientation, pivot point, and (in edit mode only) any proportional editing setting. In the earlier tutorial I showed you where the transform orientation and pivot point drop-down boxes are located (on the 3D View pane's menu bar) but I didn't discuss them in any detail; nor did I draw your attention to the button where proportional editing is enabled and its type subsequently set. We'll touch on all of these in an introductory way in this "context" series of tutorials.
So What the Heck Is Context?I had a somewhat difficult time trying to think of a common analogy for context in Blender to give you a basic idea of what it means, and here's the best I can come up with at present:
Up until about the mid 16th century, the commonly held belief was in a geocentric model of the universe where the Earth was at the center of creation and everything else revolved or moved around it in some very elaborate, complex dance. With the advent of new (early) scientific instruments, forms of math, and methods of approach, it gradually became clear that this wasn't the case and that, instead the sun was the center of our little solar system. We remained a bit vague about everything else out there, but this shift in "context" allowed a far most simple and elegant understanding of how things work. As time went by and even more advancements were made, our view of the universe further changed -- drastically! -- until we arrive at the present day with an expanding Big Bang universe where the Earth is just a tiny, insignificant grain of sand on an incomprehensibly vast beach.
I don't want to stretch this analogy very far because Blender has nothing to do with cosmology; but this does give a sense of shifting perceptions about the relationship between things -- objects -- and it's in this sense that I use "context" for objects in Blender much as everyone since Einstein's General Theory of Relativity has stressed "frame of reference" when talking about celestial ones.
In Blender there's a twist: you get to choose and set the context and it takes care of the hard part of figuring it all out mathematically behind the scenes. Instead of having just one "universal" point that everything is fixed to, rotates around, and is referenced to, for almost all transformations Blender lets you pick that point. That's essentially what you use the pivot center and transform orientations settings for.
The other analogy I can give you is if you've done a lot of building and/or scripting in-world using prims. If you have, you'll know that things like movement and rotation and resizing are highly dependent on whether you're working with a root prim or a child prim and you'll be familiar with "global" vs "local"values for position and rotation. That's context. In-world Opensim building gives you little or no control over which context you have to use whereas, for the most part, Blender is quite happy to let you pick what you want and it will jump through the math hoops to make it happen -- which is really nice since it's been 40+ years since I last took a class in the 3-dimensional trigonometry necessary to perform those calculations.
The Basics And A Few Simple ExamplesPerhaps the easiest way to give you a glimpse of this is to do some assisted "playing" with things so you see it on your screen. In today's tutorial we'll just play with the "pivot center" part of context. In the next tutorial we'll look at the orientation element.
Let's start with one of the most basic objects: a cube. Before we can even put it into our scene we must already start thinking about context. Blender will want to know where to place the cube which means that Blender must have its own internal context or some sort: an idea of 3-dimensional screen space. It will also want to know how big and what rotation the cube should have, initially, which means Blender must also have an internal concept of scale and orientation. It has all of these, and this is what we might as well call Blender's "global" space.
Blender's global space is centered at the location coordinates <0,0,0> where the x-axis is left-right, the y-axis is front-back, and the z-axis is up-down. This is (very roughly) the same one that Opensim uses except in Opensim the "center" exists in a hypothetical region located at 0,0 on the grid map, the center is located at <0,0,0> of that region, and calling it a center is a complete misnomer because you're not allowed to use negative global values so it's actually a corner. Blender doesn't care about that stuff (and doesn't have multiple regions) so it's perfectly happy to stick <0,0,0> in the middle and let you do anything you like around that point because it makes Blender's math work more easily. All if its internal programming is based on that "context." By default Blender puts the 3D cursor there when you first start the program, and you rapidly learn to "just know" that's the center.
It also matters a great deal whether we're in Object mode or Edit mode. In Object mode Blender always uses its own global 3D space. In edit mode you have the choice of whether to work in global space or local space. I'll explain the difference, shortly, but for now let's just make sure we're in Object mode before we add our new cube.
We want to place our new cube at Blender's global center and as long as you haven't moved the 3D cursor somewhere else, that's where it will go. Whenever we add any object, by default it gets positioned at the current location of the 3D cursor. If you've moved it -- intentionally or accidentally -- you can get the cursor back to center using the menu command Object > Snap > Cursor to Center (or alternatively you can use the hotkey combination shift + S which will make the snap options pop up on the screen wherever your mouse pointer is, then you can chose "Cursor to Center" from that list).
With our at the center, add a mesh cube. You can do it either by clicking the "Cube" button in the toolshelf's Create tab, or via menu using Add > Mesh > Cube.
As soon as you do so, the "most recent actions" area of the toolshelf will show you any additional options associated with adding a cube. A cube is one of the simplest, most basic shapes so there aren't very many, but it does bring up an aspect of context: numbers.
Blender is giving us the options to change the size of the cube (its radius), its location, and its rotation. These are all numerical values so the means Blender attaches some sort of meaning to them. Luckily for us, they're extremely convenient values because they match our in-world building experience where 1 Blender unit = 1m and where angles are expressed in degrees (rather than radians which many Opensim script functions use). You have the ability to change this via User Preferences but since it matches Opensim's scale and orientation there's no reason we'd want to.
We'll accept the default values and let's now deselect our cube for a moment since by default it will be selected for us as soon as we add it (press the "A" hotkey to deselect all).
If you look closely at the center of the cube you'll see a small orange dot there. This is what Blender uses to keep track of each object in a scene. The dot marks Blender's global reference to the object and bases its global position, rotation and scale on that location. This might seem identical to the way Opensim treats an object, and at its most basic level that's true. With Blender, however, this dot has a special name -- the "origin" -- and it is a separate but integral part of each object. The origin represents -- or rather, explicitly marks -- the object's global context.
Let's see this in action.
Note: in subsequent pictures you'll see that I've added different colours to the face of the cube to show where the original faces were. Yours won't look like that and will be simple grey.
Before we change the default, let's first see that with things set to the default our cube behaves the same way we'd expect it to behave in world. Try scaling it (hotkey S) or rotating it (hotkey R) just to confirm. Each time, either cancel the action or use the ctrl + Z hotkey to undo any changes and preserve our original cube.You'll not see the cube do anything unexpected at all...it will transform exactly the way you'd expect a cube to do in-world. That's because the default settings we're using make it behave that way.
Now let's do something you can't easily do in world: let's change the center point that the cube is using as the context for transformations.
If you can't see the 3D Pane properties side panel on the right, press "N" to toggle its visibility. Look for the section in it called "3D Cursor" which tells you the current location of the 3D cursor and also is one of a variety of methods for changing it. Change the X-axis part of it's position to 2.0 and you'll see the 3D cursor move to that new location on the screen.
Now also change the pivot point for transformations to "3D Cursor" instead of the default. This is telling Blender that instead of doing our changes using the center of our object as the context, we want to use the 3D cursor as the center instead. When you do this you'll notice that your transformation handles now move to that location of the 3D cursor as well, giving us visual confirmation of where our new pivot point is located (and handles we can grab and drag to actually do the transformations).
Now try doing the same scaling and rotation transformations again that you did a few moments ago. Big difference!
Let's look at another one.
Use undo (ctrl + Z) to undo and position or scaling or rotations you've done so our cube is back to its original condition when you first added it.
Now we want to add a couple more cubes to our scene. We'll put our first extra one at the location <3,0,0> so move the 3D Cursor there and then add a cube just like we did when adding the original one. Then move your 3D Cursor to the position <0,0,3> and add another cube. Now de-select all (hotkey "A") and then select the cubes in the order I indicate on the picture below:
The last cube selected is what I normally call the "primary selection" but Blender's fancy name for it is "active element" which, you might have noticed, was one of the options to use for your pivot point. There are other options there as well, and this particular configuration of 3 selected cubes will let me demonstrate the difference between each so as you read this, try initiating a simple rotation action (hotkey R) with that pivot center set, and watch what happens as you move your mouse. Then cancel the action by right-clicking (or pressing the Esc key on your keyboard). If you accidentally confirm a rotation just use ctrl+Z to undo.
Your pivot center options are:
- Active element: all three cubes will rotate together around the origin point of the active element (the "primary selection").
- Median point: all three cubes will rotate together around the point that is mathematically their median (an average of the location of each of their origins)
- Individual origins: each box rotates independently around its own origin
- 3D Cursor: this is the one we already looked at above where the 3D cursor is the point all 3 cubes will rotate around.
- Bounding box center: this one draws the smallest imaginary rectangular box around all selected objects's origins that it can, then uses the geometric center of that box as the point around which all three objects rotate. This is the default value (if I remember correctly...it's possible I changed this as part of my User Preferences)
You might want to repeat the above five once more, this time using the S hotkey to scale instead. Again you'll see that the way that things scale relative to one another varies quite radically between the various methods, each with its own potential uses when doing "real" work instead of playing with some basic cubes.
Flexible Object OriginsI mentioned that an object's origin is a separate and integral part of an object -- that it marks an object's global context. Let me show you how this works and why it's potentially important.
So far our transformations have involved objects, so what we're actually doing is manipulating them based on their origins. When you first create an object the origin is at the geometric center of its mesh. When you move the object (in Object mode) you're moving the origin and the mesh itself goes along for the ride. When you scale it, it scales relative to its origin. Because this origin is at the center of the mesh it's been behaving the same way we expect things to transform in Opensim.
Things get interesting when we change that origin's position relative to the rest of the mesh. With one exception, we can't do that directly -- you can't "select" the origin and move it. Instead, you position the origin and then position the rest of the mesh relative to that origin by moving it while in edit mode. Edit mode locks the origin in its current position and any changes you make to the mesh while in edit mode have no effect on the origin.
Let's look at that by adding a 4th cube but let's put it on a different layer and hide the other three (we'll come back to them again in a bit so we'll keep them). Click on a different layer, then position the 3D cursor at <0,0,0>, then add another cube.
Your cube will be automatically selected for you when you add it so now you can simply press the Tab hotkey to enter edit mode. Again by default, the entire mesh will be selected for you. While in edit mode let's move our cube up by 1.5m. You can do this most easily using the hotkey combination: GZ1.5 (G = grab, Z = constrain movement to the z-axis, 1.5= the distance we want to move it along that axis).
As you can see, the little orange dot that marks the object's origin remains fixed at the <0,0,0> point in space and it's only our mesh that moves. In edit mode the origin will never change.
Now switch back to Object mode (Tab) and you'll notice that your cube is still sitting up above the origin point. Now try some scaling and rotations with this edited cube. Yet again, a significant difference because our origin is no longer in the same position relative to the rest of the mesh that we're used to in Opensim, yet all of our transformations in Object mode are made relative to the origin of an object.
Once you've played with that a little to get a feel for it, let's go back to our three other cubes and finish off this part of the "context" set of tutorials with them. Click back on your 1st layer (assuming that's where your other 3 cubes are sitting). Now select the cube that's sitting up above the others (at position <0,0,3>.
I mentioned a moment ago that there was one exception about being able to change an origin's position relative to its mesh. The one exception is that you can move an object around and transform it as much as you like in Object mode and then, at any time, apply any one (or all) of those transformations to have it "locked in" as the mesh's new state relative to its origin. Let's do that for this cube.
From the 3D View menu, use Object > Apply > Location. You'll see the cube's little orange origin dot suddenly move to the <0,0,0> point which it will now share with the other cube below it. Now do the same thing with the cube you moved to the <3,0,0> location so all three cubes now have their origins applied at the same <0,0,0> center spot. Now select all three cubes in the same order you selected them before.
Yet again, play with scaling and rotation and change the pivot point. This time you'll notice yet another drastic change in the way the transformations are applied, because for all of them the origin is now identical to one another and pivot points in object mode are all based on an object's origin, not on the mesh itself.
As we've seen in a very short period of time, the "pivot point" context of a mesh has a huge impact on how transformations affect it. Next time we'll look at another part of the context equation: orientation.