Example #1
0
 /// <summary>
 /// Method to draw map and all its contents
 /// </summary>
 /// <param name="gfxDevice">Graphics device instance</param>
 /// <param name="projection">projection matrix</param>
 /// <param name="view">view matrix</param>
 /// <param name="lightsSetup">lights setup array as required by all static objects</param>
 /// <param name="fogColor">fog color as a vector3</param>
 /// <param name="fogSetup">fog setup as required by all static objects</param>
 /// <param name="basicEffect">basic effect class to enable primative drawing</param>
 /// <param name="camPos">camera position (note: N O T the focus point - used to translate the skybox when its drawn)</param>
 public static void DrawMap(GraphicsDevice gfxDevice, Matrix projection, ContentManager contentMgr, Matrix view, Vector3[] lightsSetup, Vector3 fogColor, int[] fogSetup, BasicEffect basicEffect, Vector3 camPos)
 {
     //Draw skybox
     if (skyBoxDrawer != null)
     {
         skyBoxDrawer.Draw(view, projection, gfxDevice);
     }
     //Draw all objects:
     foreach (Object item in BBNMap.content.Values)
     {
         if (shouldDrawPathNodeConnections)
         {
             if (item is Node)
             {
                 for (int i = 0; i < (item as Node).getEdgeCount(); ++i) // draw all edges
                 {
                     Edge e = (item as Node).getEdge(i);
                     Algorithms.Draw3DLine(Color.Red, e.node1.Position, e.node2.Position, basicEffect, gfxDevice, projection, view, Matrix.Identity);
                 }
             }
         }
         if (item is Drawer)
         {
             (item as Drawer).Draw(view, projection, lightsSetup, fogColor, fogSetup);
         }
         else if (item is Marker)
         {
             Drawer dTemp = new Drawer((item as Marker).Position, contentMgr, true);
             dTemp.addAttribute("modelName", MODEL_USED_FOR_MAP_EDITOR);
             dTemp.addAttribute("x", Convert.ToString((item as Marker).Position.X));
             dTemp.addAttribute("y", Convert.ToString((item as Marker).Position.Y));
             dTemp.addAttribute("z", Convert.ToString((item as Marker).Position.Z));
             dTemp.addAttribute("scaleX", "0.25");
             dTemp.addAttribute("scaleY", "0.25");
             dTemp.addAttribute("scaleZ", "0.25");
             dTemp.addAttribute("yaw", "0");
             dTemp.addAttribute("pitch", "0");
             dTemp.addAttribute("roll", "0");
             dTemp.onAttributeChange();
             dTemp.update(new KeyboardState(), new GamePadState(), new GamePadState());
             dTemp.Draw(view, projection, lightsSetup, fogColor, fogSetup);
         }
     }
 }