sf :: Textura aplicada de manera incorrecta

En mi motor isométrico 2D, tengo las siguientes clases:

`maps(variable)/layers(variable)/cubes(variable)/sides(6)/points(4)/coordinates(3)`

Cadasides contiene 4points(1point = 1coordinate(x, y, z)).Cada cubo contiene 6 lados.Puedo crear un mapa con el tamaño que quiero con cubos (igual, el tamaño que quiero).

Folers:

assets/numTexture/numLight.png

Calcule con numTexture y numLight un número que es textureNumberEntry (cargué todos numLight.png (texturas) en una matriz).

Pero texturizar va mal:

Defino las coordenadas de mis cubos en la clase de capa:

for(int J = 0; J < mapSize; J++)
{
    for(int I = 0; I < mapSize; I++)
    {
        x = (J - I) * (cubeSize/2);
        y = (J + I) * (cubeSize/4);

        c = new cube(cubeSize, x, y, z, I, J);
        cs.push_back(*c);
    }
}

En side.cpp, tengo un interruptor en sideType (si es la parte superior, izquierda, etc ... defino de manera diferente las coordenadas de mis puntos). Tengo 6 de ellos para cada cubo (solo datos aquí) De esta manera:

    switch(typeSide)
        {
            case 0://DOWN_SIDE
                light = 0;

                tmp_x = x + (size/2);
                tmp_y = y + (size/2);
                p0 = new point(tmp_x, tmp_y, tmp_z);

                tmp_x = x + size;
                tmp_y = y + (3 * (size/4));
                p1 = new point(tmp_x, tmp_y, tmp_z);

                tmp_x = x + (size/2);
                tmp_y = y + size;
                p2 = new point(tmp_x, tmp_y, tmp_z);

                tmp_x = x;
                tmp_y = y + (3 * (size/4));
                p3 = new point(tmp_x, tmp_y, tmp_z);
                break;

//ETC. ....

Y la función display () para mostrar el mapa:

void GRAPHICS_HANDLER::display()
{
    x = 0;
    y = 0;

    if(maps.size() > 0 && maps[0].layers().size() > 0)//If there is any map and layers to display
    {
        for(int l = 0; l <= getCurrentLayerID(); l++)//FOR EACH LAYER, WE STOP TO THE CURRENT EDITED LAYER
        {
            for(unsigned int c = 0; c < maps[currentMapID].layers()[l].cubes().size(); c++)//FOR EACH CUBES
            {
                if(maps[currentMapID].layers()[l].cubes()[c].getFlat())//If flat mode is enabled: to draw texture like grass, etc...(cf. screen): We draw only one side
                {
                    for(unsigned int p = 0; p < 4; p++)//FOR EACH POINTS
                    {
//--------------------------------------------------------------------------------------LOAD MAP-----------------------------------------------------------------------------------------------------------//
//--------------------------------------------------------------------------CUBE CLICK DETECTION::TEXTURE CHANGE--------------------------------------------------//
                        if(cubeClicked || brushMode && currentSelectedCube > -1 && currentSelectedCube < maps[currentMapID].layers()[maps[currentMapID].currentLayerId()].cubes().size())
                        {
                            maps[currentMapID].layers()[maps[currentMapID].currentLayerId()].cubes()[currentSelectedCube].setTexture(currentSelectedTexture);

                            if(!brushMode)
                                cubeClicked = false;
                        }
//--------------------------------------------------------------------------CUBE CLICK DETECTION::TEXTURE CHANGE--------------------------------------------------//
//--------------------------------------------------------------------------------------CURSOR - NOT WORKING-----------------------------------------------------------------------------------------------------------------//
                        //...
//--------------------------------------------------------------------------------------CURSOR - NOT WORKING-----------------------------------------------------------------------------------------------------------------*/

                        if(enableOffset)
                        {
                            x = maps[currentMapID].layers()[l].cubes()[c].sides()[0]->pointPosition(p)[0] + offsetLeft;//it's like doing something like point[p].x + offset left
                            y = maps[currentMapID].layers()[l].cubes()[c].sides()[0]->pointPosition(p)[1] + offsetTop;
                        }
                        else
                        {
                            x = maps[currentMapID].layers()[l].cubes()[c].sides()[0]->pointPosition(p)[0];//it's like doing something like point[p].x + offset left
                            y = maps[currentMapID].layers()[l].cubes()[c].sides()[0]->pointPosition(p)[1];
                        }

                        points[p].position = sf::Vector2f(x, y);
                        points[p].texCoords = sf::Vector2f(x, y);

//--------------------------------------------------------------------------------------GRID-----------------------------------------------------------------------------------------------------------------//
                        //GRID DISPLAY //MISS AN EDGE .
                        isoGrid[p].position = points[p].position;
                        isoGrid[p].color = sf::Color(195, 195, 195, gridOpacity);
//--------------------------------------------------------------------------------------GRID-----------------------------------------------------------------------------------------------------------------//

                        maps[currentMapID].layers()[l].cubes()[c].sides()[0]->setLight(5);
                        textureEntryNumber = (maps[currentMapID].layers()[l].cubes()[c].sides()[0]->getTexture() - 1) * 9 + (maps[currentMapID].layers()[l].cubes()[c].sides()[0]->getLight() - 1);//WRONG
//--------------------------------------------------------------------------------------GRID-----------------------------------------------------------------------------------------------------------------//
//--------------------------------------------------------------------------------------LOAD MAP-----------------------------------------------------------------------------------------------------------//
                    }
//--------------------------------------------------------------------------------------DISPLAY MAP-----------------------------------------------------------------------------------------------------------//
                    if(grid && maps[currentMapID].layers()[l].cubes()[c].sides()[0]->getTexture() <= 1)//IF GRID = TRUE OR TEXTURE LESS OR EQUAL TO 1 => DISPLAY GRID
                    {
                        if(l == maps[currentMapID].currentLayerId())
                        {
                            window->draw(isoGrid);
                        }
                    }
                    else if(maps[currentMapID].layers()[l].cubes()[c].sides()[0]->getTexture() > 1)//IF THERE IS ANY TEXTURE TO DISPLAY(>1) => DISPLAY TEXTURE
                    {
                        window->draw(points, &textures[textureEntryNumber]);
                    }
//--------------------------------------------------------------------------------------DISPLAY MAP-----------------------------------------------------------------------------------------------------------//
                }
                else
                {
                    for(unsigned int s = 0; s < 6; s++)//FOR EACH SIDES(side number will always be 6, no need to make this dynamic
                    {
                        for(unsigned int p = 0; p < 4; p++)//FOR EACH POINTS
                        {
//--------------------------------------------------------------------------------------LOAD MAP-----------------------------------------------------------------------------------------------------------//
//--------------------------------------------------------------------------CUBE CLICK DETECTION::TEXTURE CHANGE--------------------------------------------------//
                            if(cubeClicked || brushMode && currentSelectedCube > -1 && currentSelectedCube < maps[currentMapID].layers()[maps[currentMapID].currentLayerId()].cubes().size())
                            {
                                maps[currentMapID].layers()[maps[currentMapID].currentLayerId()].cubes()[currentSelectedCube].setTexture(currentSelectedTexture);

                                if(flatMode)
                                    maps[currentMapID].layers()[maps[currentMapID].currentLayerId()].cubes()[currentSelectedCube].setFlat(true);
                                else
                                    maps[currentMapID].layers()[maps[currentMapID].currentLayerId()].cubes()[currentSelectedCube].setFlat(false);


         ,                       if(!brushMode)
                                    cubeClicked = false;
                            }
//--------------------------------------------------------------------------CUBE CLICK DETECTION::TEXTURE CHANGE--------------------------------------------------//
//--------------------------------------------------------------------------------------CURSOR - NOT WORKING-----------------------------------------------------------------------------------------------------------------//
                            //...
//--------------------------------------------------------------------------------------CURSOR - NOT WORKING-----------------------------------------------------------------------------------------------------------------*/

                            if(enableOffset)
                            {
                                x = maps[currentMapID].layers()[l].cubes()[c].sides()[s]->pointPosition(p)[0] + offsetLeft;//it's like doing something like point[p].x + offset left
                                y = maps[currentMapID].layers()[l].cubes()[c].sides()[s]->pointPosition(p)[1] + offsetTop;
                            }
                            else
                            {
                                x = maps[currentMapID].layers()[l].cubes()[c].sides()[s]->pointPosition(p)[0];//it's like doing something like point[p].x + offset left
                                y = maps[currentMapID].layers()[l].cubes()[c].sides()[s]->pointPosition(p)[1];
                            }

                            points[p].position = sf::Vector2f(x, y);
                            points[p].texCoords = sf::Vector2f(x, y);

//--------------------------------------------------------------------------------------GRID-----------------------------------------------------------------------------------------------------------------//
                            //GRID DISPLAY //MISS AN EDGE
                            if(s ==3)
                            {
                                isoGrid[p].position = points[p].position;
                                isoGrid[p].color = sf::Color(195, 195, 195, gridOpacity);
                            }
//--------------------------------------------------------------------------------------GRID-----------------------------------------------------------------------------------------------------------------//

                            textureEntryNumber = (maps[currentMapID].layers()[l].cubes()[c].sides()[s]->getTexture() - 1) * 9 + (maps[currentMapID].layers()[l].cubes()[c].sides()[s]->getLight() - 1);//WRONG
//--------------------------------------------------------------------------------------GRID-----------------------------------------------------------------------------------------------------------------//
//--------------------------------------------------------------------------------------LOAD MAP-----------------------------------------------------------------------------------------------------------//
                        }
//--------------------------------------------------------------------------------------DISPLAY MAP-----------------------------------------------------------------------------------------------------------//
                        if(grid && maps[currentMapID].layers()[l].cubes()[c].sides()[s]->getTexture() <= 1)//IF GRID = TRUE OR TEXTURE LESS OR EQUAL TO 1 => DISPLAY GRID
                        {
                            if(l == maps[currentMapID].currentLayerId())
                            {
                                window->draw(isoGrid);
                            }
                        }
                        else if(maps[currentMapID].layers()[l].cubes()[c].sides()[s]->getTexture() > 1)//IF THERE IS ANY TEXTURE TO DISPLAY(>1) => DISPLAY TEXTURE
                        {
                            window->draw(points, &textures[textureEntryNumber]);
                        }
//--------------------------------------------------------------------------------------DISPLAY MAP-----------------------------------------------------------------------------------------------------------//
                    }
                }
            }
        }
    }

    window->display();
}

Desplácese para ver los comentarios y las etiquetas.

Problemas:

Textura ampliada solo cuando textura con detalles, no hay problema con la textura de un color (probablemente el vértice se junta, incluso desde diferentessf::VertexArray.

Nota: clase como mapas / capas / cubos / etc. ... son solo datos.

Las imágenes de texturas (numLIght) que deberían mostrarse en la pantalla tienen este aspecto:

EDITAR: Las texturas funcionan cuando la imagen es solo un color, sin detalles:

Ya no sé qué tiene de malo mi código. Tal vez, recodificaré la pantalla de función () ...

Respuestas a la pregunta(1)

Su respuesta a la pregunta