コード例 #1
0
        private void addGimmicksToMapList(String lgbGroupName, LgbGimmickEntry gim)
        {
            SgbFile thisFile = gim.Gimmick;

            LgbGimmickEntry.HeaderData hdr = gim.Header;
            foreach (var iGroup in thisFile.Data)
            {
                SgbGroup eGroup = iGroup as SgbGroup;
                foreach (var iEntry in eGroup.Entries)
                {
                    SgbModelEntry eEntry = iEntry as SgbModelEntry;
                    if (eEntry != null)
                    {
                        TransformedModel mdl = eEntry.Model;
                        TransformedModel newMdl;

                        Vector3 pos = new Vector3();
                        Vector3 rot = new Vector3();
                        //Scale is not added or multiplied

                        pos.X = mdl.Translation.X + hdr.Translation.X;
                        pos.Y = mdl.Translation.Y + hdr.Translation.Y;
                        pos.Z = mdl.Translation.Z + hdr.Translation.Z;
                        rot.X = mdl.Rotation.X + hdr.Rotation.X;
                        rot.Y = mdl.Rotation.Y + hdr.Rotation.Y;
                        rot.Z = mdl.Rotation.Z + hdr.Rotation.Z;

                        newMdl = new TransformedModel(mdl.Model, pos, rot, mdl.Scale);

                        addToMapList(lgbGroupName, newMdl);
                    }
                }
            }
        }
コード例 #2
0
        private void Build()
        {
            const int CountOffset          = 0x04;
            const int SizeOffset           = 0x08;
            const int BlockPositionsOffset = 0x34;
            const int BlockPositionSize    = 0x04;

            byte[] buffer = File.GetData();

            int blockCount = BitConverter.ToInt32(buffer, CountOffset);
            int blockSize  = BitConverter.ToInt32(buffer, SizeOffset);

            string blockDirectory = File.Path.Substring(0, File.Path.LastIndexOf('/') + 1);

            Parts = new TransformedModel[blockCount];
            for (int i = 0; i < blockCount; ++i)
            {
                string    blockPath      = blockDirectory + string.Format("{0:D4}.mdl", i);
                ModelFile blockModelFile = (ModelFile)File.Pack.Collection.GetFile(blockPath);

                short x = BitConverter.ToInt16(buffer, BlockPositionsOffset + BlockPositionSize * i + 0);
                short z = BitConverter.ToInt16(buffer, BlockPositionsOffset + BlockPositionSize * i + 2);

                Vector3 translation = new Vector3 {
                    X = blockSize * (x + 0.5f),
                    Y = 0,
                    Z = blockSize * (z + 0.5f)
                };
                Parts[i] = new TransformedModel(blockModelFile.GetModelDefinition(), translation, Vector3.Zero, Vector3.One);
            }
        }
コード例 #3
0
        public static MapModelEntry ToMapModelEntry(this TransformedModel t, int modelId)
        {
            //Id
            MapModelEntry m = new MapModelEntry();

            m.modelId = modelId;

            //Translation, rotation, scale
            Transform entryTransform = new Transform();

            entryTransform.translation = new Vector3(t.Translation.X, t.Translation.Y, t.Translation.Z);

            Matrix rotationMatrix = Matrix.Identity *
                                    Matrix.RotationX(t.Rotation.X) *
                                    Matrix.RotationY(t.Rotation.Y) *
                                    Matrix.RotationZ(t.Rotation.Z);
            Quaternion rotationQuaternion = ExtractRotationQuaternion(rotationMatrix);

            entryTransform.rotation = rotationQuaternion;

            entryTransform.scale = new Vector3(t.Scale.X, t.Scale.Y, t.Scale.Z);

            m.transform = entryTransform;
            return(m);
        }
コード例 #4
0
        private void Build()
        {
            const int CountOffset = 0x04;
            const int SizeOffset = 0x08;
            const int BlockPositionsOffset = 0x34;
            const int BlockPositionSize = 0x04;

            var buffer = File.GetData();

            var blockCount = BitConverter.ToInt32(buffer, CountOffset);
            var blockSize = BitConverter.ToInt32(buffer, SizeOffset);

            var blockDirectory = File.Path.Substring(0, File.Path.LastIndexOf('/') + 1);

            Parts = new TransformedModel[blockCount];
            for (var i = 0; i < blockCount; ++i) {
                var blockPath = blockDirectory + string.Format("{0:D4}.mdl", i);
                var blockModelFile = (ModelFile)File.Pack.Collection.GetFile(blockPath);

                var x = BitConverter.ToInt16(buffer, BlockPositionsOffset + BlockPositionSize * i + 0);
                var z = BitConverter.ToInt16(buffer, BlockPositionsOffset + BlockPositionSize * i + 2);

                var translation = new Vector3 {
                    X = blockSize * (x + 0.5f),
                    Y = 0,
                    Z = blockSize * (z + 0.5f)
                };
                Parts[i] = new TransformedModel(blockModelFile.GetModelDefinition(), translation, Vector3.Zero, Vector3.One);
            }
        }
