public override void Create() { food.Clear(); wormi.Clear(); incLen = 0; curSpeed = 0.1f; curTime = 0; // 3D scene with Octree scene = new Scene(Main.Instance.Context); scene.CreateComponent <Octree>(); scene.CreateComponent <DebugRenderer>(); soundNode = scene.CreateChild("Sound"); eating = Main.Instance.ResourceCache.GetSound("Sounds/BigExplosion.wav"); death = Main.Instance.ResourceCache.GetSound("Sounds/NutThrow.wav"); soundSource = soundNode.CreateComponent <SoundSource>(); // Create a directional light to the world. Enable cascaded shadows on it var lightNode = scene.CreateChild("DirectionalLight"); lightNode.SetDirection(new Vector3(0.6f, -1.0f, 0.8f)); // The direction vector does not need to be normalized var light = lightNode.CreateComponent <Light>(); light.LightType = LightType.Directional; light.CastShadows = true; light.ShadowBias = new BiasParameters(0.00025f, 0.5f); light.ShadowCascade = new CascadeParameters(10.0f, 50.0f, 200.0f, 0.0f, 0.8f); CameraNode = scene.CreateChild("Camera"); camera = CameraNode.CreateComponent <Camera>(); camera.FarClip = 1000; CameraNode.Position = new Vector3(0.0f, 35.0f, -35.0f); CameraNode.LookAt(Vector3.Zero, Vector3.Up); Main.Instance.Renderer.SetViewport(0, new Viewport(Main.Instance.Context, scene, camera, null)); CModel floor = CModel.LoadPrefab(scene, "floor.xml"); floor.GetNode().SetScale(50); floor.SetMaterial("Terrain.xml"); for (int q = 0; q < 10; q++) { WormPiece p = new WormPiece(); p.mesh = CModel.LoadPrefab(scene, "WormSphere.xml"); p.mesh.GetNode().Position = new Vector3(-q * DIST, 0, 0); p.mesh.GetNode().Rotation = new Quaternion(0, 90, 0); //p.mesh.LoadAnimation("Move.ani"); //p.mesh.LoadAnimation("Eat.ani"); //p.mesh.Play("Move.ani"); wormi.Add(p); } for (int q = 0; q < 20; q++) { SpawnFood(); } particleNode = scene.CreateChild("Particles"); emitter = particleNode.CreateComponent <ParticleEmitter>(); }