Example #1
0
        /// <summary>
        /// The get portals.
        /// </summary>
        /// <param name="meta">The meta.</param>
        /// <returns></returns>
        /// <remarks></remarks>
        public static Portal[] GetPortals(ref Meta meta)
        {
            meta.Map.OpenMap(MapTypes.Internal);
            meta.Map.BR.BaseStream.Position = meta.offset + 108;
            int tempc = meta.Map.BR.ReadInt32();
            int tempr = meta.Map.BR.ReadInt32() - meta.magic;
            Portal[] temp = new Portal[tempc];
            for (int x = 0; x < tempc; x++)
            {
                meta.Map.BR.BaseStream.Position = tempr + (x * 36);
                temp[x] = new Portal(ref meta.Map.BR, meta.magic);
            }

            meta.Map.CloseMap();
            return temp;
        }
Example #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="PortalContainer"/> class.
        /// </summary>
        /// <param name="portals">The portals.</param>
        /// <param name="device">The device.</param>
        /// <remarks></remarks>
        public PortalContainer(Portal[] portals, ref Device device)
        {
            Default = new Material();
            Default.Diffuse = Color.White;
            Default.Ambient = Color.White;
            RedTransparent = new Material();
            RedTransparent.Diffuse = Color.FromArgb(50, 255, 0, 0);
            RedTransparent.Ambient = Color.FromArgb(50, 255, 0, 0);

            Red = new Material();
            Red.Diffuse = Color.Red;
            Red.Ambient = Color.Red;
            Black = new Material();
            Black.Diffuse = Color.Black;
            Black.Ambient = Color.Black;
            vb = new VertexBuffer[portals.Length];
            verticeCount = new int[portals.Length];
            spheres = new Mesh[portals.Length];
            mat = new Matrix[portals.Length];
            for (int x = 0; x < portals.Length; x++)
            {
                spheres[x] = Mesh.Sphere(device, portals[x].BoundingRadius, 10, 10);
                mat[x] = Matrix.Translation(portals[x].X, portals[x].Y, portals[x].Z);

                vb[x] = new VertexBuffer(
                    typeof(CustomVertex.PositionColored),
                    portals[x].Vertices.Count,
                    device,
                    Usage.WriteOnly,
                    CustomVertex.PositionColored.Format,
                    Pool.Managed);
                CustomVertex.PositionColored[] verts = (CustomVertex.PositionColored[])vb[x].Lock(0, 0);

                // Lock the buffer (which will return our structs)
                verticeCount[x] = portals[x].Vertices.Count;
                for (int i = 0; i < portals[x].Vertices.Count; i++)
                {
                    verts[i].Position = new Vector3(
                        portals[x].Vertices[i].X, portals[x].Vertices[i].Y, portals[x].Vertices[i].Z);
                }

                vb[x].Unlock();
            }
        }