Beispiel #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="coll"/> class.
        /// </summary>
        /// <param name="meta">The meta.</param>
        /// <remarks></remarks>
        public coll(ref Meta meta)
        {
            BinaryReader BR = new BinaryReader(meta.MS);
            BR.BaseStream.Position = 28;
            int tempc = BR.ReadInt32();
            int tempr = BR.ReadInt32() - meta.magic - meta.offset;
            for (int xxx = 0; xxx < tempc; xxx++)
            {
                BR.BaseStream.Position = tempr + (xxx * 12);
                string index1string = meta.Map.Strings.Name[BR.ReadUInt16()];
                BR.BaseStream.Position = tempr + (xxx * 12) + 4;
                int tempcxx = BR.ReadInt32();
                int temprxx = BR.ReadInt32() - meta.magic - meta.offset;
                for (int xx = 0; xx < tempcxx; xx++)
                {
                    BR.BaseStream.Position = temprxx + (xx * 20);
                    string index2string = meta.Map.Strings.Name[BR.ReadUInt16()];
                    BR.BaseStream.Position = temprxx + (xx * 20) + 4;
                    int tempcx = BR.ReadInt32();
                    int temprx = BR.ReadInt32() - meta.magic - meta.offset;

                    // Meshes = new CollisionMesh[tempc];
                    for (int x = 0; x < tempcx; x++)
                    {
                        CollisionMesh cm = new CollisionMesh();
                        cm.index1 = xxx;
                        cm.index1string = index1string;
                        cm.index2 = xx;
                        cm.index2string = index2string;
                        if (ConditionStrings.IndexOf(cm.index2string) == -1)
                        {
                            ConditionStrings.Add(cm.index2string);
                        }

                        cm.index3 = x;

                        BR.BaseStream.Position = temprx + (x * 68) + 52;
                        int tempc2 = BR.ReadInt32();
                        int tempr2 = BR.ReadInt32() - meta.magic - meta.offset;

                        cm.Faces = new ushort[tempc2 * 3];
                        for (int y = 0; y < tempc2; y++)
                        {
                            BR.BaseStream.Position = tempr2 + (y * 12);
                            cm.Faces[y * 3] = BR.ReadUInt16();
                            cm.Faces[(y * 3) + 1] = BR.ReadUInt16();
                            cm.Faces[(y * 3) + 2] = cm.Faces[(y * 3) + 1]; // BR.ReadUInt16();
                        }

                        // ***** Test Code ****//
                        BR.BaseStream.Position = temprx + (x * 68) + 12;
                        tempc2 = BR.ReadInt32();
                        tempr2 = BR.ReadInt32() - meta.magic - meta.offset;
                        cm.Normals = new Vector4[tempc2];
                        for (int y = 0; y < tempc2; y++)
                        {
                            BR.BaseStream.Position = tempr2 + (y * 16) + 0;
                            cm.Normals[y].X = BR.ReadSingle();
                            cm.Normals[y].Y = BR.ReadSingle();
                            cm.Normals[y].Z = BR.ReadSingle();
                            cm.Normals[y].W = BR.ReadSingle();
                        }

                        BR.BaseStream.Position = temprx + (x * 68) + 44;
                        tempc2 = BR.ReadInt32();
                        tempr2 = BR.ReadInt32() - meta.magic - meta.offset;
                        cm.SurfaceData = new surfaceData[tempc2];
                        for (int y = 0; y < tempc2; y++)
                        {
                            BR.BaseStream.Position = tempr2 + (y * 8) + 0;
                            cm.SurfaceData[y] = new surfaceData();
                            cm.SurfaceData[y].Plane = BR.ReadInt16();
                        }

                        BR.BaseStream.Position = temprx + (x * 68) + 52;
                        tempc2 = BR.ReadInt32();
                        tempr2 = BR.ReadInt32() - meta.magic - meta.offset;

                        int[] startEdges = new int[tempc2];
                        int[] endEdges = new int[tempc2];
                        int[] forwardEdges = new int[tempc2];
                        int[] reverseEdges = new int[tempc2];
                        int[] face1 = new int[tempc2];
                        int[] face2 = new int[tempc2];
                        for (int y = 0; y < tempc2; y++)
                        {
                            BR.BaseStream.Position = tempr2 + (y * 12) + 0;
                            startEdges[y] = BR.ReadUInt16();
                            endEdges[y] = BR.ReadUInt16();

                            BR.BaseStream.Position = tempr2 + (y * 12) + 4;
                            forwardEdges[y] = BR.ReadUInt16();
                            reverseEdges[y] = BR.ReadUInt16();

                            BR.BaseStream.Position = tempr2 + (y * 12) + 8;
                            face1[y] = BR.ReadUInt16();
                            face2[y] = BR.ReadUInt16();
                        }

                        for (int y = 0; y < forwardEdges.Length; y++)
                        {
                            int cSurface = face1[y];
                            if (cm.SurfaceData[cSurface].Vertices == null)
                            {
                                cm.SurfaceData[cSurface].Vertices = new List<int>();
                                int edge = y;
                                int nextEdge = 0;
                                cm.SurfaceData[cSurface].Vertices.Add(startEdges[edge]);
                                do
                                {
                                    if (cSurface == face1[edge])
                                    {
                                        cm.SurfaceData[cSurface].Vertices.Add(endEdges[edge]);
                                        edge = forwardEdges[edge];
                                    }
                                    else if (cSurface == face2[edge])
                                    {
                                        cm.SurfaceData[cSurface].Vertices.Add(startEdges[edge]);
                                        edge = reverseEdges[edge];
                                    }

                                    if (cSurface == face1[edge])
                                    {
                                        nextEdge = endEdges[edge];
                                    }
                                    else if (cSurface == face2[edge])
                                    {
                                        nextEdge = startEdges[edge];
                                    }
                                }
                                while (!cm.SurfaceData[cSurface].Vertices.Contains(nextEdge));
                            }
                        }

                        for (int y = 0; y < reverseEdges.Length; y++)
                        {
                            int cSurface = face2[y];
                            if (cm.SurfaceData[cSurface].Vertices == null)
                            {
                                cm.SurfaceData[cSurface].Vertices = new List<int>();
                                int edge = y;
                                int nextEdge = 0;
                                cm.SurfaceData[cSurface].Vertices.Add(endEdges[edge]);
                                do
                                {
                                    if (cSurface == face1[edge])
                                    {
                                        cm.SurfaceData[cSurface].Vertices.Add(endEdges[edge]);
                                        edge = forwardEdges[edge];
                                    }
                                    else if (cSurface == face2[edge])
                                    {
                                        cm.SurfaceData[cSurface].Vertices.Add(startEdges[edge]);
                                        edge = reverseEdges[edge];
                                    }

                                    if (cSurface == face1[edge])
                                    {
                                        nextEdge = endEdges[edge];
                                    }
                                    else if (cSurface == face2[edge])
                                    {
                                        nextEdge = startEdges[edge];
                                    }
                                }
                                while (!cm.SurfaceData[cSurface].Vertices.Contains(nextEdge));
                            }
                        }

                        // ***** End Test Code ****//
                        BR.BaseStream.Position = temprx + (x * 68) + 60;
                        tempc2 = BR.ReadInt32();
                        tempr2 = BR.ReadInt32() - meta.magic - meta.offset;

                        // Meshes[x] = new CollisionMesh();
                        cm.Vertices = new Vector3[tempc2];
                        for (int y = 0; y < tempc2; y++)
                        {
                            BR.BaseStream.Position = tempr2 + (y * 16);
                            cm.Vertices[y].X = BR.ReadSingle();
                            cm.Vertices[y].Y = BR.ReadSingle();
                            cm.Vertices[y].Z = BR.ReadSingle();
                        }

                        Meshes.Add(cm);
                    }
                }
            }

            BR.BaseStream.Position = 36;
            tempc = BR.ReadInt32();
            tempr = BR.ReadInt32() - meta.magic - meta.offset;
            for (int xxx = 0; xxx < tempc; xxx++)
            {
                BR.BaseStream.Position = tempr + (20 * xxx);
                PathfindingSphere ps = new PathfindingSphere();
                ps.nodeindex = BR.ReadInt32();
                ps.position = new Vector3();
                ps.position.X = BR.ReadSingle();
                ps.position.Y = BR.ReadSingle();
                ps.position.Z = BR.ReadSingle();
                ps.radius = BR.ReadSingle();
                Spheres.Add(ps);
            }
        }
