Guten Abend, habe begonnen mich in XNA einzuarbeiten, ist nun zu einem 3D-TileMap-Engine "mutiert".
Es prüft, ob in einem 2D Bild, einen bestimmten RGB-Wert vorhanden ist => True, Objekt setzen:
Ich habe eine 1:
RGBOf-Function
Ich hab mir ein 2D-PerlinNoise(BlackWhite)-Gebilde aus dem Internet gesucht,(ANHANG).
Nunja, es laggt sehr arg, liegt es an der Methode des TileMapping, welche Art von -Dateityp empfehlt ihr mir für solche Konstruktionen?
Es prüft, ob in einem 2D Bild, einen bestimmten RGB-Wert vorhanden ist => True, Objekt setzen:
Ich habe eine 1:
VB.NET-Quellcode
- public int mapWidth, mapHeight;
- public Texture2D mapTex;
- public Color[,] RGBOf;
- public List<Entity> EntityList_ = new List<Entity>();
- public Level(string levelName)
- {
- floor = new Floor(50,50);
- mapText = Basic.content.Load<Texture2D>("Levels" + levelName);
- mapWidth = mapTex.Width;
- mapHeight = mapTex.Height;
- RGBOf= textureToColor(mapTex);
- floor = new Floor(mapWidth, mapHeight);
- ceiling = new Ceiling(mapWidth, mapHeight);
- Install();
- }
- float x_ = 20;
- private void Install()
- {
- EntityList_.Add(new Object_1(x_,0,0));
- for (int x = 0; x < mapWidth; x++)
- {
- for (int y = 0; y < mapHeight; y++)
- {
- if (RGBOf[x, y] == Color.White)
- {
- EntityList_.Add(new Object1(x, 0, y));
- }
- }
- }
- Basic.CountOfEntities = EntityList_.Count.ToString();
- }
RGBOf-Function
VB.NET-Quellcode
- public Color[,] textureToColor(Texture2D tex)
- {
- Color[] color1d = new Color[tex.Width*tex.Height];
- tex.GetData(color1d);
- Color[,] data = new Color[tex.Width,tex.Height];
- for(int i = 0;i < tex.Width;i++)
- {
- for (int j = 0; j < tex.Height; j++)
- {
- data[i, j] = color1d[i + j * tex.Width];
- }
- }
- return data;
- }
Ich hab mir ein 2D-PerlinNoise(BlackWhite)-Gebilde aus dem Internet gesucht,(ANHANG).
Nunja, es laggt sehr arg, liegt es an der Methode des TileMapping, welche Art von -Dateityp empfehlt ihr mir für solche Konstruktionen?
Dieser Beitrag wurde bereits 3 mal editiert, zuletzt von „NGE'o“ ()