示例#1
0
        public int PrintTimeSinceReset()
        {
            int iElapsedTime = TimeSinceReset;

            Diag.WriteOut("Time since reset: " + iElapsedTime.ToString());
            return(iElapsedTime);
        }
示例#2
0
        public int PrintTimeSinceStart(string text)
        {
            int iElapsedTime = (int)System.DateTime.Now.Subtract(starttime).TotalMilliseconds;

            Diag.WriteOut(text + ": " + iElapsedTime.ToString());
            return(iElapsedTime);
        }
示例#3
0
        public static Rot RotBetween(Vector3 v1, Vector3 v2)
        {
            Rot rResult = new Rot();

            Vector3 VectorNorm1 = new Vector3(v1).Normalize();
            Vector3 VectorNorm2 = new Vector3(v2).Normalize();

            Vector3 RotationAxis = Vector3.CrossProduct(VectorNorm1, VectorNorm2);

            //Test.Debug(  "math: " << RotationAxis ); // Test.Debug

            //Test.Debug(  Math.Abs( RotationAxis.x ) << " " << Math.Abs( RotationAxis.y ) << " " << Math.Abs( RotationAxis.z ) ); // Test.Debug
            if (Math.Abs(RotationAxis.x) < 0.0005 && Math.Abs(RotationAxis.y) < 0.0005 && Math.Abs(RotationAxis.z) < 0.0005)
            {
                Vector3 RandomVector = new Vector3(VectorNorm1);
                RandomVector.x += 0.5;
                RandomVector.Normalize();
                RotationAxis = Vector3.CrossProduct(VectorNorm1, RandomVector);

                rResult = mvMath.AxisAngle2Rot(RotationAxis, Math.PI);
            }
            else
            {
                double DotProduct = Vector3.DotProduct(VectorNorm1, VectorNorm2);
                Diag.Debug("DotProduct: " + DotProduct.ToString()); // Test.Debug
                double Vangle = Math.Acos(DotProduct);
                Diag.Debug("math: " + Vangle.ToString());           // Test.Debug
                rResult = AxisAngle2Rot(RotationAxis, Vangle);
            }
            return(rResult);
        }
示例#4
0
        public int PrintElapsedTime(string text)
        {
            int iElapsedTime = (int)System.DateTime.Now.Subtract(lastelapsedtime).TotalMilliseconds;

            Diag.WriteOut(text + ": " + iElapsedTime.ToString());
            lastelapsedtime = System.DateTime.Now;
            return(iElapsedTime);
        }
示例#5
0
        KeyFilterSdlKeyCache()
        {
            Diag.Debug("Instantiating KeyFilterFormsKeyCache()");
            IRenderer renderer = RendererFactory.GetInstance();

            renderer.KeyDown += new SdlDotNet.KeyboardEventHandler(renderer_KeyDown);
            renderer.KeyUp   += new SdlDotNet.KeyboardEventHandler(renderer_KeyUp);
        }
