//--------------------------------------------------------------
void vbo::setup(){
    
    ofEnableDepthTest();
    ofEnableBlendMode(OF_BLENDMODE_ADD);
    glEnable(GL_POINT_SMOOTH);
    glPointSize(1.0);
    
    resetImg();
    resetVerts();
    
}
Exemple #2
0
// Constructor: init the texture, set starting positions for the object and set texture coordinates
//	Call base constructor to initialize inherited vars
Image::Image(int iHeight, int iWidth, const string& sImage) : Graphic(iHeight, iWidth)
{
	InitializeTexture(&m_pTexture, sImage);

	// Set initial geometry coords
	resetImg();

	m_pTextCoords[0][0] = 0;
	m_pTextCoords[0][1] = 0;
	m_pTextCoords[1][0] = 0;
	m_pTextCoords[1][1] = m_pTexture.height;
	m_pTextCoords[2][0] = m_pTexture.width;
	m_pTextCoords[2][1] = m_pTexture.height;
	m_pTextCoords[3][0] = m_pTexture.width;
	m_pTextCoords[3][1] = 0;
}
//--------------------------------------------------------------
void vbo::update(){
    
    if (timer % 80 == 0) {
        
        if (y < HEIGHT) {
            if(x < WIDTH) {
                
                xValue = pixels[y*WIDTH*3+x*3];
                yValue = pixels[y*WIDTH*3+x*3+1];
                zValue = pixels[y*WIDTH*3+x*3+2];
                                
                x++;

            }else{
                x = 0;
                y++;
            }
            
        }else{
            y = 0;
        }

    }
    
    
    if (timer < lastingTime) {
        timer++;
    }else{
        
        timer = 0;
        resetImg();
        resetVerts();
        
    }


    if (!overdose) {
    
        for (int i = 0; i < WIDTH; i++) {
            for (int j = 0; j < HEIGHT; j++) {

                myVerts[j*WIDTH+i].x += (vec[j*WIDTH+i].x * vecLength[j*WIDTH+i]/10000);
                myVerts[j*WIDTH+i].y += (vec[j*WIDTH+i].y * vecLength[j*WIDTH+i]/10000);
                myVerts[j*WIDTH+i].z += (vec[j*WIDTH+i].z * vecLength[j*WIDTH+i]/20000);
                
                if(vecLength[j*WIDTH+i] > 100){
                    vec[j*WIDTH+i].normalize();
                }

            }
        }

        vec[longestVec] = myVerts[longestVec] - ofVec3f(0,0,0);
        if(vec[longestVec].length() > initialLength * 200){
            resetVerts();
        }
        
    }

    myVbo.updateVertexData(myVerts, NUM_PARTICLES);

}