Beispiel #1
0
        public bool Load(string FileName)
        {
            try
            {
                FileStream   fileStream = File.OpenRead(FileName);
                BinaryReader br         = new BinaryReader(fileStream, koreanEncoding);

                bh = new BinaryHelper(br);

                try
                {
                    FormatString = koreanEncoding.GetString(br.ReadBytes(4));

                    uint DataOffset = bh.ReadDWord();
                    uint RowCount   = bh.ReadDWord();
                    uint FieldCount = bh.ReadDWord();
                    uint UnknownDW  = bh.ReadDWord();

                    CellData = new string[RowCount, FieldCount];

                    for (int i = 0; i < FieldCount; i++)
                    {
                        ColumnWidth.Add(bh.ReadWord());
                    }

                    for (int i = 0; i < FieldCount; i++)
                    {
                        ColumnHeader.Add(bh.ReadWString());
                    }

                    IDColumnName = bh.ReadWString();

                    for (int i = 0; i < RowCount; i++)
                    {
                        RowData.Add(bh.ReadWString());
                    }

                    for (int rowID = 0; rowID < RowCount; rowID++)
                    {
                        for (int colID = 0; colID < FieldCount; colID++)
                        {
                            string sdata = bh.ReadWString();
                            CellData[rowID, colID] = sdata;
                        }
                    }
                }
                finally
                {
                    br.Close();
                    fileStream.Close();
                }
            }
            catch (Exception)
            {
                return(false);
            }
            return(true);
        }
Beispiel #2
0
        public bool Load(string FileName)
        {
            try
            {
                FileStream fileStream = File.OpenRead(FileName);
                br = new BinaryReader(fileStream, koreanEncoding);
                bh = new BinaryHelper(br);

                try
                {
                    uint skeleton_count = bh.ReadWord();
                    for (int skeltonID = 0; skeltonID < skeleton_count; skeltonID++)
                    {
                        Skeleton.Add(bh.ReadZString());
                    }

                    uint animation_count = bh.ReadWord();
                    for (int animationID = 0; animationID < animation_count; animationID++)
                    {
                        Animation.Add(bh.ReadZString());
                    }

                    uint effect_count = bh.ReadWord();
                    for (int effectID = 0; effectID < effect_count; effectID++)
                    {
                        Effect.Add(bh.ReadZString());
                    }

                    uint char_count = bh.ReadWord();
                    for (int charID = 0; charID < char_count; charID++)
                    {
                        CHRCharacter chr = new CHRCharacter();
                        chr.isActive = (br.ReadByte() != 0);

                        if (chr.isActive)
                        {
                            chr.SkeletonID = bh.ReadWord();
                            chr.Name       = bh.ReadZString();

                            for (int modelID = 0; modelID < bh.ReadWord(); modelID++)
                            {
                                chr.Model.Add(bh.ReadWord());
                            }

                            for (int charanimID = 0; charanimID < bh.ReadWord(); charanimID++)
                            {
                                chr.Animation.Add(new CHRAnimation()
                                {
                                    Type = bh.ReadWord(),
                                    ID   = bh.ReadWord()
                                });
                            }

                            for (int chareffectID = 0; chareffectID < bh.ReadWord(); chareffectID++)
                            {
                                chr.Effect.Add(new CHREffect()
                                {
                                    BoneID   = bh.ReadWord(),
                                    EffectID = bh.ReadWord()
                                });
                            }
                        } // isActive
                        Character.Add(chr);
                    }     // for char
                }         // tryf
                finally
                {
                    br.Close();
                    fileStream.Close();
                }
            }
            catch (Exception)
            {
                return(false);
            }
            return(true);
        }
