private Texture BuildTexture(byte[] imageData, SlimDX.Direct3D9.Format imageFormat, int width, int height) { if (imageFormat == SlimDX.Direct3D9.Format.R8G8B8) { MemoryStream memoryStream; using (memoryStream = new MemoryStream()) { Tex.makeRGB8(imageData, width, height).Save((Stream)memoryStream, ImageFormat.Bmp); memoryStream.Write(imageData, 0, imageData.Length); memoryStream.Position = 0L; return(Texture.FromStream(_Device, (Stream)memoryStream, width, height, 0, Usage.SoftwareProcessing, SlimDX.Direct3D9.Format.A8B8G8R8, Pool.Default, Filter.None, Filter.None, 0)); } } else if (imageFormat == SlimDX.Direct3D9.Format.A8R8G8B8) { MemoryStream memoryStream; using (memoryStream = new MemoryStream()) { Tex.makeRGB(imageData, width, height).Save((Stream)memoryStream, ImageFormat.Bmp); memoryStream.Write(imageData, 0, imageData.Length); memoryStream.Position = 0L; return(Texture.FromStream(_Device, (Stream)memoryStream, width, height, 0, Usage.SoftwareProcessing, SlimDX.Direct3D9.Format.A8B8G8R8, Pool.Default, Filter.None, Filter.None, 0)); } } else { Texture texture = new Texture(_Device, width, height, 0, Usage.None, imageFormat, Pool.Managed); using (Stream data = (Stream)texture.LockRectangle(0, LockFlags.None).Data) { data.Write(imageData, 0, ((IEnumerable <byte>)imageData).Count <byte>()); texture.UnlockRectangle(0); } return(texture); } }
/////////////////////////////////////////// static async Task RequestHeight(BoundingBox regionBounds) { var request = new ElevationRequest() { Bounds = regionBounds, Row = 32, Col = 32, BingMapsKey = _ApiKey }; Response response = await request.Execute(); if (response.StatusCode != 200) { Log.Warn("Bing Maps API error:\n" + string.Join('\n', response.ErrorDetails)); return; } ElevationData data = response.ResourceSets[0].Resources[0] as ElevationData; Color[] heights = new Color[32 * 32]; for (int y = 0; y < 32; y++) { for (int x = 0; x < 32; x++) { // Mount everest is 8,848m tall heights[x + (31 - y) * 32] = Color.White * (data.Elevations[x + y * 32] / 9000.0f); } } mapHeight = new Tex(TexType.ImageNomips, TexFormat.Rgba128); mapHeight.SetColors(32, 32, heights); mapHeight.AddressMode = TexAddress.Clamp; Geo.BoundsToWorld(regionBounds, regionBounds, out mapHeightSize, out mapHeightCenter); terrain.SetHeightData(mapHeight, mapHeightSize * worldScale, mapHeightCenter * worldScale); }
/// <summary> /// This is called when the game should draw itself. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> protected override void Draw(GameTime gameTime) { if (SaveQ.Count >= TexQ.Count && SaveQ.Count > 0) { (string path, string clean, Texture2D tex) = SaveQ.Dequeue(); Save(path, clean, tex); } if (SaveQ.Count < TexQ.Count && TexQ.Count > 0) { // TODO: Add your drawing code here Tex = TexQ.Dequeue(); if (Tex != null) { GraphicsDevice.Clear(Color.CornflowerBlue); spriteBatch.Begin(); float s = (float)graphics.PreferredBackBufferWidth / Tex.Width; float s2 = (float)graphics.PreferredBackBufferHeight / Tex.Height; spriteBatch.Draw(Tex, Vector2.Zero, null, Color.White, 0f, Vector2.Zero, new Vector2(s <= s2 ? s : s2), SpriteEffects.None, 0); spriteBatch.End(); Tex.Dispose(); Tex = null; } base.Draw(gameTime); //Thread.Sleep(250); } }
public async Task <Dictionary <string, string> > GetTexPaths() { if (SecondaryCategory == XivStrings.Maps) { var _tex = new Tex(XivCache.GameInfo.GameDirectory); var mapNamePaths = await _tex.GetMapAvailableTex(UiPath); return(mapNamePaths); } else if (SecondaryCategory == XivStrings.HUD) { //ui/uld/aozactionlearned.tex return(new Dictionary <string, string>() { { Name, "ui/uld/" + Name.ToLower() + ".tex" } }); } else { var block = ((IconNumber / 1000) * 1000).ToString().PadLeft(6, '0'); var icon = IconNumber.ToString().PadLeft(6, '0'); return(new Dictionary <string, string>() { { Name, "ui/icon/" + block + '/' + icon + ".tex" } }); } }
bool LoadTexture() { byte[] file = File.ReadAllBytes(Program.Root + "/floor.png"); Tex tex = Tex.FromMemory(file); return(tex != null); }
// =========================================================== // Methods // =========================================================== new void Start() { base.Start(); // moving deprecated fields to new one if (texturesBackground.Length == 0 && textureBackground != null) { Array.Resize(ref texturesBackground, 1); var tex = new Tex(); tex.texture = textureBackground; tex.color = textureBackgroundColor; texturesBackground[0] = tex; textureBackground = null; } if (texturesForeground.Length == 0 && textureForeground != null) { Array.Resize(ref texturesForeground, 1); var tex = new Tex(); tex.texture = textureForeground; tex.color = textureForegroundColor; texturesForeground[0] = tex; textureForeground = null; } }
public async Task SetMaterial(XivMtrl mtrl, StainingTemplateFile dyeFile) { _mtrl = mtrl; DyeTemplateFile = dyeFile; _viewport = _view.ColorsetRowViewport; _viewport.BackgroundColor = System.Windows.Media.Colors.Gray; _viewport.Background = Brushes.Gray; if (_NeedLights) { _NeedLights = false; } _viewport.Camera.UpDirection = new System.Windows.Media.Media3D.Vector3D(0, 1, 0); _viewport.Camera.LookDirection = new System.Windows.Media.Media3D.Vector3D(0, 0, -1); _viewport.Camera.Position = new System.Windows.Media.Media3D.Point3D(0, 0, 3); if (TileTextureNormal == null) { var _tex = new Tex(XivCache.GameInfo.GameDirectory); TileTextureNormal = await _tex.GetTexData("chara/common/texture/-tile_n.tex"); TileTextureDiffuse = await _tex.GetTexData("chara/common/texture/-tile_d.tex"); } }
protected override void Start() { base.Start(); if (version == 169) { Upgrade_169_171(); } // moving deprecated fields to new one if (texturesBackground.Length == 0 && textureBackground != null) { Array.Resize(ref texturesBackground, 1); var tex = new Tex(); tex.texture = textureBackground; tex.color = textureBackgroundColor; texturesBackground[0] = tex; textureBackground = null; } if (texturesForeground.Length == 0 && textureForeground != null) { Array.Resize(ref texturesForeground, 1); var tex = new Tex(); tex.texture = textureForeground; tex.color = textureForegroundColor; texturesForeground[0] = tex; textureForeground = null; } }
public Tex ReadFromStream(Stream stream) { using (var reader = new BinaryReader(stream, Encoding.UTF8, true)) { var tex = new Tex { Magic1 = reader.ReadNString(16) }; if (tex.Magic1 != "TEXV0005") { throw new UnknownTexHeaderMagicException(nameof(tex.Magic1), tex.Magic1); } tex.Magic2 = reader.ReadNString(16); if (tex.Magic2 != "TEXI0001") { throw new UnknownTexHeaderMagicException(nameof(tex.Magic2), tex.Magic2); } tex.Header = _texHeaderReader.ReadFromStream(stream); tex.MipmapsContainer = _texMipmapContainerReader.ReadFromStream(stream); _texMipmapContainerReader.ReadMipmapsFromStream(stream, tex); return(tex); } }
/// <summary> /// The event handler for the add custom texture button clicked /// </summary> private async void AddCustomTextureButton_Click(object sender, RoutedEventArgs e) { var selectedFile = TextureMapComboBox.SelectedItem as FileEntry; var openFileDialog = new OpenFileDialog { Filter = "Texture Files(*.DDS;*.BMP;*.PNG) |*.DDS;*.BMP;*.PNG" }; var result = openFileDialog.ShowDialog(); if (result != System.Windows.Forms.DialogResult.OK) { return; } ; var _tex = new Tex(XivCache.GameInfo.GameDirectory); try { var data = await _tex.MakeTexData(selectedFile.Path, openFileDialog.FileName); await AddFile(selectedFile, SelectedItem, data); } catch (Exception ex) { FlexibleMessageBox.Show( string.Format(UIMessages.TextureImportErrorMessage, ex.Message), UIMessages.TextureImportErrorTitle, MessageBoxButtons.OK, MessageBoxIcon.Error); return; } }
public ITex ReadFrom(BinaryReader reader) { if (reader == null) { throw new ArgumentNullException(nameof(reader)); } var tex = new Tex { Magic1 = reader.ReadNString(maxLength: 16) }; if (tex.Magic1 != "TEXV0005") { throw new UnknownMagicException(nameof(TexReader), nameof(tex.Magic1), tex.Magic1); } tex.Magic2 = reader.ReadNString(maxLength: 16); if (tex.Magic2 != "TEXI0001") { throw new UnknownMagicException(nameof(TexReader), nameof(tex.Magic2), tex.Magic2); } tex.Header = _texHeaderReader.ReadFrom(reader); tex.ImagesContainer = _texImageContainerReader.ReadFrom(reader, tex.Header.Format); if (tex.IsGif) { tex.FrameInfoContainer = _texFrameInfoContainerReader.ReadFrom(reader); } return(tex); }
int BuildTextures<T>(T[] textures, string prefix, int startDepth, ref List<MadSprite> sprites) { int counter = 0; foreach (var gTexture in textures) { Tex tex = gTexture as Tex; AtlasTex atlasTex = gTexture as AtlasTex; if ((tex != null && !tex.Valid) || (atlasTex != null && !atlasTex.Valid)) { continue; } string name = string.Format("_{0}{1:D2}", prefix, counter + 1); var sprite = CreateHidden<MadSprite>(name); sprite.guiDepth = startDepth + counter; if (tex != null) { sprite.texture = tex.texture; } else { sprite.inputType = MadSprite.InputType.TextureAtlas; sprite.textureAtlas = atlas; sprite.textureAtlasSpriteGUID = atlasTex.spriteGUID; } sprite.tint = tex != null ? tex.color : atlasTex.color;; sprites.Add(sprite); counter++; } return startDepth + counter; }
} // the rate for each state (how many ticks before switching a frame) #endregion public SpriteAnalyzer(Hero hero, State state) { Rate = (int)state / 10; //using the rate of each state declared in Global to decide how many ticks pass until the frame switches #region tex and color Tex = Global.cm.Load <Texture2D>(hero.ToString() + "/" + state.ToString()); //accessing the desired sprite Color[] c = new Color[Tex.Width]; //creating a new color array Tex.GetData <Color>(0, new Rectangle(0, Tex.Height - 1, Tex.Width, 1), c, 0, c.Length); //inserting the color from the texture into the color array #endregion #region black List <int> black = new List <int>(); //creating a new list for the locations of the black dots responsible for dividing the sprite for (int i = 0; i < c.Length; i++) //for every pixel in the bottom of the sprite { if (c[i] != c[1]) //if the dot is black { black.Add(i); //add the location of the dot into the list } } #endregion #region recs for (int i = 0; i < black.Count() - 2; i += 2) //for every second black dot in the array starting from the first one besides the last two -- we dont go over the last 2 because for every dot we have to access the two dots after it { Recs.Add(new Rectangle(black[i], 0, black[i + 2] - black[i], Tex.Height - 2)); //make a rectangle starting at the dot and ending two dots after it which marks the frame } #endregion #region orgs for (int i = 1; i < black.Count() - 1; i += 2) // for every second dot starting from the second dot { Orgs.Add(new Vector2(black[i] - black[i - 1], Tex.Height - 2)); // we add every second dot into the orgs array to mark it is and origin for the specific frame } #endregion makeTranBg(); //calling for a function to erase the picture background and make it transparent }
bool LoadTexture() { byte[] file = File.ReadAllBytes(SK.Settings.assetsFolder + "/floor.png"); Tex tex = Tex.FromMemory(file); return(tex != null); }
void LoadSkyImage(string file) { cubemap = Tex.FromCubemapEquirectangular(file, out SphericalHarmonics lighting); Renderer.SkyTex = cubemap; Renderer.SkyLight = lighting; }
internal static void Initialize() { Material = Material.Find(DefaultIds.material); MaterialEquirect = Material.Find(DefaultIds.materialEquirect); MaterialFont = Material.Find(DefaultIds.materialFont); MaterialHand = Material.Find(DefaultIds.materialHand); MaterialUI = Material.Find(DefaultIds.materialUI); Tex = Tex.Find(DefaultIds.tex); TexBlack = Tex.Find(DefaultIds.texBlack); TexGray = Tex.Find(DefaultIds.texGray); TexFlat = Tex.Find(DefaultIds.texFlat); TexRough = Tex.Find(DefaultIds.texRough); Cubemap = Tex.Find(DefaultIds.cubemap); MeshQuad = Mesh.Find(DefaultIds.meshQuad); MeshCube = Mesh.Find(DefaultIds.meshCube); MeshSphere = Mesh.Find(DefaultIds.meshSphere); Shader = Shader.Find(DefaultIds.shader); ShaderPbr = Shader.Find(DefaultIds.shaderPbr); ShaderUnlit = Shader.Find(DefaultIds.shaderUnlit); ShaderFont = Shader.Find(DefaultIds.shaderFont); ShaderEquirect = Shader.Find(DefaultIds.shaderEquirect); ShaderUI = Shader.Find(DefaultIds.shaderUI); SoundClick = Sound.Find(DefaultIds.soundClick); SoundUnclick = Sound.Find(DefaultIds.soundUnclick); }
public RiderVertex(Vector2 position, Vector2 uv, Tex unit, Color Color) { Position = position; tex_coord = uv; texture_unit = (float)unit; color = Utility.ColorToRGBA_LE(Color); }
/////////////////////////////////////////// static void Initialize() { // Art resources for the terrain widget pedestalModel = Model.FromFile("Pedestal.glb", Default.ShaderUI); compassModel = Model.FromFile("Compass.glb"); widgetModel = Model.FromFile("MoveWidget.glb"); terrain = new Terrain( chunkDetail: 64, chunkSize: 0.6f, chunkGrid: 2); terrain.clipRadius = 0.3f; // Add a floor if we're in VR, and hide the hands if we're in AR! if (SK.System.displayType == Display.Opaque) { floorMesh = Mesh.GeneratePlane(new Vec2(10, 10)); floorMat = Default.Material.Copy(); floorMat[MatParamName.DiffuseTex] = Tex.FromFile("floor.png"); floorMat[MatParamName.TexScale] = 8; } else { Default.MaterialHand[MatParamName.ColorTint] = Color.Black; //Input.HandVisible(Handed.Max, false); } // Load up an initial, default location LoadLocation(0); }
bool MakeTexture() { Tex r8 = new Tex(TexType.ImageNomips, TexFormat.R8); Tex r16 = new Tex(TexType.ImageNomips, TexFormat.R16); Tex r32 = new Tex(TexType.ImageNomips, TexFormat.R32); if (r8 == null || r16 == null || r32 == null) { return(false); } int s = 8; byte [] r8Data = new byte [s * s]; ushort[] r16Data = new ushort[s * s]; float [] r32Data = new float [s * s]; for (int i = 0; i < s * s; i++) { float y = (float)(i / s) / s; r8Data [i] = (byte)(y * byte.MaxValue); r16Data[i] = (ushort)(y * ushort.MaxValue); r32Data[i] = y; } r8.SetColors(s, s, r8Data); r16.SetColors(s, s, r16Data); r32.SetColors(s, s, r32Data); r8.AddressMode = TexAddress.Clamp; r16.AddressMode = TexAddress.Clamp; r32.AddressMode = TexAddress.Clamp; singleChannelTex[MatParamName.DiffuseTex] = r8; return(true); }
/// <summary> /// Retrieve texture paths. /// If both low and high res are false, low res is still returned. /// Maps only have a single resolution. /// </summary> /// <param name="addLowRes"></param> /// <param name="addHiRes"></param> /// <returns></returns> public async Task <Dictionary <string, string> > GetTexPaths(bool addLowRes = true, bool addHiRes = false) { var resPaths = new Dictionary <string, string>(); if (SecondaryCategory == XivStrings.Maps) { var _tex = new Tex(XivCache.GameInfo.GameDirectory); var mapNamePaths = await _tex.GetMapAvailableTex(UiPath); return(mapNamePaths); } else if (SecondaryCategory == XivStrings.HUD) { //ui/uld/aozactionlearned.tex HasHiRes = true; if (addHiRes && !addLowRes) { resPaths.Add(Name, "ui/uld/" + Name.ToLower() + HiResUiExt + ".tex"); } else if (addHiRes && addLowRes) { resPaths.Add(Name + "SD", "ui/uld/" + Name.ToLower() + ".tex"); resPaths.Add(Name + "HD", "ui/uld/" + Name.ToLower() + HiResUiExt + ".tex"); } else { resPaths.Add(Name, "ui/uld/" + Name.ToLower() + ".tex"); } } else if (SecondaryCategory == XivStrings.LoadingScreen) { resPaths.Add(Name, UiPath + '/' + Name + ".tex"); } else { HasHiRes = true; var block = ((IconNumber / 1000) * 1000).ToString().PadLeft(6, '0'); var icon = IconNumber.ToString().PadLeft(6, '0'); if (addHiRes && !addLowRes) { resPaths.Add(Name, "ui/icon/" + block + '/' + icon + HiResUiExt + ".tex"); } else if (addHiRes && addLowRes) { resPaths.Add(Name + "SD", "ui/icon/" + block + '/' + icon + ".tex"); resPaths.Add(Name + "HD", "ui/icon/" + block + '/' + icon + HiResUiExt + ".tex"); } else { resPaths.Add(Name, "ui/icon/" + block + '/' + icon + ".tex"); } } return(resPaths); }
public override void SetPixel(int x, int y, Col color) { if (Tex == null) { return; } Tex.SetPixel(x, y, color); }
public void ReadMipmapsFromStream(Stream stream, Tex tex) { for (var i = 0; i < tex.MipmapsContainer.MipmapCount; i++) { var mipmap = _texMipmapReader.ReadFromStream(stream, tex); tex.MipmapsContainer.Mipmaps.Add(mipmap); } }
public override void Apply() { if (Tex == null) { return; } Tex.Apply(); }
/// <summary>Gives this <see cref="Block"/>'s <see cref="Renderer"/> a <see cref="Material"/>.</summary> /// <param name="diffusePath"><c>ex. "Content\\Vanilla\\Blocks\\ArmorBlock\\diffuse.png"</c></param> /// <param name="toWho">0: only parent, 1: only children, 2: both, 3: nothing (use with <see cref="IPrefabEditor{T}"/> where T is <see cref="Material"/>)</param> /// <param name="targets">Does this <see cref="BlockAttribute"/> apply to just the preview, just the original, or both?</param> public Material(string diffusePath, bool diffusePoint, byte toWho = 2, int identifier = 0, AppliesTo targets = AppliesTo.Both) : base(identifier, targets) { Diffuse = new Tex { path = diffusePath, point = diffusePoint }; ToWho = toWho; }
public override Col GetPixel(int x, int y) { if (Tex != null) { return(Tex.GetPixel(x, y)); } return(Col.black); }
/////////////////////////////////////////// public static async Task RequestHeight(string apiKey, BoundingBox regionBounds, Action <Tex, Vec3, Vec2> OnReceivedHeight) { // Here's an elevation request! This doesn't provide an image, rather, // it gives us a grid of height values. It's limited to a maximum of // 1024 values per request, so we're only asking for a grid of 32x32 // elevations. // However! This request does work exactly within the bounds provided, // so we're getting what we expect from the results of this request. // Details about the request can be found here: // https://github.com/microsoft/BingMapsRESTToolkit/blob/master/Docs/API%20Reference.md#ElevationRequest ElevationRequest request = new ElevationRequest() { Bounds = regionBounds, Row = 32, Col = 32, BingMapsKey = apiKey }; Response response = await ServiceManager.GetResponseAsync(request); // StatusCode is a web response status code, where 200-299 means // success. Details here: // https://developer.mozilla.org/en-US/docs/Web/HTTP/Status if (response.StatusCode < 200 || response.StatusCode >= 300) { Log.Warn("Bing Maps API error:\n" + string.Join('\n', response.ErrorDetails)); return; } // Convert the elevation data we've received into a grayscale heightmap texture! ElevationData data = response.ResourceSets[0].Resources[0] as ElevationData; Color[] heights = new Color[32 * 32]; for (int y = 0; y < 32; y++) { for (int x = 0; x < 32; x++) { float height = data.Elevations[x + y * 32] / Geo.EarthTallest; // Height data is provided upside-down, so we're flipping it with // this index on the Y axis. heights[x + (31 - y) * 32] = Color.White * height; } } // Create a texture from the elevation data! We're storing it as // Rgba128 to preserve floating point precision in the height values. Tex texture = new Tex(TexType.ImageNomips, TexFormat.Rgba128); texture.SetColors(32, 32, heights); texture.AddressMode = TexAddress.Clamp; // Our bounds should be correct, but we still need it in StereoKit // units, so convert! Geo.BoundsToWorld(regionBounds, regionBounds, out Vec3 size, out Vec2 center); // Done! Pass the results back. OnReceivedHeight(texture, size, center); }
// GET: GymClassTypes public ActionResult Index(int memberId = 0) { Tex.VerboseLog("Home/Index", memberId.ToString()); try { MemberBookings gmb = new MemberBookings(); DateTime oneHourFromNow = DateTime.Now.AddHours(1); var allFutureClasses = db.GymClass.Where(cl => cl.ClassDateTime > DateTime.Now).OrderBy(bk => bk.ClassDateTime).ToList(); GymMember gm; if (memberId == 0) { gm = GetCurrentGymMember(); } else { gm = db.GymMembers.Find(memberId); } var allBookableClasses = new List <ClassDetail>(); foreach (GymClass cl in allFutureClasses) { var bookableClass = cl.ToViewModel(true); if (gm != null) { var memberBooking = db.MemberClassBookings.Where(bk => bk.GymClassId == cl.GymClassId && bk.GymMemberId == gm.GymMemberId).FirstOrDefault(); if (memberBooking != null) { bookableClass.MemberStatus = memberBooking.Waiting ? MemberClassStatus.BookedWaiting : MemberClassStatus.BookedClass; } else { int nNonWaitBookings = db.MemberClassBookings.Where(bk => bk.GymClassId == cl.GymClassId && !bk.Waiting).Count(); if (nNonWaitBookings < cl.MaxCapacity) { bookableClass.MemberStatus = MemberClassStatus.EligibleClass; } else { bookableClass.MemberStatus = (bookableClass.nBookings < cl.MaxCapacity + cl.MaxWaitList ? MemberClassStatus.EligibleWaiting : MemberClassStatus.None); } } } bookableClass.IsLessThanAnHourAway = bookableClass.ClassDateTime <= oneHourFromNow; allBookableClasses.Add(bookableClass); } gmb.GymClasses = allBookableClasses; gmb.CurrentMember = gm; gmb.AllMembers = db.GymMembers.OrderBy(m => m.LastName).ToList(); foreach (var memb in gmb.AllMembers) { memb.FullName = String.Format("{0} {1}", memb.FirstName, memb.LastName); } return(View(gmb)); } catch (Exception ex) { Tex.Dump(ex, "Home Index Excetpion"); throw; } }
/// <summary> /// The event handler for the add custom texture button clicked /// </summary> private async void AddCustomTextureButton_Click(object sender, RoutedEventArgs e) { var selectedItem = TextureMapComboBox.SelectedItem as ModComboBox; var mod = selectedItem.SelectedMod; byte[] modData; var includedMod = new IncludedMods { Name = $"{Path.GetFileNameWithoutExtension(mod.fullPath)} ({((Category)ModListTreeView.SelectedItem).Name})", FullPath = mod.fullPath }; var includedModsList = IncludedModsList.Items.Cast <IncludedMods>().ToList(); var tex = new Tex(_gameDirectory); var ddsDirectory = new DirectoryInfo(CustomTextureTextBox.Text); if (selectedItem.TexTypePath.Type == XivTexType.ColorSet) { var mtrl = new Mtrl(_gameDirectory, XivDataFiles.GetXivDataFile(mod.datFile), GetLanguage()); var xivMtrl = await mtrl.GetMtrlData(mod.data.modOffset, mod.fullPath, int.Parse(Settings.Default.DX_Version)); modData = tex.DDStoMtrlData(xivMtrl, ddsDirectory, ((Category)ModListTreeView.SelectedItem).Item, GetLanguage()); } else { var texData = await tex.GetTexData(selectedItem.TexTypePath); modData = await tex.DDStoTexData(texData, ((Category)ModListTreeView.SelectedItem).Item, ddsDirectory); } if (includedModsList.Any(item => item.Name.Equals(includedMod.Name))) { if (FlexibleMessageBox.Show( string.Format(UIMessages.ExistingOption, includedMod.Name), UIMessages.OverwriteTitle, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes) { _selectedModOption.Mods[mod.fullPath].ModDataBytes = modData; } } else { IncludedModsList.Items.Add(includedMod); _selectedModOption.Mods.Add(mod.fullPath, new ModData { Name = mod.name, Category = mod.category, FullPath = mod.fullPath, ModDataBytes = modData }); } }
public void UpdateTexture() { GameObject terrain = GameObject.Find("Terrain"); Tex tex = terrain.GetComponent <Terrain>().textures; material.SetTexture("_Map", tex.map); material.SetFloat("_Tilling", tex.tilling); material.SetFloat("_BlendRate", tex.blend); }
private void DrawTexture( Tex tex, DoubleRect rect, FloatRect uv, Vector2d origin, Vector2d rotationAnchor, float opacity, bool pretty = false ) { var angle = Angle.FromLine(origin, rotationAnchor); var t = Utility.RotateRect(rect, Vector2d.Zero, angle); var transform = new Vector2d[] { (t[0] + origin), // 0 tl (t[1] + origin), // 1 tr (t[2] + origin), // 2 br (t[3] + origin), // 3 bl }; var texrect = GameDrawingMatrix.ScreenCoords(transform); var color = Color.FromArgb((int)(255f * opacity), Color.White); Color[] colors = new Color[] { color, color, color, color }; if (pretty) { var random = new Random((Environment.TickCount / 100) % 255); for (int i = 0; i < colors.Length; i++) { bool redness = random.Next() % 2 == 0; bool blueness = random.Next() % 2 == 0; var random1 = Math.Max(200, random.Next() % 255); int red = Math.Min(255, redness ? (random1 * 2) : (random1 / 2)); int green = Math.Min(255, (blueness && redness) ? (random1) : (random1 / 2)); int blue = Math.Min(255, blueness ? (random1 * 2) : (random1 / 2)); colors[i] = Color.FromArgb((int)(255f * opacity), red, green, blue); } } var u1 = uv.Left; var v1 = uv.Top; var u2 = uv.Right; var v2 = uv.Bottom; var verts = new RiderVertex[] { new RiderVertex(texrect[0], new Vector2(uv.Left, uv.Top), tex, colors[0]), new RiderVertex(texrect[1], new Vector2(uv.Right, uv.Top), tex, colors[1]), new RiderVertex(texrect[2], new Vector2(uv.Right, uv.Bottom), tex, colors[2]), new RiderVertex(texrect[3], new Vector2(uv.Left, uv.Bottom), tex, colors[3]) }; Array.Add(verts[0]); Array.Add(verts[1]); Array.Add(verts[2]); Array.Add(verts[3]); Array.Add(verts[2]); Array.Add(verts[0]); }
new void Start() { base.Start(); // moving deprecated fields to new one if (texturesBackground.Length == 0 && textureBackground != null) { Array.Resize(ref texturesBackground, 1); var tex = new Tex(); tex.texture = textureBackground; tex.color = textureBackgroundColor; texturesBackground[0] = tex; textureBackground = null; } if (texturesForeground.Length == 0 && textureForeground != null) { Array.Resize(ref texturesForeground, 1); var tex = new Tex(); tex.texture = textureForeground; tex.color = textureForegroundColor; texturesForeground[0] = tex; textureForeground = null; } }
int BuildTextures(Tex[] textures, string prefix, int startDepth, ref List<MadSprite> sprites) { int counter = 0; foreach (var texture in textures) { if (texture.texture == null) { continue; } string name = string.Format("{0}{1:D2}", prefix, counter + 1); var sprite = MadTransform.CreateChild<MadSprite>(transform, name); #if !MAD_DEBUG sprite.gameObject.hideFlags = HideFlags.HideInHierarchy; #endif sprite.guiDepth = startDepth + counter; sprite.texture = texture.texture; sprite.tint = texture.color; sprites.Add(sprite); counter++; } return startDepth + counter; }
void UpdateTextureColors(List<MadSprite> sprites, Tex[] textures) { if (sprites.Count != textures.Length) { Debug.LogWarning("Different number of sprites and registered textures. (" + sprites.Count + ", " + textures.Length + ")"); return; } for (int i = 0; i < sprites.Count; i++) { var sprite = sprites[i]; Tex texture = textures[i]; sprite.visible = visible; sprite.tint = ComputeColor(texture.color); } }