Esempio n. 1
0
        static public void loadWorld()
        {
            CollisionSystem collision = new CollisionSystemPersistentSAP();

            world = new World(collision);

            string mapName = Botv2.Utilities.GameHelper.getMapName();
            string mapPath = Path.GetDirectoryName(Bot.process.Modules[0].FileName) + "/csgo/maps/" + mapName;

            FileStream stream = File.OpenRead(mapPath);
            BSP        map    = new BSP(stream);

            List <Vector3>  vertices = map.getVertices();
            List <ushort[]> edges    = map.getEdges();
            List <Face>     faces    = map.getOriginalFaces();

            map.getFaces();
            int[] surfedges   = map.getSurfedges();
            int[] textureData = map.getTextureInfo();

            stream.Close();

            for (int i = 0; i < faces.Count; i++)
            {
                Face                       face      = faces[i];
                List <JVector>             jVertices = new List <JVector>();
                List <VertexPositionColor> temp      = new List <VertexPositionColor>();

                for (int b = 0; b <= face.numEdges; b++)
                {
                    if (surfedges[face.firstEdge + b] < 0)
                    {
                        temp.Add(new VertexPositionColor(vertices[(int)edges[Math.Abs(surfedges[face.firstEdge + b])][0]], Color.LightGray));
                        temp.Add(new VertexPositionColor(vertices[(int)edges[Math.Abs(surfedges[face.firstEdge + b])][1]], Color.LightGray));
                        continue;
                    }

                    int edgeIndex  = Math.Abs(surfedges[face.firstEdge + b]);
                    int verticeOne = edges[edgeIndex][1];
                    int verticeTwo = edges[edgeIndex][0];

                    temp.Add(new VertexPositionColor(vertices[verticeOne], Color.LightGray));
                    temp.Add(new VertexPositionColor(vertices[verticeTwo], Color.LightGray));
                }

                foreach (VertexPositionColor v in temp)
                {
                    jVertices.Add(new JVector(v.Position.X, v.Position.Y, v.Position.Z));
                }
                RigidBody rigBody = new RigidBody(new ConvexHullShape(jVertices));

                world.AddBody(rigBody);
            }
        }
Esempio n. 2
0
        public override void Load()
        {
            mapName = Botv2.Utilities.GameHelper.getMapName();
            mapPath = Path.GetDirectoryName(Bot.process.Modules[0].FileName) + "/csgo/maps/" + mapName;

            FileStream stream = File.OpenRead(mapPath);
            BSP        map    = new BSP(stream);

            List <Vector3>  vertices = map.getVertices();
            List <ushort[]> edges    = map.getEdges();
            List <Face>     faces    = map.getOriginalFaces();

            map.getFaces();
            int[] surfedges   = map.getSurfedges();
            int[] textureData = map.getTextureInfo();

            stream.Close();

            this.EdgesEffect                    = new BasicEffect(this.GraphicsDevice);
            this.EdgesEffect.World              = Matrix.Identity;
            this.EdgesEffect.TextureEnabled     = false;
            this.EdgesEffect.VertexColorEnabled = true;

            this.Edges = new VertexPositionColor[edges.Count * 2];

            for (int i = 0; i < edges.Count; i++)
            {
                //if (edges[i][0] > vertices.Count - 1 || edges[i][1] > vertices.Count - 1) continue;

                Edges[i * 2]       = new VertexPositionColor(vertices[edges[i][0]], Color.Black);
                Edges[(i * 2) + 1] = new VertexPositionColor(vertices[edges[i][1]], Color.Black);
            }

            Faces = new List <VertexPositionColor[]>();

            for (int i = 0; i < faces.Count; i++)
            {
                Face face = faces[i];

                //if (faces[i].texinfo > textureData.Length) continue;

                List <VertexPositionColor> temp = new List <VertexPositionColor>();

                for (int b = 0; b <= face.numEdges; b++)
                {
                    if (surfedges[face.firstEdge + b] < 0)
                    {
                        temp.Add(new VertexPositionColor(vertices[(int)edges[Math.Abs(surfedges[face.firstEdge + b])][0]], Color.LightGray));
                        temp.Add(new VertexPositionColor(vertices[(int)edges[Math.Abs(surfedges[face.firstEdge + b])][1]], Color.LightGray));
                        continue;
                    }

                    int edgeIndex  = Math.Abs(surfedges[face.firstEdge + b]);
                    int verticeOne = edges[edgeIndex][1];
                    int verticeTwo = edges[edgeIndex][0];

                    temp.Add(new VertexPositionColor(vertices[verticeOne], Color.LightGray));
                    temp.Add(new VertexPositionColor(vertices[verticeTwo], Color.LightGray));
                }

                Faces.Add(temp.ToArray());
            }
        }