Screen recording of today's lecture: http://dennett.cs-i.brandeis.edu/talks/cs65a/L03a/Resources/L03a.mov
In today's lesson we learn how to manage a large model, movie, or game in a way that allows multiple people to work on it simultaneously and also allows one to keep and modify just one master copy of each repeated object (e.g one domino model that is replicated to thousands).
This technique is called modularization. It breaks a complex problem into many smaller subproblems which can be worked on independently.
The key technique we will use is to divide a complex scene into a number of different groups of objects. Each of these groups of objects will have its own blend file and potentially its own artists, designers, coders, etc.
The main project itself will consist of a blend file in which groups of objects from several different files are linked in. Blender has several primitive shapes you can add to a scene (cube, sphere, cone, cylinder, etc.) but this group/linking method allows you to create your own new object types that can be added easily to any Blender scene. A major benefit is that if any of the smaller blender files is changed or updated, the next time someone opens the main blender file, all of those changes will be reflected in the main file.
Today we will show how to create some new objects for use in the Virtual World project, how to put them into named groups, and how to link those groups into the main blender file.
Creating the brick
Start up blender which should bring up the standard cube and
resize the cube using the properties subpane to it has dimensions 10x1x10
Make it translucent
Click on the Materials tab in the Properties window
Scroll down to the bottom and expand the "Transparency" item
Check the transparency box and set the opacity to 0.5
Scroll up to the Diffuse Color box, click on it and select a "blue" color.
This should create a translucent blue box.
Put it into a named linkable group
Click on the Object tab in the Properties window.
Scroll down to the Groups section and click on the "+"
tab to the right of the "Add to groups" button. This
reveals a textfield underneath where you can type the name of the group.
Lets call it "brick"
Then press the "Add to group" button and select "brick" from the menu list that appears.
Save into the virtualworldkit folder
Use the File->SaveAs item to save this as brick.blend
We have now made an object that can be linked into our virtual world!
Link the brick into the world.blend file
Open up the world.blend file (using File->Open)
Next link in the brick by using File->Link to select the brick.blend file,
this will display a list of items within brick.blend, you should
select the "Groups" element and inside that select the "brick"
The press the "Link/Append" button in the upper right.
The translucent brick has now been imported. It can be scaled, rotated, translated
and duplicated in the virtual world. Resize to fit your taste, make several copies,
and place them on the platform.
Hit "P" to play and observe how they interact with the ball.
Save your main file and use Relative Paths!!!
A very important step is to tell Blender it should link in the various objects
using "relative" paths. If you don't do this, then when you change the name
of the folder containing all of your blend files for this project, blender will
not be able to find the files. It is easy to do...
Also, it is important that all files to be links into the main blend file be in the same folder as the main blend file. When we start adding soundtracks and image textures, those must also be in the same folder. This allows you to then compress the entire folder and upload it to a server where other people can download it (e.g. the graders), expand it, and open it up in blender.
Now, go back to the brick.blend file and change the color to blue
and save it. When you then open your world.blend file, you'll see that the translucent
bricks have now all changed from blue to red!
Now go back to the brick.blend file and change the dimensions of the brick
and save. When you reopen the world.blend, your the bricks should all have the new shape!
In this class, we will create many new and interesting objects. I will be creating a game asset library where we can share our objects with each other and the world. Here is a link to a site that has some initial models (e.g. a few skyboxes) that you can use in your homeworks or other games.
Creating a funnel: Last time we created a bowl with a hole at the bottom by cutting a sphere in half in edit mode, using the properties->modifiers->solidify feature to turn it into a solid object. We will repeat that process in class in a separate file and then show how to link it into the main blend file.
Creating a half-pipe and a flat disk: we will also create these two other objects, make them linkable, and link them to the main blend file.
The key idea here is that you can select an object and then create a new constraint where you specify the type of joint to be used and the target object that should be connected to the selected object using the joint. Below is an example of a specification of a hinge joint between the selected object (a lever) and the target object (leverbase).
It seems that the current version of Blender (2.61) does not import rigid body constraints when you link in a group. So this type of constraint would need to be added after you linked in the components...