コード例 #1
0
ファイル: remReplace.cs プロジェクト: hejob/SB3Utility
        public static remMaterial CreateMaterial(ImportedMaterial impMat)
        {
            remMaterial remMat = new remMaterial();
            remMat.name = new remId(impMat.Name);
            remMat.diffuse = new Color3(impMat.Diffuse.Red, impMat.Diffuse.Green, impMat.Diffuse.Blue);
            remMat.ambient = new Color3(impMat.Ambient.Red, impMat.Ambient.Green, impMat.Ambient.Blue);
            remMat.specular = new Color3(impMat.Specular.Red, impMat.Specular.Green, impMat.Specular.Blue);
            remMat.emissive = new Color3(impMat.Emissive.Red, impMat.Emissive.Green, impMat.Emissive.Blue);
            remMat.specularPower = (int)impMat.Power;
            remMat.texture = new remId(impMat.Textures[0]);

            return remMat;
        }
コード例 #2
0
ファイル: remEditor.cs プロジェクト: hejob/SB3Utility
        public void MergeMaterial(remMaterial mat)
        {
            var newMat = mat.Clone();

            bool found = false;
            for (int i = 0; i < Parser.MATC.Count; i++)
            {
                var oldMat = Parser.MATC[i];
                if (oldMat.name == newMat.name)
                {
                    Parser.MATC.ChildList.RemoveAt(i);
                    Parser.MATC.ChildList.Insert(i, newMat);
                    found = true;
                    break;
                }
            }

            if (!found)
            {
                Parser.MATC.AddChild(newMat);
            }
            InitTextures(false, false);
        }
コード例 #3
0
ファイル: REMParser.cs プロジェクト: hejob/SB3Utility
        private static remMATCsection ReadMaterials(string sectionName, int sectionLength, int numMaterials, byte[] sectionBuffer)
        {
            remMATCsection matSec = new remMATCsection(numMaterials);
            int secBufIdx = 0;
            for (int subSection = 0; subSection < numMaterials; subSection++)
            {
                byte[] type = new byte[4] { sectionBuffer[secBufIdx+0], sectionBuffer[secBufIdx+1], sectionBuffer[secBufIdx+2], sectionBuffer[secBufIdx+3] };
                int length = BitConverter.ToInt32(sectionBuffer, secBufIdx+4);

                remMaterial mat = new remMaterial();
                Trace.Assert(TypeCheck(remMaterial.ClassType, type));
                mat.name = GetIdentifier(sectionBuffer, secBufIdx+8);

                for (int i = 0; i < mat.properties.Length; i++)
                    mat[i] = BitConverter.ToSingle(sectionBuffer, secBufIdx+8+256 + i*4);
                mat.specularPower = BitConverter.ToInt32(sectionBuffer, secBufIdx+8+256+12*4);
                mat.unk_or_flag = BitConverter.ToInt32(sectionBuffer, secBufIdx+8+256+12*4+4);
                mat.unknown = GetIdentifier(sectionBuffer, secBufIdx+8+256+12*4+4+4);

                if (length >= 0x240+256)
                    mat.texture = GetIdentifier(sectionBuffer, secBufIdx+0x240);

                matSec.AddChild(mat);

                secBufIdx += length;
            }
            if (secBufIdx != sectionLength)
                Report.ReportLog("Warning! MATC section has wrong length.");
            return matSec;
        }