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

C++ Tesselator类代码示例

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

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



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

示例1: Array

/*! Get the tesselated shape as arrays of vertices and indices
	The geometry function extracts the triangle information from 
	the tesselated contours.  It fills an array of vertices and an 
	array of indices with the tesselation data, which can be used 
	with a Mesh to draw it to screen.
	
	<luacode>
	local vertex = Array()
	local index = Array()

	tess:geometry(vertex, index)

	local mesh = Mesh(ctx)
	mesh:vertex(vertex)
	mesh:index(index)
	mesh.primitive = GL.TRIANGLES
	</luacode>
	
	@param vertices The vertex array
	@param indices The indices array
	
	@name Tesselator:geometry
	
	@see Array
	@see opengl.Mesh
*/
int lua_tess_geometry(lua_State *L) {
	Tesselator *s = Glue<Tesselator>::checkto(L, 1);
	AlloArray *vertex = lua_array_checkto(L, 2);
	AlloArray *index = lua_array_checkto(L, 3);
	s->geometry(vertex, index);
	return 0;
}
开发者ID:LuaAV,项目名称:LuaAV,代码行数:33,代码来源:lua_opengl_tess.cpp


示例2: createGraphicsBase

static void createGraphicsBase(const std::vector<std::vector<Point2f> >& polygons, GraphicsBase& result, bool evenodd, bool texcoords = false, float stx = 0, float sty = 0, const Matrix* matrix = NULL)
{
	Tesselator tes;
	tes.tesselate(polygons, evenodd);

	int start = result.vertices.size();
	int ntriangles = tes.triangles.size() / 2;

	for (std::size_t i = 0; i < ntriangles; ++i)
	{
		float x = tes.triangles[i * 2 + 0];
		float y = tes.triangles[i * 2 + 1];

		result.vertices.push_back(Point2f(x, y));
		if (texcoords)
		{
			float tx, ty;
			matrix->transformPoint(x, y, &tx, &ty);
			result.texcoords.push_back(Point2f(tx * stx, ty * sty));
		}

		result.indices.push_back(start + i);
	}
	result.vertices.Update();
	result.indices.Update();
	if (texcoords)
		result.texcoords.Update();
}
开发者ID:popcade,项目名称:gideros,代码行数:28,代码来源:shape.cpp


示例3: lua_tess_Vertex

/*! Set a contour vertex
	@param pos The position
	@name Tesselator:Vertex
*/
int lua_tess_Vertex(lua_State *L) {
	Tesselator *s = Glue<Tesselator>::checkto(L, 1);
	vec2 v;
	if(lua::to_vec<double>(L, 2, 2, &(v.x))) {
		s->Vertex(v);
	}
	else {
		luaL_error(L, "Tesselator.vertex: invalid arguments\n");
	}
	return 0;
}
开发者ID:LuaAV,项目名称:LuaAV,代码行数:15,代码来源:lua_opengl_tess.cpp


示例4: mergeRings

	void Polygon::tesselate( AppearanceManager &appearanceManager, const TVec3d& normal )
	{
		_indices.clear();

		if ( !_exteriorRing || _exteriorRing->size() < 3 )
		{ 
			mergeRings( appearanceManager );
			return;
		}

		TexCoords texCoords;
		bool t = appearanceManager.getTexCoords( _exteriorRing->getId(), texCoords );
		_exteriorRing->finish( t ? &texCoords : &_texCoords );
		if ( t ) std::copy( texCoords.begin(), texCoords.end(), std::back_inserter( _texCoords ) );

		for ( unsigned int i = 0; i < _interiorRings.size(); i++ ) {
			TexCoords texCoords;
			bool t = appearanceManager.getTexCoords( _interiorRings[i]->getId(), texCoords );
			_interiorRings[i]->finish( t ? &texCoords : &_texCoords );
			if ( t ) std::copy( texCoords.begin(), texCoords.end(), std::back_inserter( _texCoords ) );
		}

		// Compute the total number of vertices
		unsigned int vsize = _exteriorRing->size();
		for ( unsigned int i = 0; i < _interiorRings.size(); i++ )
			vsize += _interiorRings[i]->size();

		Tesselator* tess = appearanceManager.getTesselator();
		tess->init( vsize, normal );

		tess->addContour( _exteriorRing->getVertices(), texCoords );

		for ( unsigned int i = 0; i < _interiorRings.size(); i++ )
			tess->addContour( _interiorRings[i]->getVertices(), texCoords ); 

		tess->compute();
		_vertices.reserve( tess->getVertices().size() );
		std::copy( tess->getVertices().begin(), tess->getVertices().end(), std::back_inserter( _vertices ) );

		unsigned int indicesSize = tess->getIndices().size();
		if ( indicesSize > 0 ) 
		{
			_indices.resize( indicesSize );
			memcpy( &_indices[0], &tess->getIndices()[0], indicesSize * sizeof(unsigned int) );
		}
		clearRings();
	}
