protected override void OnLoad(EventArgs e) { var l = BuildLevel(); var sp = GameObjectFactory.Instance.CreateSpawnPoint(new Vector2D(-50, -50), 6, 75); l.StaticGameObjects.Add(sp); GameObjectFactory.Instance.SaveLevel(l, "l1.level"); var playerOne = GameObjectFactory.Instance.CreatePlayer("Some Guy", l.SpawnPoints[0]); _camera = new FirstPersonCamera(ref playerOne); _gi = new SandboxGameInstance(l); _gi.LivingGameObjects.Add(playerOne); _renderer = new Renderer(((GameInstance)_gi)); base.OnLoad(e); }
public void RenderScene(Camera c) { c.SetupCamera(); c.UseCamera(); foreach (var g in _gameInstance.CurrentLevel.Chunks) { DrawLevelChunk(g); } GL.PushMatrix(); GL.Disable(EnableCap.Lighting); foreach ( var g in (from g1 in (from g2 in _gameInstance.CurrentLevel.StaticGameObjects select g2 as GameObject).Union( (from g3 in _gameInstance.LivingGameObjects select g3 as GameObject) ) orderby new Line2D(c.Position, g1.Position).Length descending where g1.IsVisible select g1)) { if (g is DynamicGameObject) { } if (g is StaticGameObject) { // BillboardCheatSphericalBegin(); GL.BindTexture(TextureTarget.Texture2D, ContentManager.Instance[g.TextureHandle].glID); GL.PushMatrix(); GL.Translate(g.X, g.Z, g.Y); GL.Rotate(-c.Angle+90, 0, 1, 0); // GL.Disable(EnableCap.Texture2D); GL.Begin(BeginMode.Quads); GL.TexCoord2(1, 0); GL.Vertex2(.5, 1); GL.TexCoord2(0, 0); GL.Vertex2(-.5, 1); GL.TexCoord2(0, 1); GL.Vertex2(-.5, 0); GL.TexCoord2(1, 1); GL.Vertex2(.5, 0); GL.End(); //GL.Enable(EnableCap.Texture2D); // BillboardEnd(); GL.PopMatrix(); } } GL.Enable(EnableCap.Lighting); GL.PopMatrix(); }