public List <IData3DCollection> AddMapImages(BaseUtils.Map2d [] list) { if (list.Length > 0) { var datasetMapImg = Data3DCollection <TexturedQuadData> .Create("mapimage", Color.White, 1.0f); for (int i = 0; i < list.Length; i++) { BaseUtils.Map2d map = list[i]; if (_cachedTextures.ContainsKey(map.FileName)) { datasetMapImg.Add(_cachedTextures[map.FileName]); } else { Bitmap bmp = map.Image as Bitmap; // either a stored one, or loaded Vector3 centre = new Vector3((map.TopLeft.X + map.BottomRight.X) / 2, 0, (map.TopRight.Y + map.BottomLeft.Y) / 2); float width = map.TopRight.X - map.BottomLeft.X; float height = map.TopLeft.Y - map.BottomRight.Y; // its rectangular.. so does not really matter which left/right/top/bot you use var texture = TexturedQuadData.FromBitmap(bmp, centre, TexturedQuadData.NoRotation, width, height); _cachedTextures[map.FileName] = texture; datasetMapImg.Add(texture); } } _datasets.Add(datasetMapImg); } return(_datasets); }
public List <IData3DSet> AddMapImages(BaseUtils.Map2d [] list) { if (list.Length > 0) { var datasetMapImg = Data3DSetClass <TexturedQuadData> .Create("mapimage", Color.White, 1.0f); for (int i = 0; i < list.Length; i++) { BaseUtils.Map2d img = list[i]; if (_cachedTextures.ContainsKey(img.FileName)) { datasetMapImg.Add(_cachedTextures[img.FileName]); } else { Bitmap bmp = (Bitmap)Bitmap.FromFile(img.FilePath); Vector3 centre = new Vector3((img.TopLeft.X + img.BottomRight.X) / 2, 0, (img.TopRight.Y + img.BottomLeft.Y) / 2); float width = img.TopRight.X - img.BottomLeft.X; float height = img.TopLeft.Y - img.BottomRight.Y; // its rectangular.. so does not really matter which left/right/top/bot you use var texture = TexturedQuadData.FromBitmap(bmp, centre, TexturedQuadData.NoRotation, width, height); _cachedTextures[img.FileName] = texture; datasetMapImg.Add(texture); } } _datasets.Add(datasetMapImg); } return(_datasets); }