示例#1
0
    public void ReadMCDD(MemoryStream ADTstream, ADTRootData.MeshChunkData chunkData, int MCDDsize) // there seems to be a high-res (?) mode which is not taken into account
    // in live clients (32 bytes instead of 8) (?). if inlined to MCNK is low-res.
    {
        //Debug.Log(MCDD + "found " + MCDDsize + " ----------I have info to parse it now");

        // skip for now
        ADTstream.Seek(MCDDsize, SeekOrigin.Current);
    }
示例#2
0
    }  // normals

    public void ReadMCSE(MemoryStream ADTstream, ADTRootData.MeshChunkData chunkData, int MCSEsize)
    {
        if (MCSEsize != 0)
        {
            Debug.Log("MCSE found " + MCSEsize + " ----------I have info to parse it now");
            ADTstream.Seek(MCSEsize, SeekOrigin.Current); // skip for now
        }
    }
示例#3
0
    } // vertex shading

    public void FillMCCV(ADTRootData.MeshChunkData chunkData)
    {
        chunkData.VertexColors = new Color32[145];
        for (int col = 0; col < 145; col++)
        {
            Color32 colorBGRA = new Color32(127, 127, 127, 127);
            chunkData.VertexColors[col] = colorBGRA;
        }
    } // fill vertex shading with 127
示例#4
0
    ////////////////////////////
    ////// MCNK Subchunks //////
    ////////////////////////////

    public void ReadMCVT(MemoryStream ADTstream, ADTRootData.MeshChunkData chunkData)
    {
        StreamTools s = new StreamTools();

        for (int v = 1; v <= 145; v++)
        {
            chunkData.VertexHeights.Add(s.ReadFloat(ADTstream));
        }
    }
示例#5
0
 public void ReadMCLV(MemoryStream ADTstream, ADTRootData.MeshChunkData chunkData)
 {
     for (int v = 1; v <= 145; v++)
     {
         byte[] ARGB = new byte[4];
         for (int b = 0; b < 4; b++)
         {
             ARGB[b] = (byte)ADTstream.ReadByte();
         }
         chunkData.VertexLighting.Add(ARGB);
     }
     // Alpha is ignored.
     // In contrast to MCCV does not only color but also lightens up the vertices.
     // Result of baking level-designer placed omni lights. With WoD, they added the actual lights to do live lighting.
 } // chunk lighting
示例#6
0
    } // fill vertex shading with 127

    public void ReadMCNR(MemoryStream ADTstream, ADTRootData.MeshChunkData chunkData)
    {
        StreamTools s = new StreamTools();

        chunkData.VertexNormals = new Vector3[145];
        for (int n = 0; n < 145; n++)
        {
            Vector3 normsRaw = new Vector3(ADTstream.ReadByte(), ADTstream.ReadByte(), ADTstream.ReadByte());

            var calcX = s.NormalizeValue(normsRaw.x); if (calcX <= 0)
            {
                calcX = 1 + calcX;
            }
            else if (calcX > 0)
            {
                calcX = (1 - calcX) * (-1);
            }
            var calcY = s.NormalizeValue(normsRaw.y); if (calcY <= 0)
            {
                calcY = 1 + calcY;
            }
            else if (calcY > 0)
            {
                calcY = (1 - calcY) * (-1);
            }
            var calcZ = s.NormalizeValue(normsRaw.z); if (calcZ <= 0)
            {
                calcZ = 1 + calcZ;
            }
            else if (calcZ > 0)
            {
                calcZ = (1 - calcZ) * (-1);
            }

            chunkData.VertexNormals[n] = new Vector3(calcX, calcZ, calcY);
        }
        // skip unused 13 byte padding //
        ADTstream.Seek(13, SeekOrigin.Current);
    }  // normals
示例#7
0
    } // chunk lighting

    public void ReadMCCV(MemoryStream ADTstream, ADTRootData.MeshChunkData chunkData)
    {
        chunkData.VertexColors = new Color32[145];

        List <int> vertcolors = new List <int>();

        for (int col = 0; col < 145; col++)
        {
            int channelR = ADTstream.ReadByte();
            vertcolors.Add(channelR);
            int channelG = ADTstream.ReadByte();
            vertcolors.Add(channelG);
            int channelB = ADTstream.ReadByte();
            vertcolors.Add(channelB);
            int channelA = ADTstream.ReadByte();
            vertcolors.Add(channelA);

            Color32 colorsRGBA = new Color32((byte)channelR, (byte)channelG, (byte)channelB, (byte)channelA);
            Color32 colorBGRA  = new Color32(colorsRGBA.b, colorsRGBA.g, colorsRGBA.r, colorsRGBA.a);
            chunkData.VertexColors[col] = colorBGRA;
        }
    } // vertex shading