Beispiel #3
0
        private ZSCPart ReadPart()
        {
            uint transFlags = ZSC_TRANSITION_NONE;

            ZSCPart part = new ZSCPart
            {
                MeshID     = bh.ReadWord(),
                MaterialID = bh.ReadWord()
            };

            while (true)
            {
                byte IDFlag = br.ReadByte();
                if (IDFlag == 0)
                {
                    break;
                }
                byte size = br.ReadByte();
                switch (IDFlag)
                {
                case ZSC_PART_POSITION:     // $01 - Size $0C (12)
                    part.Position = bh.ReadVector3f() * 0.01f;
                    transFlags    = transFlags | ZSC_TRANSITION_TRANSLATE;
                    break;

                case ZSC_PART_ROTATION:     // $02 - Size $10 (16)
                    part.Rotation = bh.ReadQuaternion();
                    transFlags    = transFlags | ZSC_TRANSITION_ROTATE;
                    break;

                case ZSC_PART_SCALE:     // $03 - Size $0C (12)
                    part.Scale = bh.ReadVector3f();
                    transFlags = transFlags | ZSC_TRANSITION_SCALE;
                    break;

                case ZSC_PART_AXISROTATION:     // $04 - Size $0C (12)
                    part.AxisRotation = bh.ReadQuaternion();
                    break;

                case ZSC_PART_BONEINDEX:     // $05 - Size $02 (02)
                    part.BoneID = (int)bh.ReadWord();
                    break;

                case ZSC_PART_DUMMYINDEX:     // $06 - Size $02 (02)
                    part.DummyID = (int)bh.ReadWord();
                    break;

                case ZSC_PART_PARENT:     // $07 - Size $02 (02)
                    part.ParentID = (int)bh.ReadWord();
                    break;

                case ZSC_PART_COLLISION:     // $1D - Size $02 (02)
                    part.CollisionType = bh.ReadWord();
                    break;

                case ZSC_PART_ZMOPATH:     // $1E (30)
                    byte[] bs = br.ReadBytes(size);
                    part.ZMOPath = koreanEncoding.GetString(bs);
                    break;

                case ZSC_PART_RANGEMODE:     // $1F - Size $02 (02)
                    part.RangeMode = bh.ReadWord();
                    break;

                case ZSC_PART_LIGHTMAPMODE:     // $20 - Size $02 (02)
                    part.UseLightmap = bh.ReadWord();
                    break;

                default:
                    br.ReadBytes(size);
                    break;
                } // switch case
            }
            ;

            part.TransformMatrix = Matrix4.IDENTITY;

            if ((transFlags & ZSC_TRANSITION_ROTATE) != 0)
            {
                part.TransformMatrix = new Matrix4(part.Rotation.ToRotationMatrix());
            }

            if ((transFlags & ZSC_TRANSITION_SCALE) != 0)
            {
                part.TransformMatrix.SetScale(part.Scale);
            }

            if ((transFlags & ZSC_TRANSITION_TRANSLATE) != 0)
            {
                part.TransformMatrix.SetTrans(part.Position);
            }
            return(part);
        } // Read PART
Beispiel #4
0
        public bool Load(string FileName)
        {
            try
            {
                FileStream fileStream = File.OpenRead(FileName);
                br = new BinaryReader(fileStream, koreanEncoding);
                bh = new BinaryHelper(br);

                try
                {
                    MeshCount = bh.ReadWord();
                    for (int meshID = 0; meshID < MeshCount; meshID++)
                    {
                        MeshName.Add(bh.ReadZString());
                    }

                    MaterialCount = bh.ReadWord();
                    for (int materialID = 0; materialID < MaterialCount; materialID++)
                    {
                        ZSCMaterial mat = new ZSCMaterial();
                        mat.Path = bh.ReadZString();
                        br.ReadBytes(2); // Skip 2 bytes!
                        mat.UseAlpha    = (bh.ReadWord() > 0);
                        mat.DoubleSided = (bh.ReadWord() > 0);
                        mat.AlphaTest   = bh.ReadWord();
                        mat.AlphaRef    = (bh.ReadWord() / 256.0f);
                        mat.zTest       = (bh.ReadWord() > 0);
                        mat.zWrite      = (bh.ReadWord() > 0);
                        mat.BlendType   = bh.ReadWord();
                        mat.Specular    = bh.ReadWord();
                        mat.Alpha       = br.ReadSingle();
                        mat.GlowType    = bh.ReadWord();
                        mat.r           = br.ReadSingle();
                        mat.g           = br.ReadSingle();
                        mat.b           = br.ReadSingle();
                        Material.Add(mat);
                    }

                    uint effectsNames_count = bh.ReadWord();
                    for (int effID = 0; effID < effectsNames_count; effID++)
                    {
                        EffectName.Add(bh.ReadZString());
                    }

                    uint models_count = bh.ReadWord();
                    for (int modID = 0; modID < models_count; modID++)
                    {
                        ZSCModel model = new ZSCModel();
                        model.BBRadius = bh.ReadDWord();
                        model.BBX      = bh.ReadDWord();
                        model.BBY      = bh.ReadDWord();

                        uint parts_count = bh.ReadWord();
                        if (parts_count > 0)
                        {
                            // PARTS
                            for (int jparts = 0; jparts < parts_count; jparts++)
                            {
                                ZSCPart part = ReadPart();
                                if (jparts == 0)
                                {
                                    part.ParentID = -1;
                                }
                                model.Part.Add(part);
                            } // parts

                            // EFFECTS
                            uint effects_count = bh.ReadWord();
                            for (int jeffects = 0; jeffects < effects_count; jeffects++)
                            {
                                ZSCEffect effect = ReadEffect();
                                model.Effect.Add(effect);
                            }
                        } // if > 0
                        else
                        {
                            Model.Add(model);
                            continue;
                        }

                        model.BBoxMin = bh.ReadVector3f() * 0.01f;
                        model.BBoxMax = bh.ReadVector3f() * 0.01f;
                        Model.Add(model);
                    }
                }
                finally
                {
                    br.Close();
                    fileStream.Close();
                }
            }
            catch (Exception)
            {
                return(false);
            }
            return(true);
        }