public BSPTexture(BinaryReader bspFile, BSPPalette palette) { name = new string( bspFile.ReadChars(16)); width = bspFile.ReadInt32(); height = bspFile.ReadInt32(); offset = bspFile.ReadInt32(); // Skip past the next 3 offsets, straight to the start of fullsize mip texture data bspFile.BaseStream.Seek(12, SeekOrigin.Current); int byteCount = width * height; textureData = new byte[byteCount]; textureData = bspFile.ReadBytes(byteCount); texture = new Texture2D(width, height); int index = 0; for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { texture.SetPixel(x, y, palette.Colours[textureData[index]]); index++; } } texture.Apply(); }
public MDL(string fileName) { Name = fileName; palette = new BSPPalette("palette.lmp"); mdlFile = new BinaryReader(File.Open("Assets/Resources/Models/" + fileName, FileMode.Open)); header = new MDLHeader(mdlFile); LoadSkins(mdlFile); LoadTextureCoords(mdlFile); LoadTriangles(mdlFile); LoadFrames(mdlFile); BuildMesh(); }
public BSPMap(string mapFileName) { palette = new BSPPalette("palette.lmp"); bspFile = new BinaryReader(File.Open("Assets/Resources/Maps/" + mapFileName, FileMode.Open)); header = new BSPHeader(bspFile); LoadEntities(bspFile); LoadPlanes(bspFile); LoadTextures(bspFile); LoadVertices(bspFile); LoadNodes(bspFile); LoadTextureInfo(bspFile); LoadLeaves(bspFile); LoadFaces(bspFile); LoadEdges(bspFile); LoadModels(bspFile); bspFile.Close(); }
public MDLSkin(BinaryReader mdlFile, MDLHeader header, BSPPalette palette) { group = mdlFile.ReadInt32(); int byteCount = header.skinWidth * header.skinHeight; textureData = new byte[byteCount]; textureData = mdlFile.ReadBytes(byteCount); texture = new Texture2D(header.skinWidth, header.skinHeight); int index = 0; for (int y = 0; y < header.skinHeight; y++) { for (int x = 0; x < header.skinWidth; x++) { texture.SetPixel(x, y, palette.Colours[textureData[index]]); index++; } } texture.Apply(); }