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


C++ HeightMap::getColumnsNumber方法代码示例

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


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

示例1: createMesh

void Scene::createMesh( const HeightMap& hmap,
                        set<Vector3D> &vertexes, 
                        set<shared_ptr<Poly>> &triangles, 
                        set<Vector3D> &normals )
{
    Vector3D *vec[4];
    Vector2D tex[4] = { Vector2D( 0, 0 ), Vector2D( 0, 1 ), Vector2D( 1, 0 ), Vector2D( 1, 1 ) };	// Текстурные координаты одинаковы для всех полигонов ( пополигонный тайлинг)
    int max_i = hmap.getColumnsNumber();
    int max_j = hmap.getRowsNumber();
    for( int i = 0; i < max_i; i++ )
    {
        for( int j = 0; j < max_j; j++ )
        {
            HMPoint *pnt = hmap.getPoint(i, j);
            if( pnt )
            {
                auto v1 = vertexes.insert( Vector3D( pnt->m_coord.x,      m_ground,           pnt->m_coord.y ) );
                auto v2 = vertexes.insert( Vector3D( pnt->m_coord.x,      pnt->m_height,      pnt->m_coord.y ) );
                auto v3 = vertexes.insert( Vector3D( pnt->m_coord.x+m_step,  m_ground,        pnt->m_coord.y ) );
                auto v4 = vertexes.insert( Vector3D( pnt->m_coord.x+m_step,  pnt->m_height,   pnt->m_coord.y) );
                auto v5 = vertexes.insert( Vector3D( pnt->m_coord.x,       m_ground,          pnt->m_coord.y+m_step ) );
                auto v6 = vertexes.insert( Vector3D( pnt->m_coord.x,       pnt->m_height,     pnt->m_coord.y+m_step ) );
                auto v7 = vertexes.insert( Vector3D( pnt->m_coord.x+m_step,  m_ground,        pnt->m_coord.y+m_step ) );
                auto v8 = vertexes.insert( Vector3D( pnt->m_coord.x+m_step,  pnt->m_height,   pnt->m_coord.y+m_step ) );

                vec[0] = const_cast<Vector3D*>( &(*v2.first) ); 
                vec[1] = const_cast<Vector3D*>( &(*v6.first) ); 
                vec[2] = const_cast<Vector3D*>( &(*v8.first) ); 
                vec[3] = const_cast<Vector3D*>( &(*v4.first) );
                auto norm = normals.insert( Vector3D( 0, 1, 0 ) );
                shared_ptr<Poly> tri = shared_ptr<Poly>( new Poly( vec, tex, 4, &(*norm.first) ) );
                triangles.insert( tri );

                vec[0] = const_cast<Vector3D*>( &(*v1.first) ); 
                vec[1] = const_cast<Vector3D*>( &(*v5.first) );
                vec[2] = const_cast<Vector3D*>( &(*v7.first) );
                vec[3] = const_cast<Vector3D*>( &(*v3.first) );
                norm = normals.insert( Vector3D( 0, -1, 0 ) );
                tri = shared_ptr<Poly>( new Poly( vec, tex, 4, &(*norm.first) ) );
                triangles.insert( tri );

                if( j>0 )
                {
                    HMPoint *pntj1 = hmap.getPoint(i,j-1);
                    if( !pntj1 )
					{
						vec[0] = const_cast<Vector3D*>( &(*v1.first) ); 
						vec[1] = const_cast<Vector3D*>( &(*v2.first) );
						vec[2] = const_cast<Vector3D*>( &(*v4.first) );
						vec[3] = const_cast<Vector3D*>( &(*v3.first) );
						norm = normals.insert( Vector3D( 0, 0, -1 ) );
						shared_ptr<Poly> tri( new Poly( vec, tex, 4, &(*norm.first) ) );
						triangles.insert( tri );
					}
					else
					{
                        //! Доборочная грань вниз
                        if( pnt->m_height > pntj1->m_height )
                        {
							vec[0] = const_cast<Vector3D*>( &(*v2.first) );
							vec[1] = const_cast<Vector3D*>( &(*v4.first) );
							vec[2] = const_cast<Vector3D*>( &(*vertexes.find( Vector3D( vec[1]->x, pntj1->m_height, vec[1]->z ) ) ) );
							vec[3] = const_cast<Vector3D*>( &(*vertexes.find( Vector3D( vec[0]->x, pntj1->m_height, vec[0]->z ) ) ) );
							//! Нормаль смотрит вниз
							norm = normals.insert( Vector3D(0, 0, -1) );
							shared_ptr<Poly> tri( new Poly( vec, tex, 4, &(*norm.first) ) );
							triangles.insert( tri );
						}
                        if( pnt->m_height < pntj1->m_height)
						{
							vec[0] = const_cast<Vector3D*>( &(*v2.first) );
							vec[1] = const_cast<Vector3D*>( &(*v4.first) );
							vec[2] = const_cast<Vector3D*>( &(*vertexes.find( Vector3D( vec[1]->x, pntj1->m_height, vec[1]->z ) ) ) );
							vec[3] = const_cast<Vector3D*>( &(*vertexes.find( Vector3D( vec[0]->x, pntj1->m_height, vec[0]->z ) ) ) );
							//! Нормаль смотрит вверх
							norm = normals.insert( Vector3D(0, 0, 1) );
							shared_ptr<Poly> tri( new Poly( vec, tex, 4, &(*norm.first) ) );
							triangles.insert( tri );
						}
					}
				}
                if ( i>0 )
				{
                    HMPoint *pnti1 = hmap.getPoint(i-1,j);
					if( !pnti1 )
					{
						vec[0] = const_cast<Vector3D*>( &(*v1.first) );
						vec[1] = const_cast<Vector3D*>( &(*v2.first) );
						vec[2] = const_cast<Vector3D*>( &(*v6.first) );
						vec[3] = const_cast<Vector3D*>( &(*v5.first) );
						norm = normals.insert( Vector3D(-1, 0, 0) );
						shared_ptr<Poly> tri( new Poly( vec, tex, 4, &(*norm.first) ) );
						triangles.insert( tri );
					}
					else
					{
						//! Доборочная грань влево
                        if( pnt->m_height > pnti1->m_height )
						{
							vec[0] = const_cast<Vector3D*>( &(*v2.first) );
//.........这里部分代码省略.........
开发者ID:kovalexius,项目名称:findPath3d,代码行数:101,代码来源:Scene.cpp


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