示例#1
0
        private bool associatePaletteMaterialToAtr()
        {
            foreach (var palette in this.palettes)
            {
                var nameCategory = palette.Key;
                var mapAtrs      = palette.Value;
                foreach (var mapAtr in mapAtrs)
                {
                    if (!(mapAtr.Value is DoGAAtrPaletteMaterial))
                    {
                        continue;
                    }
                    var paletteMaterial = mapAtr.Value as DoGAAtrPaletteMaterial;
                    var nameAtrInSuf    = mapAtr.Key;

                    var atr = new DoGAAtr(nameAtrInSuf, this.pathAtr);
                    atr.setColor("amb", new Rgb(paletteMaterial.valAmb, paletteMaterial.valAmb, paletteMaterial.valAmb));
                    atr.setColor("dif", new Rgb(paletteMaterial.valDif, paletteMaterial.valDif, paletteMaterial.valDif));
                    atr.setColor("tra", new Rgb(paletteMaterial.valTra, paletteMaterial.valTra, paletteMaterial.valTra));
                    atr.setColor("ref", new Rgb(paletteMaterial.valRef, paletteMaterial.valRef, paletteMaterial.valRef));
                    atr.setColor("spc", new Rgb(paletteMaterial.valSp1, paletteMaterial.valSp1, paletteMaterial.valSp1));
                    atr.setColor("spcsize", new Rgb(paletteMaterial.valSp2, paletteMaterial.valSp2, paletteMaterial.valSp2));
                    atr.spcH = paletteMaterial.valSp3;

                    mapAtr.Value.atr = atr;
                }
            }

            return(true);
        }
示例#2
0
        private bool associatePaletteFileImageToAtr()
        {
            foreach (var palette in this.palettes)
            {
                var nameCategory = palette.Key;
                var mapAtrs      = palette.Value;
                foreach (var mapAtr in mapAtrs)
                {
                    if (!(mapAtr.Value is DoGAAtrPaletteFileImage))
                    {
                        continue;
                    }
                    var paletteFileImage = mapAtr.Value as DoGAAtrPaletteFileImage;
                    var nameAtrInSuf     = mapAtr.Key;
                    var nameFileImage    = paletteFileImage.nameFileImage;
                    if (nameFileImage == null)
                    {
                        continue;
                    }

                    var atr = new DoGAAtr(nameAtrInSuf, this.pathAtr);
                    atr.addInfoTexture("colormap", new TextureInfo("colormap", nameFileImage, 0.0f, 1.0f));

                    mapAtr.Value.atr = atr;
                }
            }

            return(true);
        }
示例#3
0
        public DoGAAtr getAtrFromPalette(string nameAtrInSuf, string nameAtrColor, string nameAtrTexture, string nameAtrMaterial,
                                         Dictionary <string, DoGAAtr> atrsInPartsAssembler = null)
        {
            DoGAAtr atr = null;

            if (this.atrsGenie.ContainsKey(nameAtrInSuf.ToLower()))
            {
                atr = this.atrsGenie[nameAtrInSuf.ToLower()].CloneDeep();
            }
            else
            {
                atr = new DoGAAtr(nameAtrInSuf, this.pathAtr);
            }

            if (!this.doesUsePalette(nameAtrInSuf))
            {
                return(atr);
            }

            // If atr found in L3 attribute, use it and ignore palette.
            if (atrsInPartsAssembler != null && nameAtrColor != null && atrsInPartsAssembler.ContainsKey(nameAtrColor))
            {
                atr.clearTexture();
                atr.merge(atrsInPartsAssembler[nameAtrColor]);
                return(atr);
            }

            var atrRet = this.mergeAtrFromPalette(atr, nameAtrColor, nameAtrTexture, nameAtrMaterial);

            return(atrRet);
        }
示例#4
0
        public void merge(DoGAAtr atr)
        {
            this.path = atr.path;
            this.pathsTexture.Add(atr.path);

            foreach (var typeColor in atr.colors.Keys)
            {
                if (this.colors.ContainsKey(typeColor))
                {
                    this.multiplyColor(typeColor, atr.colors[typeColor]);
                }
                else
                {
                    this.colors.Add(typeColor, atr.colors[typeColor].CloneDeep());
                }
            }
            if (atr.spcH != null)
            {
                this.spcH = atr.spcH;
            }

            foreach (var typeMap in atr.textures.Keys)
            {
                if (this.textures.ContainsKey(typeMap))
                {
                    this.textures[typeMap] = atr.textures[typeMap].CloneDeep();
                }
                else
                {
                    this.textures.Add(typeMap, atr.textures[typeMap].CloneDeep());
                }
            }
            this.option.merge(atr.option);
        }
