Esempio n. 1
0
        Batch GetBatch(int index)
        {
            const int itemSize = 0x18;

            binaryReader.Goto(BatchOffset + itemSize * index);
            binaryReader.PositionAnchor = BatchOffset;
            Batch batch = new Batch(binaryReader);

            binaryReader.ResetAnchor();
            binaryReader.Back();

            return(batch);
        }
Esempio n. 2
0
        }                     // see CreateInverse

        public Texture(ABinaryReader binaryReader)
        {
            Width  = binaryReader.Read16();
            Height = binaryReader.Read16();
            Format = (TextureFormat)binaryReader.Read8();
            Unk1   = binaryReader.Read8();

            if (binaryReader.Read16() != 0)
            {
                throw new Exception("Texture.unk4 != 0");
            }

            uint offset = binaryReader.Read32();

            data = new Color[Width * Height];

            binaryReader.Goto(offset);

            switch (Format)
            {
            case TextureFormat.I4:
                ReadI4(binaryReader);
                break;

            case TextureFormat.I8:
                ReadI8(binaryReader);
                break;

            case TextureFormat.IA4:
                ReadIA4(binaryReader);
                break;

            case TextureFormat.IA8:
                ReadIA8(binaryReader);
                break;

            case TextureFormat.RGB565:
                ReadRGB565(binaryReader);
                break;

            case TextureFormat.RGB5A3:
                ReadRGB5A3(binaryReader);
                break;

            case TextureFormat.RGBA8:
                ReadRGB8(binaryReader);
                break;

            case TextureFormat.CMP:
                ReadCMP(binaryReader);
                break;

            default:
                throw new NotImplementedException(String.Format("Encountered an indexed texture Format {0}, which aren't implemented.", Format));
            }

            binaryReader.Back();
        }
Esempio n. 3
0
        public GraphObject(ABinaryReader binaryReader)
        {
            Visible     = true;
            ParentIndex = binaryReader.ReadS16();
            ChildIndex  = binaryReader.ReadS16();
            NextIndex   = binaryReader.ReadS16();
            PrevIndex   = binaryReader.ReadS16();

            if (binaryReader.Read8() != 0)
            {
#if AROOKAS_DEMOLISHER_CHECKPADDING
                throw new Exception(String.Format("GraphObject padding != 0 at 0x{0:X8}.", binaryReader.Stream.Position));
#endif
            }

            RenderFlags = (GraphObjectRenderFlags)binaryReader.Read8();

            if (binaryReader.Read16() != 0)
            {
#if AROOKAS_DEMOLISHER_CHECKPADDING
                throw new Exception(String.Format("GraphObject padding != 0 at 0x{0:X8}.", binaryReader.Stream.Position));
#endif
            }

            Scale       = new Vector3(binaryReader.ReadSingle(), binaryReader.ReadSingle(), binaryReader.ReadSingle());
            Rotation    = new Vector3(binaryReader.ReadSingle(), binaryReader.ReadSingle(), binaryReader.ReadSingle());
            Position    = new Vector3(binaryReader.ReadSingle(), binaryReader.ReadSingle(), binaryReader.ReadSingle());
            BoundingBox = new BoundingBox(binaryReader.ReadVector3D().ToVector3(), binaryReader.ReadVector3D().ToVector3());
            unk3        = binaryReader.ReadSingle();

            int partCount = binaryReader.ReadS16();

            if (binaryReader.Read16() != 0)
            {
#if AROOKAS_DEMOLISHER_CHECKPADDING
                throw new Exception(String.Format("GraphObject padding != 0 at 0x{0:X8}.", binaryReader.Stream.Position));
#endif
            }

            int partOffset = binaryReader.ReadS32();

            if (binaryReader.Read32s(7).Any(zero => zero != 0))
            {
#if AROOKAS_DEMOLISHER_CHECKPADDING
                throw new Exception(String.Format("GraphObject padding != 0 at 0x{0:X8}.", binaryReader.Stream.Position));
#endif
            }

            binaryReader.Goto(partOffset);
            parts = CollectionHelper.Initialize <Part>(partCount, () => new Part(binaryReader));
            binaryReader.Back();
        }
Esempio n. 4
0
        public Batch(ABinaryReader binaryReader)
        {
            FaceCount = binaryReader.Read16();
            int size = (binaryReader.Read16() << 5);

            Attributes = (BatchAttributes)(uint)binaryReader.Read32();
            UseNormals = (binaryReader.Read8() != 0);
            positions  = binaryReader.Read8();
            int uvCount = binaryReader.Read8();

            UseNBT = (binaryReader.Read8() != 0);
            Offset = binaryReader.Read32();

            if (binaryReader.Read8s(8).Any(zero => zero != 0))
            {
#if AROOKAS_DEMOLISHER_CHECKPADDING
                throw new Exception(String.Format("Batch padding != 0 at 0x{0:X8}.", binaryReader.Stream.Position));
#endif
            }

            int faces = 0;
            List <Primitive> primitives = new List <Primitive>();
            binaryReader.Goto(Offset);

            while (faces < FaceCount && binaryReader.Position < Offset + size)
            {
                Primitive primitive = new Primitive(binaryReader, UseNBT, uvCount, Attributes);

                if (!primitive.Type.IsDefined())
                {
                    break;
                }

                primitives.Add(primitive);
                faces += primitive.FaceCount;
            }

            binaryReader.Back();

            this.primitives = primitives.ToArray();
        }