当前位置: 首页>>代码示例>>C++>>正文


C++ TriMesh::appendIndices方法代码示例

本文整理汇总了C++中TriMesh::appendIndices方法的典型用法代码示例。如果您正苦于以下问题:C++ TriMesh::appendIndices方法的具体用法?C++ TriMesh::appendIndices怎么用?C++ TriMesh::appendIndices使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TriMesh的用法示例。


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

示例1: setup

void BasicApplicationApp::setup()
{

	plane.appendVertex(Vec3f(0, 0, 0)); // [ (0,0,0) ]
    plane.appendColorRgba(Colorf(1.f,0,0));
    plane.appendTexCoord(Vec2f(0,0));
    
    plane.appendVertex(Vec3f(600, 0, 0)); // [ (0,0,0), (600,0,0) ]
    plane.appendColorRgba(Colorf(1.f,1.f,0));
    plane.appendTexCoord(Vec2f(1.f,0));
    
    plane.appendVertex(Vec3f(600, 600, 0)); // [ (0,0,0), (600,0,0), (600,600,0)]
    plane.appendColorRgba(Colorf(0,1.f,0));
    plane.appendTexCoord(Vec2f(1.f,1.f));
    
    plane.appendVertex(Vec3f(0, 600, 0)); // [ (0,0,0), (600,0,0), (600,600,0), (0,600,0)]
    plane.appendColorRgba(Colorf(0,0,1.f));
    plane.appendTexCoord(Vec2f(0.f,1.f));
    
    uint indices[6] = {0,1,2,2,3,0};
    plane.appendIndices(&indices[0], 6);
    
    mTexture = gl::Texture( loadImage()))

}
开发者ID:deniskovalev,项目名称:ciResonate,代码行数:25,代码来源:BasicApplicationApp.cpp

示例2: regenerateVboMesh

void BatchedMesh::regenerateVboMesh(MaterialRef material) {
  // cout << "BatchedMesh::regenerateVboMesh(): Regenerating VboMesh for
  // material:"
  //     << material << endl;

  TriMesh combinedMesh;
  vector<Vec3f> vertices;
  vector<ColorAf> colors;
  vector<Vec2f> texCoords;
  vector<uint32_t> indices;
  uint32_t vertCount = 0;
  _materialBounds[material] = AxisAlignedBox3f();

  for (BatchInfoRef batchInfo : _meshes[material]) {
    TriMesh *internalMesh = batchInfo->mesh->getInternalMesh(
        batchInfo->transform->getTransformMatrixLocal());

    vertices = internalMesh->getVertices();
    combinedMesh.appendVertices(vertices.data(), vertices.size());

    colors = internalMesh->getColorsRGBA();
    combinedMesh.appendColorsRgba(colors.data(), colors.size());

    texCoords = internalMesh->getTexCoords();
    combinedMesh.appendTexCoords(texCoords.data(), texCoords.size());

    indices = internalMesh->getIndices();
    std::transform(std::begin(indices), std::end(indices), std::begin(indices),
                   [vertCount](uint32_t x) { return x + vertCount; });
    combinedMesh.appendIndices(indices.data(), indices.size());

    vertCount += vertices.size();

    _materialBounds[material].include(internalMesh->calcBoundingBox());
  }

  _vboMeshes[material] = gl::VboMesh::create(combinedMesh);

  // Recalculate master bounds
  _bounds = AxisAlignedBox3f();
  for (auto &kvp : _materialBounds) {
    _bounds.include(kvp.second);
  }
}
开发者ID:,项目名称:,代码行数:44,代码来源:

示例3: createMesh

void SmoothDisplacementMappingApp::createMesh()
{
	// use the TriMesh class to easily construct the vertex buffer object
	TriMesh mesh;

	// create vertex, normal and texcoord buffers
	const int RES_X = 400;
	const int RES_Z = 100;
	const Vec3f size(200.0f, 1.0f, 50.0f);

	for(int x=0;x<RES_X;++x) {
		for(int z=0;z<RES_Z;++z) {
			float u = float(x) / RES_X;
			float v = float(z) / RES_Z;
			mesh.appendVertex( size * Vec3f( u - 0.5f , 0.0f, v - 0.5f ) );
			mesh.appendNormal( Vec3f::yAxis() );
			mesh.appendTexCoord( Vec2f( u, v ) );
		}
	}

	// create index buffer
	vector< uint32_t > indices;
	for(int x=0;x<RES_X-1;++x) {
		for(int z=0;z<RES_Z-1;++z) {
			uint32_t i = x * RES_Z + z;

			indices.push_back( i ); indices.push_back( i + 1 ); indices.push_back( i + RES_Z );
			indices.push_back( i + RES_Z );  indices.push_back( i + 1 ); indices.push_back( i + RES_Z + 1 );
		}
	}
	mesh.appendIndices( &indices.front(), indices.size() );

	// construct vertex buffer object
	gl::VboMesh::Layout layout;
	layout.setStaticPositions();
	layout.setStaticTexCoords2d();
	layout.setStaticIndices();
	layout.setStaticNormals();

	mVboMesh = gl::VboMesh( mesh, layout );
}
开发者ID:audionerd,项目名称:Cinder-Samples,代码行数:41,代码来源:SmoothDisplacementMappingApp.cpp

