Update for AtlasBuilder ok

Need to improuve duplicate vertex for mapping texture.
This commit is contained in:
Troispoils 2024-02-27 17:04:09 +01:00
parent 4777783ffb
commit b9a2b87fe9
11 changed files with 160 additions and 33 deletions

View file

@ -10,12 +10,12 @@ namespace Map3DRendering {
private PortalEngine portalEngine;
private CellEngine cellEngine;
private LandBlockExtrator landblockExtraction;
private TerrainAtlasManager terrainAtlasManager;
private readonly int NumberLandBlocks = 255;
private readonly int BlockSize = 17;
private readonly int allBlocks = 255 * 17 * 255 * 17;
private readonly int cellSize = 8;
private readonly int radius = 0x10; // Rayon du voisinage
private readonly int radius = 0x5; // Rayon du voisinage
public int[,] _vertexArrayObject;
public int[,] _vertexBufferObject;
@ -31,10 +31,6 @@ namespace Map3DRendering {
public MapRender() {
portalEngine = new PortalEngine();
cellEngine = new CellEngine();
terrainAtlasManager = new(portalEngine);
terrainAtlasManager.ExtractTexture();
terrainAtlasManager.GenerateAtlas();
landblockExtraction = new(portalEngine, cellEngine);
@ -74,7 +70,7 @@ namespace Map3DRendering {
}
}
private void InitializeBlock(int x, int y, BlockStruct block, Shader _shader) {
int lenghPacket = 11;
int lenghPacket = 13;
// Initialisez le VAO, VBO et EBO pour le bloc à (x, y)...
// Utilisez le code de votre méthode OnLoad originale pour configurer le VAO, VBO et EBO.
int tempVertexArray = GL.GenVertexArray();
@ -104,6 +100,10 @@ namespace Map3DRendering {
var farcolorLocation = _shader.GetAttribLocation("aColorFar");
GL.EnableVertexAttribArray(farcolorLocation);
GL.VertexAttribPointer(farcolorLocation, 4, VertexAttribPointerType.Float, false, lenghPacket * sizeof(float), 7 * sizeof(float));
var texturecoordLocation = _shader.GetAttribLocation("aTexCoord");
GL.EnableVertexAttribArray(texturecoordLocation);
GL.VertexAttribPointer(texturecoordLocation, 2, VertexAttribPointerType.Float, false, lenghPacket * sizeof(float), 11 * sizeof(float));
}
public void Render(Shader shader) {
for (int y = startY; y <= endY; y++) {
@ -112,7 +112,7 @@ namespace Map3DRendering {
var model = Matrix4.Identity;//CreateTranslation(x * BlockSize, 0, y * BlockSize); // Ajustez selon votre système de coordonnées
shader.SetMatrix4("model", model);
GL.BindVertexArray(_vertexArrayObject[x, y]);
GL.DrawElements(PrimitiveType.Lines, GetIndiceLenght(), DrawElementsType.UnsignedInt, 0);
GL.DrawElements(PrimitiveType.Triangles, GetIndiceLenght(), DrawElementsType.UnsignedInt, 0);
}
}
}