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()); }
private void Render() { GL.ClearColor(0.0f, 0.0f, 1.0f, 0.0f); GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit); GL.PushMatrix(); // For translation and scale GL.MatrixMode(MatrixMode.Modelview); GL.LoadIdentity(); GL.Rotate(angleX, 0f, 1f, 0f); GL.Rotate(angleY, 0f, 0f, 1f); GL.Scale(distance, distance, distance); GL.Translate(x, y, z); label1.Text = "X: " + x.ToString() + " Y: " + y.ToString() + " Z: " + z.ToString() + "\r\n" + "AngleX: " + angleX.ToString() + " AngleY: " + angleY.ToString() + " Distance: " + distance.ToString(); GL.Disable(EnableCap.Texture2D); // TODO: Draw box // Edges DrawEdges(); GL.Enable(EnableCap.PolygonSmooth); GL.Enable(EnableCap.DepthTest); GL.Enable(EnableCap.Texture2D); GL.Enable(EnableCap.AlphaTest); GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha); GL.Enable(EnableCap.Blend); GL.AlphaFunc(AlphaFunction.Greater, 0f); GL.Disable(EnableCap.CullFace); //pm = PolygonMode.Line; GL.PolygonMode(MaterialFace.FrontAndBack, pm); GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)TextureMagFilter.Nearest); GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.Nearest); GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapS, (float)TextureWrapMode.Repeat); GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapT, (float)TextureWrapMode.Repeat); GL.TexEnv(TextureEnvTarget.TextureEnv, TextureEnvParameter.TextureEnvMode, (int)TextureEnvMode.Replace); if (!checkManual.Checked) { for (int i = 0; i < model.model.mdlData[0].polygon.header.num_objs; i++) { sBMD0.Model.ModelData.Polygon.Display poly = model.model.mdlData[0].polygon.display[i]; if (poly.materialID >= model.model.mdlData[0].material.material.Length) { poly.materialID = 0; } sBMD0.Model.ModelData.Material.MatDef mat = (sBMD0.Model.ModelData.Material.MatDef)model.model.mdlData[0].material.material[poly.materialID]; sBTX0.Texture.TextInfo texInfo = (sBTX0.Texture.TextInfo)tex.texture.texInfo.infoBlock.infoData[mat.texID]; GL.BindTexture(TextureTarget.Texture2D, poly.materialAssoc); GL.MatrixMode(MatrixMode.Texture); GL.LoadIdentity(); GL.Scale(1.0f / (float)texInfo.width, 1.0f / (float)texInfo.height, 1.0f); // Scale the texture to fill the polygon BMD0.GeometryCommands(poly.commands); } } else { int i = (int)numericPoly.Value; sBMD0.Model.ModelData.Polygon.Display poly = model.model.mdlData[0].polygon.display[i]; if (poly.materialID >= model.model.mdlData[0].material.material.Length) { poly.materialID = 0; } sBMD0.Model.ModelData.Material.MatDef mat = (sBMD0.Model.ModelData.Material.MatDef)model.model.mdlData[0].material.material[poly.materialID]; sBTX0.Texture.TextInfo texInfo = (sBTX0.Texture.TextInfo)tex.texture.texInfo.infoBlock.infoData[mat.texID]; GL.BindTexture(TextureTarget.Texture2D, poly.materialAssoc); GL.MatrixMode(MatrixMode.Texture); GL.LoadIdentity(); GL.Scale(1.0f / (float)texInfo.width, 1.0f / (float)texInfo.height, 1.0f); // Scale the texture to fill the polygon BMD0.GeometryCommands(poly.commands); } GL.PopMatrix(); GL.Flush(); glControl1.SwapBuffers(); }