示例4: createTriMesh

TriMesh MeshHelper::createTriMesh( vector<uint32_t> &indices, const vector<Vec3f> &positions, 
	const vector<Vec3f> &normals, const vector<Vec2f> &texCoords )
{
	TriMesh mesh;
	if ( indices.size() > 0 ) {
		mesh.appendIndices( &indices[ 0 ], indices.size() );
	}
	if ( normals.size() > 0 ) {
		for ( vector<Vec3f>::const_iterator iter = normals.begin(); iter != normals.end(); ++iter ) {
			mesh.appendNormal( *iter );
		}
	}
	if ( positions.size() > 0 ) {
		mesh.appendVertices( &positions[ 0 ], positions.size() );
	}
	if ( texCoords.size() > 0 ) {
		for ( vector<Vec2f>::const_iterator iter = texCoords.begin(); iter != texCoords.end(); ++iter ) {
			mesh.appendTexCoord( *iter );
		}
	}
	return mesh;
}
开发者ID:bgstaal,项目名称:Cinder-MeshHelper,代码行数:22,代码来源:MeshHelper.cpp

示例5: appendIndices

 static void appendIndices( TriMesh& mesh, std::vector<uint32_t>& indices )
 {
     mesh.appendIndices( &indices[0], indices.size() );
 }
开发者ID:simongeilfus,项目名称:LuaBindings,代码行数:4,代码来源:BindCinderTriMesh.cpp

示例6: generateCapsule


//.........这里部分代码省略.........
    // Top half sphere
    
    // Generate the group of rings for the sphere
    for(unsigned int ring = 0; ring <= mNumRings; ring++ )
    {
        double r0 = mRadius * sinf ( ring * fDeltaRingAngle);
        double y0 = mRadius * cosf (ring * fDeltaRingAngle);
        
        // Generate the group of segments for the current ring
        for(unsigned int seg = 0; seg <= mNumSegments; seg++)
        {
            double x0 = r0 * cosf(seg * fDeltaSegAngle);
            double z0 = r0 * sinf(seg * fDeltaSegAngle);
            
            Vec3f p(x0, 0.5f * mHeight + y0, z0);
            Vec3f n(x0, y0, z0);
            mesh.appendVertex(p);
            mesh.appendNormal(n.normalized());
            mesh.appendTexCoord(Vec2f((double) seg / (double) mNumSegments, (double) ring / (double) mNumRings * sphereRatio));
            mesh.appendColorRgb(Colorf(1.0, 0, 0));
            
            // each vertex (except the last) has six indices pointing to it
            indices.push_back(offset + mNumSegments + 1);
            indices.push_back(offset + mNumSegments);
            indices.push_back(offset);
            indices.push_back(offset + mNumSegments + 1);
            indices.push_back(offset);
            indices.push_back(offset + 1);
            
            offset ++;
        } // end for seg
    } // end for ring
    
    // Cylinder part
    double deltaAngle = ((M_PI * 2.0) / mNumSegments);
    double deltamHeight = mHeight/(double)mNumSegHeight;
    
    for (unsigned short i = 1; i < mNumSegHeight; i++) {
        for (unsigned short j = 0; j<=mNumSegments; j++)
        {
            double x0 = mRadius * cosf(j*deltaAngle);
            double z0 = mRadius * sinf(j*deltaAngle);
            
            Vec3f p(x0, 0.5f*mHeight-i*deltamHeight, z0);
            Vec3f n(x0, 0, z0);
            mesh.appendVertex(p);
            mesh.appendNormal(n.normalized());
            mesh.appendTexCoord(Vec2f(j/(double)mNumSegments, i/(double)mNumSegHeight * cylinderRatio + sphereRatio));
            mesh.appendColorRgb(Colorf(0, 1.0 - (float(j)/float(mNumSegments)), 0));

            
            indices.push_back(offset + mNumSegments + 1);
            indices.push_back(offset + mNumSegments);
            indices.push_back(offset);
            indices.push_back(offset + mNumSegments + 1);
            indices.push_back(offset);
            indices.push_back(offset + 1);
            
            offset ++;
        }
    }

    // Bottom half sphere
    
    // Generate the group of rings for the sphere
    for(unsigned int ring = 0; ring <= mNumRings; ring++)
    {
        double r0 = mRadius * sinf (M_PI_2 + ring * fDeltaRingAngle);
        double y0 =  mRadius * cosf (M_PI_2 + ring * fDeltaRingAngle);
        
        // Generate the group of segments for the current ring
        for(unsigned int seg = 0; seg <= mNumSegments; seg++)
        {
            double x0 = r0 * cosf(seg * fDeltaSegAngle);
            double z0 = r0 * sinf(seg * fDeltaSegAngle);
            
            Vec3f p(x0, -0.5f*mHeight + y0, z0);
            Vec3f n(x0, y0, z0);
            mesh.appendVertex(p);
            mesh.appendNormal(n.normalized());
            mesh.appendTexCoord(Vec2f((double) seg / (double) mNumSegments, (double) ring / (double) mNumRings*sphereRatio + cylinderRatio + sphereRatio));
            mesh.appendColorRgb(Colorf(0, 0, float(ring)/float(mNumRings)));

            
            if (ring != mNumRings) 
            {
                // each vertex (except the last) has six indices pointing to it
                indices.push_back(offset + mNumSegments + 1);
                indices.push_back(offset + mNumSegments);
                indices.push_back(offset);
                indices.push_back(offset + mNumSegments + 1);
                indices.push_back(offset);
                indices.push_back(offset + 1);
            }
            offset ++;
        } // end for seg
    } // end for ring
    
    mesh.appendIndices( &indices[0], indices.size());
}
开发者ID:deniskovalev,项目名称:ciResonate,代码行数:101,代码来源:verticesApp.cpp

