void shadowTest() { someRobot.RenderAll(); GL.PushMatrix(); float[] lPos = l.getPosition(); GL.Translate(lPos[0], lPos[1], lPos[2]); GL.PointSize(50.0f); GL.Begin(BeginMode.Points); GL.Vertex3(0.0f, 0.0f, 0.0f); GL.End(); GL.PointSize(1.0f); GL.PopMatrix(); float[] mat = l.getShadowMatrix(new float[] { 0.0f, 1.0f, 0.0f, 0.0f }); GL.Enable(EnableCap.PolygonOffsetFill); GL.MultMatrix(mat); //GL.Enable(EnableCap.Blend); GL.Color4(0.0f, 0.0f, 0.0f, 1.0f); someRobot.HideTextures(); someRobot.RenderAll(); someRobot.ShowTextures(); //GL.Disable(EnableCap.Blend); GL.Disable(EnableCap.PolygonOffsetFill); }
public void Render() { //Track all unoccupied tiles and clean up for (int i = 0; i < terrain.tiles.GetLength(0); i++) { for (int j = 0; j < terrain.tiles.GetLength(1); j++) { Tile t = terrain.tiles[i, j]; FloorTile ft = null; if (t is FloorTile) { ft = (FloorTile)t; ft.MarkUnOccupied(); //initially, its unoccupied } if (!t.IsCollideable() && t is FloorTile) { for (int k = 0; k < robots.Count; k++) //till the robot says otherwise! { int robPosX = robots[k].MapPosX; int robPosY = robots[k].MapPosY; if (robPosX == i && robPosY == j) //check if its occupied { ft.MarkOccupied(); //if it is, then mark it occupied } } } } } //Track all travelling projectiles fired by the robots for (int i = 0; i < projectiles.Count; i++) { if (projectiles[i].IsDead()) { projectiles.Remove(projectiles[i]); i = 0; //Reset count back to 0 } } GL.PushMatrix(); /* Render Map */ GL.PushMatrix(); GL.Translate(0.0f, 0.0f, 0.0f); /* Render terrain */ GL.PushMatrix(); terrain.Render(); GL.PopMatrix(); /* Render robots */ GL.PushMatrix(); for (int j = 0; j < robots.Count; j++) { Robot robot = robots[j]; for (int i = 0; i < projectiles.Count; i++) { if (robot.ProjectileTest(projectiles[i])) { projectiles.Remove(projectiles[i]); i = 0; } } if (robot.IsDead()) { robots.Remove(robot); SetTile(new LightRubblePile(), robot.MapPosX, robot.MapPosY); j = 0; } else { //GL.Translate(robot.PosX * 1.0f, 0.0f, robot.PosY * 1.0f); robot.RenderAll(); //GL.Translate(-robot.PosX * 1.0f, 0.0f, robot.PosY * -1.0f); } } GL.PopMatrix(); /* Render projectiles */ GL.PushMatrix(); foreach (Projectile projectile in projectiles) { projectile.RenderAll(); } GL.PopMatrix(); /* Render factories */ GL.PushMatrix(); foreach (Factory factory in factories) { GL.Translate(factory.PosX * 1.0f, 0.0f, factory.PosY * -1.0f); factory.Render(); GL.Translate(-factory.PosX * 1.0f, 0.0f, factory.PosY * 1.0f); } GL.PopMatrix(); /* Render buildings (or blocks) */ GL.PushMatrix(); foreach (Block block in blocks) { GL.Translate(block.PosX * 1.0f, 0.0f, block.PosY * -1.0f); block.Render(); GL.Translate(-block.PosX * 1.0f, 0.0f, block.PosY * 1.0f); } GL.PopMatrix(); /* Render the bases */ GL.PushMatrix(); foreach (Base cBase in bases) { cBase.Render(); } GL.PopMatrix(); /* Render Remote Control Unit */ GL.PushMatrix(); remoteControlUnit.Render(); GL.PopMatrix(); GL.PopMatrix(); //foreach (Light light in lights) // light.unapply(); GL.PopMatrix(); }