public void TestPatternSphericalMapping3D() { (double u, double v)uv; uv = TextureMap.SphericalMap(new Point(0, 0, -1)); Assert.AreEqual(uv, (0.0, 0.5)); uv = TextureMap.SphericalMap(new Point(1, 0, 0)); Assert.AreEqual(uv, (0.25, 0.5)); uv = TextureMap.SphericalMap(new Point(0, 0, 1)); Assert.AreEqual(uv, (0.5, 0.5)); uv = TextureMap.SphericalMap(new Point(-1, 0, 0)); Assert.AreEqual(uv, (0.75, 0.5)); uv = TextureMap.SphericalMap(new Point(0, 1, 0)); Assert.AreEqual(uv, (0.5, 1.0)); uv = TextureMap.SphericalMap(new Point(0, -1, 0)); Assert.AreEqual(uv, (0.5, 0.0)); uv = TextureMap.SphericalMap(new Point(MathHelper.SQRT2 / 2.0, MathHelper.SQRT2 / 2.0, 0.0)); Assert.AreEqual(uv, (0.25, 0.75)); }
public void TestPatternPlanarMapping3D() { (double u, double v)uv; uv = TextureMap.PlanarMap(new Point(0.25, 0, 0.5)); Assert.AreEqual(uv, (0.25, 0.5)); uv = TextureMap.PlanarMap(new Point(0.25, 0, -0.25)); Assert.AreEqual(uv, (0.25, 0.75)); uv = TextureMap.PlanarMap(new Point(0.25, 0.5, -0.25)); Assert.AreEqual(uv, (0.25, 0.75)); uv = TextureMap.PlanarMap(new Point(1.25, 0, 0.5)); Assert.AreEqual(uv, (0.25, 0.5)); uv = TextureMap.PlanarMap(new Point(0.25, 0, -1.75)); Assert.AreEqual(uv, (0.25, 0.25)); uv = TextureMap.PlanarMap(new Point(1, 0, -1)); Assert.AreEqual(uv, (0.0, 0.0)); uv = TextureMap.PlanarMap(new Point(0, 0, 0)); Assert.AreEqual(uv, (0.0, 0.0)); }
public void LoadMapProperties() { MapName = MapName; ChosenTileSight = ChosenTileSight; ChosenCharSight = ChosenCharSight; NoRescue = NoRescue; NoSwitch = NoSwitch; ChosenElement = ChosenElement; ChosenScroll = ChosenScroll; BG.LoadFromSource(ZoneManager.Instance.CurrentMap.Background); BlankBG.LoadFromSource(ZoneManager.Instance.CurrentMap.BlankBG); TextureMap.LoadFromDict(ZoneManager.Instance.CurrentMap.TextureMap); bool foundSong = false; for (int ii = 0; ii < Music.Count; ii++) { string song = Music[ii]; if (song == ZoneManager.Instance.CurrentMap.Music) { ChosenMusic = ii; foundSong = true; break; } } if (!foundSong) { ChosenMusic = -1; } }
public override void Draw(GameTime gameTime) { TextureMap current = null; switch (State) { case ButtonState.Pressed: current = textureMapPressed; break; case ButtonState.Hover: current = textureMapHover; break; } if (current == null) { current = textureMapNormal; } RenderTarget.DrawBitmap( current.Bitmap, GetRectangle(), 1.0f, BitmapInterpolationMode.Linear, current.SourceRectangle ); }
public static void DumpSpriteCollectionMetadata(tk2dSpriteCollectionData sprites) { string path = "DUMPsprites/" + sprites.spriteCollectionName; string diskPath = Path.Combine(ResourcesDirectory, path.Replace('/', Path.DirectorySeparatorChar).Replace('\\', Path.DirectorySeparatorChar) + ".json"); if (File.Exists(diskPath)) { return; } Directory.GetParent(diskPath).Create(); JSONHelper.WriteJSON(AssetSpriteData.FromTK2D(sprites), diskPath); for (int i = 0; i < sprites.spriteDefinitions.Length; i++) { tk2dSpriteDefinition frame = sprites.spriteDefinitions[i]; Texture2D texOrig = (Texture2D)frame.material.mainTexture; if (!frame.Valid || (frame.materialInst != null && TextureMap.ContainsValue((Texture2D)frame.materialInst.mainTexture))) { continue; } string pathFull = path + "/" + frame.name; diskPath = Path.Combine(ResourcesDirectory, pathFull.Replace('/', Path.DirectorySeparatorChar).Replace('\\', Path.DirectorySeparatorChar) + ".json"); if (!File.Exists(diskPath)) { Directory.GetParent(diskPath).Create(); JSONHelper.WriteJSON(AssetSpriteData.FromTK2D(sprites, frame, true), diskPath); } } }
public void TextureMapPattern_ShouldMapToSphereUsingSphereMap(Point point, Color expected) { var checkers = new UvCheckers(16, 8, Color.Black, Color.White); var pattern = new TextureMap(checkers, TextureMapper.SphericalMap); Assert.Equal(expected, pattern.PatternAt(point)); }
private void WriteTextureMap(uint version, TextureMap map) { WriteStringWithHash(version, map.Name); WriteInt(map.Field44); WriteByte(map.Field48); WriteByte(map.Field49); WriteByte(map.Field4A); WriteByte(map.Field4B); WriteFloat(map.Field4C); WriteFloat(map.Field50); WriteFloat(map.Field54); WriteFloat(map.Field58); WriteFloat(map.Field5C); WriteFloat(map.Field60); WriteFloat(map.Field64); WriteFloat(map.Field68); WriteFloat(map.Field6C); WriteFloat(map.Field70); WriteFloat(map.Field74); WriteFloat(map.Field78); WriteFloat(map.Field7C); WriteFloat(map.Field80); WriteFloat(map.Field84); WriteFloat(map.Field88); }
public override void Initialize() { Contract.Requires <InvalidOperationException>(DiffuseMapKey != null); DiffuseMap = Content.Load <Texture>(DiffuseMapKey); if (!DiffuseMap.IsInited) { DiffuseMap.Initialize(); } TextureMap.Add(TextureReference.Diffuse.ToString(), DiffuseMap); }
public override void Render() { TextureMap map = MapEditor.Instance.FGAutotiler.GenerateFakeTileMap(Room, Position, Width / 8, Height / 8, (short)GetChar("tiletype", '3'));; for (int i = 0; i < map.Textures.Length; i++) { map.Textures[i].Position += Position; } map.Draw(); }
public override void Initialize() { Contract.Requires <InvalidOperationException>(NormalMapKey != null); base.Initialize(); NormalMap = Content.Load <Texture>(NormalMapKey); if (!NormalMap.IsInited) { NormalMap.Initialize(); } TextureMap.Add(TextureReference.NormalMap.ToString(), NormalMap); }
public GrassTile(TextureMap <TileType> tileTextures, TextureMap <DecorationType> decorTextures, Decorations decorations, SpriteBatch spriteBatch, Random rand) : base(tileTextures, decorTextures, decorations, spriteBatch, rand) { TileType = TileType.Grass; AnimationInterval = TimeSpan.FromMilliseconds(rand.Next(1000, 3000)); int variation = rand.Next(-COLOR_VARIANCE, COLOR_VARIANCE); SpriteColor = new Color(28 + variation, 42 + variation, 9 + variation); SetupDecoration(); }
public DirtTile(TextureMap <TileType> tileTextures, TextureMap <DecorationType> decorTextures, Decorations decorations, SpriteBatch spriteBatch, Random rand) : base(tileTextures, decorTextures, decorations, spriteBatch, rand) { TileType = TileType.Dirt; int variation = rand.Next(-COLOR_VARIANCE, COLOR_VARIANCE); SpriteColor = new Color(40 + variation, 31 + variation, 25 + variation); SetupDecoration(); }
static void Main(string[] args) { Console.WriteLine("Generating a texture mapping scene!"); var sphere = new Sphere(); sphere.Transform = Matrix.Translation(-1.5, 1, 0); var uvmap = new TextureMap(new CheckersPattern(20, 10, Color.White, new Color(0, 0.5, 0)), Mapping.Spherical); sphere.Material.Pattern = uvmap; sphere.Material.Ambient = 0.1; sphere.Material.Specular = 0.4; sphere.Material.Shininess = 10; sphere.Material.Diffuse = 0.6; var plane = new Plane(); uvmap = new TextureMap(new UVAlignCheck(Color.White, Color.Red, Color.Yellow, Color.Green, Color.Cyan), Mapping.Planar); plane.Material.Pattern = uvmap; plane.Material.Ambient = 0.1; plane.Material.Diffuse = 0.8; var cylinder = new Cylinder(); cylinder.Minimum = 0.0; cylinder.Maximum = 1.0; cylinder.Transform = Matrix.Translation(1.5, 0, 0); uvmap = new TextureMap(new CheckersPattern(16, 8, Color.White, new Color(0.5, 0, 0)), Mapping.Cylindrical); cylinder.Material.Pattern = uvmap; cylinder.Material.Ambient = 0.1; cylinder.Material.Specular = 0.6; cylinder.Material.Shininess = 15; cylinder.Material.Diffuse = 0.8; var world = new World(); world.Lights.Add(new PointLight(new Point(-10, 10, -10), Color.White)); world.Objects.Add(sphere); world.Objects.Add(plane); world.Objects.Add(cylinder); var camera = new Camera(400, 400, 0.5); camera.Transform = Matrix.ViewTransform(new Point(1, 2, -10), Point.Zero, Vector.VectorY); var c = camera.Render(world); System.IO.File.WriteAllText("uvmapping.ppm", c.GetPPM()); Console.WriteLine("Done!"); }
public override void CacheImage(Image <Rgb, byte> i) { if (CachedImage != null && i.Equals(CachedImage)) //skip if the image is the same. { return; } DisplayedImage = i; CachedImage = DisplayedImage.Copy(); // cache texture representation _map = new TextureMap(i, NumberBins, TextureScale); }
protected void SetTextureMap(TextureMap textureMap) { if (textureMap.SourceRectangle.HasValue) { Bitmap = textureMap.Bitmap; SourceRectangle = textureMap.SourceRectangle; Size = new Size2((int)SourceRectangle.Value.Width, (int)SourceRectangle.Value.Height); } else { SetBitmap(textureMap.Bitmap); } }