示例#6
0
        // based on http://nehe.gamedev.net
        public void RenderHeightMap(int[,] HeightMap, int iMapSize)        // This Renders The Height Map As Quads
        {
            int X = 0, Y = 0;
            int x, y, z;

            if (HeightMap == null)
            {
                Diag.Debug("Error: no height map data available");    // Test.Debug
                return;
            }

            Gl.glBegin(Gl.GL_QUADS);

            // Test.Debug(  "drawing quads..." ); // Test.Debug
            for (X = 2; X < (iMapSize - 3); X += 1)
            {
                // Test.Debug(  "X " << X ); // Test.Debug
                for (Y = 2; Y < (iMapSize - 3); Y += 1)
                {
                    Vector3 Normal = new Vector3();; // = VectorNormals[ X + 128 * Y ];
                    Normal.z = 1;
                    Normal.x = (HeightMap[X + 10, Y] - HeightMap[X, Y]) / 10.0f;
                    Normal.y = (HeightMap[X, Y + 10] - HeightMap[X, Y]) / 10.0f;

                    x = X;
                    y = Y;
                    z = HeightMap[X, Y];
                    Gl.glNormal3d(Normal.x, Normal.y, Normal.z);
                    Gl.glTexCoord2d((double)X / (double)iMapSize, (double)Y / (double)iMapSize);
                    Gl.glVertex3i(x, y, z);

                    x = X + 1;
                    y = Y;
                    z = HeightMap[X + 1, Y];
                    Gl.glNormal3d(Normal.x, Normal.y, Normal.z);
                    Gl.glTexCoord2d((double)(X + 1) / (double)iMapSize, (double)(Y) / (double)iMapSize);
                    Gl.glVertex3i(x, y, z);

                    x = X + 1;
                    y = Y + 1;
                    z = HeightMap[X + 1, Y + 1];
                    Gl.glNormal3d(Normal.x, Normal.y, Normal.z);
                    Gl.glTexCoord2d((double)(X + 1) / (double)iMapSize, (double)(Y + 1) / (double)iMapSize);
                    Gl.glVertex3i(x, y, z);

                    x = X;
                    y = Y + 1;
                    z = HeightMap[X, Y + 1];
                    Gl.glNormal3d(Normal.x, Normal.y, Normal.z);
                    Gl.glTexCoord2d((double)(X) / (double)iMapSize, (double)(Y + 1) / (double)iMapSize);
                    Gl.glVertex3i(x, y, z);
                }
            }
            //Test.Debug(  "Quads done" << X ); // Test.Debug
            Gl.glEnd();
        }
示例#7
0
 public static void WriteOut(object inputobject)
 {
     if (inputobject.GetType().IsArray)
     {
         Array inputarray = (Array)inputobject;
         if (inputarray.Rank == 1)
         {
             string sCombinedString = "";
             foreach (object item in inputarray)
             {
                 if (item.GetType() == typeof(bool))
                 {
                     sCombinedString += ToString(item);
                 }
                 else
                 {
                     sCombinedString += ToString(item) + ", ";
                 }
             }
             Debug(sCombinedString);
         }
         else if (inputarray.Rank == 2)
         {
             for (int i = 0; i < inputarray.GetUpperBound(0) + 1; i++)
             {
                 Diag.WriteOut(GetArraySlice(inputarray, i));
             }
         }
         else if (inputarray.Rank == 3)
         {
             for (int k = 0; k < inputarray.GetUpperBound(0) + 1; k++)
             {
                 Console.WriteLine("i = " + k.ToString());
                 for (int i = 0; i < inputarray.GetUpperBound(1) + 1; i++)
                 {
                     string sLine = "";
                     for (int j = 0; j < inputarray.GetUpperBound(2) + 1; j++)
                     {
                         sLine += ToString(inputarray.GetValue(new int[] { k, i, j })) + ", ";
                     }
                     Debug(sLine);
                 }
                 Debug("");
             }
         }
     }
     else if (inputobject.GetType() == typeof(ArrayList))
     {
         string sCombinedString = "";
         foreach (object item in (ArrayList)inputobject)
         {
             sCombinedString += item.ToString() + ", ";
         }
         Debug(sCombinedString);
     }
     else if (typeof(ICollection).IsInstanceOfType(inputobject))
     {
         string sCombinedString = "";
         foreach (object item in (ICollection)inputobject)
         {
             if (item.GetType() == typeof(DictionaryEntry))
             {
                 sCombinedString += "{" + ((DictionaryEntry)item).Key.ToString() + ", " + ((DictionaryEntry)item).Value.ToString() + "},";
             }
             else
             {
                 sCombinedString += item.ToString() + ", ";
             }
         }
         Debug(sCombinedString);
     }
     else
     {
         Debug(inputobject);
     }
 }
