Exemplo n.º 1
0
        public VertexShapeLODElement(Stream stream)
        {
            versionNumber = StreamUtils.ReadInt16(stream);

            BindingAttributes      = StreamUtils.ReadInt32(stream);
            QuantizationParameters = new QuantizationParameters(stream);
        }
Exemplo n.º 2
0
        public Date(Stream stream)
        {
            data = new Int16[6];

            for (int i = 0, c = data.Length; i < c; ++i)
            {
                data[i] = StreamUtils.ReadInt16(stream);
            }
        }
Exemplo n.º 3
0
        public PropertyTable(Stream stream)
        {
            VersionNumber          = StreamUtils.ReadInt16(stream);
            NodePropertyTableCount = StreamUtils.ReadInt32(stream);

            NodeObjectIDs      = new Int32[NodePropertyTableCount];
            NodePropertyTables = new NodePropertyTable[NodePropertyTableCount];

            for (int i = 0; i < NodePropertyTableCount; ++i)
            {
                NodeObjectIDs[i]      = StreamUtils.ReadInt32(stream);
                NodePropertyTables[i] = new NodePropertyTable(stream);
            }
        }
Exemplo n.º 4
0
 public MetaDataNodeElement(Stream stream) : base(stream)
 {
     versionNumber = StreamUtils.ReadInt16(stream);
 }
Exemplo n.º 5
0
        public VertexBasedShapeCompressedRepData(Stream stream)
        {
            VersionNumber          = StreamUtils.ReadInt16(stream);
            NormalBinding          = StreamUtils.ReadByte(stream);
            TextureCoordBinding    = StreamUtils.ReadByte(stream);
            ColourBinding          = StreamUtils.ReadByte(stream);
            QuantizationParameters = new QuantizationParameters(stream);

            var primitiveListIndices = Int32CompressedDataPacket.GetArrayI32(stream, Int32CompressedDataPacket.PredictorType.Stride1);

            MemoryStream vertexDataStream;

            if (QuantizationParameters.BitsPerVertex == 0)
            {
                LosslessCompressedRawVertexData = new LosslessCompressedRawVertexData(stream);

                vertexDataStream = new MemoryStream(LosslessCompressedRawVertexData.VertexData);
            }

            else
            {
                throw new NotImplementedException("LossyQuantizedRawVertexData NOT IMPLEMENTED");
            }

            var readNormals       = NormalBinding == 1;
            var readTextureCoords = TextureCoordBinding == 1;
            var readColours       = ColourBinding == 1;

            var vertexEntrySize  = 3 + (readNormals ? 3 : 0) + (readTextureCoords ? 2 : 0) + (readColours ? 3 : 0);
            var vertexEntryCount = (vertexDataStream.Length / 4) / vertexEntrySize;

            var vertexPositions          = new float[vertexEntryCount][];
            var vertexNormals            = readNormals ? new float[vertexEntryCount][] : null;
            var vertexColours            = readColours ? new float[vertexEntryCount][] : null;
            var vertexTextureCoordinates = readTextureCoords ? new float[vertexEntryCount][] : null;

            for (int i = 0; i < vertexEntryCount; ++i)
            {
                if (readTextureCoords)
                {
                    vertexTextureCoordinates[i] = new float[] { StreamUtils.ReadFloat(vertexDataStream), StreamUtils.ReadFloat(vertexDataStream) }
                }
                ;

                if (readColours)
                {
                    vertexColours[i] = new float[] { StreamUtils.ReadFloat(vertexDataStream), StreamUtils.ReadFloat(vertexDataStream), StreamUtils.ReadFloat(vertexDataStream) }
                }
                ;

                if (readNormals)
                {
                    vertexNormals[i] = new float[] { StreamUtils.ReadFloat(vertexDataStream), StreamUtils.ReadFloat(vertexDataStream), StreamUtils.ReadFloat(vertexDataStream) }
                }
                ;

                vertexPositions[i] = new float[] { StreamUtils.ReadFloat(vertexDataStream), StreamUtils.ReadFloat(vertexDataStream), StreamUtils.ReadFloat(vertexDataStream) };
            }

            Positions = vertexPositions;
            Normals   = vertexNormals;

            var triStripCount = primitiveListIndices.Length - 1;
            var triStrips     = new int[triStripCount][];

            for (int triStripIndex = 0; triStripIndex < triStripCount; ++triStripIndex)
            {
                var startIndex = primitiveListIndices[triStripIndex];
                var endIndex   = primitiveListIndices[triStripIndex + 1];

                var indicesCount = endIndex - startIndex;
                var indices      = new int[indicesCount];

                for (int i = 0; i < indicesCount; ++i)
                {
                    indices[i] = startIndex + i;
                }

                triStrips[triStripIndex] = indices;
            }

            TriStrips = triStrips;
        }
    }
}
Exemplo n.º 6
0
 public TriStripSetShapeLODElement(Stream stream)
     : base(stream)
 {
     versionNumber = StreamUtils.ReadInt16(stream);
     VertexBasedShapeCompressedRepData = new VertexBasedShapeCompressedRepData(stream);
 }
Exemplo n.º 7
0
 public GUID(Stream stream)
 {
     guid = new Guid(StreamUtils.ReadInt32(stream), StreamUtils.ReadInt16(stream), StreamUtils.ReadInt16(stream), StreamUtils.ReadBytes(stream, 8, false));
 }
Exemplo n.º 8
0
 public PartNodeElement(Stream stream)
     : base(stream)
 {
     versionNumber = StreamUtils.ReadInt16(stream);
     reservedField = StreamUtils.ReadInt32(stream);
 }