Portal tutorial
From Blender2crystal
Contents |
[edit] Introduction
This is a tutorial that will show you how to create portals between scenes in blender.
We will do the following:
- Create some geometry, basically two rooms with one separating passage way between them.
- Create three sectors, for each of the rooms and the passage respectively.
- Create the portals between them by using blender2crystal portal tool, and see the result in crystalspace.
[edit] Basic Concepts
In this tutorial a number of concepts will be used, such as portals, scenes, sectors, object normals, we now give a little overview of each of them. If you are experienced in these you can jump straight into the next section.
[edit] Scenes / Sectors
In Crystal Space we call sectors to the different parts of a world.
A sector is a part of a bigger world usually connected to other sectors by portals (we'll get into this straight away). Each blender scene will result in a different sector when exporting for crystalspace.
[edit] Portals
Portals are the polygons that connect different sectors . Each portal allows traversing from one sector to another one.
Important: One thing to keep in mind is that portals are one way, ie, if you want to be able to go from sector1 to sector2 and back you'll need the following:
- a portal in sector1 to go to sector2
- a portal in sector2 to go to sector1
From blender we will just create one of the portals, and the portal tool will create the "going back" portal automagically.
[edit] Object Normals
This is a very basic concept but still might be good to revisit it:
In Crystal Space each polygon only has one face, ie, you can only see it from one side.
The basic idea is: Each face has vector called "normal vector"; to see it we must go into edit mode, and select the "Draw normals" option on the mesh tools (Fig 2.1), along with an appropiate size for them.
The visibility rule is You can see a polygon when its normal vector is pointing at you(Fig 2.2).
Now we're ready to go into the tutorial..
[edit] Creating Rooms Geometry
[edit] Activate global snap to grid
First we will set snap to grid for all actions. You can find this in the Blender info window (the title bar when you make it bigger). This is quite helpful, as otherwise it will be difficult or even impossible to get the portals and room borders right.
[edit] Create two rooms and snap them to the grid
After doing this we create two rooms of equal size (it's not totally necessary but its convenient to start like this so its easy to get the initial geometry to fit together).
Then move the rooms so they are one in front of the other.
Finally move the faces closest to each other so they're also snapped to the grid, otherwise later it will be difficult to fit the passageway in the middle.
[edit] Subdivide rooms
Once all faces and rooms are correctly snapped to the grid, we will subdivide (look Fig 5) the rooms twice. This will allow enough polygons for later remove one in each room for the doors.
After this, select one polygon in each room, one in front of the other. This will be the portals, and now we will create a passage between both by extruding one of them.
Note: the objective is to get three rooms (two rooms and a passage) with the holes for the portals, and two polygons to create the portals from. The polygons can be in any of the sectors, but for this tutorial we'll keep them in the middle sector so that later we can assign them from there.
[edit] Creating a passage between both rooms
[edit] Extrude the passage from one of the rooms
To create the passage do the following actions:
- Select one of your (future) portals.
- Extrude the face from upper view (ctrl+e in edit mode)
[edit] Separate the passage from its room
Now we have the passage but its still attached to its room, for one sector world this is ok, but as we will need to get each part into a different scene we need to have them as different objects. Do the following:
- Select all faces that make the passage (including the portal).
- Separate (P in edit mode)
[edit] Fill the missing polygon in the passage
Finally fill the missing polygon in the passage, this will later become a portal (as well as the opposite polygon).
- Fill the missing polygon in the entrance (select its borders and hit "F").
Once we're finished with this procedure we have:
- one room with a missing polygon for the door
- one room with no missing polygon
- a more or less cubic passage.
[edit] Separate Rooms into different Scenes
[edit] Finish rooms setup
Now we will create three scenes (that will become sectors in crystalspace) and set the map so only one room is present in each of the sectors, but before this we will finish preparing the rooms while they're in the same scene. There is some actions to take:
- Make new scenes (click on <> at top next to SCE:Scene should see ADD NEW there)
- Make sure all normals are looking inside in each of the rooms (CTRL + SHIFT + N to invert them)
- Open a polygon in the room that is still totally close (select it in edit mode and delete).
Now we should have the three rooms ready to separate in different sectors:
- Two similar rooms with a polygon missing (this will be filled by the portal later)
- One closed passageway
[edit] Separate into scenes
To separate the rooms we create two new scenes using the "Full Copy" option, after this just delete all rooms but one from each of the scenes, so you end up with one of the rooms in each scene (as seen in the following image).
[edit] Separate the portals polygons
Now the only thing missing is to split the portals from the passage, note for making the portals we need one lonely polygon, so we have to split it from its mesh. As we want to make portals into each of the adjacent rooms we need the two polygons on the sides.
To do this go into edit mode, select one face, and hit letter "P" (separate), then do the other face.
[edit] Assign Portals
Now we will assign the portals, before doing so you have to check you have the following right:
- First room is missing one polygon right where the passage would end.
- Second room is also missing one polygon right where the passage would end.
- The passage ending polygons are separated from the walls itself. We will use this polygons to create the portals. For now apply size and rotation to the portals (Ctrl+A).
After checking this go to the passage scene, and select one of the portals, take note of what scene it should go to. Next we will create our portal entity:
- Click the "eye" icon at the top of the Blender2Crystal GUI pane.
- Click the "cube" on the left of the GUI pane.
- Click "+special
- Click "portal"
- Type in the name of the Blender scene containing the room this portal should link to.
Now you can check in the other scene that the portal was actually created, also the original object has been tagged as portal with some properties. Yes? Good :) Now go and do the other one.
[edit] Run in CrystalSpace
Ok we're ready... run the world with the exporter as you're used to and you should see something similar to Fig. 14. If some of the portals dont look ok check that there is no duplicate portals, and also that the normals are looking at the correct side.
[edit] Getting the full working resulting file
(CS/CEL 1.2.1 + b2cs_svn)
and a Regions/Zones application portals3.blend