示例#5
0
 public List <TextureInfo> getInfoTexture(string typeMap)
 {
     Debug.Assert(DoGAAtr.getIsValidNameTypeMap(typeMap));
     if (!this.getHasInfoTexture(typeMap))
     {
         return(null);
     }
     return(this.textures[typeMap]);
 }
示例#6
0
 public Rgb getColor(string typeColor)
 {
     Debug.Assert(DoGAAtr.getIsValidNameTypeColor(typeColor));
     if (!this.getHasColor(typeColor))
     {
         return(null);
     }
     return(this.colors[typeColor]);
 }
示例#7
0
 public Range <Vec2> getRangeMap(string typeRange)
 {
     Debug.Assert(DoGAAtr.getIsValidNameTypeRangeMap(typeRange));
     if (!this.getHasRangeMap(typeRange))
     {
         return(null);
     }
     return(this.mapRanges[typeRange]);
 }
示例#8
0
 public void setRangeMap(string typeRange, Range <Vec2> range)
 {
     Debug.Assert(DoGAAtr.getIsValidNameTypeRangeMap(typeRange));
     if (this.getHasRangeMap(typeRange))
     {
         this.mapRanges[typeRange] = range;
     }
     else
     {
         this.mapRanges.Add(typeRange, range);
     }
 }
示例#9
0
        public override object VisitOnAtr(DoGAE1PParser.OnAtrContext context)
        {
            var nameAtr = StringUtil.stripQuote(context.name.Text.ToLower());

            this.atr = new DoGAAtr(nameAtr, this.path);
            var result = base.VisitOnAtr(context);

            this.mapAtrsPalette.Add(nameAtr, this.atr);
            this.atr = null;

            return(result);
        }
示例#10
0
 public void setColor(string typeColor, Rgb rgb)
 {
     Debug.Assert(DoGAAtr.getIsValidNameTypeColor(typeColor));
     if (this.colors.ContainsKey(typeColor))
     {
         this.colors[typeColor] = rgb;
     }
     else
     {
         this.colors.Add(typeColor, rgb);
     }
 }
示例#11
0
 public void addInfoTexture(string typeMap, TextureInfo infoTexture)
 {
     Debug.Assert(DoGAAtr.getIsValidNameTypeMap(typeMap));
     Debug.Assert(typeMap == infoTexture.typeMap);
     if (this.getHasInfoTexture(typeMap))
     {
         this.textures[typeMap].Add(infoTexture);
     }
     else
     {
         var infosTexture = new List <TextureInfo>();
         infosTexture.Add(infoTexture);
         this.textures.Add(typeMap, infosTexture);
     }
 }
示例#12
0
 public void multiplyColor(string typeColor, Rgb rgb)
 {
     Debug.Assert(DoGAAtr.getIsValidNameTypeColor(typeColor));
     if (this.colors.ContainsKey(typeColor))
     {
         var rgbOrg = this.colors[typeColor];
         rgbOrg.r *= rgb.r;
         rgbOrg.g *= rgb.g;
         rgbOrg.b *= rgb.b;
     }
     else
     {
         this.colors.Add(typeColor, rgb);
     }
 }
示例#13
0
        public DoGAAtr getAtrFromPalette(DoGAAtr atr, string nameAtrColor, string nameAtrTexture, string nameAtrMaterial,
                                         Dictionary <string, DoGAAtr> atrsInPartsAssembler = null)
        {
            if (!this.doesUsePalette(atr.name))
            {
                return(atr);
            }

            // If atr found in L3 attribute, use it and ignore palette.
            if (atrsInPartsAssembler != null && nameAtrColor != null && atrsInPartsAssembler.ContainsKey(nameAtrColor))
            {
                atr.clearTexture();
                atr.merge(atrsInPartsAssembler[nameAtrColor]);
                return(atr);
            }

            var atrRet = this.mergeAtrFromPalette(atr, nameAtrColor, nameAtrTexture, nameAtrMaterial);

            return(atrRet);
        }
