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


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

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


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

示例1: addTriangleIndices

void ciFaceTracker::addTriangleIndices(TriMesh& mesh) const {
    for (int i = 0; i < mTri.rows; i++) {
        int i0 = mTri.it(i, 0), i1 = mTri.it(i, 1), i2 = mTri.it(i, 2);
        bool visible = getVisibility(i0) && getVisibility(i1) && getVisibility(i2);
        if (mUseInvisible || visible) {
            mesh.appendTriangle(i0, i1, i2);
        }
    }
}
开发者ID:KeeganRen,项目名称:FaceVFX,代码行数:9,代码来源:ciFaceTracker.cpp

示例2: addQuad

void TerrainApp::addQuad( int x, int y )
{
	Vec2f p00( x, y );
	Vec2f p10( x + 1, y );
	Vec2f p11( x + 1, y + 1 );
	Vec2f p01( x, y + 1 );

	float zScale = mHeight;
	float noiseScale = mNoiseScale;
	float z00 = zScale * mPerlin.fBm( p00 * noiseScale );
	float z10 = zScale * mPerlin.fBm( p10 * noiseScale );
	float z11 = zScale * mPerlin.fBm( p11 * noiseScale );
	float z01 = zScale * mPerlin.fBm( p01 * noiseScale );

	size_t idx = mTriMesh.getNumVertices();

	// positions
	Vec3f t00( p00.x - xSize / 2., z00, p00.y - ySize / 2. );
	Vec3f t10( p10.x - xSize / 2., z10, p10.y - ySize / 2. );
	Vec3f t11( p11.x - xSize / 2., z11, p11.y - ySize / 2. );
	Vec3f t01( p01.x - xSize / 2., z01, p01.y - ySize / 2. );

	mTriMesh.appendVertex( t00 );
	mTriMesh.appendVertex( t10 );
	mTriMesh.appendVertex( t01 );

	mTriMesh.appendVertex( t10 );
	mTriMesh.appendVertex( t11 );
	mTriMesh.appendVertex( t01 );

	// normals
	Vec3f n0 = ( t10 - t00 ).cross( t10 - t01 ).normalized();
	Vec3f n1 = ( t11 - t10 ).cross( t11 - t01 ).normalized();
	mTriMesh.appendNormal( n0 );
	mTriMesh.appendNormal( n0 );
	mTriMesh.appendNormal( n0 );
	mTriMesh.appendNormal( n1 );
	mTriMesh.appendNormal( n1 );
	mTriMesh.appendNormal( n1 );

	mTriMesh.appendTriangle( idx, idx + 1, idx + 2 );
	mTriMesh.appendTriangle( idx + 3, idx + 4, idx + 5 );
}
开发者ID:gaborpapp,项目名称:apps,代码行数:43,代码来源:TerrainApp.cpp

示例3: addQuadToMesh

void addQuadToMesh( TriMesh& mesh, const Vec3f& P0, const Vec3f& P1, const Vec3f& P2, const Vec3f& P3 )
{
	mesh.appendVertex( P0 );
	mesh.appendVertex( P1 );
	mesh.appendVertex( P2 );
	mesh.appendVertex( P3 );
	int vert0 = mesh.getNumVertices() - 4;
	int vert1 = mesh.getNumVertices() - 1;
	int vert2 = mesh.getNumVertices() - 2;
	int vert3 = mesh.getNumVertices() - 3;
	mesh.appendTriangle( vert0, vert1, vert3 );
	mesh.appendTriangle( vert3, vert1, vert2 );
}
开发者ID:AKS2346,项目名称:Cinder,代码行数:13,代码来源:Tube.cpp

示例4: writeMesh

