CryEngine 3 Tutorial:
Beginning Solids.
At the end of this tutorial you will have created a simple 4 wall building with a ceiling, a floor, and a door.
To place a solid first pick "solid" from the right rollupBar. There are several different solid shapes that can be created, but for now make sure that Box and 4 sides are selected in the solid parameters.
After choosing the correct parameters a solid could be created by click dragging to form the x-y base. Once released, move your mouse up to choose a z height for your solid and click to finish the solid.
At the top of the window the grid size can be adjusted so that solids can be made with more precision. For right now we will choose .5 as our grid size. The default measurement for Cryengine is 1 unit = 1 meter.
To start we are going to create a solid that is .5x20x3
Next we will create a solid that is 20x.5x3
We want these too walls to align with each other and form a corner, so we must move them closer to each other. To do this first select the move tool in the Upper Left.
When the move tool is selected an object can be selected and moved along the x,y, or z planes by clicking on the desired axis and moving the mouse in that direction. i.e. if the z axis is selected the object can be moved up or down.
We will move the one of the walls so that the two match up but so that they do not come to a corner on the outside.
To resize an object you must first select the object and then click editing mode in the bottom right.
After selecting editing mode the object should turn blue (if it does not, pressing shift+space should turn helpers on.) Because we want to resize the object so that the face lines up with the other wall we will pick ‘Face’ under selection type.
We will select the desired face, which will then be highlighted in red. And use the x/y/z axises to pull it into the correct place to be flush with the wall.
NOTE: IT IS IMPORTANT TO CLICK ‘RESET XFORM’ EVERY TIME AFTER YOU SCALE OR CHANGE THE SHAPE OF A SOLID.
The ‘reset xform’ button can be found directely underneath the editing mode button on the solid editing tool.
Now we will copy the 2 walls to make 4 walls. An important note when copying solids is that when you copy you will only be able to move the object in the direction that you have selected at the top of the window (X, Y, Z, or XY.) Once you have selected the direction you would like to move the copied solid you can copy by hitting CTRL+C. Once you have moved the new copy to the desired position click to place it.
Once you have copied both walls and lined them up, you should have a large four walled area.
Now to create roof we have two options. The first option is to copy one one of the walls and rotate it so that it lies horizontally over the building and stretch it to the corners.
To rotate select the rotate tool in the toolbar. Once chosen the grid will switch several lines that start at the solid and stretch out at various angles. To rotate along an axis select the axis from the toolbar and drag the solid until the desired angle is reached. Alternatively an angle can be typed into x/y/z fields at the bottom of the window to get a more precise rotation.
At this point we run into an issue with the cryengine in that when rotations are performed they sometimes cause the solid to no longer match up on the grid. At this point you can either force it back onto the grid by manually moving it, or you can delete the solid and create a new one for the roof.
After we stretch the roof out to all of the corners copy it down to the bottom of the building to make a floor.
Now we plan to insert a door into world so that we can enter the building. To do so make sure you deselect your current object (esc), then choose entity on the right to bring up the entity browser. Entities can be found either by looking through folders or typing a name in the filter at the bottom. At this point we are looking for a door (choose ‘door’ not animated door or advanced door). Click on the entity door and drag it into the main window, click again to place it.
Now that we have our door entity in the world we need to select a model to represent it. Click on the model field in the bottom right to bring up the model browser.
Once again, items can be browsed for, or by pressing the smart button in the bottom right you can filter for items.
In the filter field input door and it should return 20 or so items. Models are of the file type .cgf. At this point we run into the second issue with the cryengine, lack of assets. Now if you have a working option you can skip ahead in the tutorial, but for me personally I had one option for a door, and it was a broken model. So I had to create the model myself.
This however is one of the strengths of working with solids the cryengine. You are able to create complex geometry using solids and then save them to a cgf file for use as a model (which also helps increase performance).
If we are going to go through the trouble of making our own door, we might as well make it look better than just a square with a wood texture right? To start our door (metal with a glass pane) we will make a solid that is 1.5 meters wide, .25 meters thick, and 2 meters tall.
The second step is to make a door that is 1.25 meters wide, 1.75 meters tall, and thicker than our first solid.
Move the fatter solid over so that it sits inside the thin solid, but leaves an edge all the way around the thin solid.
Choose the thin solid, and then CTRL+CLICK on the fat solid so that both are selected. Then click difference in the bottom right (ignore the fact that I accidentally circled union). You may have to scroll down to see the difference button. If done correctly your solid should now look like this:
If it does not that means that you selected your objects in the incorrect order. Undo and try again.
At this point I want to decrease the size of the grid beyond what is an option in the drop down menu. Instead click setup grid, and in the ‘grid lines every’ field type .0625. Then click OK.
Create another solid and resize it so that it sits on the inside of your carved solid to make the window. However, you want this solid to leave a lip between it and the solid in the thickness direction, the solid I created is .06 units thick.
Now select both your outer and inside solid and click merge on the bottom right. Combining your two solids into one (this is necessary for saving as a .cgf)
Because we want the door to have two separate materials and textures (glass, metal) we need to set up the correct faces on different matIDs. To get started first click UV Mapping on the right side.
In the bottom right you can see the matID property I was talking about earlier, if you click on a face you can see what material ID it is currently being assigned. We need to separate the glass and metal onto two separate IDs for this to work properly. Go through and click each face that makes up the metal frame, change its id to 2 and click assign, repeat until you feel you are done.
To make sure that you have selected all the faces, switch to matID to 2 and press select. This will highlight all faces assigned matID 2 on the solid.
After you have changed all the metal faces to matID 2 (you shouldn’t have to change the glass faces as they default to 1 and should be 1) click the soccer ball looking icon (material editor dialog) in the top right. When the window opens right click on the left and select ‘Add new multi Material’
Choose a filename for your new material. I chose slidingdoor.
Now right click on your material and choose ‘Set number of sub materials’ change it to 2 and press ok.
Select SubMtl1 to change the material that will displayed on matID 1 surfaces. Because this is our glass layer I used the following settings:
Diffuse Texture map: Texture/defaults/glasstint.dds
Surface Type: glass_unbreakable (if you choose glass, it will break when hit causing your door to disappear)
Also make sure to change the color to something that looks better than white and since we are using glass change the opacity to 80.
For SubMtl2 I used the following settings:
Diffuse Texture map: Texture/decals/rust_leaking_1.dds
Surface Type: metal
Once you are happy with your final textures and colors. Click the save button at the top to save your texture. Then click apply to selected object (the top left icon). If you shoot at it in game you will notice that the materials of the window and door frame respond differently to being shot at.
Now that we have created our object and our texture it is time to save it as a model. Select the object and select ‘save to CGF’ in the bottom right corner. Choose a filename I chose slidingdoor and save.
Now that we have saved it, go ahead and delete your current door. Head back over to your door entity (or create a new one if you deleted it) and click to choose the model for it.
Now browse to the correct location for your door model that you just saved. Click root in the top left, then browse down the structure Game/Levels/YourProjectName and select the .cgf file that you just saved.
Unfortunately it the texture is not saved to the .cgf when saved so you will have to reapply it. On the right there should be an MTL field, click it and assign the texture we just made.
Congratulations you now have a custom door. Unfortunately if you go into game mode and use the door you will notice that it does not turn properly. The way to change this is to change the origin point in a modeling software and re-export the model. So instead of going through all that work we are just going to make our door a sliding door instead of a rotating door.
On the right under the model you need to change the following values to make a proper rotating door:
Under Rotation change Acceleration to 0 and Range to 0.
Under Slid change Axis to whichever axis you would like it to slid on (I changed my axis to the y because that is what mapped to moving sideways on my model.) Also change your range to the model size (my model is 1.5 units wide so I would change the range to 1.5 if I want it to slide right, or -1.5 if I want it to slide left.
Now we need to create a hole in the wall for the door, place your door up against the wall to serve as a reference point and select the clipping tool in the bottom right.
NOTE: YOU COULD ALSO MOVE THE WALLS SO THAT THEY SURROUND THE DOOR AND LEAVE A GAP, OR YOU CAN FIGHT WITH THE CLIPPING TOOL.
If you selected the clipping tool go to Display>Cycle 2D Viewport and cycle until you get the 2d perspective where the door is facing towards you on the screen (it will be a yellow square). You can zoom in using the scroll wheel (every time you switch perspective you have to click in the window to gain focus)
Click so that the two blue dots match up with one side of the door (you may have to drag one of them) and click split on the left. Now line up the dots with the other side of the door and click Clip Front or Clip Back (I believe the yellow lines points back. Only click the button once, if you did it correctly it should look like this:
If not try using the opposite clip. Have you been pressing reset xform after you change the size/shape of a solid (remember it is the bottom right below ‘editing mode’?)
Once you have convinced the clip tool to work properly create another solid and place it in the hole above the door.
Congratulations you now can enter your building. But now you want to add some textures you say?
Select the solid that you would like to apply the texture to and open the material editor (soccer ball top left)
Select a material (I chose concrete_wall_01), make sure you select a surface type and hit apply to selected object. If your textures are appearing as all black that means that your diffuse color is too low, change it to something lighter.
If your texture is not tiling well you can change this by clicking uv mapping in the bottom right. Select the face you would like to change and then the offset (left column) and scale (right column) values and hitting apply. Note: this only changes the selected face.
That is all for this tutorial. Play around and continue to mess with solids to make a more amazing building.
More coming soon hopefully.