开发者ID:jpouderoux,项目名称:libcitygml-jklimke,代码行数:47,代码来源:citymodel.cpp


示例5: CombineCallback_s

	static void CombineCallback_s(GLdouble coords[3], GLdouble *data[4], GLfloat weight[4], GLdouble **dataOut, void* polygon_data)   
	{   
		Tesselator* that = static_cast<Tesselator*>(polygon_data);
		that->CombineCallback(coords, data, weight, dataOut);
	}   
开发者ID:popcade,项目名称:gideros,代码行数:5,代码来源:shape.cpp


示例6: VertexCallback_s

	static void VertexCallback_s(GLvoid *vertex, void* polygon_data)   
	{   
		Tesselator* that = static_cast<Tesselator*>(polygon_data);
		that->VertexCallback(vertex);
	} 
开发者ID:popcade,项目名称:gideros,代码行数:5,代码来源:shape.cpp


示例7: EndCallback_s

	static void EndCallback_s(void* polygon_data)   
	{   
		Tesselator* that = static_cast<Tesselator*>(polygon_data);
		that->EndCallback();
	}
开发者ID:popcade,项目名称:gideros,代码行数:5,代码来源:shape.cpp


示例8: BeginCallback_s

	static void BeginCallback_s(GLenum type, void* polygon_data)   
	{   
		Tesselator* that = static_cast<Tesselator*>(polygon_data);
		that->BeginCallback(type);
	} 
开发者ID:popcade,项目名称:gideros,代码行数:5,代码来源:shape.cpp


示例9: lua_tess_EndContour

/*! End a contour within a polygon
	
	@name Tesselator:EndContour
*/
int lua_tess_EndContour(lua_State *L) {
	Tesselator *s = Glue<Tesselator>::checkto(L, 1);
	s->EndContour();
	return 0;
}
开发者ID:LuaAV,项目名称:LuaAV,代码行数:9,代码来源:lua_opengl_tess.cpp


示例10: lua_tess_EndPolygon

/*! End a polygon
	
	@name Tesselator:EndPolygon
*/
int lua_tess_EndPolygon(lua_State *L) {
	Tesselator *s = Glue<Tesselator>::checkto(L, 1);
	s->EndPolygon();
	return 0;
}
开发者ID:LuaAV,项目名称:LuaAV,代码行数:9,代码来源:lua_opengl_tess.cpp


示例11: py_triangulation

TriangleSetPtr py_triangulation( const GeometryPtr& obj) {
	if (!obj)throw PythonExc_ValueError("Cannot tesselate empty object.");
	Tesselator t;
	if (!obj->apply(t))throw PythonExc_ValueError("Error in tesselation.");
	else return t.getTriangulation();
}
开发者ID:kkremitzki,项目名称:plantgl,代码行数:6,代码来源:export_discretizer.cpp


示例12: Output

void  Output(double* OutputCoords[3], int* OutputIndices[3])
{
	if (tess.getIndices().size() == 0 ||OutputIndices == NULL || OutputIndices == NULL)
	{
		return;
	}
	std::vector<TVec3d>::iterator itr = tess.getVertices().begin();
	for (int i = 0;itr != tess.getVertices().end(); itr++, i++)
	{
		OutputCoords[i][0] = itr->x;
		OutputCoords[i][1] = itr->y;
		OutputCoords[i][2] = itr->z;
#ifdef _DEBUG
		//test
		std::cout<<OutputCoords[i][0]<<OutputCoords[i][1]<<OutputCoords[i][2]<<std::endl;
#endif
	}
#ifdef _DEBUG
	//test
	std::cout<<"good5"<<std::endl;
#endif
	std::vector<unsigned int>::iterator itr2 = tess.getIndices().begin();
	for (int i = 0; itr2 != tess.getIndices().end(); itr2 += 3, i++)
	{
		OutputIndices[i][0] = *itr2;
		OutputIndices[i][1] = *(itr2 + 1);
		OutputIndices[i][2] = *(itr2 + 2);
#ifdef _DEBUG	
		//test
		std::cout<<OutputIndices[i][0]<<OutputIndices[i][1]<<OutputIndices[i][2]<<std::endl;
#endif
	}
	//very important
	tess.getIndices().clear();
	tess.getVertices().clear();
	tess.getTexCoords().clear();
	std::vector<Vec3*>::iterator itr3 = IntRingCoords.begin();
	for (;itr3 != IntRingCoords.end(); itr3++)
	{
		delete *itr3;
		*itr3 = NULL;
	}
	IntRingCoords.clear();
	IntRingCoordsNum.clear();
#ifdef _DEBUG
	//test
	std::cout<<"good6"<<std::endl;	
#endif
}
开发者ID:johnzjq,项目名称:mySVN,代码行数:49,代码来源:Interface.cpp


