Update for AtlasBuilder ok
Need to improuve duplicate vertex for mapping texture.
This commit is contained in:
parent
4777783ffb
commit
b9a2b87fe9
11 changed files with 160 additions and 33 deletions
|
|
@ -28,21 +28,22 @@ public class AtlasBuilder {
|
|||
|
||||
public void GenerateAtlas() {
|
||||
int count = (int)Math.Ceiling(Math.Sqrt(textures.Count));
|
||||
int atlasSize = (int)TEXTURESIZE * count;
|
||||
int atlasSize = (int)TEXTURESIZE * count;
|
||||
|
||||
using (MagickImage atlas = new MagickImage(new MagickColor("#FFFFFF"), atlasSize, atlasSize)) {
|
||||
int index = 0;
|
||||
using (MagickImage atlas = new MagickImage(new MagickColor("#FFFFFF"), atlasSize, atlasSize)) {
|
||||
int index = 0;
|
||||
|
||||
foreach (var kvp in textures) {
|
||||
int x = (index % count) * (int)TEXTURESIZE;
|
||||
int y = (index / count) * (int)TEXTURESIZE;
|
||||
atlas.Draw(new Drawables().Composite(x, y, kvp));
|
||||
index++;
|
||||
if (index >= count * count) break;
|
||||
}
|
||||
|
||||
atlas.Write("atlas.jpg");
|
||||
foreach (var kvp in textures) {
|
||||
int x = (index % count) * (int)TEXTURESIZE;
|
||||
int y = (index / count) * (int)TEXTURESIZE;
|
||||
atlas.Composite(kvp, x, y);
|
||||
|
||||
index++;
|
||||
if (index >= count * count) break;
|
||||
}
|
||||
|
||||
atlas.Write("atlas.jpg");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue