Represents a model list texture file.
Exemple #1
0
        /// <summary>
        /// Loads the file from the specified stream.
        /// </summary>
        /// <param name="stream">The stream to read from.</param>
        public override void Load(Stream stream)
        {
            BinaryReader reader = new BinaryReader(stream, Encoding.GetEncoding("EUC-KR"));

            short modelFileCount = reader.ReadInt16();

            for (int i = 0; i < modelFileCount; i++) {
                string modelFile = reader.ReadNullTerminatedString();

                ModelFiles.Add(modelFile);
            }

            short textureFileCount = reader.ReadInt16();

            for (int i = 0; i < textureFileCount; i++) {
                TextureFile texture = new TextureFile();
                texture.FilePath = reader.ReadNullTerminatedString();
                texture.UseSkinShader = reader.ReadInt16() != 0;
                texture.AlphaEnabled = reader.ReadInt16() != 0;
                texture.TwoSided = reader.ReadInt16() != 0;
                texture.AlphaTestEnabled = reader.ReadInt16() != 0;
                texture.AlphaReference = reader.ReadInt16();
                texture.DepthTestEnabled = reader.ReadInt16() != 0;
                texture.DepthWriteEnabled = reader.ReadInt16() != 0;
                texture.BlendType = (BlendType)reader.ReadInt16();
                texture.UseSpecularShader = reader.ReadInt16() != 0;
                texture.Alpha = reader.ReadSingle();
                texture.GlowType = (GlowType)reader.ReadInt16();
                texture.GlowColour = reader.ReadColour3();

                TextureFiles.Add(texture);
            }

            short effectFileCount = reader.ReadInt16();

            for (int i = 0; i < effectFileCount; i++) {
                string effectFile = reader.ReadNullTerminatedString();

                EffectFiles.Add(effectFile);
            }

            short objectCount = reader.ReadInt16();

            for (int i = 0; i < objectCount; i++) {
                ModelListObject @object = new ModelListObject();

                int cylinderRadius = reader.ReadInt32();
                @object.BoundingCylinder = new BoundingCylinder(new Vector2(reader.ReadInt32(), reader.ReadInt32()), cylinderRadius);

                int partCount = reader.ReadInt16();

                if (partCount > 0) {
                    for (int j = 0; j < partCount; j++) {
                        ModelListPart part = new ModelListPart();
                        part.Model = reader.ReadInt16();
                        part.Texture = reader.ReadInt16();

                        byte propertyType = 0;

                        while ((propertyType = reader.ReadByte()) != 0) {
                            byte size = reader.ReadByte();

                            switch ((ModelListPropertyType)propertyType) {
                                case ModelListPropertyType.Position:
                                    part.Position = reader.ReadVector3();
                                    break;
                                case ModelListPropertyType.Rotation:
                                    part.Rotation = reader.ReadQuaternion(true);
                                    break;
                                case ModelListPropertyType.Scale:
                                    part.Scale = reader.ReadVector3();
                                    break;
                                case ModelListPropertyType.AxisRotation:
                                    part.AxisRotation = reader.ReadQuaternion(true);
                                    break;
                                case ModelListPropertyType.Parent:
                                    part.Parent = reader.ReadInt16();
                                    break;
                                case ModelListPropertyType.Collision:
                                    part.Collision = (CollisionType)reader.ReadInt16();
                                    break;
                                case ModelListPropertyType.ConstantAnimation:
                                    part.AnimationFilePath = reader.ReadString(size);
                                    break;
                                case ModelListPropertyType.VisibleRangeSet:
                                    part.VisibleRangeSet = reader.ReadInt16();
                                    break;
                                case ModelListPropertyType.UseLightmap:
                                    part.UseLightmap = reader.ReadInt16() != 0;
                                    break;
                                case ModelListPropertyType.BoneIndex:
                                    part.BoneIndex = reader.ReadInt16();
                                    break;
                                case ModelListPropertyType.DummyIndex:
                                    part.DummyIndex = reader.ReadInt16();
                                    break;
                                default:
                                    if (propertyType >= (int)ModelListPropertyType.Animation && propertyType < (int)ModelListPropertyType.Animation + ModelListPart.ANIMATION_COUNT) {
                                        propertyType -= (int)ModelListPropertyType.Animation;

                                        if (propertyType < ModelListPart.MONSTER_ANIMATION_COUNT) {
                                            part.MonsterAnimations[propertyType] = reader.ReadString(size);
                                        } else {
                                            propertyType -= ModelListPart.MONSTER_ANIMATION_COUNT;
                                            part.AvatarAnimations[propertyType] = reader.ReadString(size);
                                        }
                                    } else {
                                        stream.Seek(size, SeekOrigin.Current);
                                    }
                                    break;
                            }
                        }

                        @object.Parts.Add(part);
                    }

                    int effectCount = reader.ReadInt16();

                    for (int j = 0; j < effectCount; j++) {
                        ModelListEffect effect = new ModelListEffect();
                        effect.EffectType = (EffectType)reader.ReadInt16();
                        effect.Effect = reader.ReadInt16();

                        byte propertyType = 0;

                        while ((propertyType = reader.ReadByte()) != 0) {
                            byte size = reader.ReadByte();

                            switch ((ModelListPropertyType)propertyType) {
                                case ModelListPropertyType.Position:
                                    effect.Position = reader.ReadVector3();
                                    break;
                                case ModelListPropertyType.Rotation:
                                    effect.Rotation = reader.ReadQuaternion(true);
                                    break;
                                case ModelListPropertyType.Scale:
                                    effect.Scale = reader.ReadVector3();
                                    break;
                                case ModelListPropertyType.Parent:
                                    effect.Parent = reader.ReadInt16();
                                    break;
                                default:
                                    stream.Seek(size, SeekOrigin.Current);
                                    break;
                            }
                        }

                        @object.Effects.Add(effect);
                    }

                    @object.BoundingBox = new BoundingBox(reader.ReadVector3(), reader.ReadVector3());
                }

                Objects.Add(@object);
            }
        }