Beispiel #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="coll"/> class.
        /// </summary>
        /// <param name="meta">The meta.</param>
        /// <remarks></remarks>
        public coll(ref Meta meta)
        {
            BinaryReader BR = new BinaryReader(meta.MS);

            BR.BaseStream.Position = 28;
            int tempc = BR.ReadInt32();
            int tempr = BR.ReadInt32() - meta.magic - meta.offset;

            for (int xxx = 0; xxx < tempc; xxx++)
            {
                BR.BaseStream.Position = tempr + (xxx * 12);
                string index1string = meta.Map.Strings.Name[BR.ReadUInt16()];
                BR.BaseStream.Position = tempr + (xxx * 12) + 4;
                int tempcxx = BR.ReadInt32();
                int temprxx = BR.ReadInt32() - meta.magic - meta.offset;
                for (int xx = 0; xx < tempcxx; xx++)
                {
                    BR.BaseStream.Position = temprxx + (xx * 20);
                    string index2string = meta.Map.Strings.Name[BR.ReadUInt16()];
                    BR.BaseStream.Position = temprxx + (xx * 20) + 4;
                    int tempcx = BR.ReadInt32();
                    int temprx = BR.ReadInt32() - meta.magic - meta.offset;

                    // Meshes = new CollisionMesh[tempc];
                    for (int x = 0; x < tempcx; x++)
                    {
                        CollisionMesh cm = new CollisionMesh();
                        cm.index1       = xxx;
                        cm.index1string = index1string;
                        cm.index2       = xx;
                        cm.index2string = index2string;
                        if (ConditionStrings.IndexOf(cm.index2string) == -1)
                        {
                            ConditionStrings.Add(cm.index2string);
                        }

                        cm.index3 = x;

                        BR.BaseStream.Position = temprx + (x * 68) + 52;
                        int tempc2 = BR.ReadInt32();
                        int tempr2 = BR.ReadInt32() - meta.magic - meta.offset;

                        cm.Faces = new ushort[tempc2 * 3];
                        for (int y = 0; y < tempc2; y++)
                        {
                            BR.BaseStream.Position = tempr2 + (y * 12);
                            cm.Faces[y * 3]        = BR.ReadUInt16();
                            cm.Faces[(y * 3) + 1]  = BR.ReadUInt16();
                            cm.Faces[(y * 3) + 2]  = cm.Faces[(y * 3) + 1]; // BR.ReadUInt16();
                        }

                        // ***** Test Code ****//
                        BR.BaseStream.Position = temprx + (x * 68) + 12;
                        tempc2     = BR.ReadInt32();
                        tempr2     = BR.ReadInt32() - meta.magic - meta.offset;
                        cm.Normals = new Vector4[tempc2];
                        for (int y = 0; y < tempc2; y++)
                        {
                            BR.BaseStream.Position = tempr2 + (y * 16) + 0;
                            cm.Normals[y].X        = BR.ReadSingle();
                            cm.Normals[y].Y        = BR.ReadSingle();
                            cm.Normals[y].Z        = BR.ReadSingle();
                            cm.Normals[y].W        = BR.ReadSingle();
                        }

                        BR.BaseStream.Position = temprx + (x * 68) + 44;
                        tempc2         = BR.ReadInt32();
                        tempr2         = BR.ReadInt32() - meta.magic - meta.offset;
                        cm.SurfaceData = new surfaceData[tempc2];
                        for (int y = 0; y < tempc2; y++)
                        {
                            BR.BaseStream.Position  = tempr2 + (y * 8) + 0;
                            cm.SurfaceData[y]       = new surfaceData();
                            cm.SurfaceData[y].Plane = BR.ReadInt16();
                        }

                        BR.BaseStream.Position = temprx + (x * 68) + 52;
                        tempc2 = BR.ReadInt32();
                        tempr2 = BR.ReadInt32() - meta.magic - meta.offset;

                        int[] startEdges   = new int[tempc2];
                        int[] endEdges     = new int[tempc2];
                        int[] forwardEdges = new int[tempc2];
                        int[] reverseEdges = new int[tempc2];
                        int[] face1        = new int[tempc2];
                        int[] face2        = new int[tempc2];
                        for (int y = 0; y < tempc2; y++)
                        {
                            BR.BaseStream.Position = tempr2 + (y * 12) + 0;
                            startEdges[y]          = BR.ReadUInt16();
                            endEdges[y]            = BR.ReadUInt16();

                            BR.BaseStream.Position = tempr2 + (y * 12) + 4;
                            forwardEdges[y]        = BR.ReadUInt16();
                            reverseEdges[y]        = BR.ReadUInt16();

                            BR.BaseStream.Position = tempr2 + (y * 12) + 8;
                            face1[y] = BR.ReadUInt16();
                            face2[y] = BR.ReadUInt16();
                        }

                        for (int y = 0; y < forwardEdges.Length; y++)
                        {
                            int cSurface = face1[y];
                            if (cm.SurfaceData[cSurface].Vertices == null)
                            {
                                cm.SurfaceData[cSurface].Vertices = new List <int>();
                                int edge     = y;
                                int nextEdge = 0;
                                cm.SurfaceData[cSurface].Vertices.Add(startEdges[edge]);
                                do
                                {
                                    if (cSurface == face1[edge])
                                    {
                                        cm.SurfaceData[cSurface].Vertices.Add(endEdges[edge]);
                                        edge = forwardEdges[edge];
                                    }
                                    else if (cSurface == face2[edge])
                                    {
                                        cm.SurfaceData[cSurface].Vertices.Add(startEdges[edge]);
                                        edge = reverseEdges[edge];
                                    }

                                    if (cSurface == face1[edge])
                                    {
                                        nextEdge = endEdges[edge];
                                    }
                                    else if (cSurface == face2[edge])
                                    {
                                        nextEdge = startEdges[edge];
                                    }
                                }while (!cm.SurfaceData[cSurface].Vertices.Contains(nextEdge));
                            }
                        }

                        for (int y = 0; y < reverseEdges.Length; y++)
                        {
                            int cSurface = face2[y];
                            if (cm.SurfaceData[cSurface].Vertices == null)
                            {
                                cm.SurfaceData[cSurface].Vertices = new List <int>();
                                int edge     = y;
                                int nextEdge = 0;
                                cm.SurfaceData[cSurface].Vertices.Add(endEdges[edge]);
                                do
                                {
                                    if (cSurface == face1[edge])
                                    {
                                        cm.SurfaceData[cSurface].Vertices.Add(endEdges[edge]);
                                        edge = forwardEdges[edge];
                                    }
                                    else if (cSurface == face2[edge])
                                    {
                                        cm.SurfaceData[cSurface].Vertices.Add(startEdges[edge]);
                                        edge = reverseEdges[edge];
                                    }

                                    if (cSurface == face1[edge])
                                    {
                                        nextEdge = endEdges[edge];
                                    }
                                    else if (cSurface == face2[edge])
                                    {
                                        nextEdge = startEdges[edge];
                                    }
                                }while (!cm.SurfaceData[cSurface].Vertices.Contains(nextEdge));
                            }
                        }

                        // ***** End Test Code ****//
                        BR.BaseStream.Position = temprx + (x * 68) + 60;
                        tempc2 = BR.ReadInt32();
                        tempr2 = BR.ReadInt32() - meta.magic - meta.offset;

                        // Meshes[x] = new CollisionMesh();
                        cm.Vertices = new Vector3[tempc2];
                        for (int y = 0; y < tempc2; y++)
                        {
                            BR.BaseStream.Position = tempr2 + (y * 16);
                            cm.Vertices[y].X       = BR.ReadSingle();
                            cm.Vertices[y].Y       = BR.ReadSingle();
                            cm.Vertices[y].Z       = BR.ReadSingle();
                        }

                        Meshes.Add(cm);
                    }
                }
            }

            BR.BaseStream.Position = 36;
            tempc = BR.ReadInt32();
            tempr = BR.ReadInt32() - meta.magic - meta.offset;
            for (int xxx = 0; xxx < tempc; xxx++)
            {
                BR.BaseStream.Position = tempr + (20 * xxx);
                PathfindingSphere ps = new PathfindingSphere();
                ps.nodeindex  = BR.ReadInt32();
                ps.position   = new Vector3();
                ps.position.X = BR.ReadSingle();
                ps.position.Y = BR.ReadSingle();
                ps.position.Z = BR.ReadSingle();
                ps.radius     = BR.ReadSingle();
                Spheres.Add(ps);
            }
        }