コード例 #5
0
        void ExportSgbFile(String lgbGroup, SgbFile sgbFile, int depth, Vector3 translation, Vector3 rotation, Vector3 scale)
        {
            if (sgbFile == null)
            {
                return;
            }

            bool onec = false;

            addToFileList(sgbFile.File.Path);

            foreach (var sgbGroup in sgbFile.Data.OfType <SgbGroup>())
            {
                //Entry is model
                foreach (var mdl in sgbGroup.Entries.OfType <SgbModelEntry>())
                {
                    addToFileList(mdl.Model.Model.File.Path);

                    TransformedModel tMdl = mdl.Model;
                    TransformedModel newMdl;

                    Vector3 pos = new Vector3();
                    Vector3 rot = new Vector3();

                    pos.X = tMdl.Translation.X + translation.X;
                    pos.Y = tMdl.Translation.Y + translation.Y;
                    pos.Z = tMdl.Translation.Z + translation.Z;
                    rot.X = tMdl.Rotation.X + rotation.X;
                    rot.Y = tMdl.Rotation.Y + rotation.Y;
                    rot.Z = tMdl.Rotation.Z + rotation.Z;

                    newMdl = new TransformedModel(tMdl.Model, pos, rot, tMdl.Scale);

                    addToMapList(lgbGroup, newMdl);
                }

                //Entry is another Sgb
                foreach (var gimmickEntry in sgbGroup.Entries.OfType <SaintCoinach.Graphics.Sgb.SgbGimmickEntry>())
                {
                    addGimmickInfoToMapList(gimmickEntry, depth);
                    ExportSgbFile(lgbGroup, gimmickEntry.Gimmick, depth + 1, gimmickEntry.Header.Translation,
                                  gimmickEntry.Header.Rotation, gimmickEntry.Header.Scale);
                    addHeaderToMapList("GimmickEnd", depth);
                }

                //Entry is Sgb1C
                foreach (var sgb1c in sgbGroup.Entries.OfType <SgbGroup1CEntry>())
                {
                    if (!onec)
                    {
                        addHeaderToMapList("Gimmick1C", depth);
                        ExportSgbFile(lgbGroup, sgb1c.Gimmick, depth + 1, translation,
                                      rotation, scale);
                        addHeaderToMapList("GimmickEnd", depth);
                        onec = true;
                    }
                }
            }
        }
コード例 #6
0
ファイル: DataWriter.cs プロジェクト: takhlaq/FFXIVHousingSim
        /// <summary>
        /// Returns an appropriate HousingExteriorFixtureModel corresponding to this TransformedModel.
        /// </summary>
        /// <param name="t"></param>
        /// <returns></returns>
        private static HousingExteriorFixtureModel ReadTransformedModelForModelInfo(TransformedModel t)
        {
            HousingExteriorFixtureModel thisModel = new HousingExteriorFixtureModel();

            thisModel.modelPath = t.Model.File.Path;
            thisModel.modelName = thisModel.modelPath.Substring(thisModel.modelPath.LastIndexOf('/') + 1);
            thisModel.modelName = Path.GetFileNameWithoutExtension(thisModel.modelName);
            thisModel.numMeshes = t.Model.GetModel(ModelQuality.High).Meshes.Length;
            thisModel.transform = TransformFromVectors(t.Translation, t.Rotation, t.Scale);

            return(thisModel);
        }
コード例 #7
0
ファイル: LgbModelEntry.cs プロジェクト: newb23/FFXIVDeviare
        public LgbModelEntry(IO.PackCollection packs, byte[] buffer, int offset)
        {
            this.Header = buffer.ToStructure <HeaderData>(offset);
            this.Name   = buffer.ReadString(offset + Header.NameOffset);

            var mdlFilePath = buffer.ReadString(offset + Header.ModelFileOffset);

            if (!string.IsNullOrWhiteSpace(mdlFilePath))
            {
                SaintCoinach.Graphics.ModelFile mdlFile = (SaintCoinach.Graphics.ModelFile)packs.GetFile(mdlFilePath);
                this.Model = new TransformedModel(mdlFile.GetModelDefinition(), Header.Translation, Header.Rotation, Header.Scale);
            }
        }
