• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ gl::VboMesh类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中gl::VboMesh的典型用法代码示例。如果您正苦于以下问题:C++ VboMesh类的具体用法?C++ VboMesh怎么用?C++ VboMesh使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了VboMesh类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: Vec3f

void Controller::createSphere( gl::VboMesh &vbo, int res )
{
	float X = 0.525731112119f; 
	float Z = 0.850650808352f;
	
	static Vec3f verts[12] = {
		Vec3f( -X, 0.0f, Z ), Vec3f( X, 0.0f, Z ), Vec3f( -X, 0.0f, -Z ), Vec3f( X, 0.0f, -Z ),
		Vec3f( 0.0f, Z, X ), Vec3f( 0.0f, Z, -X ), Vec3f( 0.0f, -Z, X ), Vec3f( 0.0f, -Z, -X ),
		Vec3f( Z, X, 0.0f ), Vec3f( -Z, X, 0.0f ), Vec3f( Z, -X, 0.0f ), Vec3f( -Z, -X, 0.0f ) };
	
	static GLuint triIndices[20][3] = { 
		{0,4,1}, {0,9,4}, {9,5,4}, {4,5,8}, {4,8,1}, {8,10,1}, {8,3,10}, {5,3,8}, {5,2,3}, {2,7,3},
		{7,10,3}, {7,6,10}, {7,11,6}, {11,0,6}, {0,1,6}, {6,1,10}, {9,0,11}, {9,11,2}, {9,2,5}, {7,2,11} };
	
	gl::VboMesh::Layout layout;
	layout.setStaticPositions();
	layout.setStaticNormals();
	
	mPosCoords.clear();
	mNormals.clear();
	for( int i=0; i<20; i++ ){
		drawSphereTri( verts[triIndices[i][0]], verts[triIndices[i][1]], verts[triIndices[i][2]], res );
	}
	vbo = gl::VboMesh( mPosCoords.size(), 0, layout, GL_TRIANGLES );	
	vbo.bufferPositions( mPosCoords );
	vbo.bufferNormals( mNormals );
}
开发者ID:thessalianpine,项目名称:Eyeo2012,代码行数:27,代码来源:Controller.cpp


示例2: drawInstanced

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 );
}
开发者ID:audionerd,项目名称:Cinder-Samples,代码行数:7,代码来源:HexagonMirrorApp.cpp


示例3: glPointSize

void EpicMonsterApp::setupVBO(){
    /*  A dummy VboMesh the same size as the
     texture to keep the vertices on the GPU */
    int totalVertices = SIDE * SIDE;
    vector<Vec2f> texCoords;
    vector<uint32_t> indices;
    gl::VboMesh::Layout layout;
    layout.setStaticIndices();
    layout.setStaticPositions();
    layout.setStaticTexCoords2d();
    layout.setStaticNormals();
    layout.setDynamicColorsRGBA();
    
    glPointSize(1.0f);
    mVboMesh = gl::VboMesh( totalVertices, totalVertices, layout, GL_POINTS);
    
    for( int x = 0; x < SIDE; ++x ) {
        for( int y = 0; y < SIDE; ++y ) {
            indices.push_back( x * SIDE + y );
            texCoords.push_back( Vec2f( x/(float)SIDE, y/(float)SIDE ) );
        }
    }
    
    mVboMesh.bufferIndices( indices );
    mVboMesh.bufferTexCoords2d( 0, texCoords );
}
开发者ID:EeroHeikkinen,项目名称:cinderworkshop,代码行数:26,代码来源:EpicMonsterApp.cpp


示例4: createVbo

void kinectPointCloudApp::createVbo()
{
	gl::VboMesh::Layout layout;
	
	layout.setStaticPositions();
	layout.setStaticTexCoords2d();
	layout.setStaticIndices();
	
	std::vector<Vec3f> positions;
	std::vector<Vec2f> texCoords;
	std::vector<uint32_t> indices; 
	
	int numVertices = VBO_X_RES * VBO_Y_RES;
	int numShapes	= ( VBO_X_RES - 1 ) * ( VBO_Y_RES - 1 );

	mVboMesh		= gl::VboMesh( numVertices, numShapes, layout, GL_POINTS );
	
	for( int x=0; x<VBO_X_RES; ++x ){
		for( int y=0; y<VBO_Y_RES; ++y ){
			indices.push_back( x * VBO_Y_RES + y );

			float xPer	= x / (float)(VBO_X_RES-1);
			float yPer	= y / (float)(VBO_Y_RES-1);
			
			positions.push_back( Vec3f( ( xPer * 2.0f - 1.0f ) * VBO_X_RES, ( yPer * 2.0f - 1.0f ) * VBO_Y_RES, 0.0f ) );
			texCoords.push_back( Vec2f( xPer, yPer ) );			
		}
	}
	
	mVboMesh.bufferPositions( positions );
	mVboMesh.bufferIndices( indices );
	mVboMesh.bufferTexCoords2d( 0, texCoords );
}
开发者ID:Julien60,项目名称:CinderKinectLayers,代码行数:33,代码来源:kinectPointCloudApp.cpp


