コード例 #1
0
void BookAR::updateData(const ci::Surface32f& image, gl::VboMesh& mesh, float max_height)
{
	uint32_t book_w = image.getWidth();
	uint32_t book_h = image.getHeight();

	if (!mesh || mesh.getNumVertices() != book_w * book_h)
	{//needs refresh
		gl::VboMesh::Layout layout;
		layout.setDynamicColorsRGB();
		layout.setDynamicPositions();
		_mesh_book = gl::VboMesh( book_w * book_h, 0, layout, GL_POINTS );
	}
	Surface32f::ConstIter pixelIter = image.getIter();
	gl::VboMesh::VertexIter vertexIter( mesh );

	while( pixelIter.line() ) {
		while( pixelIter.pixel() ) {
			Color color( pixelIter.r(), pixelIter.g(), pixelIter.b() );
			float height = color.dot( Color( 0.3333f, 0.3333f, 0.3333f ) );

			// the x and the z coordinates correspond to the pixel's x & y
			float x = pixelIter.x() - book_h / 2.0f;
			float z = pixelIter.y() - book_h / 2.0f;

			vertexIter.setPosition( x, height * max_height, z );
			vertexIter.setColorRGB( color );
			++vertexIter;
		}
	}
}
コード例 #2
0
void HexagonMirrorApp::drawInstanced( const gl::VboMesh &vbo, size_t instanceCount )
{
    if( vbo.getNumIndices() > 0 )
        drawRangeInstanced( vbo, (size_t)0, vbo.getNumIndices(), instanceCount );
    else
        drawArraysInstanced( vbo, 0, vbo.getNumVertices(), instanceCount );
}
コード例 #3
0
ファイル: cApp.cpp プロジェクト: stdmtb/uf_0.8.6
void cApp::update(){
    if( !bStart )
        return;
    
    gl::VboMesh::VertexIter vitr( mPoints );
    for(int i=0; i<mPoints.getNumVertices(); i++ ){
        
        Vec3f &pos = ps[i];
        int x = pos.x;
        int y = pos.y;

        x = cinder::math<int>::clamp( x, 0, intensityW-1 );
        y = cinder::math<int>::clamp( y, 0, intensityH-1 );
        
        Vec3f vel( mVecMap[x][y].x, mVecMap[x][y].y, 0);
        Vec3f noise = mPln.dfBm(x, y, cs[i].a ) * 0.2;
        mVelocity[i] = mVelocity[i] + (vel + noise);
        
        vitr.setPosition( pos + mVelocity[i] );
        vitr.setColorRGBA( cs[i] );
        ++vitr;
    }
}