public System.Windows.Forms.Control Show_Info(sFile file) { BinaryReader br = new BinaryReader(File.OpenRead(file.path)); string ext = new String(br.ReadChars(4)); br.Close(); if (ext == "BTX0") { btx = BTX0.Read(file.path, file.id, pluginHost); return(new TextureControl(pluginHost, btx)); } else if (ext == "BMD0") { sBMD0 bmd = BMD0.Read(file.path, file.id, pluginHost); if (bmd.header.numSect == 2) { return(new ModelControl(pluginHost, bmd)); } else if (btx.texture.texInfo.num_objs != 0) { return(new ModelControl(pluginHost, bmd, btx)); } else { System.Windows.Forms.MessageBox.Show("There aren't textures."); } } return(new System.Windows.Forms.Control()); }
public void Read(sFile file) { BinaryReader br = new BinaryReader(File.OpenRead(file.path)); string ext = new String(br.ReadChars(4)); br.Close(); if (ext == "BTX0") { sBTX0 btx = BTX0.Read(file.path, file.id, pluginHost); Bitmap[] tex = new Bitmap[btx.texture.texInfo.num_objs]; for (int i = 0; i < btx.texture.texInfo.num_objs; i++) { string fileOut = pluginHost.Get_TempFolder() + Path.DirectorySeparatorChar + file.name + '_' + btx.texture.texInfo.names[i] + ".png"; if (File.Exists(fileOut)) { fileOut = pluginHost.Get_TempFolder() + Path.DirectorySeparatorChar + Path.GetRandomFileName() + '_' + btx.texture.texInfo.names[i] + ".png"; } tex[i] = BTX0.GetTexture(pluginHost, btx, i); tex[i].Save(fileOut); } pluginHost.Set_Object(tex); } }
private void Get_TexIDS() { for (int i = 0; i < model.model.mdlData[0].material.material.Length; i++) { sBMD0.Model.ModelData.Material.MatDef mat = model.model.mdlData[0].material.material[i]; int num_tex, num_pal; BTX0.Find_IDs(out num_tex, out num_pal, mat.texName, mat.palName, tex.texture); mat.palID = (byte)num_pal; mat.texID = (byte)num_tex; model.model.mdlData[0].material.material[i] = mat; } }
private int LoadTextures(int num_tex, int num_pal) { int id = GL.GenTexture(); GL.BindTexture(TextureTarget.Texture2D, id); Bitmap bmp = BTX0.GetTexture(pluginHost, tex, num_tex, num_pal); System.Drawing.Imaging.BitmapData bmp_data = bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height), ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format32bppRgb); GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgba, bmp_data.Width, bmp_data.Height, 0, OpenTK.Graphics.OpenGL.PixelFormat.Bgra, PixelType.UnsignedByte, bmp_data.Scan0); bmp.UnlockBits(bmp_data); GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (float)TextureMagFilter.Nearest); GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (float)TextureMinFilter.Nearest); GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapS, (float)TextureWrapMode.Repeat); GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapT, (float)TextureWrapMode.Repeat); return(id); }