示例5: clock

void BouncingBallsApp::setup()
{
	// randomize the random generator
	Rand::randSeed( clock() );

	//
	mUseMotionBlur = true;

	// set some kind of sensible maximum to the frame rate
	setFrameRate(100.0f);

	// initialize simulator
	mStepsPerSecond = 60;
	mStepsPerformed = 0;

	// create a single ball
	mBalls.push_back( BallRef( new Ball() ) );

	// create ball mesh ( much faster than using gl::drawSolidCircle() )
	size_t slices = 20;

	std::vector<Vec3f> positions;
	std::vector<Vec2f> texcoords;
	std::vector<uint32_t> indices;

	indices.push_back( positions.size() );
	texcoords.push_back( Vec2f(0.5f, 0.5f) );
	positions.push_back( Vec3f::zero() );

	for(size_t i=0;i<=slices;++i) {	
		float angle = i / (float) slices * 2.0f * (float) M_PI;
		Vec2f v(sinf(angle), cosf(angle));

		indices.push_back( positions.size() );
		texcoords.push_back( Vec2f(0.5f, 0.5f) + 0.5f * v );
		positions.push_back( Ball::RADIUS * Vec3f(v, 0.0f) );
	}

	gl::VboMesh::Layout layout;
	layout.setStaticPositions();
	layout.setStaticTexCoords2d();
	layout.setStaticIndices();

	mMesh = gl::VboMesh( (size_t) (slices + 2), (size_t) (slices + 2), layout, GL_TRIANGLE_FAN );
	mMesh.bufferPositions( &positions.front(), positions.size() );
	mMesh.bufferTexCoords2d(0, texcoords);
	mMesh.bufferIndices( indices );

	// load texture
	mTexture = gl::Texture( loadImage( loadAsset("ball.png") ) );

	// start simulation
	mTimer.start();
}
开发者ID:Henri-K,项目名称:Cinder-Samples,代码行数:54,代码来源:BouncingBallsApp.cpp


示例6: Vec3f

void GeometryShaderApp::update()
{
	// brute-force method: recreate mesh if anything changed
	if( !mVboMesh ) {
		if( mPoints.size() > 1 ) {
			// create a new vector that can contain 3D vertices
			std::vector<Vec3f> vertices;

			// to improve performance, make room for the vertices + 2 adjacency vertices
			vertices.reserve( mPoints.size() + 2);

			// first, add an adjacency vertex at the beginning
			vertices.push_back( 2.0f * Vec3f(mPoints[0]) - Vec3f(mPoints[1]) );

			// next, add all 2D points as 3D vertices
			std::vector<Vec2f>::iterator itr;
			for(itr=mPoints.begin();itr!=mPoints.end();++itr)
				vertices.push_back( Vec3f( *itr ) );

			// next, add an adjacency vertex at the end
			size_t n = mPoints.size();
			vertices.push_back( 2.0f * Vec3f(mPoints[n-1]) - Vec3f(mPoints[n-2]) );

			// now that we have a list of vertices, create the index buffer
			n = vertices.size() - 2;
			std::vector<uint32_t> indices;
			indices.reserve( n * 4 );

			for(size_t i=1;i<vertices.size()-2;++i) {
				indices.push_back(i-1);
				indices.push_back(i);
				indices.push_back(i+1);
				indices.push_back(i+2);
			}

			// finally, create the mesh
			gl::VboMesh::Layout layout;
			layout.setStaticPositions();
			layout.setStaticIndices();

			mVboMesh = gl::VboMesh( vertices.size(), indices.size(), layout, GL_LINES_ADJACENCY_EXT );
			mVboMesh.bufferPositions( &(vertices.front()), vertices.size() );
			mVboMesh.bufferIndices( indices );
		}
		else
			mVboMesh = gl::VboMesh();
	}
}
开发者ID:meshula,项目名称:Cinder-Samples,代码行数:48,代码来源:GeometryShaderApp.cpp


