Пример #1
0
        public static Dynamics Read(Reader reader, Pointer offset)
        {
            Dynamics dynamics = new Dynamics(offset);

            // Read data

            dynamics.field_0 = reader.ReadUInt32();
            dynamics.field_4 = reader.ReadUInt32();
            dynamics.field_8 = reader.ReadUInt32();
            dynamics.field_C = reader.ReadUInt32();

            // Determine type
            int type;

            if ((dynamics.field_C & 4) != 0)
            {
                type = 2;
            }
            else if ((dynamics.field_C & 2) != 0)
            {
                type = 1;
            }
            else
            {
                type = 0;
            }

            dynamics.type = (DynamicsType)type;

            // Process data (common)

            Pointer.Goto(ref reader, offset + 0x54);
            dynamics.off_speedVector = Pointer.Read(reader);

            Pointer.Goto(ref reader, offset + 0x78);
            dynamics.matrixA = Matrix.Read(reader, offset + 0x78);

            Pointer.Goto(ref reader, offset + 0xD0);
            dynamics.matrixB = Matrix.Read(reader, offset + 0xD0);

            // Process data (type specific)

            if (dynamics.type == DynamicsType.Type0_SMALL)
            {
            }
            else if (dynamics.type == DynamicsType.Type1_MEDIUM)
            {
            }
            else if (dynamics.type == DynamicsType.Type2_BIG)
            {
                Pointer.Goto(ref reader, dynamics.off_speedVector);
                dynamics.speedVector = new Vector3(reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle());
            }

            return(dynamics);
        }
Пример #2
0
        public static MechanicsIDCard Read(Reader reader, Pointer offset)
        {
            MapLoader       l = MapLoader.Loader;
            MechanicsIDCard c = new MechanicsIDCard(offset);

            c.type       = reader.ReadUInt32(); // 0x0
            c.flags      = reader.ReadUInt32(); // 0x4
            c.gravity    = reader.ReadSingle();
            c.maxRebound = reader.ReadSingle();
            reader.ReadUInt32();
            c.slopeLimit = reader.ReadSingle();
            float x = reader.ReadSingle();
            float z = reader.ReadSingle();
            float y = reader.ReadSingle();

            c.inertia       = new Vector3(x, y, z);
            c.tiltIntensity = reader.ReadSingle();
            c.tiltInertia   = reader.ReadSingle();
            c.tiltOrigin    = reader.ReadSingle();
            x            = reader.ReadSingle();
            z            = reader.ReadSingle();
            y            = reader.ReadSingle();
            c.maxInertia = new Vector3(x, y, z);
            return(c);
        }
Пример #3
0
        public static Matrix ReadRenderware(Reader reader)
        {
            MapLoader l   = MapLoader.Loader;
            Matrix    mat = new Matrix(null, 0, new Matrix4x4(), Vector4.one);

            mat.m.SetColumn(0, new Vector4(reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle(), 0f));
            mat.m.SetColumn(1, new Vector4(reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle(), 0f));
            mat.m.SetColumn(2, new Vector4(reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle(), 0f));
            mat.m.SetColumn(3, new Vector4(reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle(), 1f));             // position
            return(mat);
        }
Пример #4
0
        public static Matrix Read(Reader reader, Pointer offset)
        {
            MapLoader l = MapLoader.Loader;
            //l.print("MATRIX " + offset);
            UInt32 type = Settings.s.game != Settings.Game.R2Revolution ? reader.ReadUInt32() : 0; // 0x02: always at the start of a transformation matrix
            Matrix mat  = new Matrix(offset, type, new Matrix4x4(), null);

            if (Settings.s.engineVersion < Settings.EngineVersion.R3 && Settings.s.game != Settings.Game.R2Revolution)
            {
                Vector3 pos = Vector3.zero;

                if (Settings.s.platform != Settings.Platform.DC)
                {
                    pos = new Vector3(reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle());
                }
                mat.m.SetColumn(0, new Vector4(reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle(), 0f));
                mat.m.SetColumn(1, new Vector4(reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle(), 0f));
                mat.m.SetColumn(2, new Vector4(reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle(), 0f));
                Matrix4x4 sclMatrix = new Matrix4x4();
                sclMatrix.SetColumn(0, new Vector4(reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle(), Settings.s.platform == Settings.Platform.DC ? reader.ReadSingle() : 0f));
                sclMatrix.SetColumn(1, new Vector4(reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle(), Settings.s.platform == Settings.Platform.DC ? reader.ReadSingle() : 0f));
                sclMatrix.SetColumn(2, new Vector4(reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle(), Settings.s.platform == Settings.Platform.DC ? reader.ReadSingle() : 0f));
                if (Settings.s.platform == Settings.Platform.DC)
                {
                    pos = new Vector3(reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle());
                }

                mat.m.SetColumn(3, new Vector4(pos.x, pos.y, pos.z, 1f));
                sclMatrix.SetColumn(3, new Vector4(0, 0, 0, 1f));
                mat.SetScaleMatrix(sclMatrix);

                /*if (type != 4) {
                 *  transMatrix.SetColumn(0, rotColX);
                 *  transMatrix.SetColumn(1, rotColY);
                 *  transMatrix.SetColumn(2, rotColZ);
                 * } else {
                 *  transMatrix.SetColumn(0, sclColX);
                 *  transMatrix.SetColumn(1, sclColY);
                 *  transMatrix.SetColumn(2, sclColZ);
                 * }*/
            }
            else
            {
                if (Settings.s.platform == Settings.Platform.PS2 && Settings.s.game != Settings.Game.R2Revolution)
                {
                    Vector3 v = new Vector3(reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle());
                }
                mat.m.SetColumn(0, new Vector4(reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle()));
                mat.m.SetColumn(1, new Vector4(reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle()));
                mat.m.SetColumn(2, new Vector4(reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle()));
                mat.m.SetColumn(3, new Vector4(reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle()));
                mat.v = new Vector4(reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle());

                /*mat.SetScaleMatrix(new Matrix4x4(
                 *      new Vector4(v.x, 0, 0, 0),
                 *      new Vector4(0,v.y, 0, 0),
                 *      new Vector4(0, 0, v.z, 0),
                 *      new Vector4(0, 0, 0, v.w)));*/
            }
            if (Settings.s.game == Settings.Game.R2Revolution)
            {
                mat.type = reader.ReadUInt32();
                // There's 0x8c more?
            }
            return(mat);
        }