Ejemplo n.º 1
0
        public RoRswDataWater(BinaryReader reader, GenericFileFormatVersion version)
            : base(reader, version)
        {
            Height            = 0;
            Type              = 0;
            Amplitude         = 1;
            Phase             = 2;
            SurfaceCurveLevel = 0.5f;
            TextureCycling    = 3;

            if (version.IsCompatible(1, 3))
            {
                Height = reader.ReadSingle();

                if (version.IsCompatible(1, 8))
                {
                    Type              = reader.ReadUInt32();
                    Amplitude         = reader.ReadSingle();
                    Phase             = reader.ReadSingle();
                    SurfaceCurveLevel = reader.ReadSingle();

                    if (version.IsCompatible(1, 9))
                    {
                        TextureCycling = reader.ReadInt32();
                    }
                }
            }
        }
Ejemplo n.º 2
0
        public RoRsmMeshSurface(BinaryReader bin, GenericFileFormatVersion version)
            : base(bin, version)
        {
            SurfaceVector = new ushort[3];
            TextureVector = new ushort[3];
            for (int i = 0; i < SurfaceVector.Length; i++)
            {
                SurfaceVector[i] = bin.ReadUInt16();
            }
            for (int i = 0; i < TextureVector.Length; i++)
            {
                TextureVector[i] = bin.ReadUInt16();
            }

            TextureID = bin.ReadUInt16();
            Padding   = bin.ReadUInt16();
            TwoSide   = bin.ReadUInt32();
            if (version.IsCompatible(1, 2))
            {
                SmoothGroup = bin.ReadUInt32();
            }
            else
            {
                SmoothGroup = 0;
            }
        }
 public RoRsmMeshTextureVertex(BinaryReader bin, GenericFileFormatVersion version)
     : base(bin, version)
 {
     Color = (version.IsCompatible(1, 2) == false ? 0xFFFFFFFF : bin.ReadUInt32());
     U     = bin.ReadSingle();
     V     = bin.ReadSingle();
 }
Ejemplo n.º 4
0
 public RoRswDataModel(BinaryReader reader, GenericFileFormatVersion version)
     : base(reader, version)
 {
     name = reader.ReadWord(40);
     if (version.IsCompatible(1, 3))
     {
         unk1 = reader.ReadInt32();
         unk2 = reader.ReadSingle();
         unk3 = reader.ReadSingle();
     }
     filename = reader.ReadWord(40);
     reserved = reader.ReadWord(40);
     type     = reader.ReadWord(20);
     sound    = reader.ReadWord(20);
     todo1    = reader.ReadWord(40);
     pos      = reader.ReadVector3();
     rot      = reader.ReadVector3();
     scale    = reader.ReadVector3();
 }
Ejemplo n.º 5
0
        protected override bool ReadInternal()
        {
            MagicHead = Reader.ReadChars(4);
            Version   = new GenericFileFormatVersion(Reader);

            AnimationLen = Reader.ReadInt32();
            ShadowType   = Reader.ReadInt32();
            if (Version.IsCompatible(1, 4))
            {
                Alpha = Reader.ReadByte();
            }

            Reader.BaseStream.Position += 16;

            TextureNameCount = Reader.ReadInt32();
            TextureNames     = new string[TextureNameCount];
            for (int i = 0; i < TextureNameCount; i++)
            {
                TextureNames[i] = Reader.ReadWord(40);
            }

            MainNode = Reader.ReadWord(40);
            int nodeCount = Reader.ReadInt32();

            for (int i = 0; i < nodeCount; i++)
            {
                ReadMesh();
            }

            if (Meshes.Count == 1)
            {
                Meshes[0].IsOnly = true;
            }

            return(true);
        }