示例#8
0
        public void RefreshConfig()
        {
            configdoc = XmlHelper.OpenDom(sFilePath);
            Diag.Debug("reading config.xml ...");

            XmlElement systemnode = (XmlElement)configdoc.DocumentElement.SelectSingleNode("config");

            iDebugLevel = Convert.ToInt32(systemnode.GetAttribute("debuglevel"));
            Diag.Debug("DebugLevel " + iDebugLevel.ToString());

            clientconfig = (XmlElement)configdoc.DocumentElement.SelectSingleNode("client");

            XmlElement mapconfig = clientconfig.SelectSingleNode("map") as XmlElement;

            iMapDefaultWidth  = Convert.ToInt32(mapconfig.GetAttribute("defaultwidth"));
            iMapDefaultHeight = Convert.ToInt32(mapconfig.GetAttribute("defaultheight"));

            XmlElement heightmapconfig = clientconfig.SelectSingleNode("heightmap") as XmlElement;

            defaultHeightMapFilename = heightmapconfig.GetAttribute("defaultfilename");
            minheight = Convert.ToInt32(heightmapconfig.GetAttribute("minheight"));
            maxheight = Convert.ToInt32(heightmapconfig.GetAttribute("maxheight"));

            XmlElement heighteditingconfig = clientconfig.SelectSingleNode("heightediting") as XmlElement;

            HeightEditingDefaultBrushSize = Convert.ToInt32(heighteditingconfig.GetAttribute("defaultbrushsize"));
            HeightEditingSpeed            = Convert.ToDouble(heighteditingconfig.GetAttribute("speed"));

            XmlElement slopemapconfig = clientconfig.SelectSingleNode("slopemap") as XmlElement;

            defaultSlopeMapFilename = slopemapconfig.GetAttribute("defaultfilename");
            SlopemapExportMaxSlope  = Convert.ToDouble(slopemapconfig.GetAttribute("exportmaxslope"));
            foreach (XmlElement movementareanode in slopemapconfig.SelectNodes("movementareas/movementarea"))
            {
                double maxslope    = Convert.ToDouble(movementareanode.GetAttribute("maxslope"));
                string colorstring = movementareanode.GetAttribute("color");
                Color  color       = new Color(1, 1, 1);
                if (colorstring == "red")
                {
                    color = new Color(1, 0, 0);
                }
                else if (colorstring == "green")
                {
                    color = new Color(0, 1, 0);
                }
                else if (colorstring == "blue")
                {
                    color = new Color(0, 0, 1);
                }
                movementareas.Add(new MovementAreaConfig(maxslope, color));
            }

            XmlElement movementconfig = clientconfig.SelectSingleNode("movement") as XmlElement;

            cameratranslatespeed = Convert.ToDouble(movementconfig.GetAttribute("translatespeed"));
            camerarotatespeed    = Convert.ToDouble(movementconfig.GetAttribute("rotatespeed"));

            foreach (XmlElement mappingnode in clientconfig.SelectNodes("keymappings/key"))
            {
                string        sCommand    = mappingnode.GetAttribute("command");
                string        sKeyCodes   = mappingnode.GetAttribute("keycode");
                string[]      KeyCodes    = sKeyCodes.Split("-".ToCharArray());
                List <string> keycodelist = new List <string>(KeyCodes);
                CommandCombos.Add(new CommandCombo(sCommand, keycodelist));
            }
            foreach (XmlElement mousemovenode in clientconfig.SelectNodes("mousemoveconfigs/mousemove"))
            {
                string name       = mousemovenode.GetAttribute("name");
                string vertical   = mousemovenode.GetAttribute("vertical");
                string horizontal = mousemovenode.GetAttribute("horizontal");
                string zoom       = mousemovenode.GetAttribute("zoom");
                if (!MouseMoveConfigsByName.ContainsKey(name))
                {
                    MouseMoveConfigsByName.Add(name, new MouseMoveConfig(vertical, horizontal, zoom));
                }
            }

            Diag.Debug("... config.xml read");
        }