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

C++ V_Vector3类代码示例

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

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



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

示例1: Evaluate

void Curve::Evaluate( GraphDirection direction )
{
    uint32_t controlCount = 0;
    V_Vector3 points;
    {
        OS_HierarchyNodeDumbPtr::Iterator childItr = GetChildren().Begin();
        OS_HierarchyNodeDumbPtr::Iterator childEnd = GetChildren().End();
        for ( ; childItr != childEnd; ++childItr )
        {
            CurveControlPoint* point = Reflect::SafeCast< CurveControlPoint >( *childItr );
            if ( point )
            {
                points.push_back( point->GetPosition() );
                ++controlCount;
            }
        }
    }

    if ( controlCount < 4  || m_Type == CurveType::Linear ) 
    {     
        m_Points = points;
    }
    else if ( m_Type == CurveType::BSpline )
    {
        CurveGenerator::ComputeCurve( points, m_Resolution, m_Closed, CurveGenerator::kBSpline, m_Points ); 
    }
    else if ( m_Type == CurveType::CatmullRom )
    {
        CurveGenerator::ComputeCurve( points, m_Resolution, m_Closed, CurveGenerator::kCatmullRom, m_Points ); 
    }
    else
    {
        //whoa, did we get a bum curve type?
        HELIUM_BREAK();
    }


    //
    // Update buffer
    //

    if ( controlCount > 0 ) 
    {
        controlCount++;
    }

    uint32_t pointCount = (uint32_t)m_Points.size();
    if ( pointCount > 0 ) 
    {
        pointCount++;
    }

    m_Vertices->SetElementCount( controlCount + pointCount );
    m_Vertices->Update();

    Base::Evaluate(direction);
}
开发者ID:euler0,项目名称:Helium,代码行数:57,代码来源:Curve.cpp


示例2: GenerateInstanceOffsets

void CreateTool::GenerateInstanceOffsets( PlacementStyle style, float radius, float instanceRadius, V_Vector3& positions )
{
	switch ( style )
	{
	case PlacementStyles::Grid:
		{
			float radiusSquared = radius * radius;
			int numInstances = MAX( 2, (int) sqrt( radiusSquared / ( instanceRadius * instanceRadius ) ) );
			float delta = radius * 2.0f / numInstances;

			for ( float x = -radius; x <= radius; x += delta )
			{
				for ( float y = -radius; y <= radius; y += delta )
				{
					if ( x * x + y * y < radiusSquared )
					{
						Vector3 v = ( Editor::UpVector * x ) + ( Editor::OutVector * y );
						positions.push_back( v );
					}
				}
			}
			break;
		}

	case PlacementStyles::Radial:
	default:
		{
			float currentRadius = 0.0f;
			while ( currentRadius < radius )
			{
				float circumference = static_cast< float32_t >( HELIUM_TWOPI ) * currentRadius;
				int numInstances = MAX( 1, (int) ( circumference / ( 2.0f * instanceRadius ) ) );

				float deltaAngle = static_cast< float32_t >( HELIUM_TWOPI ) / numInstances;
				float currentAngle = static_cast< float32_t >( HELIUM_TWOPI ) * rand() / ( (float) RAND_MAX + 1.0f );

				for ( int i = 0; i < numInstances; ++i )
				{
					float x = currentRadius * cos( currentAngle );
					float y = currentRadius * sin( currentAngle );
					Vector3 v = ( Editor::UpVector * x ) + ( Editor::OutVector * y );
					positions.push_back( v );

					currentAngle += deltaAngle;
					while ( currentAngle > HELIUM_TWOPI )
					{
						currentAngle -= static_cast< float32_t >( HELIUM_TWOPI );
					}
				}

				currentRadius += instanceRadius + instanceRadius;
			}
			break;
		}
	}
}
开发者ID:Fantasticer,项目名称:Helium,代码行数:56,代码来源:CreateTool.cpp


示例3: SetupInstanceOffsets