void GeoDeVisualizerApp::writeMesh(json &j)
{
    vector<Vec3f> vertices;
    for (json::iterator vecIt = j["vertices"].begin(); vecIt != j["vertices"].end(); vecIt += 3) {
        vertices.push_back(Vec3f(*vecIt, *(vecIt+1), *(vecIt+2)));
    }
    
    u32 i = 0;
    for (json::iterator faceIt = j["face indices"].begin(); faceIt != j["face indices"].end(); faceIt += 3) {
        mTriangles.appendTriangle(3*i, 3*i+1, 3*i+2);
        mTriangles.appendVertex(vertices[*faceIt]);
        mTriangles.appendVertex(vertices[*(faceIt+1)]);
        mTriangles.appendVertex(vertices[*(faceIt+2)]);
        i++;
    }
}
开发者ID:nikhilshinday,项目名称:GeoDe,代码行数:16,代码来源:GeoDeVisualizerApp.cpp

示例5: generateQuad

BaseMeshRef SimpleMesh::generateQuad(Rectf dimensions,
                                     Rectf uvCoords = Rectf(0.0f, 0.0f, 1.0f,
                                             1.0f)) {

    // cout << "SimpleMesh::GenerateQuad(); dims: " << dimensions
    //     << " uvCoords: " << uvCoords << endl;

    TriMesh mesh;
    mesh.clear();

    // Vertexes
    mesh.appendVertex(Vec3f(dimensions.x1, dimensions.y1, 0));
    mesh.appendVertex(Vec3f(dimensions.x1, dimensions.y2, 0));
    mesh.appendVertex(Vec3f(dimensions.x2, dimensions.y2, 0));
    mesh.appendVertex(Vec3f(dimensions.x2, dimensions.y1, 0));

    // Vertex Colors
    mesh.appendColorRgb(Color(1.0f, 1.0f, 1.0f));
    mesh.appendColorRgb(Color(1.0f, 1.0f, 1.0f));
    mesh.appendColorRgb(Color(1.0f, 1.0f, 1.0f));
    mesh.appendColorRgb(Color(1.0f, 1.0f, 1.0f));

    // Tex coords
    mesh.appendTexCoord(Vec2f(uvCoords.x1, uvCoords.y1));
    mesh.appendTexCoord(Vec2f(uvCoords.x1, uvCoords.y2));
    mesh.appendTexCoord(Vec2f(uvCoords.x2, uvCoords.y2));
    mesh.appendTexCoord(Vec2f(uvCoords.x2, uvCoords.y1));

    int vert0 = mesh.getNumVertices() - 4;
    int vert1 = mesh.getNumVertices() - 1;
    int vert2 = mesh.getNumVertices() - 2;
    int vert3 = mesh.getNumVertices() - 3;

    mesh.appendTriangle(vert0, vert1, vert3);
    mesh.appendTriangle(vert3, vert1, vert2);

    mesh.recalculateNormals();

    SimpleMeshRef meshWrapper = make_shared<SimpleMesh>(mesh);
    meshWrapper->_bounds = mesh.calcBoundingBox();
    return dynamic_pointer_cast<BaseMesh>(meshWrapper);
}
开发者ID:,项目名称:,代码行数:42,代码来源:

示例6: bezierMesh