示例7: cleanup

void VboSampleApp::cleanup()
{
    //  XXX If GL resources are not cleaned up they are unavailable the next time
    //  the program is run.
    mTexture.reset();
    mVboMesh.reset();
}
开发者ID:UIKit0,项目名称:bluegin,代码行数:7,代码来源:VBOTest.cpp


示例8: vertexIter

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;
		}
	}
}
开发者ID:HVisionSensing,项目名称:CreativeCoding,代码行数:30,代码来源:BookAR.update.cpp


示例9: glDrawArraysInstancedARB

void HexagonMirrorApp::drawArraysInstanced( const gl::VboMesh &vbo, GLint first, GLsizei count, size_t instanceCount )
{
	vbo.enableClientStates();
	vbo.bindAllData();

	//#if( defined GLEE_ARB_draw_instanced )
	glDrawArraysInstancedARB( vbo.getPrimitiveType(), first, count, instanceCount );
	//#elif( defined GLEE_EXT_draw_instanced )
	//	glDrawArraysInstancedEXT( vbo.getPrimitiveType(), first, count, instanceCount );
	//#else
	// fall back to rendering a single instance
	//	glDrawArrays( vbo.getPrimitiveType(), first, count );
	//#endif

	gl::VboMesh::unbindBuffers();
	vbo.disableClientStates();
}
开发者ID:Bryanayrb,项目名称:Cinder-Samples,代码行数:17,代码来源:HexagonMirrorApp.cpp


示例10: cam

void FastTrailsApp::setup()
{
	// initialize camera
	CameraPersp cam( getWindowWidth(), getWindowHeight(), 60.0f, 0.1f, 500.0f );
	cam.setEyePoint( Vec3f(0, 0, -100.0f) );
	cam.setCenterOfInterestPoint( Vec3f::zero() );

	mCamera.setCurrentCam( cam );

	// load texture
	try { mTexture = gl::Texture( loadImage( loadAsset("gradient.png") ) ); }
	catch( const std::exception &e ) { console() << e.what() << std::endl; }

	// create VBO mesh
	gl::VboMesh::Layout layout;
	layout.setDynamicPositions();
	layout.setStaticIndices();
	layout.setStaticTexCoords2d();

	mVboMesh = gl::VboMesh( TRAIL_LENGTH, TRAIL_LENGTH, layout, GL_TRIANGLE_STRIP );

	// observation: indices and texture coordinates never change
	std::vector< uint32_t >	indices;	indices.reserve( TRAIL_LENGTH );
	std::vector< Vec2f >	texcoords;	texcoords.reserve( TRAIL_LENGTH );
	for( size_t i=0; i<TRAIL_LENGTH; ++i ) {
		indices.push_back( i );

		float x = math<float>::floor( i * 0.5f ) / ( TRAIL_LENGTH * 0.5f );
		float y = float( i % 2 );
		texcoords.push_back( Vec2f( x, y ) );
	}

	// create index and texture coordinate buffers
	mVboMesh.bufferIndices( indices );
	mVboMesh.bufferTexCoords2d( 0, texcoords );

	// clear our trail buffer
	mTrail.clear();
	
	// initialize time and angle
	mTime = getElapsedSeconds();
	mAngle= 0.0f;

	// disable vertical sync, so we can see the actual frame rate
	gl::disableVerticalSync();
}
开发者ID:audionerd,项目名称:Cinder-Samples,代码行数:46,代码来源:FastTrailsApp.cpp


示例11: draw