void CreateTool::SetupInstanceOffsets( float instanceRadius, V_Vector3& instanceOffsets )
{
	instanceOffsets.clear();
	instanceOffsets.reserve( 256 );

	float adjustedInstanceRadius = instanceRadius / s_PaintDensity;

	GenerateInstanceOffsets( s_PaintPlacementStyle, s_PaintRadius, adjustedInstanceRadius, instanceOffsets );
	SelectInstanceOffsets( s_PaintDistributionStyle, s_PaintRadius, instanceOffsets );
	JitterInstanceOffsets( instanceRadius, s_PaintJitter, instanceOffsets );
	RandomizeInstanceOffsets( instanceOffsets );
}
开发者ID:Fantasticer,项目名称:Helium,代码行数:12,代码来源:CreateTool.cpp


示例4: CalculateCurveLength

float32_t Curve::CalculateCurveLength() const
{
    const Matrix4& globalTransform = this->GetGlobalTransform();
    V_Vector3 points = m_Points;
    float32_t curveLength = 0.f;
    for ( uint32_t i = 1; i < points.size() ; ++i )
    {
        Vector3 endPoint = points[i];
        Vector3 startPoint = points[i-1];
        globalTransform.TransformVertex( endPoint );
        globalTransform.TransformVertex( startPoint );
        curveLength += (endPoint - startPoint).Length();
    }
    return curveLength;
}
开发者ID:euler0,项目名称:Helium,代码行数:15,代码来源:Curve.cpp


示例5: JitterInstanceOffsets

void CreateTool::JitterInstanceOffsets( float instanceRadius, float maxJitter, V_Vector3& offsets )
{
	V_Vector3 jitterVectors;
	jitterVectors.push_back( Editor::UpVector );
	jitterVectors.push_back( Editor::OutVector );

	V_Vector3::iterator itr = offsets.begin();
	V_Vector3::iterator end = offsets.end();
	for ( ; itr != end; ++itr )
	{
		V_Vector3::const_iterator jitterItr = jitterVectors.begin();
		V_Vector3::const_iterator jitterEnd = jitterVectors.end();
		for ( ; jitterItr != jitterEnd; ++jitterItr )
		{
			int searchTries = 10;
			while ( searchTries > 0 )
			{
				--searchTries;
				float jitter = ( rand() / ( (float) RAND_MAX + 1.0f ) ) * 2.0f - 1.0f;
				float randomNumber = rand() / ( (float) RAND_MAX + 1.0f );
				float testNumber = GetNormalProbabilityFromPercent( jitter );
				if ( randomNumber <= testNumber )
				{
					(*itr) += (*jitterItr) * jitter * maxJitter;
					searchTries = 0;
				}
			}
		}
	}
}
开发者ID:Fantasticer,项目名称:Helium,代码行数:30,代码来源:CreateTool.cpp


示例6: GetVertices

void AlignedBox::Transform(const Matrix4& matrix)
{
    // get the currents sample bounds
    V_Vector3 vertices;
    GetVertices( vertices );

    // reseed this box
    Reset();

    // iterate and resample the bounds
    V_Vector3::iterator itr = vertices.begin();
    V_Vector3::iterator end = vertices.end();
    for ( ; itr != end; ++itr )
    {
        // transform the sample
        matrix.TransformVertex( *itr );

        // test the sample
        Test( *itr );
    }
}
开发者ID:justinliew,项目名称:Math,代码行数:21,代码来源:AlignedBox.cpp


示例7: octree

