public GeometricTransformAttributeElement(Stream stream) : base(stream) { StoredValuesMask = StreamUtils.ReadUInt16(stream); var elementValueList = new List <Single>(16); var storedValuesMask = StoredValuesMask; for (int i = 0, c = 16; i < c; ++i) { if ((storedValuesMask & 0x8000) > 0) { var value = StreamUtils.ReadFloat(stream); elementValueList.Add(value); TransformationMatrix[i] = value; } storedValuesMask = (UInt16)(storedValuesMask << 1); } ElementValues = elementValueList.ToArray(); }
public RGB(Stream stream) : base() { data = new Single[] { StreamUtils.ReadFloat(stream), StreamUtils.ReadFloat(stream), StreamUtils.ReadFloat(stream) }; }
public PropertyProxyMetaDataElement(Stream stream) { PropertyKeys = new List <MbString>(); PropertyValueTypes = new List <byte>(); PropertyValues = new List <object>(); var propertyKey = new MbString(stream); while (propertyKey.Count > 0) { PropertyKeys.Add(propertyKey); var propertyValueType = StreamUtils.ReadByte(stream); PropertyValueTypes.Add(propertyValueType); switch (propertyValueType) { case 1: { PropertyValues.Add(new MbString(stream)); // MbString break; } case 2: { PropertyValues.Add(StreamUtils.ReadInt32(stream)); // Int32 break; } case 3: { PropertyValues.Add(StreamUtils.ReadFloat(stream)); // Single break; } case 4: { PropertyValues.Add(new Date(stream)); // Date break; } default: { throw new Exception(String.Format("Property Value Type {0} is not recognised.", propertyValueType)); } } propertyKey = new MbString(stream); } }
public RGBA(Stream stream) : base(stream) { data = new Single[] { base.Red, base.Green, base.Blue, StreamUtils.ReadFloat(stream) }; }
public BaseShapeNodeElement(Stream stream) : base(stream) { TransformedBBox = new BBoxF32(stream); UntransformedBBox = new BBoxF32(stream); Area = StreamUtils.ReadFloat(stream); VertexCountRange = new CountRange(stream); NodeCountRange = new CountRange(stream); PolygonCountRange = new CountRange(stream); Size = StreamUtils.ReadInt32(stream); CompressionLevel = StreamUtils.ReadFloat(stream); }
public PartitionNodeElement(Stream stream) : base(stream) { PartitionFlags = StreamUtils.ReadInt32(stream); FileName = new MbString(stream); TransformedBBox = new BBoxF32(stream); Area = StreamUtils.ReadFloat(stream); VertexCountRange = new CountRange(stream); NodeCountRange = new CountRange(stream); PolygonCountRange = new CountRange(stream); if ((PartitionFlags & 0x00000001) != 0) { UntransformedBBox = new BBoxF32(stream); } }
public MaterialAttributeElement(Stream stream) : base(stream) { DataFlags = StreamUtils.ReadUInt16(stream); var patternBitsAreUsed = (DataFlags & 0x0001) > 0; if (patternBitsAreUsed && (DataFlags & 0x0002) > 0) { AmbientCommonRGBValue = StreamUtils.ReadFloat(stream); } else { AmbientColour = new RGBA(stream); } DiffuseColour = new RGBA(stream); if (patternBitsAreUsed && (DataFlags & 0x0008) > 0) { SpecularCommonRGBValue = StreamUtils.ReadFloat(stream); } else { SpecularColour = new RGBA(stream); } if (patternBitsAreUsed && (DataFlags & 0x0004) > 0) { EmissionCommonRGBValue = StreamUtils.ReadFloat(stream); } else { EmissionColour = new RGBA(stream); } Shininess = StreamUtils.ReadFloat(stream); }
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; } } }
public UniformQuantizerData(Stream stream) { Min = StreamUtils.ReadFloat(stream); Max = StreamUtils.ReadFloat(stream); NumberOfBits = StreamUtils.ReadByte(stream); }
public FloatingPointPropertyAtomElement(Stream stream) : base(stream) { Value = StreamUtils.ReadFloat(stream); }