void HexagonMirrorApp::draw()
{
    // clear the window
    gl::clear();

    // activate our camera
    gl::pushMatrices();
    gl::setMatrices( mCamera.getCamera() );

    // set render states
    gl::enable( GL_CULL_FACE );
    gl::enableDepthRead();
    gl::enableDepthWrite();
    gl::color( Color::white() );

    if( mVboMesh && mShaderInstanced && mBuffer )
    {
        // bind webcam image
        if( mWebcamTexture )
            mWebcamTexture.bind(0);

        // bind the shader, which will do all the hard work for us
        mShaderInstanced.bind();
        mShaderInstanced.uniform( "texture", 0 );
        mShaderInstanced.uniform( "scale", Vec2f( 1.0f / (3.0f * INSTANCES_PER_ROW), 1.0f / (3.0f * INSTANCES_PER_ROW) ) );

        // bind the buffer containing the model matrix for each instance,
        // this will allow us to pass this information as a vertex shader attribute.
        // See: initializeBuffer()
        glBindVertexArray(mVAO);

        // we do all positioning in the shader, and therefor we only need
        // a single draw call to render all instances.
        drawInstanced( mVboMesh, NUM_INSTANCES );

        // make sure our VBO is no longer bound
        mVboMesh.unbindBuffers();

        // unbind vertex array object containing our buffer
        glBindVertexArray(0);

        // unbind shader
        mShaderInstanced.unbind();

        if( mWebcamTexture )
            mWebcamTexture.unbind();
    }

    // reset render states
    gl::disableDepthWrite();
    gl::disableDepthRead();
    gl::disable( GL_CULL_FACE );

    // restore 2D drawing
    gl::popMatrices();
}
开发者ID:audionerd,项目名称:Cinder-Samples,代码行数:56,代码来源:HexagonMirrorApp.cpp


示例12: Vec3f

void RepulsionApp::createSphere( gl::VboMesh &vbo, int res )
{
	float X = 0.525731112119f; 
	float Z = 0.850650808352f;
	
	static Vec3f verts[12] = {
		Vec3f( -X, 0.0f, Z ), Vec3f( X, 0.0f, Z ), Vec3f( -X, 0.0f, -Z ), Vec3f( X, 0.0f, -Z ),
		Vec3f( 0.0f, Z, X ), Vec3f( 0.0f, Z, -X ), Vec3f( 0.0f, -Z, X ), Vec3f( 0.0f, -Z, -X ),
		Vec3f( Z, X, 0.0f ), Vec3f( -Z, X, 0.0f ), Vec3f( Z, -X, 0.0f ), Vec3f( -Z, -X, 0.0f ) };
	
	static GLuint triIndices[20][3] = { 
		{0,4,1}, {0,9,4}, {9,5,4}, {4,5,8}, {4,8,1}, {8,10,1}, {8,3,10}, {5,3,8}, {5,2,3}, {2,7,3},
		{7,10,3}, {7,6,10}, {7,11,6}, {11,0,6}, {0,1,6}, {6,1,10}, {9,0,11}, {9,11,2}, {9,2,5}, {7,2,11} };
	
	gl::VboMesh::Layout layout;
	layout.setStaticPositions();
	layout.setStaticNormals();
	layout.setStaticColorsRGB();
	
	mPosCoords.clear();
	mNormals.clear();
	mColors.clear();
	
	float invWidth = 1.0f/(float)FBO_WIDTH;
	float invHeight = 1.0f/(float)FBO_HEIGHT;
	for( int x = 0; x < FBO_WIDTH; ++x ) {
		for( int y = 0; y < FBO_HEIGHT; ++y ) {
			float u = ( (float)x + 0.5f ) * invWidth;
			float v = ( (float)y + 0.5f ) * invHeight;
			Colorf c = Colorf( u, v, 0.0f );
			
			for( int i=0; i<20; i++ ){
				drawSphereTri( verts[triIndices[i][0]], verts[triIndices[i][1]], verts[triIndices[i][2]], res, c );
			}
		}
	}
	vbo = gl::VboMesh( mPosCoords.size(), 0, layout, GL_TRIANGLES );	
	vbo.bufferPositions( mPosCoords );
	vbo.bufferNormals( mNormals );
	vbo.bufferColorsRGB( mColors );
	vbo.unbindBuffers();
}
开发者ID:thessalianpine,项目名称:Eyeo2012,代码行数:42,代码来源:RepulsionApp.cpp


示例13: glDrawElementsInstancedARB

void HexagonMirrorApp::drawRangeInstanced( const gl::VboMesh &vbo, size_t startIndex, size_t indexCount, size_t instanceCount )
{
	if( vbo.getNumIndices() <= 0 )
		return;

	vbo.enableClientStates();
	vbo.bindAllData();

	//#if( defined GLEE_ARB_draw_instanced )
	glDrawElementsInstancedARB( vbo.getPrimitiveType(), indexCount, GL_UNSIGNED_INT, (GLvoid*) ( sizeof( uint32_t ) * startIndex ), instanceCount );
	//#elif( defined GLEE_EXT_draw_instanced )
	//	glDrawElementsInstancedEXT( vbo.getPrimitiveType(), indexCount, GL_UNSIGNED_INT, (GLvoid*)( sizeof(uint32_t) * startIndex ), instanceCount );
	//#else
	// fall back to rendering a single instance
	//	glDrawElements( vbo.getPrimitiveType(), indexCount, GL_UNSIGNED_INT, (GLvoid*)( sizeof(uint32_t) * startIndex ) );
	//#endif

	gl::VboMesh::unbindBuffers();
	vbo.disableClientStates();
}
开发者ID:Bryanayrb,项目名称:Cinder-Samples,代码行数:20,代码来源:HexagonMirrorApp.cpp


