Пример #1
0
            public Waterbox(ROMHandler.ROMHandler rom, uint adr, int number, Collision colheader)
            {
                ROM = rom;
                Address = adr;
                Number = number;
                ParentCollisionHeader = colheader;

                byte[] segdata = (byte[])ROM.SegmentMapping[(byte)(adr >> 24)];
                if (segdata == null) return;

                Position = new Vector3d(
                    (double)Endian.SwapInt16(BitConverter.ToInt16(segdata, (int)(adr & 0xFFFFFF))),
                    (double)Endian.SwapInt16(BitConverter.ToInt16(segdata, (int)((adr & 0xFFFFFF) + 2))),
                    (double)Endian.SwapInt16(BitConverter.ToInt16(segdata, (int)((adr & 0xFFFFFF) + 4))));

                SizeXZ = new Vector2d(
                    (double)Endian.SwapInt16(BitConverter.ToInt16(segdata, (int)((adr & 0xFFFFFF) + 6))),
                    (double)Endian.SwapInt16(BitConverter.ToInt16(segdata, (int)((adr & 0xFFFFFF) + 8))));

                RoomPropRaw = (Endian.SwapUInt32(BitConverter.ToUInt32(segdata, (int)((adr & 0xFFFFFF) + 12))) & 0xFFFFFF);
            }
Пример #2
0
            public Polygon(ROMHandler.ROMHandler rom, uint adr, int number, Collision colheader)
            {
                ROM = rom;
                Address = adr;
                Number = number;
                ParentCollisionHeader = colheader;

                byte[] segdata = (byte[])ROM.SegmentMapping[(byte)(adr >> 24)];
                if (segdata == null) return;

                PolygonType = Endian.SwapUInt16(BitConverter.ToUInt16(segdata, (int)(adr & 0xFFFFFF)));
                NormalXDirection = Endian.SwapInt16(BitConverter.ToInt16(segdata, (int)(adr & 0xFFFFFF) + 0x8));
                NormalYDirection = Endian.SwapInt16(BitConverter.ToInt16(segdata, (int)(adr & 0xFFFFFF) + 0xA));
                NormalZDirection = Endian.SwapInt16(BitConverter.ToInt16(segdata, (int)(adr & 0xFFFFFF) + 0xC));
                CollisionPlaneDistFromOrigin = Endian.SwapInt16(BitConverter.ToInt16(segdata, (int)(adr & 0xFFFFFF) + 0xE));

                /* Read vertex IDs & fetch vertices */
                VertexIDs = new ushort[3];
                Vertices = new Vector3d[3];
                for (int i = 0; i < 3; i++)
                {
                    ushort vidx = (ushort)(Endian.SwapUInt16(BitConverter.ToUInt16(segdata, (int)(adr & 0xFFFFFF) + 0x2 + (i * 2))) & 0xFFF);
                    VertexIDs[i] = vidx;
                    Vertices[i] = ParentCollisionHeader.Vertices[vidx];
                }
            }