Ejemplo n.º 1
0
Cubemap::~Cubemap()
{
    for (int i = 0; i < getFacesCount(); i++)
    {
        CubemapFace::destroy(faces[i].get());
    }
}
Ejemplo n.º 2
0
    // Get pixels for a cubemap face at an eye.
    virtual void* getCurrentCubemapPixels(CubemapFace face, Eye eye) {
        if(!current_cubemap_) return nullptr;

        if(eye >= current_cubemap_->getEyesCount()) return nullptr;
        auto cubemap_eye = current_cubemap_->getEye(eye);

        if(face >= cubemap_eye->getFacesCount()) return nullptr;
        auto cubemap_face = cubemap_eye->getFace(face);

        if(cubemap_face) return cubemap_face->getContent()->getPixels();
        return nullptr;
    }
Ejemplo n.º 3
0
    virtual int getCurrentCubemapByteSize(CubemapFace face, Eye eye) {
        if(!current_cubemap_) return 0;

        if(eye >= current_cubemap_->getEyesCount()) return 0;
        auto cubemap_eye = current_cubemap_->getEye(eye);

        if(face >= cubemap_eye->getFacesCount()) return 0;
        auto cubemap_face = cubemap_eye->getFace(face);

        if(cubemap_face) {
            int w = cubemap_face->getContent()->getWidth();
            int h = cubemap_face->getContent()->getHeight();
            int bit_per_pixel;
            if(cubemap_face->getContent()->getFormat() == AV_PIX_FMT_RGBA) {
                bit_per_pixel = 32;
            }
            if(cubemap_face->getContent()->getFormat() == AV_PIX_FMT_YUV420P) {
                bit_per_pixel = 12;
            }
            return w * h * bit_per_pixel / 8;
        }
        return 0;
    }
Ejemplo n.º 4
0
void Light::update() const
{
    if( m_needUpdate )
    {
        m_vertexArray.clear();
        m_vertexArrayDebug.clear();

        for( size_t k(0); k < getFacesCount(); k++ )
        {
            Face& face = getFace(k);

            Vector2d p1 = face.v1.getCoords();
            Vector2d p2 = face.v2.getCoords();
            Vector2d p3 = face.v3.getCoords();
                    
            sf::VertexArray array(sf::Triangles, 3);

            array[0].position = sf::Vector2f(p1.x, p1.y);
            array[1].position = sf::Vector2f(p2.x, p2.y);
            array[2].position = sf::Vector2f(p3.x, p3.y);

            array[0].color = m_colors[face.v1.getIndice()];
            array[1].color = m_colors[face.v2.getIndice()];
            array[2].color = m_colors[face.v3.getIndice()];
                    
            m_vertexArray.push_back(array);
        }

        if( m_debugMode )
        {
            for( size_t k(0); k < getFacesCount(); k++ )
            {
                Face& face = getFace(k);

                Vector2d p1 = face.v1.getCoords();
                Vector2d p2 = face.v2.getCoords();
                Vector2d p3 = face.v3.getCoords();
                    
                sf::VertexArray lines(sf::LinesStrip, 4);

                lines[0].position = sf::Vector2f(p1.x, p1.y);
                lines[1].position = sf::Vector2f(p2.x, p2.y);
                lines[2].position = sf::Vector2f(p3.x, p3.y);
                lines[3].position = sf::Vector2f(p1.x, p1.y);

                lines[0].color = sf::Color::White;
                lines[1].color = sf::Color::White;
                lines[2].color = sf::Color::White;
                lines[3].color = sf::Color::White;

                m_vertexArray.push_back(lines);
            }

            const Rect& rect = getGlobalBounds();
            Point origin = convertToGlobal(getOrigin());

            sf::VertexArray circle(sf::LinesStrip, 10);

            double angus = 0;
                
            for( size_t k(0); k < 10; k++ )
            {
                circle[k].position = sf::Vector2f(origin.x + std::cos(angus) * 11, origin.y + std::sin(angus) * 11);
                circle[k].color = sf::Color::Red;
                angus+=.698131701f;
            }

            m_vertexArrayDebug.push_back(circle);

            sf::VertexArray lines(sf::LinesStrip, 5);

            lines[0].position = sf::Vector2f(rect.pos.x - 1, rect.pos.y - 1);
            lines[1].position = sf::Vector2f(rect.pos.x + rect.size.x + 1, rect.pos.y - 1);
            lines[2].position = sf::Vector2f(rect.pos.x + rect.size.x + 1, rect.pos.y + rect.size.y + 1);
            lines[3].position = sf::Vector2f(rect.pos.x - 1, rect.pos.y + rect.size.y + 1);
            lines[4].position = sf::Vector2f(rect.pos.x - 1, rect.pos.y - 1);

            lines[0].color = sf::Color::Red;
            lines[1].color = sf::Color::Red;
            lines[2].color = sf::Color::Red;
            lines[3].color = sf::Color::Red;
            lines[4].color = sf::Color::Red;

            m_vertexArrayDebug.push_back(lines);
        }

        m_needUpdate = false;
    }
}