示例14: initFaintVbo

void CatalogApp::initFaintVbo()
{
	gl::VboMesh::Layout layout;
	layout.setStaticPositions();
	layout.setStaticColorsRGB();
	
	int numFaintStars	= mFaintStars.size();
	mFaintVbo			= gl::VboMesh( numFaintStars, 0, layout, GL_POINTS );
	vector<Vec3f> positions;
	vector<Color> colors;

	for( int i=0; i<numFaintStars; i++ ){
		positions.push_back( mFaintStars[i]->mPos );
		colors.push_back( Color( mFaintStars[i]->mColor, 0.0f, 0.0f ) );
	}
	
	mFaintVbo.bufferPositions( positions );
	mFaintVbo.bufferColorsRGB( colors );
	mFaintVbo.unbindBuffers();
}
开发者ID:thessalianpine,项目名称:Eyeo2012,代码行数:20,代码来源:CatalogApp.cpp


示例15: setup

void VboSampleApp::setup()
{
    mCamera.setAspectRatio(getWindowAspectRatio());

    mTexture = bluegin::getTextureAsset("cinder_logo.png");
    mTexture.setMinFilter(GL_LINEAR);
    mTexture.setMagFilter(GL_LINEAR);

	gl::VboMesh::Layout layout;
	layout.setStaticIndices();
	layout.setStaticPositions();
    layout.setStaticTexCoords2d();

    const int vertexCount = 4;
    const int indexCount  = 6;

	mVboMesh = gl::VboMesh( vertexCount, indexCount, layout, GL_TRIANGLES );

    vector<Vec3f> positions;
    positions.push_back(Vec3f(-1.0f, 1.0f, 0));
    positions.push_back(Vec3f(-1.0f, -1.0f, 0));
    positions.push_back(Vec3f(1.0f, -1.0f, 0));
    positions.push_back(Vec3f(1.0f, 1.0f, 0));
    mVboMesh.bufferPositions(positions);

    vector<Vec2f> texcoords;
    texcoords.push_back(Vec2f(0, 0));
    texcoords.push_back(Vec2f(0, 1.0f));
    texcoords.push_back(Vec2f(1.0f, 1.0f));
    texcoords.push_back(Vec2f(1.0f, 0));
    mVboMesh.bufferTexCoords2d(0, texcoords);

    vector<index_t> indices;
    indices.push_back(index_t(0));
    indices.push_back(index_t(1));
    indices.push_back(index_t(2));
    indices.push_back(index_t(2));
    indices.push_back(index_t(3));
    indices.push_back(index_t(0));
    mVboMesh.bufferIndices(indices);
}
开发者ID:UIKit0,项目名称:bluegin,代码行数:41,代码来源:VBOTest.cpp


示例16: update

void VboSampleApp::update()
{
    // mCamera.lookAt(Vec3f(0, 0, 5.0f), Vec3f(0, 0, 0));
	gl::setMatrices( mCamera );

    vector<Vec3f> positions;
    positions.push_back(Vec3f(-1.0f+0.2f*sin(getElapsedSeconds()), 1.0f, 0));
    positions.push_back(Vec3f(-1.0f, -1.0f, 0));
    positions.push_back(Vec3f(1.0f, -1.0f, 0));
    positions.push_back(Vec3f(1.0f, 1.0f, 0));
    mVboMesh.bufferPositions(positions);
}
开发者ID:UIKit0,项目名称:bluegin,代码行数:12,代码来源:VBOTest.cpp


示例17: createVbo

