To make objects visible, we need to define some lighting. We do this by creating a method that defines the type of lighting we want in the game. Let's set this up by going through the following steps:
- In the WhackABox project, open the Game.cs file.
- Add the InitializeLights() method anywhere in the class, as shown in the following code block:
private void InitializeLights()
{
var lightNode = camera.Node.CreateChild();
lightNode.SetDirection(new Vector3(1f, -1.0f, 1f));
var light = lightNode.CreateComponent<Light>();
light.Range = 10;
light.LightType = LightType.Directional;
light.CastShadows = true;
Renderer.ShadowMapSize *= 4;
}
Again, everything in UrhoSharp is a node, and lights are no exception to that rule. We create a generic node on the camera node by accessing the stored camera component and accessing the node it belongs to. We then set the direction of that node and create a Light component to define a light. The range of the...