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


C++ GeometryPtr::endTriangles方法代码示例

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


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

示例1: renderScene

void renderScene(void) {

	//open file
	fstream file;
	stringstream filename;
	filename << "ProjectionData_"<< time(0)<<".dat";

	file.open(filename.str().c_str(),ios::out);


for(int q(100);q>=50;--q)
{
file << "FRAME NO. "<<q<<endl;
for(int fu(0);fu<2;++fu){
	/*if(_m[0]<1)
		_m[0] += 0.1;
	else
		_m[0] = 0.99;*/
/*
	if(_m[4]<1)
		_m[4] += 0.10;
	else
		_m[4] = 0.99;

	if(_m[8]<1)
		_m[8] += 0.10;
	else
		_m[8] = 0.99;*/
	int window_w = 1280;
	int window_h = 1024;

	cout << "render scene... "<<endl;

	TriangleIterator ti;
	glEnable(GL_DEPTH_TEST);
	glEnable(GL_CULL_FACE);
	glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);

	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	glBegin(GL_TRIANGLES);

	//map<int, vector<Pnt3f> > _COLORS;
	map<int, int> _COLORS;

	for(ti = TEST->beginTriangles();ti != TEST->endTriangles();++ti)
	{
		int rgb_index = 0;
		int r(0),g(0),b(0);
		while(_COLORS[rgb_index] != NULL)
		{
			// create random color
			r = (int)rand() % 255;
			g = (int)rand() % 255;
			b = (int)rand() % 255;

			// calculate index
			rgb_index = 256 * g + 256 * 256 * r + b;
			//cout << rgb_index << endl;
		}

		// SAVE ALL _USED_ COLORS
		vector<Pnt3f> v;
		v.push_back(ti.getPosition(0));
		v.push_back(ti.getPosition(1));
		v.push_back(ti.getPosition(2));
		_COLORS[rgb_index] = ti.getIndex();

		//cout << "r " << r << " g "<<g << " b "<<b<<endl;

		// get points from triangle
		Pnt3f p1 = ti.getPosition(0);
		Pnt3f p2 = ti.getPosition(1);
		Pnt3f p3 = ti.getPosition(2);

		//set color and add vertices
		//glColor3f(r,g,b);
		glColor3ub(r,g,b);
		glVertex3f(p1[0],p1[1],p1[2]);
		glVertex3f(p2[0],p2[1],p2[2]);
		glVertex3f(p3[0],p3[1],p3[2]);

	}
	glEnd();

	glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
	glEnable(GL_POLYGON_OFFSET_FILL);
	glPolygonOffset(1.0, 1.0);

	glBegin(GL_TRIANGLES);
	// set background color
	glColor3f(0,0,0);
	for(ti = TEST->beginTriangles();ti != TEST->endTriangles();++ti)
	{
		Pnt3f p1 = ti.getPosition(0);
		Pnt3f p2 = ti.getPosition(1);
		Pnt3f p3 = ti.getPosition(2);

		glVertex3f(p1[0],p1[1],p1[2]);
		glVertex3f(p2[0],p2[1],p2[2]);
//.........这里部分代码省略.........
开发者ID:stefanedm,项目名称:track,代码行数:101,代码来源:main.cpp

示例2: enter

Action::ResultE OOCOSGFeeder::enter(NodePtr& node)
{
    GeometryPtr geo = GeometryPtr::dcast(node->getCore());
    
    if(geo == NullFC)
        return Action::Continue;
    
    GeoPositionsPtr pos = geo->getPositions();
    UInt32 pntindexbase;
    
    if(_poss.find(pos) != _poss.end())
    {
        pntindexbase = _poss[pos];
        pos = NullFC;
    }
    else
    {
        pntindexbase = _pntindexbase;
        _poss[pos]   = _pntindexbase;
        _pntindexbase += pos->getSize();
    }   
    
    UInt32 matind = MaterialPool::addMaterial(geo->getMaterial());

    if(pos != NullFC)
    {
        if(_pfunc != NULL)
        {
            Pnt3f p;
            UInt32 s = pos->getSize();
            
            for(UInt32 i = 0; i < s; ++i)
            {
                if(_npts != 0)
                {
                    ++_pntprog;
                    
                    Real32 prog = _pntprog / (Real32)_npts;
                    if(prog > _nextpntprog)
                    {
                        PLOG << _nextpntprog * 100 << "%..";
                        _nextpntprog += 0.1;
                    }
                }
                
                pos->getValue(p, i);
                
                _pfunc(_rec, p);
            }            
        }
    }
    
    if(_tfunc != NULL)
    {
        TriangleIterator it, end = geo->endTriangles();

        for(it = geo->beginTriangles(); 
            it != end; 
            ++it)
        {
            if(_ntris != 0)
            {
                ++_triprog;

                Real32 prog = _triprog / (Real32)_ntris;
                if(prog > _nexttriprog)
                {
                    PLOG << _nexttriprog * 100 << "%..";
                    _nexttriprog += 0.1;
                }
            }
                
            _tfunc(_rec, it.getPositionIndex(0) + pntindexbase, 
                         it.getPositionIndex(1) + pntindexbase, 
                         it.getPositionIndex(2) + pntindexbase,
                         matind);
        }
    }
    
    return Action::Continue;
}
开发者ID:mlimper,项目名称:OpenSG1x,代码行数:81,代码来源:OOCOSGFeeder.cpp


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