示例#14
0
        private bool associatePaletteRefToAtr()
        {
            foreach (var palette in this.palettes)
            {
                var nameCategory = palette.Key;
                var mapAtrs      = palette.Value;
                foreach (var mapAtr in mapAtrs)
                {
                    if (!(mapAtr.Value is DoGAAtrPaletteRef))
                    {
                        continue;
                    }
                    var paletteRef   = mapAtr.Value as DoGAAtrPaletteRef;
                    var nameAtrInSuf = mapAtr.Key;

                    var nameAtrColor    = paletteRef.nameAtrColor;
                    var nameAtrTexture  = paletteRef.nameAtrTexture;
                    var nameAtrMaterial = paletteRef.nameAtrMaterial;

                    DoGAAtr atr;
                    if (this.atrsGenie.ContainsKey(nameAtrInSuf.ToLower()))
                    {
                        atr = this.atrsGenie[nameAtrInSuf.ToLower()].CloneDeep();
                    }
                    else
                    {
                        atr = new DoGAAtr(nameAtrInSuf, this.pathAtr);
                    }

                    var atrRet = this.mergeAtrFromPalette(atr, nameAtrColor, nameAtrTexture, nameAtrMaterial);
                    mapAtr.Value.atr = atrRet;
                }
            }

            return(true);
        }
示例#15
0
 public DoGAAtrPaletteFileAtr(string nameAtrInSuf, DoGAAtr atr)
 {
     this.nameAtrInSuf = StringUtil.stripQuote(nameAtrInSuf);
     this.atr          = atr;
 }
示例#16
0
 public bool getHasColor(string typeColor)
 {
     Debug.Assert(DoGAAtr.getIsValidNameTypeColor(typeColor));
     return(this.colors.ContainsKey(typeColor) ? true : false);
 }
示例#17
0
        private void extractMapAtr(Dictionary <string, string> profiles, string prefix, ref Dictionary <string, DoGAAtrPaletteBase> mapPalette, ref HashSet <string> setNamesFileAtr)
        {
            // Color1=C1,White,  color.atr,C1
            // Color14=C4,Light Purple, 0.95,0.64,0.86
            // Texture1=NO,None
            // T10,Camouflage 1,  meisai1.pic, texture.bmp,320,0,351,31

            var tablePostfix = new string[] { "s", "Max" };
            int numElems     = 0;

            foreach (var postfix in tablePostfix)
            {
                var labelNum = prefix + postfix;
                if (profiles.ContainsKey(labelNum))
                {
                    numElems = int.Parse(profiles[labelNum]);
                }
            }
            if (numElems == 0)
            {
                return;
            }

            for (int index = 1; index <= numElems; index++)
            {
                var key   = prefix + index.ToString();
                var value = profiles[key];
                var items = value.Split(',');
                if (items.Length < 4)                   // Texture1=NO,None
                {
                    continue;
                }
                var   nameAtrKey = items[0].Trim().ToLower();
                float valR = 0.0f, valG = 0.0f, valB = 0.0f;
                if (items.Length == 5 && float.TryParse(items[2], out valR) && float.TryParse(items[3], out valG) && float.TryParse(items[4], out valB))                   // Color14=C4,Light Purple, 0.95,0.64,0.86
                {
                    var atr = new DoGAAtr(nameAtrKey, this.pathAtr);
                    atr.setColor("col", new Rgb(valR, valG, valB));
                    var palette = new DoGAAtrPaletteFileAtr(nameAtrKey, atr);
                    mapPalette.Add(nameAtrKey, palette);
                }
                else
                {
                    var   regexpAtr = new Regex(@"\.atr$");
                    var   regexpImage = new Regex(@"\.(pic|png|bmp|jpg)$");
                    var   item2 = items[2].Trim().ToLower();
                    float valTra = 0.0f, valAmb = 0.0f, valDif = 0.0f, valSp1 = 0.0f, valSp2 = 0.0f, valSp3 = 0.0f, valRef = 0.0f;
                    if (regexpAtr.IsMatch(item2))
                    {
                        // Color1=C1,White,  color.atr,C1, ...
                        var nameFileAtr      = item2;
                        var nameAtrInFileAtr = items[3].Trim().ToLower();
                        if (!setNamesFileAtr.Contains(nameFileAtr))
                        {
                            setNamesFileAtr.Add(nameFileAtr);
                        }
                        var palette = new DoGAAtrPaletteFileAtr(nameAtrKey.ToLower(), nameFileAtr, nameAtrInFileAtr);
                        mapPalette.Add(nameAtrKey, palette);
                    }
                    else if (regexpImage.IsMatch(item2))
                    {
                        var nameFileImage = item2;
                        var palette       = new DoGAAtrPaletteFileImage(nameAtrKey.ToLower(), nameFileImage);
                        mapPalette.Add(nameAtrKey, palette);
                    }
                    else if (items.Length > 9 &&
                             float.TryParse(item2, out valTra) && float.TryParse(items[3], out valAmb) &&
                             float.TryParse(items[4], out valDif) &&
                             float.TryParse(items[5], out valSp1) && float.TryParse(items[6], out valSp2) &&
                             float.TryParse(items[7], out valSp3) &&
                             float.TryParse(items[8], out valRef))
                    {
                        var palette = new DoGAAtrPaletteMaterial(nameAtrKey.ToLower(), valTra, valAmb, valDif, valSp1, valSp2, valSp3, valRef);
                        mapPalette.Add(nameAtrKey, palette);
                    }
                    else
                    {
                        // Attribute1=Rough_C1, "White", C1, Rough, M4, ...
                        var nameAtrColorRef    = items[2].Trim().ToLower();
                        var nameAtrTextureRef  = items[3].Trim().ToLower();
                        var nameAtrMaterialRef = items[4].Trim().ToLower();
                        var palette            = new DoGAAtrPaletteRef(nameAtrColorRef, nameAtrTextureRef, nameAtrMaterialRef);
                        mapPalette.Add(nameAtrKey, palette);
                    }
                }
            }
            if (prefix == "Texture")
            {
                var nameAtrNo = "no";
                mapPalette.Add(nameAtrNo, new DoGAAtrPaletteFileAtr(nameAtrNo, new DoGAAtr(nameAtrNo, null)));
            }

//			return mapPalette;
        }