Ejemplo n.º 6
0
        public RoRsmMesh(BinaryReader bin, GenericFileFormatVersion version)
            : base(bin, version)
        {
            int count;

            Head = new RoRsmMeshHeader(bin, version);

            count = bin.ReadInt32();
            if ((bin.BaseStream.Length - bin.BaseStream.Position) < (4 * count))
            {
                IsValid = false;
                return;
            }
            for (int i = 0; i < count; i++)
            {
                TextureIndexs.Add(bin.ReadInt32());
            }

            Matrix = new RoRsmMeshTransMatrix(bin, version);

            count = bin.ReadInt32();
            if ((bin.BaseStream.Length - bin.BaseStream.Position) < (9 * count))
            {
                IsValid = false;
                return;
            }
            for (int i = 0; i < count; i++)
            {
                MainVectors.Add(bin.ReadVector3());
            }

            count = bin.ReadInt32();
            for (int i = 0; i < count; i++)
            {
                TextureVectors.Add(new RoRsmMeshTextureVertex(bin, version));
            }


            count = bin.ReadInt32();
            for (int i = 0; i < count; i++)
            {
                Surfaces.Add(new RoRsmMeshSurface(bin, version));
            }

            if (version.IsCompatible(1, 5))
            {
                count = bin.ReadInt32();
                for (int i = 0; i < count; i++)
                {
                    PositionFrames.Add(new RoRsmMeshPositionFrame(bin, version));
                }
            }

            count = bin.ReadInt32();
            for (int i = 0; i < count; i++)
            {
                RotationFrames.Add(new RoRsmMeshRotationFrame(bin, version));
            }

            IsValid = true;
        }
Ejemplo n.º 7
0
        protected override bool ReadInternal()
        {
            if (base.ReadInternal() == false)
            {
                return(false);
            }

            // skip Magic Header
            Reader.BaseStream.Position += 4;             // GRSW

            Version = new GenericFileFormatVersion(Reader);

            mIniFile = Reader.ReadWord(40);
            mGndFile = Reader.ReadWord(40);
            if (Version.IsCompatible(1, 4))
            {
                mGatFile = Reader.ReadWord(40);
            }

            mWaterData = new RoRswDataWater(Reader, Version);

            // Unknown Byte Skipping
            if (Version.IsCompatible(1, 4))
            {
                int     i1 = Reader.ReadInt32();             // angle(?) in degrees
                int     i2 = Reader.ReadInt32();             // angle(?) in degrees
                Vector3 v1 = Reader.ReadVector3();           // some sort of Vector3D
                Vector3 v2 = Reader.ReadVector3();           // some sort of Vector3D
            }
            if (Version.IsCompatible(1, 7))
            {
                float f1 = Reader.ReadSingle();
            }
            if (Version.IsCompatible(1, 6))
            {
                int i1 = Reader.ReadInt32();
                int i2 = Reader.ReadInt32();
                int i3 = Reader.ReadInt32();
                int i4 = Reader.ReadInt32();
            }

            // reading Objects
            uint            objCount = Reader.ReadUInt32();
            RoRswDataModel  m;
            RoRswDataLight  l;
            RoRswDataSound  s;
            RoRswDataEffect e;

            //System.Diagnostics.Debug.WriteLine( "reading " + objCount + " Objects from RWS File" );
            for (int i = 0; i < objCount; i++)
            {
                if (Reader.BaseStream.Position + 4 >= Reader.BaseStream.Length)
                {
                    break;
                }

                int objType = Reader.ReadInt32();
                if (objType < 1 || objType > 4)
                {
                    //System.Diagnostics.Debug.WriteLine( "- UNKNOWN Object (" + objType + ") @ " + i );
                    continue;
                }

                // 1 = Model
                // 2 = Light
                // 3 = Sound
                // 4 = Effect
                if (objType == 1)
                {
                    try {
                        //System.Diagnostics.Debug.WriteLine( "- found Model @ Obj " + i );
                        m = new RoRswDataModel(Reader, Version);
                        mModelData.Add(m);
                    } catch {
                        continue;
                    }
                }
                else if (objType == 2)
                {
                    try {
                        //System.Diagnostics.Debug.WriteLine( "- found Light @ Obj " + i );
                        l = new RoRswDataLight(Reader, Version);
                        mLightData.Add(l);
                    } catch {
                        continue;
                    }
                }
                else if (objType == 3)
                {
                    try {
                        //System.Diagnostics.Debug.WriteLine( "- found Sound @ Obj " + i );
                        s = new RoRswDataSound(Reader, Version);
                        mSoundData.Add(s);
                    } catch {
                        continue;
                    }
                }
                else if (objType == 4)
                {
                    try {
                        //System.Diagnostics.Debug.WriteLine( "- found Effect @ Obj " + i );
                        e = new RoRswDataEffect(Reader, Version);
                        mEffectData.Add(e);
                    } catch {
                        continue;
                    }
                }
            }


            return(true);
        }