示例7: setup

void ssaoApp::setup()
{
    
    gl::disableVerticalSync();
    
    RENDER_MODE = DeferredRenderer::SHOW_FINAL_VIEW;
    
    //set up camera
    mCam.setPerspective( 45.0f, getWindowAspectRatio(), 0.1f, 10000.0f );
    Vec3f camPos( -14.0f, 7.0f, -14.0f );
    mCam.lookAt(camPos * 1.5f, Vec3f::zero(), Vec3f(0.0f, 1.0f, 0.0f) );
    mCam.setCenterOfInterestPoint(Vec3f::zero());
    mMayaCam.setCurrentCam(mCam);
    
    //create functions pointers to send to deferred renderer
    boost::function<void(gl::GlslProg*)> fRenderShadowCastersFunc = boost::bind( &ssaoApp::drawShadowCasters, this, boost::lambda::_1 );
    boost::function<void(gl::GlslProg*)> fRenderNotShadowCastersFunc = boost::bind( &ssaoApp::drawNonShadowCasters, this,  boost::lambda::_1 );
    boost::function<void(void)> fRenderOverlayFunc = boost::bind( &ssaoApp::drawOverlay, this );

    mDeferredRenderer.setup( fRenderShadowCastersFunc, fRenderNotShadowCastersFunc, NULL, NULL, &mCam, Vec2i(1024, 768), 1024, true, true ); //no overlay or "particles"
    
    //have these cast point light shadows
    mDeferredRenderer.addCubeLight(    Vec3f(-2.0f, 4.0f, 6.0f),      Color(0.10f, 0.69f, 0.93f) * LIGHT_BRIGHTNESS_DEFAULT, true);      //blue
    mDeferredRenderer.addCubeLight(    Vec3f(4.0f, 6.0f, -4.0f),      Color(0.94f, 0.15f, 0.23f) * LIGHT_BRIGHTNESS_DEFAULT, true);      //red
    
    //add a bunch of lights
    for(int i = 0; i < 10; i++) {
        for(int j = 0; j < 10; j++) {
        
            int randColIndex = Rand::randInt(5);
            Color randCol;
            switch( randColIndex ) {
                case 0:
                    randCol = Color(0.99f, 0.67f, 0.23f); //orange
                    break;
                case 1:
                    randCol = Color(0.97f, 0.24f, 0.85f); //pink
                    break;
                case 2:
                    randCol = Color(0.00f, 0.93f, 0.30f); //green
                    break;
                case 3:
                    randCol = Color(0.98f, 0.96f, 0.32f); //yellow
                    break;
                case 4:
                    randCol = Color(0.10f, 0.69f, 0.93f); //blue
                    break;
                case 5:
                    randCol = Color(0.94f, 0.15f, 0.23f); //red
                    break;
            };
            
            mDeferredRenderer.addCubeLight( Vec3f( i * 20, 30, j * 20), randCol * LIGHT_BRIGHTNESS_DEFAULT, false, true);
        }
    }
    
    mCurrLightIndex = 0;
    
    float size = 3000;
    
    plane.appendVertex(Vec3f(size, -1,-size));
    plane.appendColorRgba(ColorA(255,255,255,255));
    plane.appendNormal(Vec3f(.0f, 1.0f, 0.0f));
    plane.appendVertex(Vec3f(-size, -1,-size));
    plane.appendColorRgba(ColorA(255,255,255,255));
    plane.appendNormal(Vec3f(.0f, 1.0f, 0.0f));
    plane.appendVertex(Vec3f(-size, -1, size));
    plane.appendColorRgba(ColorA(255,255,255,255));
    plane.appendNormal(Vec3f(.0f, 1.0f, 0.0f));
    plane.appendVertex(Vec3f(size, -1, size));
    plane.appendColorRgba(ColorA(255,255,255,255));
    plane.appendNormal(Vec3f(.0f, 1.0f, 0.0f));
    
    uint indices[6] = {0,1,2,2,3,0};
    plane.appendIndices(&indices[0], 6);
    
    gl::VboMesh::Layout layout;
    shadowPlane = gl::VboMesh::create(plane);
    
    TriMesh bunnyMesh;
    ObjLoader loader( loadResource(RES_BUNNY) );
	loader.load( &bunnyMesh );
    
    bunny = gl::VboMesh(bunnyMesh);
    
}
开发者ID:deniskovalev,项目名称:ciResonate,代码行数:86,代码来源:ssaoApp.cpp