示例#18
0
 public bool getHasInfoTexture(string typeMap)
 {
     Debug.Assert(DoGAAtr.getIsValidNameTypeMap(typeMap));
     return(this.textures.ContainsKey(typeMap) ? true : false);
 }
示例#19
0
        public DoGAAtr mergeAtrFromPalette(DoGAAtr atr, string nameAtrColor, string nameAtrTexture, string nameAtrMaterial)
        {
            var atrsAttribute = this.palettes[DoGAAtrInfo.prefixPaletteAttribute];

            var     atrsColor = this.palettes[DoGAAtrInfo.prefixPaletteColor];
            DoGAAtr atrColor  = null;

            if (nameAtrColor != null)
            {
                if (atrsColor.ContainsKey(nameAtrColor))
                {
                    atrColor = atrsColor[nameAtrColor].atr.CloneDeep();
                }
                else if (atrsAttribute.ContainsKey(nameAtrColor))
                {
                    atrColor = atrsAttribute[nameAtrColor].atr.CloneDeep();
                }
            }
            if (atrColor != null)
            {
                atrColor.clearExceptColor();
                atr.merge(atrColor);
            }

            var     atrsTexture = this.palettes[DoGAAtrInfo.prefixPaletteTexture];
            DoGAAtr atrTexture  = null;

            if (nameAtrTexture != null)
            {
                if (atrsTexture.ContainsKey(nameAtrTexture))
                {
                    atrTexture = atrsTexture[nameAtrTexture].atr.CloneDeep();
                }
                else if (atrsAttribute.ContainsKey(nameAtrTexture))
                {
                    atrTexture = atrsAttribute[nameAtrTexture].atr.CloneDeep();
                }
            }
            if (atrTexture != null)
            {
                atrTexture.clearExceptTexture();
                atr.clearTexture();
                atr.merge(atrTexture);
            }

            var     atrsMaterial = this.palettes[DoGAAtrInfo.prefixPaletteMaterial];
            DoGAAtr atrMaterial  = null;

            if (nameAtrMaterial != null)
            {
                if (atrsMaterial.ContainsKey(nameAtrMaterial))
                {
                    atrMaterial = atrsMaterial[nameAtrMaterial].atr.CloneDeep();
                }
                else if (atrsAttribute.ContainsKey(nameAtrMaterial))
                {
                    atrMaterial = atrsAttribute[nameAtrMaterial].atr.CloneDeep();
                }
            }
            if (atrMaterial != null)
            {
                atrMaterial.clearExceptMaterial();
                atr.clearMaterial();
                atr.merge(atrMaterial);
            }

            return(atr);
        }
示例#20
0
 public bool getHasRangeMap(string typeRange)
 {
     Debug.Assert(DoGAAtr.getIsValidNameTypeRangeMap(typeRange));
     return(this.mapRanges.ContainsKey(typeRange) ? true : false);
 }