Ejemplo n.º 1
0
    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();
    }
Ejemplo n.º 2
0
    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();
    }
Ejemplo n.º 3
0
    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();
    }
Ejemplo n.º 4
0
    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();
    }