コード例 #8
0
        //Adds the given TransformedModel to the maplist to be written out
        private void addToMapList(String lgbGroupName = null, TransformedModel mdl = null)
        {
            const char sep = ',';

            string path = mdl.Model.File.Path;

            if (lgbGroupName != null)
            {
                maplist.Append(lgbGroupName);
            }

            System.Numerics.Vector3 pos  = new System.Numerics.Vector3();
            System.Numerics.Vector3 rot  = new System.Numerics.Vector3();
            System.Numerics.Vector3 scal = new System.Numerics.Vector3();

            pos.X  = mdl.Translation.X;
            pos.Y  = mdl.Translation.Y;
            pos.Z  = mdl.Translation.Z;
            rot.X  = mdl.Rotation.X;
            rot.Y  = mdl.Rotation.Y;
            rot.Z  = mdl.Rotation.Z;
            scal.X = mdl.Scale.X;
            scal.Y = mdl.Scale.Y;
            scal.Z = mdl.Scale.Z;

            maplist.Append(sep);
            maplist.Append(path + sep);
            maplist.Append(pos.X);
            maplist.Append(sep);
            maplist.Append(pos.Y);
            maplist.Append(sep);
            maplist.Append(pos.Z);
            maplist.Append(sep);
            maplist.Append(rot.X);
            maplist.Append(sep);
            maplist.Append(rot.Y);
            maplist.Append(sep);
            maplist.Append(rot.Z);
            maplist.Append(sep);
            maplist.Append(scal.X);
            maplist.Append(sep);
            maplist.Append(scal.Y);
            maplist.Append(sep);
            maplist.Append(scal.Z);
            maplist.Append(Environment.NewLine);
        }
コード例 #9
0
        public ContentModel(Engine engine, TransformedModel transformedModel, ModelQuality quality) : base(engine)
        {
            this.Parameters = new Data.ParametersBase();
            this.Definition = transformedModel.Model;
            this.Quality    = Quality;
            this.Variant    = new ModelVariantIdentifier {
                ImcVariant = ImcVariant.Default,
                StainKey   = null
            };
            this.Transformation =
                Matrix.Scaling(transformedModel.Scale.ToDx())
                * Matrix.RotationX(transformedModel.Rotation.X)
                * Matrix.RotationY(transformedModel.Rotation.Y)
                * Matrix.RotationZ(transformedModel.Rotation.Z)
                * Matrix.Translation(transformedModel.Translation.ToDx());

            Init();
        }
コード例 #10
0
        public ContentModel(Engine engine, TransformedModel transformedModel, ModelQuality quality)
            : base(engine)
        {
            this.Parameters = new Data.ParametersBase();
            this.Definition = transformedModel.Model;
            this.Quality = Quality;
            this.Variant = new ModelVariantIdentifier {
                ImcVariant = ImcVariant.Default,
                StainKey = null
            };
            this.Transformation =
                Matrix.Scaling(transformedModel.Scale.ToDx())
                * Matrix.RotationX(transformedModel.Rotation.X)
                * Matrix.RotationY(transformedModel.Rotation.Y)
                * Matrix.RotationZ(transformedModel.Rotation.Z)
                * Matrix.Translation(transformedModel.Translation.ToDx());

            Init();
        }
コード例 #11
0
 public ContentModel(Engine engine, TransformedModel transformedModel) : this(engine, transformedModel, ModelQuality.High)
 {
 }