示例13: Tessellation

bool  Tessellation(int& OutputVertNum, int& OutputIndiceNum)
{
	if (ExtRingCoords == NULL)
	{
		return false;
	}
#ifdef _DEBUG
	//test
	std::cout<<"EXT"<<std::endl;
	std::cout<<ExtRingVertNum<<std::endl;
	for (int i = 0; i < ExtRingVertNum; i++)
	{
		std::cout<<ExtRingCoords[i][0]<<ExtRingCoords[i][1]<<ExtRingCoords[i][2]<<std::endl;
	}
	std::cout<<"INT"<<std::endl;
	std::cout<<IntRingCoordsNum.size()<<std::endl;
	std::vector<int>::iterator itr = IntRingCoordsNum.begin();
	std::vector<Vec3*>::iterator itr2 = IntRingCoords.begin();
	for (;itr != IntRingCoordsNum.end(); itr++, itr2++)
	{
		std::cout<<*itr<<std::endl;
		for (int i = 0 ; i <*itr; i ++ )
		{
			std::cout<<(*itr2)[i][0]<<(*itr2)[i][1]<<(*itr2)[i][2]<<std::endl;
		}
	}
	std::cout<<"good1"<<std::endl;
#endif

	int IntRingNum = IntRingCoords.size();
	//calculate the normal
	Vec3 pNorm;
	pNorm[0] = 0.0;
	pNorm[1] = 0.0;
	pNorm[2] = 0.0;

	Vec3 lVert;
	lVert[0] = ExtRingCoords[ExtRingVertNum - 1][0];
	lVert[1] = ExtRingCoords[ExtRingVertNum - 1][1];
	lVert[2] = ExtRingCoords[ExtRingVertNum - 1][2];

	for (int i = 0 ; i < ExtRingVertNum; i++)
	{
		Vec3 pStep;
		pStep[0] = (lVert[2] + ExtRingCoords[i][2]) * (lVert[1] - ExtRingCoords[i][1]);
		pStep[1] = (lVert[0] + ExtRingCoords[i][0]) * (lVert[2] - ExtRingCoords[i][2]);
		pStep[2] = (lVert[1] + ExtRingCoords[i][1]) * (lVert[0] - ExtRingCoords[i][0]);

		pNorm[0] = pNorm[0] + pStep[0];
		pNorm[1] = pNorm[1] + pStep[1];
		pNorm[2] = pNorm[2] + pStep[2];

		lVert[0] = ExtRingCoords[i][0];
		lVert[1] = ExtRingCoords[i][1];
		lVert[2] = ExtRingCoords[i][2];
	}
#ifdef _DEBUG
	//test
	std::cout<<"good2"<<std::endl;
#endif
	//do tessellation
	//verts number
	int VertNum = ExtRingVertNum;
	for (int i = 0; i < IntRingCoordsNum.size(); i++)
		VertNum += IntRingCoordsNum[i];
	//
#ifdef _DEBUG
	//test
	std::cout<<"good2.1"<<std::endl;
	std::cout<<"VertNum: "<<VertNum<<std::endl;
	std::cout<<pNorm[0]<<pNorm[1]<<pNorm[2]<<std::endl;
#endif
	tess.init(VertNum, TVec3d(pNorm[0], pNorm[1], pNorm[2]));
	std::vector<TVec3d> ring;
	std::vector<TVec2f> tag;//no use
	//add ExtierRing
	for (int i = 0; i < ExtRingVertNum; i++)
	{
		TVec3d vert(ExtRingCoords[i][0], ExtRingCoords[i][1], ExtRingCoords[i][2]);
		ring.push_back(vert);
	}
#ifdef _DEBUG
	//test
	std::cout<<"good2.2"<<std::endl;
	std::cout<<ring.size()<<std::endl;
#endif
	tess.addContour(ring, tag);
	ring.clear();
	//add InteriorRings
	for (int i = 0; i < IntRingNum; i++)
	{	
		for (int j = 0 ; j < IntRingCoordsNum[i]; j++)
		{
			TVec3d vert(IntRingCoords[i][j][0], IntRingCoords[i][j][1], IntRingCoords[i][j][2]);
			ring.push_back(vert);
		}
		tess.addContour(ring, tag);
		ring.clear();
	}
#ifdef _DEBUG
//.........这里部分代码省略.........
开发者ID:johnzjq,项目名称:mySVN,代码行数:101,代码来源:Interface.cpp



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ Test类代码示例发布时间:2022-05-31
下一篇:
C++ TessBaseAPI类代码示例发布时间: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