//--------------------------------------------------------------
void ofxMtlMapping2DPolygon::setAsActive()
{
	if (activePolygon != this) {
        previousActivePolygon = activePolygon;
        activePolygon = this;
        activeVertexId = -1;
        
        if (previousActivePolygon) {
            previousActivePolygon->setAsIdle();
        }
        
        enableVertices();
    }
}
Beispiel #2
0
void antPlane::generateVertices()
{
    float sx = m_width / m_nColumns;
    float sz = m_depth / m_nRows;
    
    m_vertices = ( GLfloat * ) malloc( N_VERTEX_ATTRIBS * m_nVertices * sizeof( GLfloat ) );
    
    for ( int i = 0; i < m_nRows; i++ )
    {
        for ( int j = 0; j < m_nColumns; j++ )
        {
            antVec3 bl( j * sx - m_width / 2.f, 0.f, i * sz - m_depth / 2.f ); // bottom left
            antVec3 tl( j * sx - m_width / 2.f, 0.f, ( i + 1 ) * sz - m_depth / 2.f ); // top left
            antVec3 tr( ( j + 1 ) * sx - m_width / 2.f, 0.f, ( i + 1 ) * sz - m_depth / 2.f ); // top right
            antVec3 br( ( j + 1 ) * sx - m_width / 2.f, 0.f, i * sz - m_depth / 2.f ); // bottom right
            
            int v = (i * m_nColumns + j) * 6 * N_VERTEX_ATTRIBS;
            for ( int n = 0; n < N_VERTEX_ATTRIBS; n++ )
            {
                m_vertices[ v + n ] = bl.v[n];
                m_vertices[ v + (1 * N_VERTEX_ATTRIBS) + n ] = tl.v[n];
                m_vertices[ v + (2 * N_VERTEX_ATTRIBS) + n ] = tr.v[n];
                
                m_vertices[ v + (3 * N_VERTEX_ATTRIBS) + n ] = tr.v[n];
                m_vertices[ v + (4 * N_VERTEX_ATTRIBS) + n ] = br.v[n];
                m_vertices[ v + (5 * N_VERTEX_ATTRIBS) + n ] = bl.v[n];
            }
        }
    }
    
    m_hasVertices = true;    
    bindVao(0);
    bindVbo(0);
    setData( m_nVertices * N_VERTEX_ATTRIBS * sizeof(GLfloat), m_vertices );
    attrib( ATTR_POSITION_LOC, N_VERTEX_ATTRIBS );
    enableVertices();
}