sf :: Texture применяется неправильно

В моем 2D изометрическом движке у меня есть следующие классы:

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

каждыйsides содержит 4points(1point = 1coordinate(х, у, z)).Каждый куб содержит 6 сторон.Я могу создать карту с размером, который я хочу с кубиками (такой же, размер, который я хочу).

Folers:

assets/numTexture/numLight.png

Я вычисляю с помощью numTexture и numLight число, которое является textureNumberEntry (я загрузил все numLight.png (текстуры) в массив).

Но текстурирование уходит неправильно

Я определяю мои координаты кубов в классе слоя:

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);
    }
}

В side.cpp у меня есть переключатель sideType (если он сверху, слева и т. Д. Я по-разному определяю координаты моих точек). У меня есть 6 из них для каждого куба (только данные здесь) Вот так:

    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. ....

И функция display () для отображения карты:

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();
}

Прокрутите этот, чтобы увидеть комментарии и ярлыки

Проблемы:

Текстура увеличивается только тогда, когда текстура с деталями, нет проблем с одной цветовой текстурой (вероятно, вершины сочетаются друг с другом, даже из разныхsf::VertexArray.

Примечание: класс как карты / слои / кубы / и т. Д. ... только данные.

Изображения текстур (numLIght), которые должны отображаться на экране, выглядят так:

РЕДАКТИРОВАТЬ: Текстуры работают, когда изображение только цвет, без деталей:

Я больше не знаю, что не так с моим кодом. Может быть, я перекодирую функцию display () ...

Ответы на вопрос(1)

Ваш ответ на вопрос