Exemplo n.º 1
0
        void convertRawFile(string pModelFilename)
        {
            string filename = iSrcDir + pModelFilename;

            WorldModel_Raw raw_model = new WorldModel_Raw();

            if (!raw_model.Read(filename))
            {
                return;
            }

            // write WorldModel
            WorldModel model = new WorldModel();

            model.setRootWmoID(raw_model.RootWMOID);
            if (!raw_model.groupsArray.Empty())
            {
                List <GroupModel> groupsArray = new List <GroupModel>();

                int groups = raw_model.groupsArray.Length;
                for (uint g = 0; g < groups; ++g)
                {
                    GroupModel_Raw raw_group  = raw_model.groupsArray[g];
                    var            groupModel = new GroupModel(raw_group.mogpflags, raw_group.GroupWMOID, raw_group.bounds);
                    groupModel.SetMeshData(raw_group.vertexArray, raw_group.triangles.ToList());
                    groupModel.SetLiquidData(raw_group.liquid);
                    groupsArray.Add(groupModel);
                }

                model.setGroupModels(groupsArray);
            }

            model.writeFile(iDestDir + "/" + pModelFilename + ".vmo");
        }
Exemplo n.º 2
0
        public bool Read(string path)
        {
            if (!File.Exists(path))
            {
                Console.WriteLine($"ERROR: Can't open raw model file: {path}");
                return(false);
            }

            using (BinaryReader binaryReader = new BinaryReader(File.Open(path, FileMode.Open, FileAccess.Read, FileShare.Read)))
            {
                string vmapMagic = binaryReader.ReadCString();
                if (vmapMagic != SharedConst.RAW_VMAP_MAGIC)
                {
                    Console.WriteLine($"Error: {vmapMagic} != {SharedConst.RAW_VMAP_MAGIC}");
                    return(false);
                }

                // we have to read one int. This is needed during the export and we have to skip it here
                uint tempNVectors = binaryReader.ReadUInt32();

                uint groups = binaryReader.ReadUInt32();
                RootWMOID = binaryReader.ReadUInt32();

                bool succeed = true;
                groupsArray = new GroupModel_Raw[groups];
                for (uint g = 0; g < groups && succeed; ++g)
                {
                    groupsArray[g] = new GroupModel_Raw();
                    succeed        = groupsArray[g].Read(binaryReader);
                }

                return(succeed);
            }
        }
Exemplo n.º 3
0
        void ConvertRawFile(string pModelFilename)
        {
            string filename = sourceDirectory + pModelFilename;

            WorldModel_Raw raw_model = new();

            if (!raw_model.Read(filename))
            {
                return;
            }

            // write WorldModel
            WorldModel model = new();

            model.setRootWmoID(raw_model.RootWMOID);
            if (!raw_model.groupsArray.Empty())
            {
                List <GroupModel> groupsArray = new();

                int groups = raw_model.groupsArray.Length;
                for (uint g = 0; g < groups; ++g)
                {
                    GroupModel_Raw raw_group  = raw_model.groupsArray[g];
                    var            groupModel = new GroupModel(raw_group.mogpflags, raw_group.GroupWMOID, raw_group.bounds);
                    groupModel.SetMeshData(raw_group.vertexArray, raw_group.triangles.ToList());
                    groupModel.SetLiquidData(raw_group.liquid);
                    groupsArray.Add(groupModel);
                }

                model.setGroupModels(groupsArray);
            }

            if (!pModelFilename.Contains('\0'))
            {
                pModelFilename += ".vmo";
            }

            model.writeFile(destinationDirectory + "/" + pModelFilename);
        }