示例8: setup

void TextureTestApp::setup()
{
  Vec3f vertices[] = {
    { -1, -1, 0 }, {  1, -1, 0 }, {  1, 1, 0 },
    { -1, -1, 0 }, {  1,  1, 0 }, { -1, 1, 0 }, 
  };
  
  mesh.appendVertices(vertices,
                      sizeof(vertices) / sizeof(vertices[0]));

  Vec2f tex_coords[] = {
    { 0, 0.5 }, { 0.5, 0.5 }, { 0.5, 0 },
    { 0, 0.5 }, { 0.5, 0 }, { 0, 0 },
  };
  
  mesh.appendTexCoords(tex_coords,
                       sizeof(tex_coords) / sizeof(tex_coords[0]));

  uint32_t indices[] = {
    0, 1, 2,
    3, 4, 5,
  };
  
  mesh.appendIndices(indices,
                     sizeof(indices) / sizeof(indices[0]));

  mesh.recalculateNormals();
  
  // assetフォルダから画像を読み込む
  // 幅と高さは2のべき乗でなくてもよい
  image = loadImage(loadAsset("miku.png"));

  // 平行光源を1つ用意
  light = std::unique_ptr<gl::Light>(new gl::Light(gl::Light::DIRECTIONAL, 0));
  light->setAmbient(Color(0.0, 0.0, 0.0));
  light->setDiffuse(Color(1.0, 1.0, 1.0));
  light->setDirection(Vec3f(0.0, 0.0, 1.0));

  // カメラの準備
  camera = CameraPersp(getWindowWidth(), getWindowHeight(),
                       35.0, 0.5, 1000.0);

  camera.lookAt(Vec3f(0.0, 0.0, 700.0),
                Vec3f(0.0, 0.0, 0.0));

 
  // テクスチャON
  gl::enable(GL_TEXTURE_2D);
  // 半透明処理を有効化
  gl::enableAlphaBlending(true);
 
  // カリングON
  gl::enable(GL_CULL_FACE);

  // gl::color or 頂点カラーを対象にしてライティングの計算を行う
  gl::enable(GL_COLOR_MATERIAL);
  
  // ライティングON
  gl::enable(GL_LIGHTING);
  // 法線を正規化する
  gl::enable(GL_NORMALIZE);

  rx = ry = rz = 0.0;
}
开发者ID:PS14,项目名称:Cinder-Sample,代码行数:64,代码来源:TextureTestApp.cpp


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