Exemple #2
0
        /// <summary>
        /// Loads the file from the specified stream.
        /// </summary>
        /// <param name="stream">The stream to read from.</param>
        public override void Load(Stream stream)
        {
            BinaryReader reader = new BinaryReader(stream, Encoding.GetEncoding("EUC-KR"));

            short modelFileCount = reader.ReadInt16();

            for (int i = 0; i < modelFileCount; i++)
            {
                string modelFile = reader.ReadNullTerminatedString();

                ModelFiles.Add(modelFile);
            }

            short textureFileCount = reader.ReadInt16();

            for (int i = 0; i < textureFileCount; i++)
            {
                TextureFile texture = new TextureFile();
                texture.FilePath          = reader.ReadNullTerminatedString();
                texture.UseSkinShader     = reader.ReadInt16() != 0;
                texture.AlphaEnabled      = reader.ReadInt16() != 0;
                texture.TwoSided          = reader.ReadInt16() != 0;
                texture.AlphaTestEnabled  = reader.ReadInt16() != 0;
                texture.AlphaReference    = reader.ReadInt16();
                texture.DepthTestEnabled  = reader.ReadInt16() != 0;
                texture.DepthWriteEnabled = reader.ReadInt16() != 0;
                texture.BlendType         = (BlendType)reader.ReadInt16();
                texture.UseSpecularShader = reader.ReadInt16() != 0;
                texture.Alpha             = reader.ReadSingle();
                texture.GlowType          = (GlowType)reader.ReadInt16();
                texture.GlowColour        = reader.ReadColour3();

                TextureFiles.Add(texture);
            }

            short effectFileCount = reader.ReadInt16();

            for (int i = 0; i < effectFileCount; i++)
            {
                string effectFile = reader.ReadNullTerminatedString();

                EffectFiles.Add(effectFile);
            }

            short objectCount = reader.ReadInt16();

            for (int i = 0; i < objectCount; i++)
            {
                ModelListObject @object = new ModelListObject();

                int cylinderRadius = reader.ReadInt32();
                @object.BoundingCylinder = new BoundingCylinder(new Vector2(reader.ReadInt32(), reader.ReadInt32()), cylinderRadius);

                int partCount = reader.ReadInt16();

                if (partCount > 0)
                {
                    for (int j = 0; j < partCount; j++)
                    {
                        ModelListPart part = new ModelListPart();
                        part.Model   = reader.ReadInt16();
                        part.Texture = reader.ReadInt16();

                        byte propertyType = 0;

                        while ((propertyType = reader.ReadByte()) != 0)
                        {
                            byte size = reader.ReadByte();

                            switch ((ModelListPropertyType)propertyType)
                            {
                            case ModelListPropertyType.Position:
                                part.Position = reader.ReadVector3();
                                break;

                            case ModelListPropertyType.Rotation:
                                part.Rotation = reader.ReadQuaternion(true);
                                break;

                            case ModelListPropertyType.Scale:
                                part.Scale = reader.ReadVector3();
                                break;

                            case ModelListPropertyType.AxisRotation:
                                part.AxisRotation = reader.ReadQuaternion(true);
                                break;

                            case ModelListPropertyType.Parent:
                                part.Parent = reader.ReadInt16();
                                break;

                            case ModelListPropertyType.Collision:
                                part.Collision = (CollisionType)reader.ReadInt16();
                                break;

                            case ModelListPropertyType.ConstantAnimation:
                                part.AnimationFilePath = reader.ReadString(size);
                                break;

                            case ModelListPropertyType.VisibleRangeSet:
                                part.VisibleRangeSet = reader.ReadInt16();
                                break;

                            case ModelListPropertyType.UseLightmap:
                                part.UseLightmap = reader.ReadInt16() != 0;
                                break;

                            case ModelListPropertyType.BoneIndex:
                                part.BoneIndex = reader.ReadInt16();
                                break;

                            case ModelListPropertyType.DummyIndex:
                                part.DummyIndex = reader.ReadInt16();
                                break;

                            default:
                                if (propertyType >= (int)ModelListPropertyType.Animation && propertyType < (int)ModelListPropertyType.Animation + ModelListPart.ANIMATION_COUNT)
                                {
                                    propertyType -= (int)ModelListPropertyType.Animation;

                                    if (propertyType < ModelListPart.MONSTER_ANIMATION_COUNT)
                                    {
                                        part.MonsterAnimations[propertyType] = reader.ReadString(size);
                                    }
                                    else
                                    {
                                        propertyType -= ModelListPart.MONSTER_ANIMATION_COUNT;
                                        part.AvatarAnimations[propertyType] = reader.ReadString(size);
                                    }
                                }
                                else
                                {
                                    stream.Seek(size, SeekOrigin.Current);
                                }
                                break;
                            }
                        }

                        @object.Parts.Add(part);
                    }

                    int effectCount = reader.ReadInt16();

                    for (int j = 0; j < effectCount; j++)
                    {
                        ModelListEffect effect = new ModelListEffect();
                        effect.EffectType = (EffectType)reader.ReadInt16();
                        effect.Effect     = reader.ReadInt16();

                        byte propertyType = 0;

                        while ((propertyType = reader.ReadByte()) != 0)
                        {
                            byte size = reader.ReadByte();

                            switch ((ModelListPropertyType)propertyType)
                            {
                            case ModelListPropertyType.Position:
                                effect.Position = reader.ReadVector3();
                                break;

                            case ModelListPropertyType.Rotation:
                                effect.Rotation = reader.ReadQuaternion(true);
                                break;

                            case ModelListPropertyType.Scale:
                                effect.Scale = reader.ReadVector3();
                                break;

                            case ModelListPropertyType.Parent:
                                effect.Parent = reader.ReadInt16();
                                break;

                            default:
                                stream.Seek(size, SeekOrigin.Current);
                                break;
                            }
                        }

                        @object.Effects.Add(effect);
                    }

                    @object.BoundingBox = new BoundingBox(reader.ReadVector3(), reader.ReadVector3());
                }

                Objects.Add(@object);
            }
        }