void ProjectionMappingApp::bezierMesh(const int mode)
{

	const int span = mSpan;
	float hx = mHandleSize;
	float hy = mHandleSize;

	//if (mode == 0) { mMesh.clear();	}

	int k = 0;
	for (int ix = 0; ix < mGridNum.x-1; ++ix) {
		for (int iu = 0; iu < span; ++iu) {
			if (ix > 0 && iu == 0) continue;

			for (int iy = 0; iy < mGridNum.y-1; ++iy) {
				for (int iv = 0; iv < span; ++iv) {
					if (iy > 0 && iv == 0) continue;

					int loc0 = ((ix+0)*(mGridNum.y)) + (iy+0);
					int loc1 = ((ix+0)*(mGridNum.y)) + (iy+1);
					int loc2 = ((ix+1)*(mGridNum.y)) + (iy+0);
					int loc3 = ((ix+1)*(mGridNum.y)) + (iy+1);

					Vec2f p[4][4];
					p[0][0] = deform(mCtrlPoints[loc0].base+Vec2f(0,  0))  + mCtrlPoints[loc0].mag;
					p[0][1] = deform(mCtrlPoints[loc0].base+Vec2f(0,  hy)) + mCtrlPoints[loc0].mag;
					p[0][2] = deform(mCtrlPoints[loc1].base+Vec2f(0, -hy)) + mCtrlPoints[loc1].mag;
					p[0][3] = deform(mCtrlPoints[loc1].base+Vec2f(0,  0))  + mCtrlPoints[loc1].mag;

					p[1][0] = deform(mCtrlPoints[loc0].base+Vec2f(hx,  0))  + mCtrlPoints[loc0].mag;
					p[1][1] = deform(mCtrlPoints[loc0].base+Vec2f(hx,  hy)) + mCtrlPoints[loc0].mag;
					p[1][2] = deform(mCtrlPoints[loc1].base+Vec2f(hx, -hy)) + mCtrlPoints[loc1].mag;
					p[1][3] = deform(mCtrlPoints[loc1].base+Vec2f(hx,  0))  + mCtrlPoints[loc1].mag;

					p[2][0] = deform(mCtrlPoints[loc2].base+Vec2f(-hx,  0))  + mCtrlPoints[loc2].mag;
					p[2][1] = deform(mCtrlPoints[loc2].base+Vec2f(-hx,  hy)) + mCtrlPoints[loc2].mag;
					p[2][2] = deform(mCtrlPoints[loc3].base+Vec2f(-hx, -hy)) + mCtrlPoints[loc3].mag;
					p[2][3] = deform(mCtrlPoints[loc3].base+Vec2f(-hx,  0))  + mCtrlPoints[loc3].mag;

					p[3][0] = deform(mCtrlPoints[loc2].base+Vec2f(0,  0))  + mCtrlPoints[loc2].mag;
					p[3][1] = deform(mCtrlPoints[loc2].base+Vec2f(0,  hy)) + mCtrlPoints[loc2].mag;
					p[3][2] = deform(mCtrlPoints[loc3].base+Vec2f(0, -hy)) + mCtrlPoints[loc3].mag;
					p[3][3] = deform(mCtrlPoints[loc3].base+Vec2f(0,  0))  + mCtrlPoints[loc3].mag;

					mCtrlPoints[loc0].pos = p[0][0];
					mCtrlPoints[loc1].pos = p[0][3];
					mCtrlPoints[loc2].pos = p[3][0];
					mCtrlPoints[loc3].pos = p[3][3];

					float v = (float)iv/(float)(span-1);
					float u = (float)iu/(float)(span-1);

					Vec2f r[4];
					r[0] = bezierNrm(p[0], v);
					r[1] = bezierNrm(p[1], v);
					r[2] = bezierNrm(p[2], v);
					r[3] = bezierNrm(p[3], v);

					Vec2f fp = bezierNrm(r, u);

					if (mode == 0) { // create
						mMesh.appendVertex(Vec3f(fp.x, fp.y, 0));
						mMesh.appendTexCoord(Vec2f(fp.x, fp.y));
					} else { // update
						mMesh.getVertices()[k] = Vec3f(fp.x, fp.y, 0);
					}
					k++;
				}
			}
		}
	}

	if (mode == 0) { // create
		int nx = ((mGridNum.x-1)*span) - (mGridNum.x-2);
		int ny = ((mGridNum.y-1)*span) - (mGridNum.y-2);

		int id = 0;
		for (int ix = 0; ix < nx-1; ++ix) {
			for (int iy = 0; iy < ny-1; ++iy) {
				int id0 = id;
				int id1 = id+1;
				int id2 = id1+ny;
				int id3 = id2-1;
				mMesh.appendTriangle(id0, id1, id2);
				mMesh.appendTriangle(id0, id2, id3);			
				++id;
			}
			++id;
		}
	}
}
开发者ID:toshinoritakata,项目名称:MeshWarp,代码行数:91,代码来源:MeshWarpApp.cpp

