public GetDoubleValue ( double defaultvalue, string name ) : double | ||
defaultvalue | double | |
name | string | |
리턴 | double |
void LoadHeightMap(string sm3directory, TdfParser.Section terrainsection) { string filename = Path.Combine(sm3directory, terrainsection.GetStringValue("heightmap")); double heightoffset = terrainsection.GetDoubleValue("heightoffset"); double heightscale = terrainsection.GetDoubleValue("heightscale"); LogFile.GetInstance().WriteLine("heightoffset: " + heightoffset + " heightscale " + heightscale); Terrain.GetInstance().MinHeight = heightoffset; Terrain.GetInstance().MaxHeight = heightoffset + heightscale; // I guess??? Image image = new Image(filename); //Bitmap bitmap = DevIL.DevIL.LoadBitmap(filename); int width = image.Width; int height = image.Height; Terrain.GetInstance().HeightMapWidth = width; Terrain.GetInstance().HeightMapHeight = height; Terrain.GetInstance().Map = new double[width, height]; LogFile.GetInstance().WriteLine("loaded bitmap " + width + " x " + height); double minheight = Terrain.GetInstance().MinHeight; double maxheight = Terrain.GetInstance().MaxHeight; double heightmultiplier = (maxheight - minheight) / 255; LogFile.GetInstance().WriteLine("heightmultiplier: " + heightmultiplier + " minheight: " + minheight); for (int i = 0; i < width; i++) { for (int j = 0; j < height; j++) { Terrain.GetInstance().Map[i, j] = (float)(minheight + heightmultiplier * image.GetBlue(i, j)); } } terrain.HeightmapFilename = filename; }
public bool LoadMod(string modfile) { this.modfilename = modfile; TdfParser parser1 = TdfParser.FromFile(modfile); if (parser1 != null) { TdfParser.Section section1 = parser1.RootSection.SubSection(@"AI\VALUES"); if (section1 != null) { foreach (string text1 in section1.Values.Keys) { string text2 = text1; text2 = text2.ToLower(); text2 = text2.Trim(); this.units.Add(text2); this.values[text2] = section1.GetDoubleValue(text1); } } section1 = parser1.RootSection.SubSection(@"AI\NAMES"); if (section1 != null) { foreach (string text3 in section1.Values.Keys) { string text4 = text3; text4 = text4.ToLower(); text4 = text4.Trim(); this.human_names[text4] = section1.GetStringValue(text3); } } section1 = parser1.RootSection.SubSection(@"AI\DESCRIPTIONS"); if (section1 != null) { foreach (string text5 in section1.Values.Keys) { string text6 = text5; text6 = text6.ToLower(); text6 = text6.Trim(); this.descriptions[text6] = section1.GetStringValue(text5); } } this.units.Sort(); } return(false); }