void FolApp::createVbo()
{
    gl::VboMesh::Layout layout;

    layout.setStaticPositions();
    layout.setStaticTexCoords2d();
    layout.setStaticIndices();

    std::vector<Vec3f> positions;
    std::vector<Vec2f> texCoords;
    std::vector<uint32_t> indices;

    int numVertices = VBO_X_SIZE * VBO_Y_SIZE;
    int numShapes = ( VBO_X_SIZE - 1 ) * ( VBO_Y_SIZE - 1 );

    mVboMesh = gl::VboMesh( numVertices, numShapes, layout, GL_POINTS );

    for ( int x = 0; x < VBO_X_SIZE; x++ )
    {
        for ( int y = 0; y < VBO_Y_SIZE; y++ )
        {
            indices.push_back( x * VBO_Y_SIZE + y );
            float xPer = x / (float)( VBO_X_SIZE - 1 );
            float yPer = y / (float)( VBO_Y_SIZE - 1 );

            /*
            positions.push_back( Vec3f( ( xPer * 2.0f - 1.0f ) * VBO_X_SIZE,
            							( yPer * 2.0f - 1.0f ) * VBO_Y_SIZE,
            							0.0f ) );
            */
            positions.push_back( Vec3f( x, y, 0 ) );
            texCoords.push_back( Vec2f( xPer, yPer ) );
        }
    }

    mVboMesh.bufferPositions( positions );
    mVboMesh.bufferIndices( indices );
    mVboMesh.bufferTexCoords2d( 0, texCoords );
    //mVboMesh.unbindBuffers();
}
开发者ID:gaborpapp,项目名称:apps,代码行数:40,代码来源:FolApp.cpp


示例18: getElapsedSeconds

void FastTrailsApp::update()
{
	// find out how many trails we should add
	const double	trails_per_second = 2000.0;
	double			elapsed = getElapsedSeconds() - mTime;
	uint32_t		num_trails = uint32_t(elapsed * trails_per_second);
	
	// add this number of trails 
	// (note: it's an ugly function that draws a swirling trail around a sphere, just for demo purposes)
	for(size_t i=0; i<num_trails; ++i ) {
		float		phi = mAngle * 0.01f;
		float		prev_phi = phi - 0.01f;
		float		theta = phi * 0.03f;
		float		prev_theta = prev_phi * 0.03f;

		Vec3f		pos = 45.0f * Vec3f( sinf( phi ) * cosf( theta ), sinf( phi ) * sinf( theta ), cosf( phi ) );
		Vec3f		prev_pos = 45.0f * Vec3f( sinf( prev_phi ) * cosf( prev_theta ), sinf( prev_phi ) * sinf( prev_theta ), cosf( prev_phi ) );

		Vec3f		direction = pos - prev_pos;
		Vec3f		right = Vec3f( sinf( 20.0f * phi ), 0.0f, cosf( 20.0f * phi ) );
		Vec3f		normal = direction.cross( right ).normalized();

		// add two vertices, one at each side of the center line
		mTrail.push_front( pos - 1.0f * normal );
		mTrail.push_front( pos + 1.0f * normal );

		mAngle += 1.0;
	}

	// keep trail length within bounds
	while( mTrail.size() > TRAIL_LENGTH )
		mTrail.pop_back();

	// copy to trail to vbo (there's probably a faster way than this, need to check that out later)
	gl::VboMesh::VertexIter itr = mVboMesh.mapVertexBuffer();
	for( size_t i=0; i<mTrail.size(); ++i, ++itr )
		itr.setPosition( mTrail[i] );

	// advance time
	mTime += num_trails / trails_per_second;
}
开发者ID:audionerd,项目名称:Cinder-Samples,代码行数:41,代码来源:FastTrailsApp.cpp


示例19: update

void FlockingParticlesApp::update() {
	
	// update physics
	timer->stop();
	double dt = timer->getSeconds();
	timer->start();
	
	float mouseX = (float)getMousePos().x;
	float mouseY = (float)getMousePos().y;
	attractor->setPosition(Vec3f(mouseX, mouseY, 0));
	
	physics->update(dt);
	
	// copy particle positions into vbo
	gl::VboMesh::VertexIter iter = vboParticles.mapVertexBuffer();
	for(vector<Particle*>::iterator p = physics->particles.begin(); p != physics->particles.end(); p++) {
		if(!(*p)->isAlive) continue;
		iter.setPosition((*p)->position.x, (*p)->position.y, (*p)->position.z);
		++iter;
	}
}
开发者ID:audionerd,项目名称:FieldKit.cpp,代码行数:21,代码来源:FlockingParticlesApp.cpp


示例20: vitr

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;
    }
}
开发者ID:stdmtb,项目名称:uf_0.8.6,代码行数:23,代码来源:cApp.cpp



注:本文中的gl::VboMesh类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ glacier2::RouterPrx类代码示例发布时间:2022-05-31
下一篇:
C++ gl::TextureRef类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap