Example #1
0
        /// <inheritdoc />
        public void Read(BinaryReader reader)
        {
            //read face type
            PolygonFlags polygonFlags = (PolygonFlags)(ushort)(reader.ReadInt32() ^ 1);

            reader.BaseStream.Seek(8, SeekOrigin.Current); //Skip unknown float and int
            //TODO: Unknown float and int in face declaration

            // Material index
            // TODO: Use this material or material from base declaration?
            MaterialIndex = reader.ReadInt32();

            var indicesCount = reader.ReadInt32();

            Indices = new int[indicesCount];
            UVS     = new Dictionary <int, Vector2>();

            for (int i = 0; i < indicesCount; i++)
            {
                Indices[i] = reader.ReadInt32();

                if ((polygonFlags & PolygonFlags.HasUvs) != PolygonFlags.None)
                {
                    UVS.Add(Indices[i], new Vector2(reader.ReadSingle(), reader.ReadSingle()));
                }

                if ((polygonFlags & PolygonFlags.HasIntensity) != PolygonFlags.None)
                {
                    if ((polygonFlags & PolygonFlags.HasIntensityVector) != PolygonFlags.None)
                    {
                        if ((polygonFlags & PolygonFlags.HasIntensityFloat) != PolygonFlags.None)
                        {
                            reader.ReadStruct <Vector3>(); // Intensity Vector, currently unused
                        }
                    }
                    else if ((polygonFlags & PolygonFlags.HasIntensityFloat) != PolygonFlags.None)
                    {
                        reader.ReadSingle(); // Intensity float, unused too
                    }
                }
            }
        }
 internal PolyPointDescriptor(Point p, PolygonFlags flag = PolygonFlags.NORMAL)
     : this(p != null ? p.X : 0, p != null ? p.Y : 0, flag) { }
 public PolyPointDescriptor(int x, int y, PolygonFlags flag = PolygonFlags.NORMAL)
 {
     X = x;
     Y = y;
     Flag = flag;
 }