public TileGridToVolumeMapping(Section section, string name, TileGridMapping ToWarp, TriangulationTransform Transform)
            : base(ToWarp, section, name)
        {
            this.VolumeTransform = Transform;

            /*
            //Create a single grid transform for all tiles
            GridToVolumeTransform = new GridTransform();

            GridInfo gridInfo = LevelToGridInfo[this.MinDownsample];

            MappingGridVector2[] mappingPoints = new MappingGridVector2[(gridInfo.GridYDim+1) * (gridInfo.GridXDim+1)];
            int[] TriangleIndicies = new int[gridInfo.GridYDim * gridInfo.GridXDim * 6];

            int iPoint = 0;
            int iTriangle = 0;
            for(int iX = 0; iX <= gridInfo.GridXDim; iX++)
            {
                for(int iY = 0; iY <= gridInfo.GridYDim; iY++, iPoint++)
                {
                    GridVector2 controlPoint = new GridVector2(iX * this.TileSizeX,
                                                               iY * this.TileSizeY);
                    GridVector2 mappedPoint = controlPoint; //This will get warped later when we add to volume transform
                    MappingGridVector2 PointPair = new MappingGridVector2(controlPoint, mappedPoint);

                    mappingPoints[iPoint] = PointPair;

                    if(iY < gridInfo.GridYDim &&
                       iX < gridInfo.GridXDim)
                    {
                        TriangleIndicies[iTriangle++] = iPoint;
                        TriangleIndicies[iTriangle++] = iPoint + 1;
                        TriangleIndicies[iTriangle++] = iPoint + gridInfo.GridYDim + 1;

                        TriangleIndicies[iTriangle++] = iPoint + 1;
                        TriangleIndicies[iTriangle++] = iPoint + gridInfo.GridYDim + 1;
                        TriangleIndicies[iTriangle++] = iPoint + gridInfo.GridYDim + 2;
                    }
                }
            }

            //Todo: If we add the mapping points from the volume transform here they can be included in the output verticies

            GridToVolumeTransform.SetPointsAndTriangles(mappingPoints, TriangleIndicies);

            //            GridToVolumeTransform.Add(VolumeTransform);
             */
        }
Beispiel #2
0
        public static TileGridMapping CreateFromTilesetElement(XElement TilesetNode, Section section)
        {
            string Name = IO.GetAttributeCaseInsensitive(TilesetNode, "name").Value;
            string mosaicTransformPath = IO.GetAttributeCaseInsensitive(TilesetNode, "path").Value;
            int TileSizeX = System.Convert.ToInt32(IO.GetAttributeCaseInsensitive(TilesetNode, "TileXDim").Value);
            int TileSizeY = System.Convert.ToInt32(IO.GetAttributeCaseInsensitive(TilesetNode, "TileYDim").Value);
            string TilePrefix = IO.GetAttributeCaseInsensitive(TilesetNode, "FilePrefix").Value;
            string TilePostfix = IO.GetAttributeCaseInsensitive(TilesetNode, "FilePostfix").Value;
            string TileGridPath = IO.GetAttributeCaseInsensitive(TilesetNode, "path").Value;
            string GridTileFormat = null;

            XAttribute GridTileFormatAttribute = TilesetNode.Attribute("CoordFormat");
            if(GridTileFormatAttribute != null)
            {
                GridTileFormat = TileGridMapping.GridTileFormatStringFromPythonString(GridTileFormatAttribute.Value.ToString());
            }

            TileGridMapping mapping = new TileGridMapping(section, Name, TilePrefix, TilePostfix,
                                                          TileSizeX, TileSizeY, TileGridPath, GridTileFormat);

            foreach (XNode node in TilesetNode.Nodes())
            {
                XElement elem = node as XElement;
                if (elem == null)
                    continue;

                //Fetch the name if we know it
                switch (elem.Name.LocalName)
                {
                    case "Level":
                        mapping.AddLevel(System.Convert.ToInt32(IO.GetAttributeCaseInsensitive(elem, "Downsample").Value),
                                       System.Convert.ToInt32(IO.GetAttributeCaseInsensitive(elem, "GridDimX").Value),
                                       System.Convert.ToInt32(IO.GetAttributeCaseInsensitive(elem, "GridDimY").Value),
                                       IO.GetAttributeCaseInsensitive(elem, "path").Value);
                        break;
                }

            }

            return mapping;
        }
Beispiel #3
0
        protected void AddTileset(TileGridMapping mapping)
        {
            WarpedTo.Add(mapping.Name, mapping);

            TilesetNames.Add(mapping.Name);
            VolumeTransformList.Add(mapping.Name);

            ChannelNames.Add(mapping.Name);
        }
Beispiel #4
0
 protected TileGridMapping(TileGridMapping ToCopy, Section section, string name)
     : base(ToCopy, section, name)
 {
 }