コード例 #12
0
        private void ExportSgbFileUHousing(String desiredHouseID, String lgbGroup, SgbFile sgbFile, int depth, Vector3 translation, Vector3 rotation, Vector3 scale)
        {
            if (sgbFile == null)
            {
                return;
            }

            String housingPattern  = @"bg/ffxiv/(est_e1|sea_s1|fst_f1|wil_w1)/hou/dyna/(.*?)/(0000)/asset/(e1h0|s1h0|f1h0|w1h0)_(.*?)(0000)(\w?).sgb";
            String housingPattern2 = @"bgcommon/hou/dyna/(e1h0|s1h0|f1h0|w1h0)/(.*?)/(0000)/asset/(e1h0|s1h0|f1h0|w1h0)_(.*?)(0000)(\w?).sgb";
            String housingPattern3 = @"bgcommon/hou/dyna/opt/(.*?)/(0000)/asset/opt_(.*?)(0000).sgb";

            //bool onec = false;

            foreach (var sgbGroup in sgbFile.Data.OfType <SgbGroup>())
            {
                //Entry is model
                foreach (var mdl in sgbGroup.Entries.OfType <SgbModelEntry>())
                {
                    addToFileList(mdl.Model.Model.File.Path);

                    TransformedModel tMdl = mdl.Model;
                    TransformedModel newMdl;

                    Vector3 pos = new Vector3();
                    Vector3 rot = new Vector3();

                    pos.X = tMdl.Translation.X + translation.X;
                    pos.Y = tMdl.Translation.Y + translation.Y;
                    pos.Z = tMdl.Translation.Z + translation.Z;
                    rot.X = tMdl.Rotation.X + rotation.X;
                    rot.Y = tMdl.Rotation.Y + rotation.Y;
                    rot.Z = tMdl.Rotation.Z + rotation.Z;

                    newMdl = new TransformedModel(tMdl.Model, pos, rot, tMdl.Scale);

                    addToMapList(lgbGroup, newMdl);
                }

                //Entry is another Sgb
                foreach (var gimmickEntry in sgbGroup.Entries.OfType <SgbGimmickEntry>())
                {
                    //Check against each pattern to turn it into the appropriate path
                    String gimmickFileName = gimmickEntry.Gimmick.File.Path;
                    addToFileList(gimmickFileName);
                    if (Regex.IsMatch(gimmickFileName, housingPattern))
                    {
                        String newGimmickPath = CreateUnitedHouseString(desiredHouseID,
                                                                        Regex.Match(gimmickFileName, housingPattern));
                        SgbFile newGim = null;
                        if (realm.Packs.FileExists(newGimmickPath))
                        {
                            newGim = new SgbFile(realm.Packs.GetFile(newGimmickPath));
                        }
                        if (newGim != null)
                        {
                            ExportSgbFile(lgbGroup, newGim, depth + 1, gimmickEntry.Header.Translation,
                                          gimmickEntry.Header.Rotation, gimmickEntry.Header.Scale);
                        }
                    }
                    else if (Regex.IsMatch(gimmickFileName, housingPattern2))
                    {
                        String newGimmickPath = CreateUnitedHouseString(desiredHouseID,
                                                                        Regex.Match(gimmickFileName, housingPattern2));
                        SgbFile newGim = null;
                        if (realm.Packs.FileExists(newGimmickPath))
                        {
                            newGim = new SgbFile(realm.Packs.GetFile(newGimmickPath));
                        }
                        if (newGim != null)
                        {
                            ExportSgbFile(lgbGroup, newGim, depth + 1, gimmickEntry.Header.Translation,
                                          gimmickEntry.Header.Rotation, gimmickEntry.Header.Scale);
                        }
                    }
                    else if (Regex.IsMatch(gimmickFileName, housingPattern3))
                    {
                        String newGimmickPath = CreateUnitedHouseString(desiredHouseID,
                                                                        Regex.Match(gimmickFileName, housingPattern3));
                        SgbFile newGim = null;
                        if (realm.Packs.FileExists(newGimmickPath))
                        {
                            newGim = new SgbFile(realm.Packs.GetFile(newGimmickPath));
                        }
                        if (newGim != null)
                        {
                            ExportSgbFile(lgbGroup, newGim, depth + 1, gimmickEntry.Header.Translation,
                                          gimmickEntry.Header.Rotation, gimmickEntry.Header.Scale);
                        }
                    }
                    else
                    {
                        addGimmickInfoToMapList(gimmickEntry, depth);
                        ExportSgbFileUHousing(desiredHouseID, lgbGroup, gimmickEntry.Gimmick, depth + 1, gimmickEntry.Header.Translation,
                                              gimmickEntry.Header.Rotation, gimmickEntry.Header.Scale);
                        addHeaderToMapList("GimmickEnd", depth);
                    }
                }

                //Entry is Sgb1C
//                foreach (var sgb1c in sgbGroup.Entries.OfType<SgbGroup1CEntry>())
//                {
//                    if (!onec)
//                    {
//                        addHeaderToMapList("Gimmick1C", depth);
//                        ExportSgbFile(lgbGroup, sgb1c.Gimmick, depth + 1, translation,
//                            rotation, scale);
//                        addHeaderToMapList("GimmickEnd", depth);
//                        onec = true;
//                    }
//                }
            }
        }
コード例 #13
0
 public ContentModel(Engine engine, TransformedModel transformedModel)
     : this(engine, transformedModel, ModelQuality.High)
 {
 }