示例#8
0
    public void ReadMCNK(MemoryStream ADTstream, int MCNKchunkNumber, int MCNKsize)
    {
        StreamTools s = new StreamTools();
        Flags       f = new Flags();

        ADTRootData.MeshChunkData chunkData = new ADTRootData.MeshChunkData();
        long MCNKchnkPos = ADTstream.Position;

        // <Header> - 128 bytes
        chunkData.flags = f.ReadMCNKflags(ADTstream);

        chunkData.IndexX  = s.ReadLong(ADTstream);
        chunkData.IndexY  = s.ReadLong(ADTstream);
        chunkData.nLayers = s.ReadLong(ADTstream);  // maximum 4
        int nDoodadRefs = s.ReadLong(ADTstream);

        chunkData.holes_high_res = s.ReadUint64(ADTstream);  // only used with flags.high_res_holes
        int ofsLayer    = s.ReadLong(ADTstream);
        int ofsRefs     = s.ReadLong(ADTstream);
        int ofsAlpha    = s.ReadLong(ADTstream);
        int sizeAlpha   = s.ReadLong(ADTstream);
        int ofsShadow   = s.ReadLong(ADTstream); // only with flags.has_mcsh
        int sizeShadow  = s.ReadLong(ADTstream);
        int areaid      = s.ReadLong(ADTstream); // in alpha: both zone id and sub zone id, as uint16s.
        int nMapObjRefs = s.ReadLong(ADTstream);

        chunkData.holes_low_res = s.ReadShort(ADTstream);
        int unknown_but_used = s.ReadShort(ADTstream);       // in alpha: padding

        byte[] ReallyLowQualityTextureingMap = new byte[16]; // uint2_t[8][8] "predTex", It is used to determine which detail doodads to show. Values are an array of two bit
        for (int b = 0; b < 16; b++)
        {
            ReallyLowQualityTextureingMap[b] = (byte)ADTstream.ReadByte();
        }
        // unsigned integers, naming the layer.
        ulong noEffectDoodad = s.ReadUint64(ADTstream);                 // WoD: may be an explicit MCDD chunk
        int   ofsSndEmitters = s.ReadLong(ADTstream);
        int   nSndEmitters   = s.ReadLong(ADTstream);                   // will be set to 0 in the client if ofsSndEmitters doesn't point to MCSE!
        int   ofsLiquid      = s.ReadLong(ADTstream);
        int   sizeLiquid     = s.ReadLong(ADTstream);                   // 8 when not used; only read if >8.

        // in alpha, remainder is padding but unused.
        chunkData.MeshPosition = new Vector3(s.ReadFloat(ADTstream), s.ReadFloat(ADTstream), s.ReadFloat(ADTstream));
        int ofsMCCV = s.ReadLong(ADTstream);                             // only with flags.has_mccv, had uint32_t textureId; in ObscuR's structure.
        int ofsMCLV = s.ReadLong(ADTstream);                             // introduced in Cataclysm
        int unused  = s.ReadLong(ADTstream);                             // currently unused

        // </header>

        if (!chunkData.flags.has_mccv)
        {
            FillMCCV(chunkData); // fill vertex shading with 127...
        }
        long streamPosition = ADTstream.Position;

        while (streamPosition < MCNKchnkPos + MCNKsize)
        {
            ADTstream.Position = streamPosition;
            int chunkID   = s.ReadLong(ADTstream);
            int chunkSize = s.ReadLong(ADTstream);
            streamPosition = ADTstream.Position + chunkSize;
            switch (chunkID)
            {
            case (int)ChunkID.ADT.MCVT:
                ReadMCVT(ADTstream, chunkData);     // vertex heights
                break;

            case (int)ChunkID.ADT.MCLV:
                ReadMCLV(ADTstream, chunkData);     // chunk lighting
                break;

            case (int)ChunkID.ADT.MCCV:
                ReadMCCV(ADTstream, chunkData);     // vertex shading
                break;

            case (int)ChunkID.ADT.MCNR:
                ReadMCNR(ADTstream, chunkData);     // normals
                break;

            case (int)ChunkID.ADT.MCSE:
                ReadMCSE(ADTstream, chunkData, chunkSize);     // sound emitters
                break;

            case (int)ChunkID.ADT.MCBB:
                ReadMCBB(ADTstream, chunkData, chunkSize);
                break;

            case (int)ChunkID.ADT.MCDD:
                ReadMCDD(ADTstream, chunkData, chunkSize);
                break;

            default:
                SkipUnknownChunk(ADTstream, chunkID, chunkSize);
                break;
            }
        }
        ADTRootData.meshBlockData.meshChunksData.Add(chunkData);
    }
示例#9
0
 public void ReadMCBB(MemoryStream ADTstream, ADTRootData.MeshChunkData chunkData, int MCBBsize) // blend batches. max 256 per MCNK
 {
     //Debug.Log(MCBB + "found " + MCBBsize + " ----------I have info to parse it now");
     // skip for now
     ADTstream.Seek(MCBBsize, SeekOrigin.Current);
 }