void OctreeVisualizer::incomingOctreeCallback()
{
  scan_utils::Octree<char> octree(0, 0, 0, 0, 0, 0, 1, 0);
  octree.setFromMsg(octree_message_);

  std::list<scan_utils::Triangle> triangles;
  octree.getAllTriangles(triangles);

  V_Vector3 vertices;
  V_Vector3 normals;

  vertices.resize( triangles.size() * 3 );
  normals.resize( triangles.size() );
  size_t vertexIndex = 0;
  size_t normalIndex = 0;
  std::list<scan_utils::Triangle>::iterator it = triangles.begin();
  std::list<scan_utils::Triangle>::iterator end = triangles.end();
  for ( ; it != end; it++ )
  {
    Ogre::Vector3& v1 = vertices[vertexIndex++];
    Ogre::Vector3& v2 = vertices[vertexIndex++];
    Ogre::Vector3& v3 = vertices[vertexIndex++];
    Ogre::Vector3& n = normals[normalIndex++];

    v1 = Ogre::Vector3( it->p1.x, it->p1.y, it->p1.z );
    v2 = Ogre::Vector3( it->p2.x, it->p2.y, it->p2.z );
    v3 = Ogre::Vector3( it->p3.x, it->p3.y, it->p3.z );
    robotToOgre(v1);
    robotToOgre(v2);
    robotToOgre(v3);

    n = ( v2 - v1 ).crossProduct( v3 - v1 );
    n.normalise();
  }

  triangles_mutex_.lock();

  vertices_.clear();
  normals_.clear();

  vertices.swap( vertices_ );
  normals.swap( normals_ );

  new_message_ = true;
  triangles_mutex_.unlock();
}
开发者ID:janfrs,项目名称:kwc-ros-pkg,代码行数:46,代码来源:octree_visualizer.cpp


示例8: SelectInstanceOffsets

void CreateTool::SelectInstanceOffsets( DistributionStyle style, float radius, V_Vector3& offsets )
{
	V_Vector3 selectedOffsets;
	selectedOffsets.reserve( offsets.size() );

	V_Vector3::iterator itr = offsets.begin();
	V_Vector3::iterator end = offsets.end();
	for ( ; itr != end; ++itr )
	{
		switch ( style )
		{
		case DistributionStyles::Uniform:
			{
				float randomNumber = rand() / ( (float) RAND_MAX + 1.0f );
				if ( randomNumber <= 0.5f )
				{
					selectedOffsets.push_back( *itr );
				}
				break;
			}

		case DistributionStyles::Linear:
			{
				float radiusPercent = (*itr).Length() / radius;
				float randomNumber = rand() / ( (float) RAND_MAX + 1.0f );
				float testNumber = 1.0f - radiusPercent;
				if ( randomNumber <= testNumber )
				{
					selectedOffsets.push_back( *itr );
				}
				break;
			}

		case DistributionStyles::Normal:
			{
				float radiusPercent = (*itr).Length() / radius;
				float randomNumber = rand() / ( (float) RAND_MAX + 1.0f );
				float testNumber = GetNormalProbabilityFromPercent( radiusPercent );
				if ( randomNumber <= testNumber )
				{
					selectedOffsets.push_back( *itr );
				}
				break;
			}

		case DistributionStyles::Constant:
		default:
			selectedOffsets.push_back( *itr );
			break;
		}
	}

	offsets.clear();
	offsets.reserve( selectedOffsets.size() );
	itr = selectedOffsets.begin();
	end = selectedOffsets.end();
	for ( ; itr != end; ++itr )
	{
		offsets.push_back( *itr );
	}
}
开发者ID:Fantasticer,项目名称:Helium,代码行数:61,代码来源:CreateTool.cpp


示例9: while

void CreateTool::RandomizeInstanceOffsets( V_Vector3& offsets )
{
	V_Vector3 newOffsets;
	newOffsets.reserve( offsets.size() );

	while ( offsets.size() )
	{
		V_Vector3::iterator itr = offsets.begin() + ( rand() % offsets.size() );
		newOffsets.push_back( *itr );
		offsets.erase( itr );
	}

	V_Vector3::iterator itr = newOffsets.begin();
	V_Vector3::iterator end = newOffsets.end();
	for ( ; itr != end; ++itr )
	{
		offsets.push_back( *itr );
	}
}
开发者ID:Fantasticer,项目名称:Helium,代码行数:19,代码来源:CreateTool.cpp



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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