示例7: setup

void RodSoundApp::setup()
{
//  std::cout << solveBEM(constants::radius) << "\n\n";
//  std::cout << "Expected:\n" << -constants::pi * constants::radius * constants::radius * Mat2e::Identity() << "\n\n";
  
  // Setup scene
  cam.setPerspective(40.0, getWindowAspectRatio(), 0.1, 1000.0);
  cam.lookAt(eyePos, targetPos, Vec3c(0.0, 1.0, 0.0));
  
  // Setup rendering stuff
  spheredl = new gl::DisplayList(GL_COMPILE);
  spheredl->newList();
  gl::drawSphere(Vec3c::zero(), constants::radius);
  spheredl->endList();
  
  cylinderdl = new gl::DisplayList(GL_COMPILE);
  cylinderdl->newList();
  gl::drawCylinder(constants::radius, constants::radius, 1.0);
  cylinderdl->endList();
  
  l = new gl::Light(gl::Light::POINT, 0);
  
  try {
    rodTex = loadImage(loadResource(RES_SIM_YARN_TEX));
  } catch (ImageIoException e) {
    std::cerr << "Error loading textures: " << e.what();
    exit(1);
  }
  
  // Load and compile shaders
  try {
    diffuseProg = gl::GlslProg(loadResource(RES_SIM_VERT_GLSL), loadResource(RES_SIM_FRAG_GLSL));
    rodProg = gl::GlslProg(loadResource(RES_SIM_VERT_TEX_GLSL), loadResource(RES_SIM_FRAG_TEX_GLSL));
  } catch (gl::GlslProgCompileExc e) {
    std::cerr << "Error compiling GLSL program: " << e.what();
    exit(1);
  } catch (ResourceLoadExc e) {
    std::cerr << "Error loading shaders: " << e.what();
    exit(1);
  }
  
  floor.appendVertex(Vec3c(-100.0, 0.0, -100.0));
  floor.appendNormal(Vec3c(0.0, 1.0, 0.0));
  floor.appendTexCoord(Vec2c(-12.0, -12.0));
  floor.appendVertex(Vec3c(100.0, 0.0, -100.0));
  floor.appendNormal(Vec3c(0.0, 1.0, 0.0));
  floor.appendTexCoord(Vec2c(12.0, -12.0));
  floor.appendVertex(Vec3c(100.0, 0.0, 100.0));
  floor.appendNormal(Vec3c(0.0, 1.0, 0.0));
  floor.appendTexCoord(Vec2c(12.0, 12.0));
  floor.appendVertex(Vec3c(-100.0, 0.0, 100.0));
  floor.appendNormal(Vec3c(0.0, 1.0, 0.0));
  floor.appendTexCoord(Vec2c(-12.0, 12.0));
  floor.appendTriangle(0, 1, 2);
  floor.appendTriangle(0, 3, 2);
  
  ci::Surface s(4, 4, false);
  auto iter = s.getIter();
  do {
    do {
      Vec2i pos = iter.getPos();
      unsigned char val = pos.x > 0 && pos.x < 3 && pos.y > 0 && pos.y < 3 ? 100 : 150;
      iter.r() = iter.g() = iter.b() = val;
    } while (iter.pixel());
  } while (iter.line());
  floorTex = gl::Texture(s);
  floorTex.setMagFilter(GL_NEAREST);
  floorTex.setWrap(GL_REPEAT, GL_REPEAT);
  
  // Load the rod
  loadDefaultRod(50);
  // loadRodFile("");
  loadStdEnergies();
  
  PROFILER_START("Total");
}
开发者ID:RafaelMarinheiro,项目名称:yarn-cloth-sim,代码行数:76,代码来源:RodSoundApp.cpp


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