Creating a Simple Portal
From C4 Engine Wiki
Contents |
Introduction
This tutorial walks you through the steps needed to create a simple portal that will transport you to another area in the world, in the same zone.
By now you should be familiar with creating a new world, adding a skybox, and adding some light - if not, look at the first few chapters of the tutorial "Creating a Basic World".
I have created a basic world with these elements already added, as well as a grassy floor and a stone block in the corner. I have also made sure that you cannot fall off the floor by adding four invisible barriers around the edge of the world. The "Portal-Template" world used in this tutorial is available here.
The "Portal-Template" world only contains elements from the "Demo" world included with C4 Engine, so it can be safely extracted into the data\wld folder.
Opening the "Portal-Template" World
Run C4.exe, press tilde to show the menu bar, choose Open World from the Tools pulldown menu, and then open the world named Portal-Template.wld for editing.
Your display should look similar to the image below:
Add Plate
Make sure that Toggle Backfaces is toggled and the backfaces are visible as we will be adding a plate and a portal.
But first we need a material for the portal, create/use any that you want, for this example I used the water material created here and named it portal – in the final world, faint ripples can be seen on the surface of the portal (But you can use any texture for this). Make sure that the material has a diffuse color with alpha less than 255.
The alpha value will control how much light gets through the portal and how much is reflected from the portal surface. The higher the value, the darker the portal.
Now with the portal material selected
Add a plate, click on the Geometries panel and select Plate.
Draw a plate over the stone using the top right viewport, make sure to leave a gap around the top left and right edges, so that it looks a bit like a doorway into the stone.
The top right and the bottom right viewports should look like the image below.
You can see in the bottom viewport that the plate has been drawn partially away from the block. Click on the select tool and click away from the plate so that the plate loses focus. You may now see the plate disappear in the view port as seen in the image below.
But notice it is still there by moving the camera and viewing the portal from the opposite side.
Select the plate and press CTRL-I to open the Node Info dialog. Click the "Geometry is inverted" option, and click OK.
The material is now displayed on the correct side.
Open the Node Info dialog again and select the rendering tab, make sure that the plate does not display shadows and click ‘Geometry covers a remote portal’
From the Controller Tab, Select Teleport.
Click Ok
Add Remote Portal
Now that plate is configured, it is time to add a Remote Portal. Select Remote Portal from the Zones and Portals panel. And paint a portal over the doorway that we created earlier using the top right viewport.
Notice from the top left viewport though, the portal is facing the wrong way, the portal is accessed from the right as seen below.
Use the select and rotate tool to flip the portal round, using the top left viewport, it’s a bit fiddly because the portal does not have a middle handle, so flip it 180 degrees and moving it back into position, to look like this.
Now open Node Info and make sure that the ‘Remote portal uses oblique frustum’ is checked and port is typed into ‘Remote location type:’
Click Ok
Add Locator Marker
We now need to add a Locator Marker from the Markers, Triggers and Effects panel.
In the plane of the portal, place the locator marker at the center of the portal and give it the locator type 'cent'. This tells the engine how to align the portal with the destination marker.
Click Ok
Group the Items
Now select the portal, plate and marker. It is easy to select more than one object using the Box Select tool, but first the barriers in front of and behind the proposed selection need to be hidden. Select both barriers and press CTRL-H to hide them. Then use the Box Select tool to select the portal, plate and marker items.
Once the items are selected, press CTRL-G to group them; the world editor will draw a circle around the group. While still selected, move the items closer to the stone block to give the illusion of a gateway embedded in the block.
Add the Destination
All that's left to do now is add the destination to our very small world.
From the Markers, Triggers and Effects panel, add a Location Marker to the top-right viewport. Add the marker to the bottom right area of the view, orienting the marker so that it points towards the entrance to our portal.
Using the bottom-left viewport, raise the marker so that we are not teleported into the middle of the floor!
Open the Node Info and change the Location type to port. Click OK.
Run the world and you should be able to see yourself while looking through the portal. You can even fire a few shots at yourself!
Summary
We've added a basic portal to a world using just one zone, so we didn't have to link the portal to any others.
A more advanced use of portals would include adding zones to the world and then adding remote portals to move between them.
The final world is available here.
The "Portal-Test" world needs to be extracted into the data\wld folder.
See also
See also Working with Portals.
























