Now that you've gotten a little more friendly with Blender in the first tutorial and started rendering some images after reading the second tutorial, you are probably itching to add some extra cool 3D modeling bits to your images.

Wait no longer! In this tutorial, you'll learn how to add spheres, arrows, and text to your renders. Also, the end will discuss the "proper" way of deleting objects to stop memory leaks.

Please check out the Getting Started page before you do this tutorial to make sure you have the AstroBlend library installed correctly.

Adding Arrows

We actually already did this in the first tutorial and in the interest of time and perpetuating my own laziness, I'll refer you to there for the details.

Adding Spheres

The commands for adding a sphere are very similar to adding an arrow, except that you don't need to tell Blender to point the sphere anywhere because its a sphere, and that would be silly. To add a sphere, one could run the following in the text editor, as an external script, or by just copying and pasting into the python console:

import science

sphere_name = "GreenSphere"
sphere_color = (0, 1, 0) # (R,G,B)     
sph = science.simpleobjects.Sphere(sphere_name, color = sphere_color)
sph.location = (3, 0, 0)
sph.scale = (2., 2., 2.)

If you do this, you should see the following green sphere, on the x-axis at 3 Blender Units, with a radius of 2 Blender Units:

Adding Text

The final thing you might want to add is some text. And since you probably want this text facing your camera as your camera moves around, this text will have pointing capabilities. The first thing we need to do is make some text! Assuming you're starting with a new Blend file, we'll load the science library and add some text:

import science

# make a science camera
cam = science.Camera()
cam.location = (0, 10, 0)

# make some text w/o shading
text = science.simpleobjects.Text("I am text!", color=(0,0,1))
text.pointing = cam.location # have it face the camera
text.location = (0, -2, 0)

This will first initialize the camera to be tracked to an empty, and then set the camera along the y-axis at 10 Blender Units. Then, text is added in a lovely shade of blue, which is then placed where the camera is pointing, and set facing the camera by putting the text's empty mesh at the location of the camera. You should see the following:

To see how this will look to the camera, we can click on the 3D viewer and press "0" on the number pad. This will then show:

One thing of note - if you look at the object selector panel you will see three objects related to the text:

(1) I am text! - the actual text object
(2) EmptyI am text! - the empty used to point the text at the camera
(3) CenterOf:I am text! - a hidden empty which lies at the center of the text, 
    and is used in pointing the text at the camera
The extra "CenterOf" object is necessary because of the fact that if we linked the empty straight to the text object, the empty would point to the start of the text, not the middle. By parenting the text to the "CenterOf" object, we can point the "CenterOf" object at the "Empty" text object and do the pointing this way.

This is an important to point to make since if we move the text "by hand" we have to make sure to move the "CenterOf" object by unhiding and dragging it around. If we try to move the text object directly, it will no longer point correctly as shown below:

Because I picked up and dragged the text, instead of its "CenterOf" object, the text is now almost out of the frame of the camera. So beware of that!! Its probably best just to move text objects by command line.

Deleting Things

Deleting the text, arrow, and sphere objects is done just like with you uploaded simulation models:




Call yt Directly

Previous Tutorial

Simple Movies

Next Tutorial